var utt=Object.defineProperty;var pNe=e=>{throw TypeError(e)};var htt=(e,t,s)=>t in e?utt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var on=(e,t,s)=>htt(e,typeof t!="symbol"?t+"":t,s),wde=(e,t,s)=>t.has(e)||pNe("Cannot "+s);var ar=(e,t,s)=>(wde(e,t,"read from private field"),s?s.call(e):t.get(e)),Sa=(e,t,s)=>t.has(e)?pNe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),Mn=(e,t,s,n)=>(wde(e,t,"write to private field"),n?n.call(e,s):t.set(e,s),s),Ci=(e,t,s)=>(wde(e,t,"access private method"),s);var GD=(e,t,s,n)=>({set _(a){Mn(e,t,a,s)},get _(){return ar(e,t,n)}});function mtt(e,t){for(var s=0;sn[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.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 s(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=s(a);fetch(a.href,o)}})();var Ny=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ho(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function y6e(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var s=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};s.prototype=t.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(s,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}),s}var v6e={exports:{}},Eae={},_6e={exports:{}},Ji={};/** * @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 o6=Symbol.for("react.element"),ftt=Symbol.for("react.portal"),ptt=Symbol.for("react.fragment"),gtt=Symbol.for("react.strict_mode"),xtt=Symbol.for("react.profiler"),ytt=Symbol.for("react.provider"),vtt=Symbol.for("react.context"),_tt=Symbol.for("react.forward_ref"),btt=Symbol.for("react.suspense"),wtt=Symbol.for("react.memo"),jtt=Symbol.for("react.lazy"),gNe=Symbol.iterator;function ktt(e){return e===null||typeof e!="object"?null:(e=gNe&&e[gNe]||e["@@iterator"],typeof e=="function"?e:null)}var b6e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w6e=Object.assign,j6e={};function g3(e,t,s){this.props=e,this.context=t,this.refs=j6e,this.updater=s||b6e}g3.prototype.isReactComponent={};g3.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};g3.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function k6e(){}k6e.prototype=g3.prototype;function Aye(e,t,s){this.props=e,this.context=t,this.refs=j6e,this.updater=s||b6e}var Eye=Aye.prototype=new k6e;Eye.constructor=Aye;w6e(Eye,g3.prototype);Eye.isPureReactComponent=!0;var xNe=Array.isArray,N6e=Object.prototype.hasOwnProperty,Iye={current:null},S6e={key:!0,ref:!0,__self:!0,__source:!0};function C6e(e,t,s){var n,a={},o=null,l=null;if(t!=null)for(n in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(o=""+t.key),t)N6e.call(t,n)&&!S6e.hasOwnProperty(n)&&(a[n]=t[n]);var i=arguments.length-2;if(i===1)a.children=s;else if(1>>1,ve=ce[_e];if(0>>1;_ea(Ae,Te))Lea(Ue,Ae)?(ce[_e]=Ue,ce[Le]=Te,_e=Le):(ce[_e]=Ae,ce[Ze]=Te,_e=Ze);else if(Lea(Ue,Te))ce[_e]=Ue,ce[Le]=Te,_e=Le;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;e.unstable_now=function(){return o.now()}}else{var l=Date,i=l.now();e.unstable_now=function(){return l.now()-i}}var d=[],m=[],p=1,g=null,v=3,_=!1,k=!1,w=!1,S=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function I(ce){for(var ge=s(m);ge!==null;){if(ge.callback===null)n(m);else if(ge.startTime<=ce)n(m),ge.sortIndex=ge.expirationTime,t(d,ge);else break;ge=s(m)}}function R(ce){if(w=!1,I(ce),!k)if(s(d)!==null)k=!0,ie(D);else{var ge=s(m);ge!==null&&de(R,ge.startTime-ce)}}function D(ce,ge){k=!1,w&&(w=!1,T(q),q=-1),_=!0;var Te=v;try{for(I(ge),g=s(d);g!==null&&(!(g.expirationTime>ge)||ce&&!re());){var _e=g.callback;if(typeof _e=="function"){g.callback=null,v=g.priorityLevel;var ve=_e(g.expirationTime<=ge);ge=e.unstable_now(),typeof ve=="function"?g.callback=ve:g===s(d)&&n(d),I(ge)}else n(d);g=s(d)}if(g!==null)var Me=!0;else{var Ze=s(m);Ze!==null&&de(R,Ze.startTime-ge),Me=!1}return Me}finally{g=null,v=Te,_=!1}}var B=!1,$=null,q=-1,W=5,K=-1;function re(){return!(e.unstable_now()-Kce||125_e?(ce.sortIndex=Te,t(m,ce),s(d)===null&&ce===s(m)&&(w?(T(q),q=-1):w=!0,de(R,Te-_e))):(ce.sortIndex=ve,t(d,ce),k||_||(k=!0,ie(D))),ce},e.unstable_shouldYield=re,e.unstable_wrapCallback=function(ce){var ge=v;return function(){var Te=v;v=ge;try{return ce.apply(this,arguments)}finally{v=Te}}}})(I6e);E6e.exports=I6e;var Dtt=E6e.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 Ott=A,qm=Dtt;function Ds(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wme=Object.prototype.hasOwnProperty,Rtt=/^[: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]*$/,vNe={},_Ne={};function Ftt(e){return wme.call(_Ne,e)?!0:wme.call(vNe,e)?!1:Rtt.test(e)?_Ne[e]=!0:(vNe[e]=!0,!1)}function ztt(e,t,s,n){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return n?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Btt(e,t,s,n){if(t===null||typeof t>"u"||ztt(e,t,s,n))return!0;if(n)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Nh(e,t,s,n,a,o,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=n,this.attributeNamespace=a,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=l}var xu={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){xu[e]=new Nh(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];xu[t]=new Nh(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){xu[e]=new Nh(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){xu[e]=new Nh(e,2,!1,e,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(e){xu[e]=new Nh(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){xu[e]=new Nh(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){xu[e]=new Nh(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){xu[e]=new Nh(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){xu[e]=new Nh(e,5,!1,e.toLowerCase(),null,!1,!1)});var Dye=/[\-:]([a-z])/g;function Oye(e){return e[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(e){var t=e.replace(Dye,Oye);xu[t]=new Nh(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Dye,Oye);xu[t]=new Nh(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Dye,Oye);xu[t]=new Nh(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){xu[e]=new Nh(e,1,!1,e.toLowerCase(),null,!1,!1)});xu.xlinkHref=new Nh("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){xu[e]=new Nh(e,1,!1,e.toLowerCase(),null,!0,!0)});function Rye(e,t,s,n){var a=xu.hasOwnProperty(t)?xu[t]:null;(a!==null?a.type!==0:n||!(2i||a[l]!==o[i]){var d=` `+a[l].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),d}while(1<=l&&0<=i);break}}}finally{Nde=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?RA(e):""}function $tt(e){switch(e.tag){case 5:return RA(e.type);case 16:return RA("Lazy");case 13:return RA("Suspense");case 19:return RA("SuspenseList");case 0:case 2:case 15:return e=Sde(e.type,!1),e;case 11:return e=Sde(e.type.render,!1),e;case 1:return e=Sde(e.type,!0),e;default:return""}}function Sme(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case $C:return"Fragment";case BC:return"Portal";case jme:return"Profiler";case Fye:return"StrictMode";case kme:return"Suspense";case Nme:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case D6e:return(e.displayName||"Context")+".Consumer";case L6e:return(e._context.displayName||"Context")+".Provider";case zye:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Bye:return t=e.displayName||null,t!==null?t:Sme(e.type)||"Memo";case _v:t=e._payload,e=e._init;try{return Sme(e(t))}catch{}}return null}function Utt(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Sme(t);case 8:return t===Fye?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function z1(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function R6e(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Vtt(e){var t=R6e(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),n=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var a=s.get,o=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(l){n=""+l,o.call(this,l)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return n},setValue:function(l){n=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function YD(e){e._valueTracker||(e._valueTracker=Vtt(e))}function F6e(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),n="";return e&&(n=R6e(e)?e.checked?"true":"false":e.value),e=n,e!==s?(t.setValue(e),!0):!1}function kre(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Cme(e,t){var s=t.checked;return rc({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function wNe(e,t){var s=t.defaultValue==null?"":t.defaultValue,n=t.checked!=null?t.checked:t.defaultChecked;s=z1(t.value!=null?t.value:s),e._wrapperState={initialChecked:n,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function z6e(e,t){t=t.checked,t!=null&&Rye(e,"checked",t,!1)}function Mme(e,t){z6e(e,t);var s=z1(t.value),n=t.type;if(s!=null)n==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(n==="submit"||n==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Tme(e,t.type,s):t.hasOwnProperty("defaultValue")&&Tme(e,t.type,z1(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function jNe(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var n=t.type;if(!(n!=="submit"&&n!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function Tme(e,t,s){(t!=="number"||kre(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var FA=Array.isArray;function u4(e,t,s,n){if(e=e.options,t){t={};for(var a=0;a"+t.valueOf().toString()+"",t=XD.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function wI(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var JA={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},qtt=["Webkit","ms","Moz","O"];Object.keys(JA).forEach(function(e){qtt.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),JA[t]=JA[e]})});function V6e(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||JA.hasOwnProperty(e)&&JA[e]?(""+t).trim():t+"px"}function q6e(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var n=s.indexOf("--")===0,a=V6e(s,t[s],n);s==="float"&&(s="cssFloat"),n?e.setProperty(s,a):e[s]=a}}var Htt=rc({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 Ime(e,t){if(t){if(Htt[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Ds(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Ds(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Ds(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Ds(62))}}function Pme(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 Lme=null;function $ye(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Dme=null,h4=null,m4=null;function SNe(e){if(e=d6(e)){if(typeof Dme!="function")throw Error(Ds(280));var t=e.stateNode;t&&(t=Oae(t),Dme(e.stateNode,e.type,t))}}function H6e(e){h4?m4?m4.push(e):m4=[e]:h4=e}function W6e(){if(h4){var e=h4,t=m4;if(m4=h4=null,SNe(e),t)for(e=0;e>>=0,e===0?32:31-(rrt(e)/srt|0)|0}var QD=64,JD=4194304;function zA(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Mre(e,t){var s=e.pendingLanes;if(s===0)return 0;var n=0,a=e.suspendedLanes,o=e.pingedLanes,l=s&268435455;if(l!==0){var i=l&~a;i!==0?n=zA(i):(o&=l,o!==0&&(n=zA(o)))}else l=s&~a,l!==0?n=zA(l):o!==0&&(n=zA(o));if(n===0)return 0;if(t!==0&&t!==n&&!(t&a)&&(a=n&-n,o=t&-t,a>=o||a===16&&(o&4194240)!==0))return t;if(n&4&&(n|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=n;0s;s++)t.push(e);return t}function l6(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Qp(t),e[t]=s}function ort(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var n=e.eventTimes;for(e=e.expirationTimes;0=tE),DNe=" ",ONe=!1;function hLe(e,t){switch(e){case"keyup":return Drt.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mLe(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var UC=!1;function Rrt(e,t){switch(e){case"compositionend":return mLe(t);case"keypress":return t.which!==32?null:(ONe=!0,DNe);case"textInput":return e=t.data,e===DNe&&ONe?null:e;default:return null}}function Frt(e,t){if(UC)return e==="compositionend"||!Zye&&hLe(e,t)?(e=dLe(),b8=Wye=Qv=null,UC=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:s,offset:t-e};e=n}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=BNe(s)}}function xLe(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?xLe(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function yLe(){for(var e=window,t=kre();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=kre(e.document)}return t}function Yye(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Grt(e){var t=yLe(),s=e.focusedElem,n=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&xLe(s.ownerDocument.documentElement,s)){if(n!==null&&Yye(s)){if(t=n.start,e=n.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=s.textContent.length,o=Math.min(n.start,a);n=n.end===void 0?o:Math.min(n.end,a),!e.extend&&o>n&&(a=n,n=o,o=a),a=$Ne(s,o);var l=$Ne(s,n);a&&l&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),o>n?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s=document.documentMode,VC=null,$me=null,sE=null,Ume=!1;function UNe(e,t,s){var n=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Ume||VC==null||VC!==kre(n)||(n=VC,"selectionStart"in n&&Yye(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}),sE&&MI(sE,n)||(sE=n,n=Ere($me,"onSelect"),0WC||(e.current=Kme[WC],Kme[WC]=null,WC--)}function dl(e,t){WC++,Kme[WC]=e.current,e.current=t}var B1={},Ru=X1(B1),Yh=X1(!1),Uk=B1;function _5(e,t){var s=e.type.contextTypes;if(!s)return B1;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var a={},o;for(o in s)a[o]=t[o];return n&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function Xh(e){return e=e.childContextTypes,e!=null}function Pre(){Sl(Yh),Sl(Ru)}function ZNe(e,t,s){if(Ru.current!==B1)throw Error(Ds(168));dl(Ru,t),dl(Yh,s)}function CLe(e,t,s){var n=e.stateNode;if(t=t.childContextTypes,typeof n.getChildContext!="function")return s;n=n.getChildContext();for(var a in n)if(!(a in t))throw Error(Ds(108,Utt(e)||"Unknown",a));return rc({},s,n)}function Lre(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||B1,Uk=Ru.current,dl(Ru,e),dl(Yh,Yh.current),!0}function YNe(e,t,s){var n=e.stateNode;if(!n)throw Error(Ds(169));s?(e=CLe(e,t,Uk),n.__reactInternalMemoizedMergedChildContext=e,Sl(Yh),Sl(Ru),dl(Ru,e)):Sl(Yh),dl(Yh,s)}var _y=null,Rae=!1,Bde=!1;function MLe(e){_y===null?_y=[e]:_y.push(e)}function ast(e){Rae=!0,MLe(e)}function Q1(){if(!Bde&&_y!==null){Bde=!0;var e=0,t=Uo;try{var s=_y;for(Uo=1;e>=l,a-=l,Sy=1<<32-Qp(t)+a|s<q?(W=$,$=null):W=$.sibling;var K=v(T,$,I[q],R);if(K===null){$===null&&($=W);break}e&&$&&K.alternate===null&&t(T,$),C=o(K,C,q),B===null?D=K:B.sibling=K,B=K,$=W}if(q===I.length)return s(T,$),Dl&&mb(T,q),D;if($===null){for(;qq?(W=$,$=null):W=$.sibling;var re=v(T,$,K.value,R);if(re===null){$===null&&($=W);break}e&&$&&re.alternate===null&&t(T,$),C=o(re,C,q),B===null?D=re:B.sibling=re,B=re,$=W}if(K.done)return s(T,$),Dl&&mb(T,q),D;if($===null){for(;!K.done;q++,K=I.next())K=g(T,K.value,R),K!==null&&(C=o(K,C,q),B===null?D=K:B.sibling=K,B=K);return Dl&&mb(T,q),D}for($=n(T,$);!K.done;q++,K=I.next())K=_($,T,q,K.value,R),K!==null&&(e&&K.alternate!==null&&$.delete(K.key===null?q:K.key),C=o(K,C,q),B===null?D=K:B.sibling=K,B=K);return e&&$.forEach(function(ae){return t(T,ae)}),Dl&&mb(T,q),D}function S(T,C,I,R){if(typeof I=="object"&&I!==null&&I.type===$C&&I.key===null&&(I=I.props.children),typeof I=="object"&&I!==null){switch(I.$$typeof){case ZD:e:{for(var D=I.key,B=C;B!==null;){if(B.key===D){if(D=I.type,D===$C){if(B.tag===7){s(T,B.sibling),C=a(B,I.props.children),C.return=T,T=C;break e}}else if(B.elementType===D||typeof D=="object"&&D!==null&&D.$$typeof===_v&&JNe(D)===B.type){s(T,B.sibling),C=a(B,I.props),C.ref=nA(T,B,I),C.return=T,T=C;break e}s(T,B);break}else t(T,B);B=B.sibling}I.type===$C?(C=hk(I.props.children,T.mode,R,I.key),C.return=T,T=C):(R=T8(I.type,I.key,I.props,null,T.mode,R),R.ref=nA(T,C,I),R.return=T,T=R)}return l(T);case BC:e:{for(B=I.key;C!==null;){if(C.key===B)if(C.tag===4&&C.stateNode.containerInfo===I.containerInfo&&C.stateNode.implementation===I.implementation){s(T,C.sibling),C=a(C,I.children||[]),C.return=T,T=C;break e}else{s(T,C);break}else t(T,C);C=C.sibling}C=Kde(I,T.mode,R),C.return=T,T=C}return l(T);case _v:return B=I._init,S(T,C,B(I._payload),R)}if(FA(I))return k(T,C,I,R);if(JT(I))return w(T,C,I,R);iO(T,I)}return typeof I=="string"&&I!==""||typeof I=="number"?(I=""+I,C!==null&&C.tag===6?(s(T,C.sibling),C=a(C,I),C.return=T,T=C):(s(T,C),C=Gde(I,T.mode,R),C.return=T,T=C),l(T)):s(T,C)}return S}var w5=ILe(!0),PLe=ILe(!1),Rre=X1(null),Fre=null,ZC=null,e0e=null;function t0e(){e0e=ZC=Fre=null}function r0e(e){var t=Rre.current;Sl(Rre),e._currentValue=t}function Xme(e,t,s){for(;e!==null;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,n!==null&&(n.childLanes|=t)):n!==null&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===s)break;e=e.return}}function p4(e,t){Fre=e,e0e=ZC=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(qh=!0),e.firstContext=null)}function Wf(e){var t=e._currentValue;if(e0e!==e)if(e={context:e,memoizedValue:t,next:null},ZC===null){if(Fre===null)throw Error(Ds(308));ZC=e,Fre.dependencies={lanes:0,firstContext:e}}else ZC=ZC.next=e;return t}var Bj=null;function s0e(e){Bj===null?Bj=[e]:Bj.push(e)}function LLe(e,t,s,n){var a=t.interleaved;return a===null?(s.next=s,s0e(t)):(s.next=a.next,a.next=s),t.interleaved=s,Jy(e,n)}function Jy(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var bv=!1;function n0e(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function DLe(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Py(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function h1(e,t,s){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,yo&2){var a=n.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),n.pending=t,Jy(e,s)}return a=n.interleaved,a===null?(t.next=t,s0e(n)):(t.next=a.next,a.next=t),n.interleaved=t,Jy(e,s)}function j8(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var n=t.lanes;n&=e.pendingLanes,s|=n,t.lanes=s,Vye(e,s)}}function eSe(e,t){var s=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,s===n)){var a=null,o=null;if(s=s.firstBaseUpdate,s!==null){do{var l={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};o===null?a=o=l:o=o.next=l,s=s.next}while(s!==null);o===null?a=o=t:o=o.next=t}else a=o=t;s={baseState:n.baseState,firstBaseUpdate:a,lastBaseUpdate:o,shared:n.shared,effects:n.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function zre(e,t,s,n){var a=e.updateQueue;bv=!1;var o=a.firstBaseUpdate,l=a.lastBaseUpdate,i=a.shared.pending;if(i!==null){a.shared.pending=null;var d=i,m=d.next;d.next=null,l===null?o=m:l.next=m,l=d;var p=e.alternate;p!==null&&(p=p.updateQueue,i=p.lastBaseUpdate,i!==l&&(i===null?p.firstBaseUpdate=m:i.next=m,p.lastBaseUpdate=d))}if(o!==null){var g=a.baseState;l=0,p=m=d=null,i=o;do{var v=i.lane,_=i.eventTime;if((n&v)===v){p!==null&&(p=p.next={eventTime:_,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var k=e,w=i;switch(v=t,_=s,w.tag){case 1:if(k=w.payload,typeof k=="function"){g=k.call(_,g,v);break e}g=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=w.payload,v=typeof k=="function"?k.call(_,g,v):k,v==null)break e;g=rc({},g,v);break e;case 2:bv=!0}}i.callback!==null&&i.lane!==0&&(e.flags|=64,v=a.effects,v===null?a.effects=[i]:v.push(i))}else _={eventTime:_,lane:v,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(m=p=_,d=g):p=p.next=_,l|=v;if(i=i.next,i===null){if(i=a.shared.pending,i===null)break;v=i,i=v.next,v.next=null,a.lastBaseUpdate=v,a.shared.pending=null}}while(!0);if(p===null&&(d=g),a.baseState=d,a.firstBaseUpdate=m,a.lastBaseUpdate=p,t=a.shared.interleaved,t!==null){a=t;do l|=a.lane,a=a.next;while(a!==t)}else o===null&&(a.shared.lanes=0);Hk|=l,e.lanes=l,e.memoizedState=g}}function tSe(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;ts?s:4,e(!0);var n=Ude.transition;Ude.transition={};try{e(!1),t()}finally{Uo=s,Ude.transition=n}}function QLe(){return Gf().memoizedState}function cst(e,t,s){var n=f1(e);if(s={lane:n,action:s,hasEagerState:!1,eagerState:null,next:null},JLe(e))eDe(t,s);else if(s=LLe(e,t,s,n),s!==null){var a=yh();Jp(s,e,n,a),tDe(s,t,n)}}function dst(e,t,s){var n=f1(e),a={lane:n,action:s,hasEagerState:!1,eagerState:null,next:null};if(JLe(e))eDe(t,a);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var l=t.lastRenderedState,i=o(l,s);if(a.hasEagerState=!0,a.eagerState=i,dg(i,l)){var d=t.interleaved;d===null?(a.next=a,s0e(t)):(a.next=d.next,d.next=a),t.interleaved=a;return}}catch{}finally{}s=LLe(e,t,a,n),s!==null&&(a=yh(),Jp(s,e,n,a),tDe(s,t,n))}}function JLe(e){var t=e.alternate;return e===Jl||t!==null&&t===Jl}function eDe(e,t){nE=$re=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function tDe(e,t,s){if(s&4194240){var n=t.lanes;n&=e.pendingLanes,s|=n,t.lanes=s,Vye(e,s)}}var Ure={readContext:Wf,useCallback:ku,useContext:ku,useEffect:ku,useImperativeHandle:ku,useInsertionEffect:ku,useLayoutEffect:ku,useMemo:ku,useReducer:ku,useRef:ku,useState:ku,useDebugValue:ku,useDeferredValue:ku,useTransition:ku,useMutableSource:ku,useSyncExternalStore:ku,useId:ku,unstable_isNewReconciler:!1},ust={readContext:Wf,useCallback:function(e,t){return Vg().memoizedState=[e,t===void 0?null:t],e},useContext:Wf,useEffect:sSe,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,N8(4194308,4,GLe.bind(null,t,e),s)},useLayoutEffect:function(e,t){return N8(4194308,4,e,t)},useInsertionEffect:function(e,t){return N8(4,2,e,t)},useMemo:function(e,t){var s=Vg();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var n=Vg();return t=s!==void 0?s(t):t,n.memoizedState=n.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},n.queue=e,e=e.dispatch=cst.bind(null,Jl,e),[n.memoizedState,e]},useRef:function(e){var t=Vg();return e={current:e},t.memoizedState=e},useState:rSe,useDebugValue:h0e,useDeferredValue:function(e){return Vg().memoizedState=e},useTransition:function(){var e=rSe(!1),t=e[0];return e=lst.bind(null,e[1]),Vg().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var n=Jl,a=Vg();if(Dl){if(s===void 0)throw Error(Ds(407));s=s()}else{if(s=t(),Gd===null)throw Error(Ds(349));qk&30||zLe(n,t,s)}a.memoizedState=s;var o={value:s,getSnapshot:t};return a.queue=o,sSe($Le.bind(null,n,o,e),[e]),n.flags|=2048,OI(9,BLe.bind(null,n,o,s,t),void 0,null),s},useId:function(){var e=Vg(),t=Gd.identifierPrefix;if(Dl){var s=Cy,n=Sy;s=(n&~(1<<32-Qp(n)-1)).toString(32)+s,t=":"+t+"R"+s,s=LI++,0<\/script>",e=e.removeChild(e.firstChild)):typeof n.is=="string"?e=l.createElement(s,{is:n.is}):(e=l.createElement(s),s==="select"&&(l=e,n.multiple?l.multiple=!0:n.size&&(l.size=n.size))):e=l.createElementNS(e,s),e[Jg]=t,e[EI]=n,uDe(e,t,!1,!1),t.stateNode=e;e:{switch(l=Pme(s,n),s){case"dialog":_l("cancel",e),_l("close",e),a=n;break;case"iframe":case"object":case"embed":_l("load",e),a=n;break;case"video":case"audio":for(a=0;aN5&&(t.flags|=128,n=!0,aA(o,!1),t.lanes=4194304)}else{if(!n)if(e=Bre(l),e!==null){if(t.flags|=128,n=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),aA(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!Dl)return Nu(t),null}else 2*Oc()-o.renderingStartTime>N5&&s!==1073741824&&(t.flags|=128,n=!0,aA(o,!1),t.lanes=4194304);o.isBackwards?(l.sibling=t.child,t.child=l):(s=o.last,s!==null?s.sibling=l:t.child=l,o.last=l)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Oc(),t.sibling=null,s=Gl.current,dl(Gl,n?s&1|2:s&1),t):(Nu(t),null);case 22:case 23:return y0e(),n=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==n&&(t.flags|=8192),n&&t.mode&1?wm&1073741824&&(Nu(t),t.subtreeFlags&6&&(t.flags|=8192)):Nu(t),null;case 24:return null;case 25:return null}throw Error(Ds(156,t.tag))}function vst(e,t){switch(Qye(t),t.tag){case 1:return Xh(t.type)&&Pre(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return j5(),Sl(Yh),Sl(Ru),o0e(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return i0e(t),null;case 13:if(Sl(Gl),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ds(340));b5()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Sl(Gl),null;case 4:return j5(),null;case 10:return r0e(t.type._context),null;case 22:case 23:return y0e(),null;case 24:return null;default:return null}}var lO=!1,Tu=!1,_st=typeof WeakSet=="function"?WeakSet:Set,Pn=null;function YC(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(n){cc(e,t,n)}else s.current=null}function ife(e,t,s){try{s()}catch(n){cc(e,t,n)}}var fSe=!1;function bst(e,t){if(Vme=Tre,e=yLe(),Yye(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var n=s.getSelection&&s.getSelection();if(n&&n.rangeCount!==0){s=n.anchorNode;var a=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{s.nodeType,o.nodeType}catch{s=null;break e}var l=0,i=-1,d=-1,m=0,p=0,g=e,v=null;t:for(;;){for(var _;g!==s||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===e)break t;if(v===s&&++m===a&&(i=l),v===o&&++p===n&&(d=l),(_=g.nextSibling)!==null)break;g=v,v=g.parentNode}g=_}s=i===-1||d===-1?null:{start:i,end:d}}else s=null}s=s||{start:0,end:0}}else s=null;for(qme={focusedElem:e,selectionRange:s},Tre=!1,Pn=t;Pn!==null;)if(t=Pn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Pn=e;else for(;Pn!==null;){t=Pn;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var w=k.memoizedProps,S=k.memoizedState,T=t.stateNode,C=T.getSnapshotBeforeUpdate(t.elementType===t.type?w:Dp(t.type,w),S);T.__reactInternalSnapshotBeforeUpdate=C}break;case 3:var I=t.stateNode.containerInfo;I.nodeType===1?I.textContent="":I.nodeType===9&&I.documentElement&&I.removeChild(I.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ds(163))}}catch(R){cc(t,t.return,R)}if(e=t.sibling,e!==null){e.return=t.return,Pn=e;break}Pn=t.return}return k=fSe,fSe=!1,k}function aE(e,t,s){var n=t.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var a=n=n.next;do{if((a.tag&e)===e){var o=a.destroy;a.destroy=void 0,o!==void 0&&ife(t,s,o)}a=a.next}while(a!==n)}}function Bae(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var n=s.create;s.destroy=n()}s=s.next}while(s!==t)}}function ofe(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function fDe(e){var t=e.alternate;t!==null&&(e.alternate=null,fDe(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Jg],delete t[EI],delete t[Gme],delete t[sst],delete t[nst])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function pDe(e){return e.tag===5||e.tag===3||e.tag===4}function pSe(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||pDe(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function lfe(e,t,s){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Ire));else if(n!==4&&(e=e.child,e!==null))for(lfe(e,t,s),e=e.sibling;e!==null;)lfe(e,t,s),e=e.sibling}function cfe(e,t,s){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(n!==4&&(e=e.child,e!==null))for(cfe(e,t,s),e=e.sibling;e!==null;)cfe(e,t,s),e=e.sibling}var ou=null,zp=!1;function ov(e,t,s){for(s=s.child;s!==null;)gDe(e,t,s),s=s.sibling}function gDe(e,t,s){if(ix&&typeof ix.onCommitFiberUnmount=="function")try{ix.onCommitFiberUnmount(Iae,s)}catch{}switch(s.tag){case 5:Tu||YC(s,t);case 6:var n=ou,a=zp;ou=null,ov(e,t,s),ou=n,zp=a,ou!==null&&(zp?(e=ou,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):ou.removeChild(s.stateNode));break;case 18:ou!==null&&(zp?(e=ou,s=s.stateNode,e.nodeType===8?zde(e.parentNode,s):e.nodeType===1&&zde(e,s),SI(e)):zde(ou,s.stateNode));break;case 4:n=ou,a=zp,ou=s.stateNode.containerInfo,zp=!0,ov(e,t,s),ou=n,zp=a;break;case 0:case 11:case 14:case 15:if(!Tu&&(n=s.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)&&ife(s,t,l),a=a.next}while(a!==n)}ov(e,t,s);break;case 1:if(!Tu&&(YC(s,t),n=s.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=s.memoizedProps,n.state=s.memoizedState,n.componentWillUnmount()}catch(i){cc(s,t,i)}ov(e,t,s);break;case 21:ov(e,t,s);break;case 22:s.mode&1?(Tu=(n=Tu)||s.memoizedState!==null,ov(e,t,s),Tu=n):ov(e,t,s);break;default:ov(e,t,s)}}function gSe(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new _st),t.forEach(function(n){var a=Ast.bind(null,e,n);s.has(n)||(s.add(n),n.then(a,a))})}}function Sp(e,t){var s=t.deletions;if(s!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Oc()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*jst(n/1960))-n,10e?16:e,Jv===null)var n=!1;else{if(e=Jv,Jv=null,Hre=0,yo&6)throw Error(Ds(331));var a=yo;for(yo|=4,Pn=e.current;Pn!==null;){var o=Pn,l=o.child;if(Pn.flags&16){var i=o.deletions;if(i!==null){for(var d=0;dOc()-g0e?uk(e,0):p0e|=s),Qh(e,t)}function kDe(e,t){t===0&&(e.mode&1?(t=JD,JD<<=1,!(JD&130023424)&&(JD=4194304)):t=1);var s=yh();e=Jy(e,t),e!==null&&(l6(e,t,s),Qh(e,s))}function Tst(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),kDe(e,s)}function Ast(e,t){var s=0;switch(e.tag){case 13:var n=e.stateNode,a=e.memoizedState;a!==null&&(s=a.retryLane);break;case 19:n=e.stateNode;break;default:throw Error(Ds(314))}n!==null&&n.delete(t),kDe(e,s)}var NDe;NDe=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||Yh.current)qh=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return qh=!1,xst(e,t,s);qh=!!(e.flags&131072)}else qh=!1,Dl&&t.flags&1048576&&TLe(t,Ore,t.index);switch(t.lanes=0,t.tag){case 2:var n=t.type;S8(e,t),e=t.pendingProps;var a=_5(t,Ru.current);p4(t,s),a=c0e(null,t,n,e,a,s);var o=d0e();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Xh(n)?(o=!0,Lre(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,n0e(t),a.updater=zae,t.stateNode=a,a._reactInternals=t,Jme(t,n,e,s),t=rfe(null,t,n,!0,o,s)):(t.tag=0,Dl&&o&&Xye(t),ih(null,t,a,s),t=t.child),t;case 16:n=t.elementType;e:{switch(S8(e,t),e=t.pendingProps,a=n._init,n=a(n._payload),t.type=n,a=t.tag=Ist(n),e=Dp(n,e),a){case 0:t=tfe(null,t,n,e,s);break e;case 1:t=uSe(null,t,n,e,s);break e;case 11:t=cSe(null,t,n,e,s);break e;case 14:t=dSe(null,t,n,Dp(n.type,e),s);break e}throw Error(Ds(306,n,""))}return t;case 0:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Dp(n,a),tfe(e,t,n,a,s);case 1:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Dp(n,a),uSe(e,t,n,a,s);case 3:e:{if(lDe(t),e===null)throw Error(Ds(387));n=t.pendingProps,o=t.memoizedState,a=o.element,DLe(e,t),zre(t,n,null,s);var l=t.memoizedState;if(n=l.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=k5(Error(Ds(423)),t),t=hSe(e,t,n,s,a);break e}else if(n!==a){a=k5(Error(Ds(424)),t),t=hSe(e,t,n,s,a);break e}else for(Em=u1(t.stateNode.containerInfo.firstChild),Pm=t,Dl=!0,Vp=null,s=PLe(t,null,n,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(b5(),n===a){t=e0(e,t,s);break e}ih(e,t,n,s)}t=t.child}return t;case 5:return OLe(t),e===null&&Yme(t),n=t.type,a=t.pendingProps,o=e!==null?e.memoizedProps:null,l=a.children,Hme(n,a)?l=null:o!==null&&Hme(n,o)&&(t.flags|=32),oDe(e,t),ih(e,t,l,s),t.child;case 6:return e===null&&Yme(t),null;case 13:return cDe(e,t,s);case 4:return a0e(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=w5(t,null,n,s):ih(e,t,n,s),t.child;case 11:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Dp(n,a),cSe(e,t,n,a,s);case 7:return ih(e,t,t.pendingProps,s),t.child;case 8:return ih(e,t,t.pendingProps.children,s),t.child;case 12:return ih(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(n=t.type._context,a=t.pendingProps,o=t.memoizedProps,l=a.value,dl(Rre,n._currentValue),n._currentValue=l,o!==null)if(dg(o.value,l)){if(o.children===a.children&&!Yh.current){t=e0(e,t,s);break e}}else for(o=t.child,o!==null&&(o.return=t);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=Py(-1,s&-s),d.tag=2;var m=o.updateQueue;if(m!==null){m=m.shared;var p=m.pending;p===null?d.next=d:(d.next=p.next,p.next=d),m.pending=d}}o.lanes|=s,d=o.alternate,d!==null&&(d.lanes|=s),Xme(o.return,s,t),i.lanes|=s;break}d=d.next}}else if(o.tag===10)l=o.type===t.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(Ds(341));l.lanes|=s,i=l.alternate,i!==null&&(i.lanes|=s),Xme(l,s,t),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===t){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}ih(e,t,a.children,s),t=t.child}return t;case 9:return a=t.type,n=t.pendingProps.children,p4(t,s),a=Wf(a),n=n(a),t.flags|=1,ih(e,t,n,s),t.child;case 14:return n=t.type,a=Dp(n,t.pendingProps),a=Dp(n.type,a),dSe(e,t,n,a,s);case 15:return aDe(e,t,t.type,t.pendingProps,s);case 17:return n=t.type,a=t.pendingProps,a=t.elementType===n?a:Dp(n,a),S8(e,t),t.tag=1,Xh(n)?(e=!0,Lre(t)):e=!1,p4(t,s),rDe(t,n,a),Jme(t,n,a,s),rfe(null,t,n,!0,e,s);case 19:return dDe(e,t,s);case 22:return iDe(e,t,s)}throw Error(Ds(156,t.tag))};function SDe(e,t){return J6e(e,t)}function Est(e,t,s,n){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,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 Tf(e,t,s,n){return new Est(e,t,s,n)}function _0e(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ist(e){if(typeof e=="function")return _0e(e)?1:0;if(e!=null){if(e=e.$$typeof,e===zye)return 11;if(e===Bye)return 14}return 2}function p1(e,t){var s=e.alternate;return s===null?(s=Tf(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function T8(e,t,s,n,a,o){var l=2;if(n=e,typeof e=="function")_0e(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case $C:return hk(s.children,a,o,t);case Fye:l=8,a|=8;break;case jme:return e=Tf(12,s,t,a|2),e.elementType=jme,e.lanes=o,e;case kme:return e=Tf(13,s,t,a),e.elementType=kme,e.lanes=o,e;case Nme:return e=Tf(19,s,t,a),e.elementType=Nme,e.lanes=o,e;case O6e:return Uae(s,a,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case L6e:l=10;break e;case D6e:l=9;break e;case zye:l=11;break e;case Bye:l=14;break e;case _v:l=16,n=null;break e}throw Error(Ds(130,e==null?e:typeof e,""))}return t=Tf(l,s,t,a),t.elementType=e,t.type=n,t.lanes=o,t}function hk(e,t,s,n){return e=Tf(7,e,n,t),e.lanes=s,e}function Uae(e,t,s,n){return e=Tf(22,e,n,t),e.elementType=O6e,e.lanes=s,e.stateNode={isHidden:!1},e}function Gde(e,t,s){return e=Tf(6,e,null,t),e.lanes=s,e}function Kde(e,t,s){return t=Tf(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Pst(e,t,s,n,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mde(0),this.expirationTimes=Mde(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mde(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function b0e(e,t,s,n,a,o,l,i,d){return e=new Pst(e,t,s,i,d),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Tf(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:n,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},n0e(o),e}function Lst(e,t,s){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(ADe)}catch(e){console.error(e)}}ADe(),A6e.exports=Km;var Hh=A6e.exports;const N0e=ho(Hh);var EDe,kSe=Hh;EDe=kSe.createRoot,kSe.hydrateRoot;const zst=1,Bst=1e6;let Zde=0;function $st(){return Zde=(Zde+1)%Number.MAX_SAFE_INTEGER,Zde.toString()}const Yde=new Map,NSe=e=>{if(Yde.has(e))return;const t=setTimeout(()=>{Yde.delete(e),lE({type:"REMOVE_TOAST",toastId:e})},Bst);Yde.set(e,t)},Ust=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,zst)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(s=>s.id===t.toast.id?{...s,...t.toast}:s)};case"DISMISS_TOAST":{const{toastId:s}=t;return s?NSe(s):e.toasts.forEach(n=>{NSe(n.id)}),{...e,toasts:e.toasts.map(n=>n.id===s||s===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(s=>s.id!==t.toastId)}}},A8=[];let E8={toasts:[]};function lE(e){E8=Ust(E8,e),A8.forEach(t=>{t(E8)})}function ta({...e}){const t=$st(),s=a=>lE({type:"UPDATE_TOAST",toast:{...a,id:t}}),n=()=>lE({type:"DISMISS_TOAST",toastId:t});return lE({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:a=>{a||n()}}}),{id:t,dismiss:n,update:s}}function _i(){const[e,t]=A.useState(E8);return A.useEffect(()=>(A8.push(t),()=>{const s=A8.indexOf(t);s>-1&&A8.splice(s,1)}),[e]),{...e,toast:ta,dismiss:s=>lE({type:"DISMISS_TOAST",toastId:s})}}function bs(e,t,{checkForDefaultPrevented:s=!0}={}){return function(a){if(e==null||e(a),s===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function SSe(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function t0(...e){return t=>{let s=!1;const n=e.map(a=>{const o=SSe(a,t);return!s&&typeof o=="function"&&(s=!0),o});if(s)return()=>{for(let a=0;a{const{children:l,...i}=o,d=A.useMemo(()=>i,Object.values(i));return r.jsx(s.Provider,{value:d,children:l})};n.displayName=e+"Provider";function a(o){const l=A.useContext(s);if(l)return l;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return[n,a]}function Sc(e,t=[]){let s=[];function n(o,l){const i=A.createContext(l),d=s.length;s=[...s,l];const m=g=>{var T;const{scope:v,children:_,...k}=g,w=((T=v==null?void 0:v[e])==null?void 0:T[d])||i,S=A.useMemo(()=>k,Object.values(k));return r.jsx(w.Provider,{value:S,children:_})};m.displayName=o+"Provider";function p(g,v){var w;const _=((w=v==null?void 0:v[e])==null?void 0:w[d])||i,k=A.useContext(_);if(k)return k;if(l!==void 0)return l;throw new Error(`\`${g}\` must be used within \`${o}\``)}return[m,p]}const a=()=>{const o=s.map(l=>A.createContext(l));return function(i){const d=(i==null?void 0:i[e])||o;return A.useMemo(()=>({[`__scope${e}`]:{...i,[e]:d}}),[i,d])}};return a.scopeName=e,[n,qst(a,...t)]}function qst(...e){const t=e[0];if(e.length===1)return t;const s=()=>{const n=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const l=n.reduce((i,{useScope:d,scopeName:m})=>{const g=d(o)[`__scope${m}`];return{...i,...g}},{});return A.useMemo(()=>({[`__scope${t.scopeName}`]:l}),[l])}};return s.scopeName=t.scopeName,s}function $1(e){const t=Hst(e),s=A.forwardRef((n,a)=>{const{children:o,...l}=n,i=A.Children.toArray(o),d=i.find(Wst);if(d){const m=d.props.children,p=i.map(g=>g===d?A.Children.count(m)>1?A.Children.only(null):A.isValidElement(m)?m.props.children:null:g);return r.jsx(t,{...l,ref:a,children:A.isValidElement(m)?A.cloneElement(m,void 0,p):null})}return r.jsx(t,{...l,ref:a,children:o})});return s.displayName=`${e}.Slot`,s}var S0e=$1("Slot");function Hst(e){const t=A.forwardRef((s,n)=>{const{children:a,...o}=s;if(A.isValidElement(a)){const l=Kst(a),i=Gst(o,a.props);return a.type!==A.Fragment&&(i.ref=n?t0(n,l):l),A.cloneElement(a,i)}return A.Children.count(a)>1?A.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var IDe=Symbol("radix.slottable");function PDe(e){const t=({children:s})=>r.jsx(r.Fragment,{children:s});return t.displayName=`${e}.Slottable`,t.__radixId=IDe,t}function Wst(e){return A.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===IDe}function Gst(e,t){const s={...t};for(const n in t){const a=e[n],o=t[n];/^on[A-Z]/.test(n)?a&&o?s[n]=(...i)=>{const d=o(...i);return a(...i),d}:a&&(s[n]=a):n==="style"?s[n]={...a,...o}:n==="className"&&(s[n]=[a,o].filter(Boolean).join(" "))}return{...e,...s}}function Kst(e){var n,a;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function h6(e){const t=e+"CollectionProvider",[s,n]=Sc(t),[a,o]=s(t,{collectionRef:{current:null},itemMap:new Map}),l=w=>{const{scope:S,children:T}=w,C=lt.useRef(null),I=lt.useRef(new Map).current;return r.jsx(a,{scope:S,itemMap:I,collectionRef:C,children:T})};l.displayName=t;const i=e+"CollectionSlot",d=$1(i),m=lt.forwardRef((w,S)=>{const{scope:T,children:C}=w,I=o(i,T),R=va(S,I.collectionRef);return r.jsx(d,{ref:R,children:C})});m.displayName=i;const p=e+"CollectionItemSlot",g="data-radix-collection-item",v=$1(p),_=lt.forwardRef((w,S)=>{const{scope:T,children:C,...I}=w,R=lt.useRef(null),D=va(S,R),B=o(p,T);return lt.useEffect(()=>(B.itemMap.set(R,{ref:R,...I}),()=>void B.itemMap.delete(R))),r.jsx(v,{[g]:"",ref:D,children:C})});_.displayName=p;function k(w){const S=o(e+"CollectionConsumer",w);return lt.useCallback(()=>{const C=S.collectionRef.current;if(!C)return[];const I=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(S.itemMap.values()).sort((B,$)=>I.indexOf(B.ref.current)-I.indexOf($.ref.current))},[S.collectionRef,S.itemMap])}return[{Provider:l,Slot:m,ItemSlot:_},k,n]}var Zst=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Hs=Zst.reduce((e,t)=>{const s=$1(`Primitive.${t}`),n=A.forwardRef((a,o)=>{const{asChild:l,...i}=a,d=l?s:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(d,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function C0e(e,t){e&&Hh.flushSync(()=>e.dispatchEvent(t))}function gc(e){const t=A.useRef(e);return A.useEffect(()=>{t.current=e}),A.useMemo(()=>(...s)=>{var n;return(n=t.current)==null?void 0:n.call(t,...s)},[])}function Yst(e,t=globalThis==null?void 0:globalThis.document){const s=gc(e);A.useEffect(()=>{const n=a=>{a.key==="Escape"&&s(a)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[s,t])}var Xst="DismissableLayer",ffe="dismissableLayer.update",Qst="dismissableLayer.pointerDownOutside",Jst="dismissableLayer.focusOutside",CSe,LDe=A.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),J1=A.forwardRef((e,t)=>{const{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...d}=e,m=A.useContext(LDe),[p,g]=A.useState(null),v=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,_]=A.useState({}),k=va(t,$=>g($)),w=Array.from(m.layers),[S]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),T=w.indexOf(S),C=p?w.indexOf(p):-1,I=m.layersWithOutsidePointerEventsDisabled.size>0,R=C>=T,D=tnt($=>{const q=$.target,W=[...m.branches].some(K=>K.contains(q));!R||W||(a==null||a($),l==null||l($),$.defaultPrevented||i==null||i())},v),B=rnt($=>{const q=$.target;[...m.branches].some(K=>K.contains(q))||(o==null||o($),l==null||l($),$.defaultPrevented||i==null||i())},v);return Yst($=>{C===m.layers.size-1&&(n==null||n($),!$.defaultPrevented&&i&&($.preventDefault(),i()))},v),A.useEffect(()=>{if(p)return s&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(CSe=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(p)),m.layers.add(p),MSe(),()=>{s&&m.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=CSe)}},[p,v,s,m]),A.useEffect(()=>()=>{p&&(m.layers.delete(p),m.layersWithOutsidePointerEventsDisabled.delete(p),MSe())},[p,m]),A.useEffect(()=>{const $=()=>_({});return document.addEventListener(ffe,$),()=>document.removeEventListener(ffe,$)},[]),r.jsx(Hs.div,{...d,ref:k,style:{pointerEvents:I?R?"auto":"none":void 0,...e.style},onFocusCapture:bs(e.onFocusCapture,B.onFocusCapture),onBlurCapture:bs(e.onBlurCapture,B.onBlurCapture),onPointerDownCapture:bs(e.onPointerDownCapture,D.onPointerDownCapture)})});J1.displayName=Xst;var ent="DismissableLayerBranch",DDe=A.forwardRef((e,t)=>{const s=A.useContext(LDe),n=A.useRef(null),a=va(t,n);return A.useEffect(()=>{const o=n.current;if(o)return s.branches.add(o),()=>{s.branches.delete(o)}},[s.branches]),r.jsx(Hs.div,{...e,ref:a})});DDe.displayName=ent;function tnt(e,t=globalThis==null?void 0:globalThis.document){const s=gc(e),n=A.useRef(!1),a=A.useRef(()=>{});return A.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let d=function(){ODe(Qst,s,m,{discrete:!0})};const m={originalEvent:i};i.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=d,t.addEventListener("click",a.current,{once:!0})):d()}else t.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(l),t.removeEventListener("pointerdown",o),t.removeEventListener("click",a.current)}},[t,s]),{onPointerDownCapture:()=>n.current=!0}}function rnt(e,t=globalThis==null?void 0:globalThis.document){const s=gc(e),n=A.useRef(!1);return A.useEffect(()=>{const a=o=>{o.target&&!n.current&&ODe(Jst,s,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,s]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function MSe(){const e=new CustomEvent(ffe);document.dispatchEvent(e)}function ODe(e,t,s,{discrete:n}){const a=s.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});t&&a.addEventListener(e,t,{once:!0}),n?C0e(a,o):a.dispatchEvent(o)}var snt=J1,nnt=DDe,kc=globalThis!=null&&globalThis.document?A.useLayoutEffect:()=>{},ant="Portal",v3=A.forwardRef((e,t)=>{var i;const{container:s,...n}=e,[a,o]=A.useState(!1);kc(()=>o(!0),[]);const l=s||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?N0e.createPortal(r.jsx(Hs.div,{...n,ref:t}),l):null});v3.displayName=ant;function int(e,t){return A.useReducer((s,n)=>t[s][n]??s,e)}var Wc=e=>{const{present:t,children:s}=e,n=ont(t),a=typeof s=="function"?s({present:n.isPresent}):A.Children.only(s),o=va(n.ref,lnt(a));return typeof s=="function"||n.isPresent?A.cloneElement(a,{ref:o}):null};Wc.displayName="Presence";function ont(e){const[t,s]=A.useState(),n=A.useRef(null),a=A.useRef(e),o=A.useRef("none"),l=e?"mounted":"unmounted",[i,d]=int(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return A.useEffect(()=>{const m=uO(n.current);o.current=i==="mounted"?m:"none"},[i]),kc(()=>{const m=n.current,p=a.current;if(p!==e){const v=o.current,_=uO(m);e?d("MOUNT"):_==="none"||(m==null?void 0:m.display)==="none"?d("UNMOUNT"):d(p&&v!==_?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,d]),kc(()=>{if(t){let m;const p=t.ownerDocument.defaultView??window,g=_=>{const w=uO(n.current).includes(_.animationName);if(_.target===t&&w&&(d("ANIMATION_END"),!a.current)){const S=t.style.animationFillMode;t.style.animationFillMode="forwards",m=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=S)})}},v=_=>{_.target===t&&(o.current=uO(n.current))};return t.addEventListener("animationstart",v),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{p.clearTimeout(m),t.removeEventListener("animationstart",v),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:A.useCallback(m=>{n.current=m?getComputedStyle(m):null,s(m)},[])}}function uO(e){return(e==null?void 0:e.animationName)||"none"}function lnt(e){var n,a;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var cnt=Lye[" useInsertionEffect ".trim().toString()]||kc;function bh({prop:e,defaultProp:t,onChange:s=()=>{},caller:n}){const[a,o,l]=dnt({defaultProp:t,onChange:s}),i=e!==void 0,d=i?e:a;{const p=A.useRef(e!==void 0);A.useEffect(()=>{const g=p.current;g!==i&&console.warn(`${n} is changing from ${g?"controlled":"uncontrolled"} to ${i?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),p.current=i},[i,n])}const m=A.useCallback(p=>{var g;if(i){const v=unt(p)?p(e):p;v!==e&&((g=l.current)==null||g.call(l,v))}else o(p)},[i,e,o,l]);return[d,m]}function dnt({defaultProp:e,onChange:t}){const[s,n]=A.useState(e),a=A.useRef(s),o=A.useRef(t);return cnt(()=>{o.current=t},[t]),A.useEffect(()=>{var l;a.current!==s&&((l=o.current)==null||l.call(o,s),a.current=s)},[s,a]),[s,n,o]}function unt(e){return typeof e=="function"}var RDe=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"}),hnt="VisuallyHidden",Gae=A.forwardRef((e,t)=>r.jsx(Hs.span,{...e,ref:t,style:{...RDe,...e.style}}));Gae.displayName=hnt;var mnt=Gae,M0e="ToastProvider",[T0e,fnt,pnt]=h6("Toast"),[FDe]=Sc("Toast",[pnt]),[gnt,Kae]=FDe(M0e),zDe=e=>{const{__scopeToast:t,label:s="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=e,[i,d]=A.useState(null),[m,p]=A.useState(0),g=A.useRef(!1),v=A.useRef(!1);return s.trim()||console.error(`Invalid prop \`label\` supplied to \`${M0e}\`. Expected non-empty \`string\`.`),r.jsx(T0e.Provider,{scope:t,children:r.jsx(gnt,{scope:t,label:s,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:m,viewport:i,onViewportChange:d,onToastAdd:A.useCallback(()=>p(_=>_+1),[]),onToastRemove:A.useCallback(()=>p(_=>_-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:v,children:l})})};zDe.displayName=M0e;var BDe="ToastViewport",xnt=["F8"],pfe="toast.viewportPause",gfe="toast.viewportResume",$De=A.forwardRef((e,t)=>{const{__scopeToast:s,hotkey:n=xnt,label:a="Notifications ({hotkey})",...o}=e,l=Kae(BDe,s),i=fnt(s),d=A.useRef(null),m=A.useRef(null),p=A.useRef(null),g=A.useRef(null),v=va(t,g,l.onViewportChange),_=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),k=l.toastCount>0;A.useEffect(()=>{const S=T=>{var I;n.length!==0&&n.every(R=>T[R]||T.code===R)&&((I=g.current)==null||I.focus())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[n]),A.useEffect(()=>{const S=d.current,T=g.current;if(k&&S&&T){const C=()=>{if(!l.isClosePausedRef.current){const B=new CustomEvent(pfe);T.dispatchEvent(B),l.isClosePausedRef.current=!0}},I=()=>{if(l.isClosePausedRef.current){const B=new CustomEvent(gfe);T.dispatchEvent(B),l.isClosePausedRef.current=!1}},R=B=>{!S.contains(B.relatedTarget)&&I()},D=()=>{S.contains(document.activeElement)||I()};return S.addEventListener("focusin",C),S.addEventListener("focusout",R),S.addEventListener("pointermove",C),S.addEventListener("pointerleave",D),window.addEventListener("blur",C),window.addEventListener("focus",I),()=>{S.removeEventListener("focusin",C),S.removeEventListener("focusout",R),S.removeEventListener("pointermove",C),S.removeEventListener("pointerleave",D),window.removeEventListener("blur",C),window.removeEventListener("focus",I)}}},[k,l.isClosePausedRef]);const w=A.useCallback(({tabbingDirection:S})=>{const C=i().map(I=>{const R=I.ref.current,D=[R,...Ant(R)];return S==="forwards"?D:D.reverse()});return(S==="forwards"?C.reverse():C).flat()},[i]);return A.useEffect(()=>{const S=g.current;if(S){const T=C=>{var D,B,$;const I=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!I){const q=document.activeElement,W=C.shiftKey;if(C.target===S&&W){(D=m.current)==null||D.focus();return}const ae=w({tabbingDirection:W?"backwards":"forwards"}),oe=ae.findIndex(se=>se===q);Xde(ae.slice(oe+1))?C.preventDefault():W?(B=m.current)==null||B.focus():($=p.current)==null||$.focus()}};return S.addEventListener("keydown",T),()=>S.removeEventListener("keydown",T)}},[i,w]),r.jsxs(nnt,{ref:d,role:"region","aria-label":a.replace("{hotkey}",_),tabIndex:-1,style:{pointerEvents:k?void 0:"none"},children:[k&&r.jsx(xfe,{ref:m,onFocusFromOutsideViewport:()=>{const S=w({tabbingDirection:"forwards"});Xde(S)}}),r.jsx(T0e.Slot,{scope:s,children:r.jsx(Hs.ol,{tabIndex:-1,...o,ref:v})}),k&&r.jsx(xfe,{ref:p,onFocusFromOutsideViewport:()=>{const S=w({tabbingDirection:"backwards"});Xde(S)}})]})});$De.displayName=BDe;var UDe="ToastFocusProxy",xfe=A.forwardRef((e,t)=>{const{__scopeToast:s,onFocusFromOutsideViewport:n,...a}=e,o=Kae(UDe,s);return r.jsx(Gae,{"aria-hidden":!0,tabIndex:0,...a,ref:t,style:{position:"fixed"},onFocus:l=>{var m;const i=l.relatedTarget;!((m=o.viewport)!=null&&m.contains(i))&&n()}})});xfe.displayName=UDe;var m6="Toast",ynt="toast.swipeStart",vnt="toast.swipeMove",_nt="toast.swipeCancel",bnt="toast.swipeEnd",VDe=A.forwardRef((e,t)=>{const{forceMount:s,open:n,defaultOpen:a,onOpenChange:o,...l}=e,[i,d]=bh({prop:n,defaultProp:a??!0,onChange:o,caller:m6});return r.jsx(Wc,{present:s||i,children:r.jsx(knt,{open:i,...l,ref:t,onClose:()=>d(!1),onPause:gc(e.onPause),onResume:gc(e.onResume),onSwipeStart:bs(e.onSwipeStart,m=>{m.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:bs(e.onSwipeMove,m=>{const{x:p,y:g}=m.detail.delta;m.currentTarget.setAttribute("data-swipe","move"),m.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),m.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:bs(e.onSwipeCancel,m=>{m.currentTarget.setAttribute("data-swipe","cancel"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),m.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),m.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:bs(e.onSwipeEnd,m=>{const{x:p,y:g}=m.detail.delta;m.currentTarget.setAttribute("data-swipe","end"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),m.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),m.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),m.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),d(!1)})})})});VDe.displayName=m6;var[wnt,jnt]=FDe(m6,{onClose(){}}),knt=A.forwardRef((e,t)=>{const{__scopeToast:s,type:n="foreground",duration:a,open:o,onClose:l,onEscapeKeyDown:i,onPause:d,onResume:m,onSwipeStart:p,onSwipeMove:g,onSwipeCancel:v,onSwipeEnd:_,...k}=e,w=Kae(m6,s),[S,T]=A.useState(null),C=va(t,se=>T(se)),I=A.useRef(null),R=A.useRef(null),D=a||w.duration,B=A.useRef(0),$=A.useRef(D),q=A.useRef(0),{onToastAdd:W,onToastRemove:K}=w,re=gc(()=>{var pe;(S==null?void 0:S.contains(document.activeElement))&&((pe=w.viewport)==null||pe.focus()),l()}),ae=A.useCallback(se=>{!se||se===1/0||(window.clearTimeout(q.current),B.current=new Date().getTime(),q.current=window.setTimeout(re,se))},[re]);A.useEffect(()=>{const se=w.viewport;if(se){const pe=()=>{ae($.current),m==null||m()},ie=()=>{const de=new Date().getTime()-B.current;$.current=$.current-de,window.clearTimeout(q.current),d==null||d()};return se.addEventListener(pfe,ie),se.addEventListener(gfe,pe),()=>{se.removeEventListener(pfe,ie),se.removeEventListener(gfe,pe)}}},[w.viewport,D,d,m,ae]),A.useEffect(()=>{o&&!w.isClosePausedRef.current&&ae(D)},[o,D,w.isClosePausedRef,ae]),A.useEffect(()=>(W(),()=>K()),[W,K]);const oe=A.useMemo(()=>S?YDe(S):null,[S]);return w.viewport?r.jsxs(r.Fragment,{children:[oe&&r.jsx(Nnt,{__scopeToast:s,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:oe}),r.jsx(wnt,{scope:s,onClose:re,children:Hh.createPortal(r.jsx(T0e.ItemSlot,{scope:s,children:r.jsx(snt,{asChild:!0,onEscapeKeyDown:bs(i,()=>{w.isFocusedToastEscapeKeyDownRef.current||re(),w.isFocusedToastEscapeKeyDownRef.current=!1}),children:r.jsx(Hs.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":w.swipeDirection,...k,ref:C,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:bs(e.onKeyDown,se=>{se.key==="Escape"&&(i==null||i(se.nativeEvent),se.nativeEvent.defaultPrevented||(w.isFocusedToastEscapeKeyDownRef.current=!0,re()))}),onPointerDown:bs(e.onPointerDown,se=>{se.button===0&&(I.current={x:se.clientX,y:se.clientY})}),onPointerMove:bs(e.onPointerMove,se=>{if(!I.current)return;const pe=se.clientX-I.current.x,ie=se.clientY-I.current.y,de=!!R.current,ce=["left","right"].includes(w.swipeDirection),ge=["left","up"].includes(w.swipeDirection)?Math.min:Math.max,Te=ce?ge(0,pe):0,_e=ce?0:ge(0,ie),ve=se.pointerType==="touch"?10:2,Me={x:Te,y:_e},Ze={originalEvent:se,delta:Me};de?(R.current=Me,hO(vnt,g,Ze,{discrete:!1})):TSe(Me,w.swipeDirection,ve)?(R.current=Me,hO(ynt,p,Ze,{discrete:!1}),se.target.setPointerCapture(se.pointerId)):(Math.abs(pe)>ve||Math.abs(ie)>ve)&&(I.current=null)}),onPointerUp:bs(e.onPointerUp,se=>{const pe=R.current,ie=se.target;if(ie.hasPointerCapture(se.pointerId)&&ie.releasePointerCapture(se.pointerId),R.current=null,I.current=null,pe){const de=se.currentTarget,ce={originalEvent:se,delta:pe};TSe(pe,w.swipeDirection,w.swipeThreshold)?hO(bnt,_,ce,{discrete:!0}):hO(_nt,v,ce,{discrete:!0}),de.addEventListener("click",ge=>ge.preventDefault(),{once:!0})}})})})}),w.viewport)})]}):null}),Nnt=e=>{const{__scopeToast:t,children:s,...n}=e,a=Kae(m6,t),[o,l]=A.useState(!1),[i,d]=A.useState(!1);return Mnt(()=>l(!0)),A.useEffect(()=>{const m=window.setTimeout(()=>d(!0),1e3);return()=>window.clearTimeout(m)},[]),i?null:r.jsx(v3,{asChild:!0,children:r.jsx(Gae,{...n,children:o&&r.jsxs(r.Fragment,{children:[a.label," ",s]})})})},Snt="ToastTitle",qDe=A.forwardRef((e,t)=>{const{__scopeToast:s,...n}=e;return r.jsx(Hs.div,{...n,ref:t})});qDe.displayName=Snt;var Cnt="ToastDescription",HDe=A.forwardRef((e,t)=>{const{__scopeToast:s,...n}=e;return r.jsx(Hs.div,{...n,ref:t})});HDe.displayName=Cnt;var WDe="ToastAction",GDe=A.forwardRef((e,t)=>{const{altText:s,...n}=e;return s.trim()?r.jsx(ZDe,{altText:s,asChild:!0,children:r.jsx(A0e,{...n,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${WDe}\`. Expected non-empty \`string\`.`),null)});GDe.displayName=WDe;var KDe="ToastClose",A0e=A.forwardRef((e,t)=>{const{__scopeToast:s,...n}=e,a=jnt(KDe,s);return r.jsx(ZDe,{asChild:!0,children:r.jsx(Hs.button,{type:"button",...n,ref:t,onClick:bs(e.onClick,a.onClose)})})});A0e.displayName=KDe;var ZDe=A.forwardRef((e,t)=>{const{__scopeToast:s,altText:n,...a}=e;return r.jsx(Hs.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:t})});function YDe(e){const t=[];return Array.from(e.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&t.push(n.textContent),Tnt(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&&t.push(l)}else t.push(...YDe(n))}}),t}function hO(e,t,s,{discrete:n}){const a=s.originalEvent.currentTarget,o=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:s});t&&a.addEventListener(e,t,{once:!0}),n?C0e(a,o):a.dispatchEvent(o)}var TSe=(e,t,s=0)=>{const n=Math.abs(e.x),a=Math.abs(e.y),o=n>a;return t==="left"||t==="right"?o&&n>s:!o&&a>s};function Mnt(e=()=>{}){const t=gc(e);kc(()=>{let s=0,n=0;return s=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(n)}},[t])}function Tnt(e){return e.nodeType===e.ELEMENT_NODE}function Ant(e){const t=[],s=document.createTreeWalker(e,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(;s.nextNode();)t.push(s.currentNode);return t}function Xde(e){const t=document.activeElement;return e.some(s=>s===t?!0:(s.focus(),document.activeElement!==t))}var Ent=zDe,XDe=$De,QDe=VDe,JDe=qDe,eOe=HDe,tOe=GDe,rOe=A0e;function sOe(e){var t,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;ttypeof e=="boolean"?`${e}`:e===0?"0":e,ESe=ki,_3=(e,t)=>s=>{var n;if((t==null?void 0:t.variants)==null)return ESe(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:a,defaultVariants:o}=t,l=Object.keys(a).map(m=>{const p=s==null?void 0:s[m],g=o==null?void 0:o[m];if(p===null)return null;const v=ASe(p)||ASe(g);return a[m][v]}),i=s&&Object.entries(s).reduce((m,p)=>{let[g,v]=p;return v===void 0||(m[g]=v),m},{}),d=t==null||(n=t.compoundVariants)===null||n===void 0?void 0:n.reduce((m,p)=>{let{class:g,className:v,..._}=p;return Object.entries(_).every(k=>{let[w,S]=k;return Array.isArray(S)?S.includes({...o,...i}[w]):{...o,...i}[w]===S})?[...m,g,v]:m},[]);return ESe(e,l,d,s==null?void 0:s.class,s==null?void 0:s.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 Int=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nOe=(...e)=>e.filter((t,s,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===s).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 Pnt={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 aOe=A.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},d)=>A.createElement("svg",{ref:d,...Pnt,width:t,height:t,stroke:e,strokeWidth:n?Number(s)*24/Number(t):s,className:nOe("lucide",a),...i},[...l.map(([m,p])=>A.createElement(m,p)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H=(e,t)=>{const s=A.forwardRef(({className:n,...a},o)=>A.createElement(aOe,{ref:o,iconNode:t,className:nOe(`lucide-${Int(e)}`,n),...a}));return s.displayName=`${e}`,s};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I8=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 P8=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 L8=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 D8=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 lx=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 O8=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 R8=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 pb=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 gb=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 F8=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 xb=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 z8=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 B8=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 $8=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 U8=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 V8=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 x4=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 q8=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 H8=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 W8=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 G8=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 K8=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 Z8=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 Y8=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 X8=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 Q8=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 J8=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 eR=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 y4=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 v4=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 tR=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 rR=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 sR=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 nR=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 aR=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 iR=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 oR=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 lR=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 cR=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 dR=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 uR=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 hR=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 mR=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 fR=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 pR=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 gR=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 xR=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 yR=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 vR=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 _R=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 bR=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 cE=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 wR=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 dE=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 jR=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 _4=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 kR=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 NR=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 SR=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 CR=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 MR=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 TR=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 AR=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 ER=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 IR=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 PR=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 LR=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 yb=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 DR=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 OR=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 RR=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 FR=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 zR=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 BR=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 $R=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 vb=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 _b=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 Ly=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 UR=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 VR=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 qR=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 gi=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 HR=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 Dy=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 WR=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 Ki=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 GR=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 KR=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 bb=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 eg=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 ZR=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 YR=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 XR=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 wb=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 QR=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 JR=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 eF=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 jb=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 Pf=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 tF=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 rF=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 sF=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 nF=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 aF=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 iF=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 Yl=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 oF=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 kb=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 lF=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 cF=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 dF=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 uF=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 Nb=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 hF=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 mF=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 fF=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 pF=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 gF=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 xF=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 yF=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 vF=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 _F=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 bF=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 wF=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 jF=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 kF=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 NF=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 SF=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 CF=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 MF=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 TF=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 AF=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 EF=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 IF=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 g1=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 PF=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 LF=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 DF=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 OF=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 RF=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 FF=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 zF=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 BF=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 $F=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 UF=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 VF=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 x1=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 qF=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 HF=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 WF=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 GF=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 KF=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 ZF=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 mk=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 YF=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 XF=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 tg=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 Sb=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 Cb=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 QF=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 JF=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 ez=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 tz=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 rz=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 sz=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 nz=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 az=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 iz=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 oz=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 lz=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 cz=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 dz=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 uz=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 hz=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 mz=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 b4=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 fz=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 pz=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 gz=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 xz=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 yz=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 vz=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 _z=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 Mb=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 bz=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 wz=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 jz=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 kz=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 Nz=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 Sz=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 Cz=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 Mz=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 Tz=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 Az=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 Oy=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 Ez=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 Iz=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 Pz=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 Lz=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 Dz=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 Oz=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 Rz=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 Fz=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 zz=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 Bz=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 uE=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 $z=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 rg=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 Uz=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 Vz=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 qz=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 w4=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 Hz=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 Wz=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 Tb=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 Gz=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 Kz=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 Zz=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 hE=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 Yz=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 Xz=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 Qz=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 Jz=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 Pu=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 e7=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 t7=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 r7=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 s7=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 n7=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 Ni=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 fk=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 a7=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 i7=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 o7=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 l7=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 c7=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 Lm=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 d7=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 u7=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 h7=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 m7=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 f7=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 p7=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 mE=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 g7=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 sg=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 x7=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 y7=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 v7=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 _7=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 b7=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 w7=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 y1=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 j7=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 k7=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 N7=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 S7=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 C7=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 An=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 M7=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 ng=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 T7=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 A7=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 E7=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 I7=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 P7=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 Ab=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 L7=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 D7=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 O7=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 R7=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 F7=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 z7=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 B7=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 $7=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 U7=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 V7=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 q7=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 H7=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 W7=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 Eb=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 Ib=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 G7=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 K7=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 Z7=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 Pb=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 Lb=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 Db=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 Y7=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 Ob=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 X7=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 Rc=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 Q7=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 Rb=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 J7=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 eB=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 Fb=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 zb=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 tB=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 Bb=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 $b=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 Ub=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 rB=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 sB=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 mi=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 nB=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 aB=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 ad=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 iB=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 oB=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 jc=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 Zi=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 cx=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 lB=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 cB=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 dB=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 uB=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 hB=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 mB=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 fB=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 Ry=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 pB=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 gB=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 xB=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 yB=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 vB=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 kl=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 Vb=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 qb=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 Hb=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 Wb=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 Gb=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 Kb=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 Zb=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 Yb=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 ui=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 Ri=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 Xb=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 Qb=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 Jb=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 ew=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 _B=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 tw=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 bB=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 wB=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 jB=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 kB=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 NB=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 SB=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 CB=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 rw=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 by=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 sw=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 MB=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 nw=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 aw=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 iw=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 ow=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 kf=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 lw=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 cw=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 dw=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 TB=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 uw=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 hw=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 mw=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 Fc=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 vh=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 AB=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 EB=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 IB=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 j4=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 PB=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 fE=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 LB=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 DB=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 fw=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 pw=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 OB=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 RB=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 FB=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 zB=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 BB=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 $B=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 UB=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 VB=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 qB=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 HB=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 WB=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 GB=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 KB=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 ZB=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 YB=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 XB=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 QB=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 JB=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 e9=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 Pa=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 t9=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 r9=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 gw=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 s9=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 n9=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 a9=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 i9=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 o9=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 l9=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 c9=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 d9=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 u9=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 h9=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 m9=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 f9=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 xw=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 p9=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 g9=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 My=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 x9=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 yw=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 pk=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 y9=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 v9=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 gk=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 _9=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 b9=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 vw=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 _w=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 w9=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 j9=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 k9=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 N9=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 S9=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 C9=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 M9=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 T9=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 A9=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 bw=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 xk=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 E9=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 I9=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 P9=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 L9=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 D9=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 O9=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 R9=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 F9=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 z9=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 uo=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 B9=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 $9=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 U9=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 V9=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 q9=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 H9=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 W9=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 G9=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 K9=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 Z9=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 Y9=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 X9=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 Dm=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 Q9=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 J9=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 e$=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 t$=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 _h=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 r$=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 s$=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 n$=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 a$=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 i$=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 o$=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 l$=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 c$=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 d$=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 u$=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 h$=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 m$=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 ww=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 f$=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 p$=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 g$=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 x$=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 y$=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 v$=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 _$=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 b$=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 w$=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 j$=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 k$=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 N$=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 S$=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 C$=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 M$=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 T$=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 A$=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 E$=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 I$=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 Sd=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 P$=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 L$=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 Fy=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 D$=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 Fi=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 O$=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 R$=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 F$=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 z$=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 B$=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 dx=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 $$=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 U$=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 V$=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 q$=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 H$=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 W$=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 jw=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 G$=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 K$=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 Z$=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 k4=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 Qg=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 Nf=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 Y$=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 X$=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 Q$=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 J$=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 eU=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 tU=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 rU=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 jn=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 sU=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 Lf=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 Ii=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 fu=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 nU=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 aU=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 iU=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 oU=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 lU=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 cU=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 dU=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 uU=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 hU=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 mU=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 kw=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 fU=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 pU=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 gU=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 Nw=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 Sw=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 Cw=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 Mw=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 xU=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 yU=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 vU=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 _U=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 bU=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 Tw=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 wU=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 jU=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 kU=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 NU=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 v1=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 SU=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 CU=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 MU=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 TU=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 AU=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 EU=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 IU=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 PU=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 LU=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 DU=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 OU=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 Aw=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 Ew=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 RU=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 FU=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 zU=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 BU=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 $U=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 UU=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 VU=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 _1=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 qU=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 HU=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 WU=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 ya=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 GU=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 KU=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 ZU=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 YU=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 XU=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 QU=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 JU=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 eV=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 tV=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 rV=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 sV=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 N4=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 nV=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 Ud=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 aV=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 b1=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 iV=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 oV=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 lV=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 cV=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 dV=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 uV=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 hV=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 mV=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 zy=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 fV=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 Om=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 pV=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 gV=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 xV=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 yk=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 yV=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 vV=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 _V=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 bV=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 wV=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 Kp=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 jV=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 kV=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 NV=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 SV=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 CV=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 MV=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 TV=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 AV=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 EV=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 Iw=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 IV=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 PV=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 LV=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 DV=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 OV=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 RV=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 FV=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 zV=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 BV=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 $V=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 UV=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 Jh=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 VV=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 Pw=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 qV=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 HV=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 WV=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 GV=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 KV=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 ZV=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 YV=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 XV=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 QV=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 JV=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 eq=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 tq=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 rq=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 sq=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 nq=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 aq=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 iq=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 oq=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 lq=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 cq=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 dq=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 uq=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 hq=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 mq=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 fq=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 pq=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 gq=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 xq=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 yq=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 vk=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 po=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 vq=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 _q=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 Lw=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 bq=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 wq=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 jq=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 kq=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 Nq=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 Sq=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 Cq=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 Mq=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 Tq=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 Aq=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 Eq=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 Iq=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 Pq=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 Lq=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 Dq=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 Oq=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 Rq=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 ux=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 Fq=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 zq=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 w1=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 Bq=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 $q=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 Dw=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 Uq=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 Ow=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 bm=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 Vq=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 Df=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 qq=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 Hq=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 Wq=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 Gq=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 Kq=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 Zq=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 Yq=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 Rw=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 Xq=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 Qq=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 pE=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 Jq=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 eH=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 tH=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 gE=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 rH=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 S4=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 sH=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 nH=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 xE=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 yE=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 aH=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 iH=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 oH=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 lH=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 cH=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 dH=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 uH=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 hH=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 mH=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 fH=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 pH=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 gH=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 Ai=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 xH=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 yH=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 vH=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 C4=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 _H=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 wH=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 jH=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 kH=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 NH=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 SH=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 Vn=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 Fw=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 zw=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 CH=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 MH=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 TH=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 AH=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 EH=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 j1=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 IH=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 PH=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 Nl=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 LH=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 DH=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 OH=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 Bw=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 $w=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 RH=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 FH=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 zH=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 BH=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 Lu=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 M4=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 $H=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 UH=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 VH=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 qH=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 By=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 _k=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 HH=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 Rm=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 WH=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 GH=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 KH=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 ZH=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 YH=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 XH=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 QH=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 JH=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 eW=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 tW=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 rW=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 sW=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 nW=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 Uw=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 aW=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 iW=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 oW=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 lW=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 cW=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 dW=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 uW=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 bk=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 Of=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 hW=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 mW=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 fW=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 wk=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 pW=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 gW=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 xW=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 yW=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 vW=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 T4=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 A4=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 _W=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 $y=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 wW=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 Fm=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 Lo=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 zm=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 jW=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 kW=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 NW=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 SW=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 CW=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 MW=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 TW=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 E4=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 AW=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 EW=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 IW=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 PW=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 LW=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 DW=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 OW=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 Rf=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 $r=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 RW=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 FW=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 zW=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 BW=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 vE=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 Vw=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 $W=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 qw=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 Du=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 I4=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 P4=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 UW=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 VW=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 qW=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 HW=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 WW=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 GW=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 KW=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 ZW=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 YW=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 XW=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 QW=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 _E=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 Vs=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 JW=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 eG=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 tG=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 rG=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 sG=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 nG=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 aG=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 iG=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 oG=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 lG=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 cG=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 dG=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 Yi=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 uG=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 hG=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 mG=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 fG=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 pG=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 Uy=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 gG=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 ag=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 xG=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 yG=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 bE=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 vG=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 _G=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 L4=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 wG=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 jG=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 kG=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 wE=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 NG=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 SG=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 CG=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 Rl=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 MG=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 TG=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 AG=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 EG=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 jE=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 IG=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 PG=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 LG=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 D4=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 kE=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 DG=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 OG=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 RG=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 FG=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 zG=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 Vo=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 BG=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 $G=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 Hw=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 NE=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 UG=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 VG=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 qG=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 HG=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 WG=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 GG=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 KG=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 ZG=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 k1=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 YG=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 XG=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 QG=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 JG=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 eK=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 tK=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 rK=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 sK=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 nK=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 aK=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 iK=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 oK=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 jk=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 lK=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 cK=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 dK=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 uK=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 hK=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 mK=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 fK=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 N1=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 pK=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 gK=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 Ww=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 xK=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 yK=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 vK=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 _K=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 wK=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 jK=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 kK=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 NK=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 SK=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 CK=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 MK=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 TK=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 AK=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 EK=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 IK=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 PK=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 LK=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 DK=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 OK=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 SE=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 RK=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 Vy=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 FK=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 zK=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 BK=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 $K=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 UK=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 VK=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 qK=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 HK=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 WK=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 Gw=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 GK=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 Kw=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 Zw=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 KK=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 ZK=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 YK=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 XK=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 QK=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 JK=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 eZ=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 tZ=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 rZ=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 sZ=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 nZ=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 aZ=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 ec=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 iZ=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 oZ=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 Yw=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 lZ=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 id=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 cZ=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 Xw=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 dZ=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 uZ=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 Qw=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 Jw=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 e2=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 t2=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 hZ=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 r2=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 mZ=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 fZ=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 pZ=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 s2=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 gZ=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 xZ=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 yZ=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 vZ=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 wv=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 kk=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 _Z=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 od=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 Bm=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 wZ=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 jZ=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 jv=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 kZ=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 Nk=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 kv=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 NZ=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 SZ=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 CZ=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 Qa=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 MZ=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 O4=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 TZ=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 AZ=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 EZ=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 IZ=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 PZ=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 LZ=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 DZ=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 OZ=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 fi=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 RZ=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 FZ=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 zZ=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 BZ=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 $Z=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 UZ=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 VZ=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 qZ=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 HZ=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 WZ=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 GZ=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 CE=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 S1=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 KZ=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 ZZ=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 YZ=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 XZ=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 QZ=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 tc=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 JZ=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 n2=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 ME=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 gs=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 eY=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 tY=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 rY=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 sY=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 nY=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 aY=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 iY=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 oY=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 lY=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 cY=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 Ff=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 dY=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 TE=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 uY=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 hY=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 mY=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 fY=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 Sk=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 AE=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 pY=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 gY=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 xY=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 yY=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 vY=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 _Y=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 Ck=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 wY=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 jY=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 kY=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 NY=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 SY=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 CY=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 MY=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 TY=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 AY=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 EY=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 IY=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 PY=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 LY=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 a2=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 DY=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 OY=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 RY=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 FY=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 zY=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 R4=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 BY=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 $Y=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 UY=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 Yo=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 VY=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 qY=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 HY=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 WY=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 GY=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 EE=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 KY=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 ZY=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 YY=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 IE=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 XY=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 QY=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 hx=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 JY=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 eX=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 i2=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 tX=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 Mk=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 rX=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 PE=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 sX=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 nX=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 aX=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 o2=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 l2=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 iX=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 oX=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 lX=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 cX=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 dX=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 uX=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 hX=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 mX=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 fX=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 pX=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 gX=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 zf=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 c2=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 xX=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 yX=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 vX=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 _X=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 wX=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 jX=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 kX=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 NX=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 SX=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 CX=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 MX=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 TX=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 AX=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 EX=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 IX=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 PX=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 LX=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 DX=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 OX=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 RX=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 qn=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 FX=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 d2=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 zX=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 ai=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 BX=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 $X=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 UX=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 VX=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 qX=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 HX=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 WX=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 ld=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 GX=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 Uc=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 LE=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 KX=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 ZX=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 YX=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 XX=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 DE=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 QX=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 JX=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 eQ=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 tQ=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 rQ=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 sQ=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 u2=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 Ou=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 nQ=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 aQ=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 iQ=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 oQ=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 Wh=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 lQ=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 cQ=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 dQ=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 uQ=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 hQ=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 mQ=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 fQ=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 pQ=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 gQ=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 xQ=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 yQ=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 vQ=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 _Q=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 wQ=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 jQ=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 kQ=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 NQ=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 SQ=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 CQ=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 MQ=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 OE=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 h2=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 TQ=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 AQ=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 qy=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 EQ=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 IQ=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 PQ=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 e1=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 LQ=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 DQ=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 OQ=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 RQ=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 FQ=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 bn=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 zQ=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 BQ=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 $Q=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 UQ=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 VQ=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 qQ=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 HQ=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 WQ=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 m2=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 f2=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 p2=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 g2=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 x2=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 y2=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 v2=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 _2=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 b2=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 w2=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 j2=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 k2=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 N2=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 S2=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 C2=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 Ug=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 Nv=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 M2=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 T2=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 A2=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 E2=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 I2=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 P2=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 GQ=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 KQ=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 L2=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 D2=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 O2=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 R2=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 F2=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 z2=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 B2=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 $2=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 U2=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 V2=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 q2=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 H2=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 W2=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 G2=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 K2=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 Lc=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 Z2=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 Y2=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 X2=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 Q2=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 J2=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 ej=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 ZQ=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 tj=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 rj=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 sj=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 nj=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 aj=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 YQ=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 XQ=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 ij=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 oj=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 lj=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 cj=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 fx=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 QQ=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 JQ=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 eJ=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 tJ=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 rJ=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 Dn=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 sJ=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 nJ=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 aJ=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 iJ=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 oJ=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 lJ=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 cJ=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 dJ=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 uJ=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 hJ=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 mJ=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 fJ=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 pJ=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 gJ=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 C1=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 xJ=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 yJ=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 vJ=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 _J=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 wJ=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 jJ=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 kJ=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 NJ=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 F4=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 SJ=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 CJ=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 MJ=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 TJ=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 AJ=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 EJ=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 IJ=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 PJ=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 LJ=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 DJ=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 px=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 OJ=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 RJ=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 FJ=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 zJ=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 BJ=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 $J=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 UJ=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 Bf=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 VJ=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 qJ=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 HJ=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 WJ=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 dj=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 GJ=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 KJ=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 ZJ=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 YJ=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 XJ=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 QJ=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 uj=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 JJ=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 eee=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 tee=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 ree=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 see=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 RE=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 Cd=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 nee=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 aee=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 iee=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 oee=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 lee=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 FE=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 dee=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 uee=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 hee=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 mee=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 fee=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 gee=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 xee=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 yee=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 vee=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 _ee=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 bee=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 wee=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 jee=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 kee=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 Nee=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 See=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 Cee=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 Mee=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 hj=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 Os=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 Tee=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 Aee=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 mj=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 M1=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 Eee=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 Iee=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 Tk=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 Pee=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 pu=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 ch=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 Lee=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 Dee=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 go=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 Oee=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 Ree=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 fj=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 Fee=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 zee=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 Bee=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 $ee=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 Uee=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 Vee=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 qee=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 Hee=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 Wee=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 Gee=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 z4=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 Kee=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 Zee=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 Yee=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 pj=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 Xee=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 BE=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 Qee=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 Xi=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 Jee=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 Ak=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 $E=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 UE=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 ete=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 Kd=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 gj=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 xj=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 yj=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 tte=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 vj=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 rte=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 _j=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 bj=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 ste=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 nte=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 Fl=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 wj=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 ws=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 jj=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 kj=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 ate=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 VE=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 ite=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 ote=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 lte=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 dte=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 ute=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 ma=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 hte=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 mte=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 fte=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 gte=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 xte=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 yte=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 vte=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 _te=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 bte=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 wte=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 Nj=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 jte=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 kte=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 Sj=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 Nte=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 Ste=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 Cte=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 Mte=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 Tte=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 Ate=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 Ete=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 Ite=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 Pte=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 Lte=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 Dte=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 Ote=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 Rte=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 Fte=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 zte=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 Bte=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 $te=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 Ute=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 Vte=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 qte=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 Hte=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 Wte=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 Gte=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 Kte=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 Zte=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 Hy=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 Xs=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 Yte=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 Xte=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 gx=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 B4=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 $4=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 Lnt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:I8,AArrowUp:P8,ALargeSmall:L8,Accessibility:D8,Activity:lx,AirVent:O8,Airplay:R8,AlarmClock:z8,AlarmClockCheck:pb,AlarmClockMinus:gb,AlarmClockOff:F8,AlarmClockPlus:xb,AlarmSmoke:B8,Album:$8,AlignCenter:x4,AlignCenterHorizontal:U8,AlignCenterVertical:V8,AlignEndHorizontal:q8,AlignEndVertical:H8,AlignHorizontalDistributeCenter:W8,AlignHorizontalDistributeEnd:G8,AlignHorizontalDistributeStart:K8,AlignHorizontalJustifyCenter:Z8,AlignHorizontalJustifyEnd:Y8,AlignHorizontalJustifyStart:X8,AlignHorizontalSpaceAround:Q8,AlignHorizontalSpaceBetween:J8,AlignJustify:eR,AlignLeft:y4,AlignRight:v4,AlignStartHorizontal:tR,AlignStartVertical:rR,AlignVerticalDistributeCenter:sR,AlignVerticalDistributeEnd:nR,AlignVerticalDistributeStart:aR,AlignVerticalJustifyCenter:iR,AlignVerticalJustifyEnd:oR,AlignVerticalJustifyStart:lR,AlignVerticalSpaceAround:cR,AlignVerticalSpaceBetween:dR,Ambulance:uR,Ampersand:hR,Ampersands:mR,Amphora:fR,Anchor:pR,Angry:gR,Annoyed:xR,Antenna:yR,Anvil:vR,Aperture:_R,AppWindow:cE,AppWindowMac:bR,Apple:wR,Archive:_4,ArchiveRestore:dE,ArchiveX:jR,Armchair:kR,ArrowBigDown:SR,ArrowBigDownDash:NR,ArrowBigLeft:MR,ArrowBigLeftDash:CR,ArrowBigRight:AR,ArrowBigRightDash:TR,ArrowBigUp:IR,ArrowBigUpDash:ER,ArrowDown:Ly,ArrowDown01:PR,ArrowDown10:LR,ArrowDownAZ:yb,ArrowDownFromLine:DR,ArrowDownLeft:OR,ArrowDownNarrowWide:RR,ArrowDownRight:FR,ArrowDownToDot:zR,ArrowDownToLine:BR,ArrowDownUp:$R,ArrowDownWideNarrow:vb,ArrowDownZA:_b,ArrowLeft:gi,ArrowLeftFromLine:UR,ArrowLeftRight:VR,ArrowLeftToLine:qR,ArrowRight:Ki,ArrowRightFromLine:HR,ArrowRightLeft:Dy,ArrowRightToLine:WR,ArrowUp:Pf,ArrowUp01:GR,ArrowUp10:KR,ArrowUpAZ:bb,ArrowUpDown:eg,ArrowUpFromDot:ZR,ArrowUpFromLine:YR,ArrowUpLeft:XR,ArrowUpNarrowWide:wb,ArrowUpRight:QR,ArrowUpToLine:JR,ArrowUpWideNarrow:eF,ArrowUpZA:jb,ArrowsUpFromLine:tF,Asterisk:rF,AtSign:sF,Atom:nF,AudioLines:aF,AudioWaveform:iF,Award:Yl,Axe:oF,Axis3d:kb,Baby:lF,Backpack:cF,Badge:NF,BadgeAlert:dF,BadgeCent:uF,BadgeCheck:Nb,BadgeDollarSign:hF,BadgeEuro:mF,BadgeHelp:fF,BadgeIndianRupee:pF,BadgeInfo:gF,BadgeJapaneseYen:xF,BadgeMinus:yF,BadgePercent:vF,BadgePlus:_F,BadgePoundSterling:bF,BadgeRussianRuble:wF,BadgeSwissFranc:jF,BadgeX:kF,BaggageClaim:SF,Ban:CF,Banana:MF,Bandage:TF,Banknote:AF,Barcode:EF,Baseline:IF,Bath:g1,Battery:FF,BatteryCharging:PF,BatteryFull:LF,BatteryLow:DF,BatteryMedium:OF,BatteryWarning:RF,Beaker:zF,Bean:$F,BeanOff:BF,Bed:x1,BedDouble:UF,BedSingle:VF,Beef:qF,Beer:WF,BeerOff:HF,Bell:tg,BellDot:GF,BellElectric:KF,BellMinus:ZF,BellOff:mk,BellPlus:YF,BellRing:XF,BetweenHorizontalEnd:Sb,BetweenHorizontalStart:Cb,BetweenVerticalEnd:QF,BetweenVerticalStart:JF,BicepsFlexed:ez,Bike:tz,Binary:rz,Binoculars:sz,Biohazard:nz,Bird:az,Bitcoin:iz,Blend:oz,Blinds:lz,Blocks:cz,Bluetooth:mz,BluetoothConnected:dz,BluetoothOff:uz,BluetoothSearching:hz,Bold:b4,Bolt:fz,Bomb:pz,Bone:gz,Book:Fz,BookA:xz,BookAudio:yz,BookCheck:vz,BookCopy:_z,BookDashed:Mb,BookDown:bz,BookHeadphones:wz,BookHeart:jz,BookImage:kz,BookKey:Nz,BookLock:Sz,BookMarked:Cz,BookMinus:Mz,BookOpen:Oy,BookOpenCheck:Tz,BookOpenText:Az,BookPlus:Ez,BookText:Iz,BookType:Pz,BookUp:Dz,BookUp2:Lz,BookUser:Oz,BookX:Rz,Bookmark:rg,BookmarkCheck:zz,BookmarkMinus:Bz,BookmarkPlus:uE,BookmarkX:$z,BoomBox:Uz,Bot:w4,BotMessageSquare:Vz,BotOff:qz,Box:Hz,Boxes:Wz,Braces:Tb,Brackets:Gz,Brain:hE,BrainCircuit:Kz,BrainCog:Zz,BrickWall:Yz,Briefcase:Pu,BriefcaseBusiness:Xz,BriefcaseConveyorBelt:Qz,BriefcaseMedical:Jz,BringToFront:e7,Brush:t7,Bug:n7,BugOff:r7,BugPlay:s7,Building:fk,Building2:Ni,Bus:i7,BusFront:a7,Cable:l7,CableCar:o7,Cake:Lm,CakeSlice:c7,Calculator:d7,Calendar:An,Calendar1:u7,CalendarArrowDown:h7,CalendarArrowUp:m7,CalendarCheck:p7,CalendarCheck2:f7,CalendarClock:mE,CalendarCog:g7,CalendarDays:sg,CalendarFold:x7,CalendarHeart:y7,CalendarMinus:_7,CalendarMinus2:v7,CalendarOff:b7,CalendarPlus:y1,CalendarPlus2:w7,CalendarRange:j7,CalendarSearch:k7,CalendarSync:N7,CalendarX:C7,CalendarX2:S7,Camera:ng,CameraOff:M7,Candy:E7,CandyCane:T7,CandyOff:A7,Cannabis:I7,Captions:Ab,CaptionsOff:P7,Car:O7,CarFront:L7,CarTaxiFront:D7,Caravan:R7,Carrot:F7,CaseLower:z7,CaseSensitive:B7,CaseUpper:$7,CassetteTape:U7,Cast:V7,Castle:q7,Cat:H7,Cctv:W7,ChartArea:Eb,ChartBar:Pb,ChartBarBig:Ib,ChartBarDecreasing:G7,ChartBarIncreasing:K7,ChartBarStacked:Z7,ChartCandlestick:Lb,ChartColumn:Rc,ChartColumnBig:Db,ChartColumnDecreasing:Y7,ChartColumnIncreasing:Ob,ChartColumnStacked:X7,ChartGantt:Q7,ChartLine:Rb,ChartNetwork:J7,ChartNoAxesColumn:zb,ChartNoAxesColumnDecreasing:eB,ChartNoAxesColumnIncreasing:Fb,ChartNoAxesCombined:tB,ChartNoAxesGantt:Bb,ChartPie:$b,ChartScatter:Ub,ChartSpline:rB,Check:mi,CheckCheck:sB,ChefHat:nB,Cherry:aB,ChevronDown:ad,ChevronFirst:iB,ChevronLast:oB,ChevronLeft:jc,ChevronRight:Zi,ChevronUp:cx,ChevronsDown:cB,ChevronsDownUp:lB,ChevronsLeft:hB,ChevronsLeftRight:uB,ChevronsLeftRightEllipsis:dB,ChevronsRight:fB,ChevronsRightLeft:mB,ChevronsUp:pB,ChevronsUpDown:Ry,Chrome:gB,Church:xB,Cigarette:vB,CigaretteOff:yB,Circle:vh,CircleAlert:kl,CircleArrowDown:Vb,CircleArrowLeft:qb,CircleArrowOutDownLeft:Hb,CircleArrowOutDownRight:Wb,CircleArrowOutUpLeft:Gb,CircleArrowOutUpRight:Kb,CircleArrowRight:Zb,CircleArrowUp:Yb,CircleCheck:Ri,CircleCheckBig:ui,CircleChevronDown:Xb,CircleChevronLeft:Qb,CircleChevronRight:Jb,CircleChevronUp:ew,CircleDashed:_B,CircleDivide:tw,CircleDollarSign:bB,CircleDot:jB,CircleDotDashed:wB,CircleEllipsis:kB,CircleEqual:NB,CircleFadingArrowUp:SB,CircleFadingPlus:CB,CircleGauge:rw,CircleHelp:by,CircleMinus:sw,CircleOff:MB,CircleParking:aw,CircleParkingOff:nw,CirclePause:iw,CirclePercent:ow,CirclePlay:kf,CirclePlus:lw,CirclePower:cw,CircleSlash:TB,CircleSlash2:dw,CircleStop:uw,CircleUser:mw,CircleUserRound:hw,CircleX:Fc,CircuitBoard:AB,Citrus:EB,Clapperboard:IB,Clipboard:zB,ClipboardCheck:j4,ClipboardCopy:PB,ClipboardList:fE,ClipboardMinus:LB,ClipboardPaste:DB,ClipboardPen:pw,ClipboardPenLine:fw,ClipboardPlus:OB,ClipboardType:RB,ClipboardX:FB,Clock:Pa,Clock1:BB,Clock10:$B,Clock11:UB,Clock12:VB,Clock2:qB,Clock3:HB,Clock4:WB,Clock5:GB,Clock6:KB,Clock7:ZB,Clock8:YB,Clock9:XB,ClockAlert:QB,ClockArrowDown:JB,ClockArrowUp:e9,Cloud:p9,CloudAlert:t9,CloudCog:r9,CloudDownload:gw,CloudDrizzle:s9,CloudFog:n9,CloudHail:a9,CloudLightning:i9,CloudMoon:l9,CloudMoonRain:o9,CloudOff:c9,CloudRain:u9,CloudRainWind:d9,CloudSnow:h9,CloudSun:f9,CloudSunRain:m9,CloudUpload:xw,Cloudy:g9,Clover:My,Club:x9,Code:pk,CodeXml:yw,Codepen:y9,Codesandbox:v9,Coffee:gk,Cog:_9,Coins:b9,Columns2:vw,Columns3:_w,Columns4:w9,Combine:j9,Command:k9,Compass:N9,Component:S9,Computer:C9,ConciergeBell:M9,Cone:T9,Construction:A9,Contact:xk,ContactRound:bw,Container:E9,Contrast:I9,Cookie:P9,CookingPot:L9,Copy:uo,CopyCheck:D9,CopyMinus:O9,CopyPlus:R9,CopySlash:F9,CopyX:z9,Copyleft:B9,Copyright:$9,CornerDownLeft:U9,CornerDownRight:V9,CornerLeftDown:q9,CornerLeftUp:H9,CornerRightDown:W9,CornerRightUp:G9,CornerUpLeft:K9,CornerUpRight:Z9,Cpu:Y9,CreativeCommons:X9,CreditCard:Dm,Croissant:Q9,Crop:J9,Cross:e$,Crosshair:t$,Crown:_h,Cuboid:r$,CupSoda:s$,Currency:n$,Cylinder:a$,Dam:i$,Database:c$,DatabaseBackup:o$,DatabaseZap:l$,Delete:d$,Dessert:u$,Diameter:h$,Diamond:p$,DiamondMinus:m$,DiamondPercent:ww,DiamondPlus:f$,Dice1:g$,Dice2:x$,Dice3:y$,Dice4:v$,Dice5:_$,Dice6:b$,Dices:w$,Diff:j$,Disc:C$,Disc2:k$,Disc3:N$,DiscAlbum:S$,Divide:M$,Dna:A$,DnaOff:T$,Dock:E$,Dog:I$,DollarSign:Sd,Donut:P$,DoorClosed:L$,DoorOpen:Fy,Dot:D$,Download:Fi,DraftingCompass:O$,Drama:R$,Dribbble:F$,Drill:z$,Droplet:B$,Droplets:dx,Drum:$$,Drumstick:U$,Dumbbell:V$,Ear:H$,EarOff:q$,Earth:jw,EarthLock:W$,Eclipse:G$,Egg:k4,EggFried:K$,EggOff:Z$,Ellipsis:Nf,EllipsisVertical:Qg,Equal:Q$,EqualApproximately:Y$,EqualNot:X$,Eraser:J$,EthernetPort:eU,Euro:tU,Expand:rU,ExternalLink:jn,Eye:Ii,EyeClosed:sU,EyeOff:Lf,Facebook:fu,Factory:nU,Fan:aU,FastForward:iU,Feather:oU,Fence:lU,FerrisWheel:cU,Figma:dU,File:N4,FileArchive:uU,FileAudio:mU,FileAudio2:hU,FileAxis3d:kw,FileBadge:pU,FileBadge2:fU,FileBox:gU,FileChartColumn:Sw,FileChartColumnIncreasing:Nw,FileChartLine:Cw,FileChartPie:Mw,FileCheck:yU,FileCheck2:xU,FileClock:vU,FileCode:bU,FileCode2:_U,FileCog:Tw,FileDiff:wU,FileDigit:jU,FileDown:kU,FileHeart:NU,FileImage:v1,FileInput:SU,FileJson:MU,FileJson2:CU,FileKey:AU,FileKey2:TU,FileLock:IU,FileLock2:EU,FileMinus:LU,FileMinus2:PU,FileMusic:DU,FileOutput:OU,FilePen:Ew,FilePenLine:Aw,FilePlus:FU,FilePlus2:RU,FileQuestion:zU,FileScan:BU,FileSearch:UU,FileSearch2:$U,FileSliders:VU,FileSpreadsheet:_1,FileStack:qU,FileSymlink:HU,FileTerminal:WU,FileText:ya,FileType:KU,FileType2:GU,FileUp:ZU,FileUser:YU,FileVideo:QU,FileVideo2:XU,FileVolume:eV,FileVolume2:JU,FileWarning:tV,FileX:sV,FileX2:rV,Files:nV,Film:Ud,Filter:b1,FilterX:aV,Fingerprint:iV,FireExtinguisher:oV,Fish:dV,FishOff:lV,FishSymbol:cV,Flag:zy,FlagOff:uV,FlagTriangleLeft:hV,FlagTriangleRight:mV,Flame:Om,FlameKindling:fV,Flashlight:gV,FlashlightOff:pV,FlaskConical:yk,FlaskConicalOff:xV,FlaskRound:yV,FlipHorizontal:_V,FlipHorizontal2:vV,FlipVertical:wV,FlipVertical2:bV,Flower:jV,Flower2:Kp,Focus:kV,FoldHorizontal:NV,FoldVertical:SV,Folder:JV,FolderArchive:CV,FolderCheck:MV,FolderClock:TV,FolderClosed:AV,FolderCode:EV,FolderCog:Iw,FolderDot:IV,FolderDown:PV,FolderGit:DV,FolderGit2:LV,FolderHeart:OV,FolderInput:RV,FolderKanban:FV,FolderKey:zV,FolderLock:BV,FolderMinus:$V,FolderOpen:Jh,FolderOpenDot:UV,FolderOutput:VV,FolderPen:Pw,FolderPlus:qV,FolderRoot:HV,FolderSearch:GV,FolderSearch2:WV,FolderSymlink:KV,FolderSync:ZV,FolderTree:YV,FolderUp:XV,FolderX:QV,Folders:eq,Footprints:tq,Forklift:rq,Forward:sq,Frame:nq,Framer:aq,Frown:iq,Fuel:oq,Fullscreen:lq,GalleryHorizontal:dq,GalleryHorizontalEnd:cq,GalleryThumbnails:uq,GalleryVertical:mq,GalleryVerticalEnd:hq,Gamepad:pq,Gamepad2:fq,Gauge:gq,Gavel:xq,Gem:yq,Ghost:vk,Gift:po,GitBranch:_q,GitBranchPlus:vq,GitCommitHorizontal:Lw,GitCommitVertical:bq,GitCompare:jq,GitCompareArrows:wq,GitFork:kq,GitGraph:Nq,GitMerge:Sq,GitPullRequest:Iq,GitPullRequestArrow:Cq,GitPullRequestClosed:Mq,GitPullRequestCreate:Aq,GitPullRequestCreateArrow:Tq,GitPullRequestDraft:Eq,Github:Pq,Gitlab:Lq,GlassWater:Dq,Glasses:Oq,Globe:ux,GlobeLock:Rq,Goal:Fq,Grab:zq,GraduationCap:w1,Grape:Bq,Grid2x2:Ow,Grid2x2Check:$q,Grid2x2Plus:Dw,Grid2x2X:Uq,Grid3x3:bm,Grip:qq,GripHorizontal:Vq,GripVertical:Df,Group:Hq,Guitar:Wq,Ham:Gq,Hammer:Kq,Hand:pE,HandCoins:Zq,HandHeart:Yq,HandHelping:Rw,HandMetal:Xq,HandPlatter:Qq,Handshake:Jq,HardDrive:gE,HardDriveDownload:eH,HardDriveUpload:tH,HardHat:rH,Hash:S4,Haze:sH,HdmiPort:nH,Heading:cH,Heading1:xE,Heading2:yE,Heading3:aH,Heading4:iH,Heading5:oH,Heading6:lH,HeadphoneOff:dH,Headphones:uH,Headset:hH,Heart:Ai,HeartCrack:mH,HeartHandshake:fH,HeartOff:pH,HeartPulse:gH,Heater:xH,Hexagon:yH,Highlighter:vH,History:C4,Hop:bH,HopOff:_H,Hospital:wH,Hotel:jH,Hourglass:kH,House:Vn,HousePlug:NH,HousePlus:SH,IceCreamBowl:Fw,IceCreamCone:zw,IdCard:CH,Image:Nl,ImageDown:MH,ImageMinus:TH,ImageOff:AH,ImagePlay:EH,ImagePlus:j1,ImageUp:IH,ImageUpscale:PH,Images:LH,Import:DH,Inbox:OH,IndentDecrease:Bw,IndentIncrease:$w,IndianRupee:RH,Infinity:FH,Info:zH,InspectionPanel:BH,Instagram:Lu,Italic:M4,IterationCcw:$H,IterationCw:UH,JapaneseYen:VH,Joystick:qH,Kanban:By,Key:Rm,KeyRound:_k,KeySquare:HH,Keyboard:KH,KeyboardMusic:WH,KeyboardOff:GH,Lamp:eW,LampCeiling:ZH,LampDesk:YH,LampFloor:XH,LampWallDown:QH,LampWallUp:JH,LandPlot:tW,Landmark:rW,Languages:sW,Laptop:aW,LaptopMinimal:Uw,LaptopMinimalCheck:nW,Lasso:oW,LassoSelect:iW,Laugh:lW,Layers:uW,Layers2:cW,Layers3:dW,LayoutDashboard:bk,LayoutGrid:Of,LayoutList:hW,LayoutPanelLeft:mW,LayoutPanelTop:fW,LayoutTemplate:wk,Leaf:pW,LeafyGreen:gW,Lectern:xW,LetterText:yW,Library:T4,LibraryBig:vW,LifeBuoy:A4,Ligature:_W,Lightbulb:$y,LightbulbOff:bW,Link:Lo,Link2:Fm,Link2Off:wW,Linkedin:zm,List:Rf,ListCheck:jW,ListChecks:kW,ListCollapse:NW,ListEnd:SW,ListFilter:CW,ListMinus:MW,ListMusic:TW,ListOrdered:E4,ListPlus:AW,ListRestart:EW,ListStart:IW,ListTodo:PW,ListTree:LW,ListVideo:DW,ListX:OW,Loader:FW,LoaderCircle:$r,LoaderPinwheel:RW,Locate:vE,LocateFixed:zW,LocateOff:BW,Lock:Du,LockKeyhole:$W,LockKeyholeOpen:Vw,LockOpen:qw,LogIn:I4,LogOut:P4,Logs:UW,Lollipop:VW,Luggage:qW,Magnet:HW,Mail:Vs,MailCheck:WW,MailMinus:GW,MailOpen:KW,MailPlus:ZW,MailQuestion:YW,MailSearch:XW,MailWarning:QW,MailX:_E,Mailbox:JW,Mails:eG,Map:hG,MapPin:Yi,MapPinCheck:rG,MapPinCheckInside:tG,MapPinHouse:sG,MapPinMinus:aG,MapPinMinusInside:nG,MapPinOff:iG,MapPinPlus:lG,MapPinPlusInside:oG,MapPinX:dG,MapPinXInside:cG,MapPinned:uG,Martini:mG,Maximize:pG,Maximize2:fG,Medal:Uy,Megaphone:ag,MegaphoneOff:gG,Meh:xG,MemoryStick:yG,Menu:bE,Merge:vG,MessageCircle:Rl,MessageCircleCode:_G,MessageCircleDashed:bG,MessageCircleHeart:L4,MessageCircleMore:wG,MessageCircleOff:jG,MessageCirclePlus:kG,MessageCircleQuestion:wE,MessageCircleReply:NG,MessageCircleWarning:SG,MessageCircleX:CG,MessageSquare:Vo,MessageSquareCode:MG,MessageSquareDashed:TG,MessageSquareDiff:AG,MessageSquareDot:EG,MessageSquareHeart:jE,MessageSquareLock:IG,MessageSquareMore:PG,MessageSquareOff:LG,MessageSquarePlus:D4,MessageSquareQuote:kE,MessageSquareReply:DG,MessageSquareShare:OG,MessageSquareText:RG,MessageSquareWarning:FG,MessageSquareX:zG,MessagesSquare:BG,Mic:NE,MicOff:$G,MicVocal:Hw,Microchip:UG,Microscope:VG,Microwave:qG,Milestone:HG,Milk:GG,MilkOff:WG,Minimize:ZG,Minimize2:KG,Minus:k1,Monitor:jk,MonitorCheck:YG,MonitorCog:XG,MonitorDot:QG,MonitorDown:JG,MonitorOff:eK,MonitorPause:tK,MonitorPlay:rK,MonitorSmartphone:sK,MonitorSpeaker:nK,MonitorStop:aK,MonitorUp:iK,MonitorX:oK,Moon:cK,MoonStar:lK,Mountain:uK,MountainSnow:dK,Mouse:gK,MouseOff:hK,MousePointer:pK,MousePointer2:mK,MousePointerBan:fK,MousePointerClick:N1,Move:TK,Move3d:Ww,MoveDiagonal:yK,MoveDiagonal2:xK,MoveDown:bK,MoveDownLeft:vK,MoveDownRight:_K,MoveHorizontal:wK,MoveLeft:jK,MoveRight:kK,MoveUp:CK,MoveUpLeft:NK,MoveUpRight:SK,MoveVertical:MK,Music:PK,Music2:AK,Music3:EK,Music4:IK,Navigation:SE,Navigation2:DK,Navigation2Off:LK,NavigationOff:OK,Network:RK,Newspaper:Vy,Nfc:FK,Notebook:UK,NotebookPen:zK,NotebookTabs:BK,NotebookText:$K,NotepadText:qK,NotepadTextDashed:VK,Nut:WK,NutOff:HK,Octagon:KK,OctagonAlert:Gw,OctagonMinus:GK,OctagonPause:Kw,OctagonX:Zw,Omega:ZK,Option:YK,Orbit:XK,Origami:QK,Package:ec,Package2:JK,PackageCheck:eZ,PackageMinus:tZ,PackageOpen:rZ,PackagePlus:sZ,PackageSearch:nZ,PackageX:aZ,PaintBucket:iZ,PaintRoller:oZ,Paintbrush:lZ,PaintbrushVertical:Yw,Palette:id,PanelBottom:uZ,PanelBottomClose:cZ,PanelBottomDashed:Xw,PanelBottomOpen:dZ,PanelLeft:t2,PanelLeftClose:Qw,PanelLeftDashed:Jw,PanelLeftOpen:e2,PanelRight:fZ,PanelRightClose:hZ,PanelRightDashed:r2,PanelRightOpen:mZ,PanelTop:xZ,PanelTopClose:pZ,PanelTopDashed:s2,PanelTopOpen:gZ,PanelsLeftBottom:yZ,PanelsRightBottom:vZ,PanelsTopLeft:wv,Paperclip:kk,Parentheses:_Z,ParkingMeter:bZ,PartyPopper:od,Pause:Bm,PawPrint:wZ,PcCase:jZ,Pen:kv,PenLine:jv,PenOff:kZ,PenTool:Nk,Pencil:Qa,PencilLine:NZ,PencilOff:SZ,PencilRuler:CZ,Pentagon:MZ,Percent:O4,PersonStanding:TZ,PhilippinePeso:AZ,Phone:fi,PhoneCall:EZ,PhoneForwarded:IZ,PhoneIncoming:PZ,PhoneMissed:LZ,PhoneOff:DZ,PhoneOutgoing:OZ,Pi:RZ,Piano:FZ,Pickaxe:zZ,PictureInPicture:$Z,PictureInPicture2:BZ,PiggyBank:UZ,Pilcrow:HZ,PilcrowLeft:VZ,PilcrowRight:qZ,Pill:GZ,PillBottle:WZ,Pin:S1,PinOff:CE,Pipette:KZ,Pizza:ZZ,Plane:QZ,PlaneLanding:YZ,PlaneTakeoff:XZ,Play:tc,Plug:ME,Plug2:JZ,PlugZap:n2,Plus:gs,Pocket:tY,PocketKnife:eY,Podcast:rY,Pointer:nY,PointerOff:sY,Popcorn:aY,Popsicle:iY,PoundSterling:oY,Power:cY,PowerOff:lY,Presentation:Ff,Printer:TE,PrinterCheck:dY,Projector:uY,Proportions:hY,Puzzle:mY,Pyramid:fY,QrCode:Sk,Quote:AE,Rabbit:pY,Radar:gY,Radiation:xY,Radical:yY,Radio:Ck,RadioReceiver:vY,RadioTower:_Y,Radius:bY,RailSymbol:wY,Rainbow:jY,Rat:kY,Ratio:NY,Receipt:LY,ReceiptCent:SY,ReceiptEuro:CY,ReceiptIndianRupee:MY,ReceiptJapaneseYen:TY,ReceiptPoundSterling:AY,ReceiptRussianRuble:EY,ReceiptSwissFranc:IY,ReceiptText:PY,RectangleEllipsis:a2,RectangleHorizontal:DY,RectangleVertical:OY,Recycle:RY,Redo:R4,Redo2:FY,RedoDot:zY,RefreshCcw:$Y,RefreshCcwDot:BY,RefreshCw:Yo,RefreshCwOff:UY,Refrigerator:VY,Regex:qY,RemoveFormatting:HY,Repeat:EE,Repeat1:WY,Repeat2:GY,Replace:ZY,ReplaceAll:KY,Reply:IE,ReplyAll:YY,Rewind:XY,Ribbon:QY,Rocket:hx,RockingChair:JY,RollerCoaster:eX,Rotate3d:i2,RotateCcw:Mk,RotateCcwSquare:tX,RotateCw:PE,RotateCwSquare:rX,Route:nX,RouteOff:sX,Router:aX,Rows2:o2,Rows3:l2,Rows4:iX,Rss:oX,Ruler:lX,RussianRuble:cX,Sailboat:dX,Salad:uX,Sandwich:hX,Satellite:fX,SatelliteDish:mX,Save:zf,SaveAll:pX,SaveOff:gX,Scale:xX,Scale3d:c2,Scaling:yX,Scan:SX,ScanBarcode:vX,ScanEye:_X,ScanFace:bX,ScanLine:wX,ScanQrCode:jX,ScanSearch:kX,ScanText:NX,School:CX,Scissors:TX,ScissorsLineDashed:MX,ScreenShare:EX,ScreenShareOff:AX,Scroll:PX,ScrollText:IX,Search:qn,SearchCheck:LX,SearchCode:DX,SearchSlash:OX,SearchX:RX,Section:FX,Send:ai,SendHorizontal:d2,SendToBack:zX,SeparatorHorizontal:BX,SeparatorVertical:$X,Server:HX,ServerCog:UX,ServerCrash:VX,ServerOff:qX,Settings:ld,Settings2:WX,Shapes:GX,Share:LE,Share2:Uc,Sheet:KX,Shell:ZX,Shield:Ou,ShieldAlert:YX,ShieldBan:XX,ShieldCheck:DE,ShieldEllipsis:QX,ShieldHalf:JX,ShieldMinus:eQ,ShieldOff:tQ,ShieldPlus:rQ,ShieldQuestion:sQ,ShieldX:u2,Ship:aQ,ShipWheel:nQ,Shirt:iQ,ShoppingBag:mx,ShoppingBasket:oQ,ShoppingCart:Wh,Shovel:lQ,ShowerHead:cQ,Shrink:dQ,Shrub:uQ,Shuffle:hQ,Sigma:mQ,Signal:yQ,SignalHigh:fQ,SignalLow:pQ,SignalMedium:gQ,SignalZero:xQ,Signature:vQ,Signpost:bQ,SignpostBig:_Q,Siren:wQ,SkipBack:jQ,SkipForward:kQ,Skull:NQ,Slack:SQ,Slash:CQ,Slice:MQ,SlidersHorizontal:OE,SlidersVertical:h2,Smartphone:qy,SmartphoneCharging:TQ,SmartphoneNfc:AQ,Smile:IQ,SmilePlus:EQ,Snail:PQ,Snowflake:e1,Sofa:LQ,Soup:DQ,Space:OQ,Spade:RQ,Sparkle:FQ,Sparkles:bn,Speaker:zQ,Speech:BQ,SpellCheck:UQ,SpellCheck2:$Q,Spline:VQ,Split:qQ,SprayCan:HQ,Sprout:WQ,Square:fx,SquareActivity:m2,SquareArrowDown:g2,SquareArrowDownLeft:f2,SquareArrowDownRight:p2,SquareArrowLeft:x2,SquareArrowOutDownLeft:y2,SquareArrowOutDownRight:v2,SquareArrowOutUpLeft:_2,SquareArrowOutUpRight:b2,SquareArrowRight:w2,SquareArrowUp:N2,SquareArrowUpLeft:j2,SquareArrowUpRight:k2,SquareAsterisk:S2,SquareBottomDashedScissors:C2,SquareChartGantt:Ug,SquareCheck:M2,SquareCheckBig:Nv,SquareChevronDown:T2,SquareChevronLeft:A2,SquareChevronRight:E2,SquareChevronUp:I2,SquareCode:P2,SquareDashed:O2,SquareDashedBottom:KQ,SquareDashedBottomCode:GQ,SquareDashedKanban:L2,SquareDashedMousePointer:D2,SquareDivide:R2,SquareDot:F2,SquareEqual:z2,SquareFunction:B2,SquareKanban:$2,SquareLibrary:U2,SquareM:V2,SquareMenu:q2,SquareMinus:H2,SquareMousePointer:W2,SquareParking:K2,SquareParkingOff:G2,SquarePen:Lc,SquarePercent:Z2,SquarePi:Y2,SquarePilcrow:X2,SquarePlay:Q2,SquarePlus:J2,SquarePower:ej,SquareRadical:ZQ,SquareScissors:tj,SquareSigma:rj,SquareSlash:sj,SquareSplitHorizontal:nj,SquareSplitVertical:aj,SquareSquare:YQ,SquareStack:XQ,SquareTerminal:ij,SquareUser:lj,SquareUserRound:oj,SquareX:cj,Squircle:QQ,Squirrel:JQ,Stamp:eJ,Star:Dn,StarHalf:tJ,StarOff:rJ,StepBack:sJ,StepForward:nJ,Stethoscope:aJ,Sticker:iJ,StickyNote:oJ,Store:lJ,StretchHorizontal:cJ,StretchVertical:dJ,Strikethrough:uJ,Subscript:hJ,Sun:C1,SunDim:mJ,SunMedium:fJ,SunMoon:pJ,SunSnow:gJ,Sunrise:xJ,Sunset:yJ,Superscript:vJ,SwatchBook:_J,SwissFranc:bJ,SwitchCamera:wJ,Sword:jJ,Swords:kJ,Syringe:NJ,Table:IJ,Table2:F4,TableCellsMerge:SJ,TableCellsSplit:CJ,TableColumnsSplit:MJ,TableOfContents:TJ,TableProperties:AJ,TableRowsSplit:EJ,Tablet:LJ,TabletSmartphone:PJ,Tablets:DJ,Tag:px,Tags:OJ,Tally1:RJ,Tally2:FJ,Tally3:zJ,Tally4:BJ,Tally5:$J,Tangent:UJ,Target:Bf,Telescope:VJ,Tent:HJ,TentTree:qJ,Terminal:WJ,TestTube:GJ,TestTubeDiagonal:dj,TestTubes:KJ,Text:JJ,TextCursor:YJ,TextCursorInput:ZJ,TextQuote:XJ,TextSearch:QJ,TextSelect:uj,Theater:eee,Thermometer:see,ThermometerSnowflake:tee,ThermometerSun:ree,ThumbsDown:RE,ThumbsUp:Cd,Ticket:FE,TicketCheck:nee,TicketMinus:aee,TicketPercent:iee,TicketPlus:oee,TicketSlash:lee,TicketX:cee,Tickets:uee,TicketsPlane:dee,Timer:fee,TimerOff:hee,TimerReset:mee,ToggleLeft:pee,ToggleRight:gee,Toilet:xee,Tornado:yee,Torus:vee,Touchpad:bee,TouchpadOff:_ee,TowerControl:wee,ToyBrick:jee,Tractor:kee,TrafficCone:Nee,TrainFront:Cee,TrainFrontTunnel:See,TrainTrack:Mee,TramFront:hj,Trash:Tee,Trash2:Os,TreeDeciduous:Aee,TreePalm:mj,TreePine:M1,Trees:Eee,Trello:Iee,TrendingDown:Tk,TrendingUp:pu,TrendingUpDown:Pee,Triangle:Dee,TriangleAlert:ch,TriangleRight:Lee,Trophy:go,Truck:zE,Turtle:Oee,Tv:Fee,TvMinimal:fj,TvMinimalPlay:Ree,Twitch:zee,Twitter:Bee,Type:Uee,TypeOutline:$ee,Umbrella:qee,UmbrellaOff:Vee,Underline:Hee,Undo:z4,Undo2:Wee,UndoDot:Gee,UnfoldHorizontal:Kee,UnfoldVertical:Zee,Ungroup:Yee,University:pj,Unlink:BE,Unlink2:Xee,Unplug:Qee,Upload:Xi,Usb:Jee,User:Fl,UserCheck:Ak,UserCog:$E,UserMinus:UE,UserPen:ete,UserPlus:Kd,UserRound:bj,UserRoundCheck:gj,UserRoundCog:xj,UserRoundMinus:yj,UserRoundPen:tte,UserRoundPlus:vj,UserRoundSearch:rte,UserRoundX:_j,UserSearch:ste,UserX:nte,Users:ws,UsersRound:wj,Utensils:kj,UtensilsCrossed:jj,UtilityPole:ate,Variable:VE,Vault:ite,Vegan:ote,VenetianMask:lte,Vibrate:dte,VibrateOff:cte,Video:ma,VideoOff:ute,Videotape:hte,View:mte,Voicemail:fte,Volleyball:pte,Volume:_te,Volume1:gte,Volume2:xte,VolumeOff:yte,VolumeX:vte,Vote:bte,Wallet:jte,WalletCards:wte,WalletMinimal:Nj,Wallpaper:kte,Wand:Nte,WandSparkles:Sj,Warehouse:Ste,WashingMachine:Cte,Watch:Mte,Waves:Tte,Waypoints:Ate,Webcam:Ete,Webhook:Pte,WebhookOff:Ite,Weight:Lte,Wheat:Ote,WheatOff:Dte,WholeWord:Rte,Wifi:Ute,WifiHigh:Fte,WifiLow:zte,WifiOff:Bte,WifiZero:$te,Wind:qte,WindArrowDown:Vte,Wine:Wte,WineOff:Hte,Workflow:Gte,Worm:Kte,WrapText:Zte,Wrench:Hy,X:Xs,Youtube:Yte,Zap:gx,ZapOff:Xte,ZoomIn:B4,ZoomOut:$4},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 iOe=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:I8,AArrowDownIcon:I8,AArrowUp:P8,AArrowUpIcon:P8,ALargeSmall:L8,ALargeSmallIcon:L8,Accessibility:D8,AccessibilityIcon:D8,Activity:lx,ActivityIcon:lx,ActivitySquare:m2,ActivitySquareIcon:m2,AirVent:O8,AirVentIcon:O8,Airplay:R8,AirplayIcon:R8,AlarmCheck:pb,AlarmCheckIcon:pb,AlarmClock:z8,AlarmClockCheck:pb,AlarmClockCheckIcon:pb,AlarmClockIcon:z8,AlarmClockMinus:gb,AlarmClockMinusIcon:gb,AlarmClockOff:F8,AlarmClockOffIcon:F8,AlarmClockPlus:xb,AlarmClockPlusIcon:xb,AlarmMinus:gb,AlarmMinusIcon:gb,AlarmPlus:xb,AlarmPlusIcon:xb,AlarmSmoke:B8,AlarmSmokeIcon:B8,Album:$8,AlbumIcon:$8,AlertCircle:kl,AlertCircleIcon:kl,AlertOctagon:Gw,AlertOctagonIcon:Gw,AlertTriangle:ch,AlertTriangleIcon:ch,AlignCenter:x4,AlignCenterHorizontal:U8,AlignCenterHorizontalIcon:U8,AlignCenterIcon:x4,AlignCenterVertical:V8,AlignCenterVerticalIcon:V8,AlignEndHorizontal:q8,AlignEndHorizontalIcon:q8,AlignEndVertical:H8,AlignEndVerticalIcon:H8,AlignHorizontalDistributeCenter:W8,AlignHorizontalDistributeCenterIcon:W8,AlignHorizontalDistributeEnd:G8,AlignHorizontalDistributeEndIcon:G8,AlignHorizontalDistributeStart:K8,AlignHorizontalDistributeStartIcon:K8,AlignHorizontalJustifyCenter:Z8,AlignHorizontalJustifyCenterIcon:Z8,AlignHorizontalJustifyEnd:Y8,AlignHorizontalJustifyEndIcon:Y8,AlignHorizontalJustifyStart:X8,AlignHorizontalJustifyStartIcon:X8,AlignHorizontalSpaceAround:Q8,AlignHorizontalSpaceAroundIcon:Q8,AlignHorizontalSpaceBetween:J8,AlignHorizontalSpaceBetweenIcon:J8,AlignJustify:eR,AlignJustifyIcon:eR,AlignLeft:y4,AlignLeftIcon:y4,AlignRight:v4,AlignRightIcon:v4,AlignStartHorizontal:tR,AlignStartHorizontalIcon:tR,AlignStartVertical:rR,AlignStartVerticalIcon:rR,AlignVerticalDistributeCenter:sR,AlignVerticalDistributeCenterIcon:sR,AlignVerticalDistributeEnd:nR,AlignVerticalDistributeEndIcon:nR,AlignVerticalDistributeStart:aR,AlignVerticalDistributeStartIcon:aR,AlignVerticalJustifyCenter:iR,AlignVerticalJustifyCenterIcon:iR,AlignVerticalJustifyEnd:oR,AlignVerticalJustifyEndIcon:oR,AlignVerticalJustifyStart:lR,AlignVerticalJustifyStartIcon:lR,AlignVerticalSpaceAround:cR,AlignVerticalSpaceAroundIcon:cR,AlignVerticalSpaceBetween:dR,AlignVerticalSpaceBetweenIcon:dR,Ambulance:uR,AmbulanceIcon:uR,Ampersand:hR,AmpersandIcon:hR,Ampersands:mR,AmpersandsIcon:mR,Amphora:fR,AmphoraIcon:fR,Anchor:pR,AnchorIcon:pR,Angry:gR,AngryIcon:gR,Annoyed:xR,AnnoyedIcon:xR,Antenna:yR,AntennaIcon:yR,Anvil:vR,AnvilIcon:vR,Aperture:_R,ApertureIcon:_R,AppWindow:cE,AppWindowIcon:cE,AppWindowMac:bR,AppWindowMacIcon:bR,Apple:wR,AppleIcon:wR,Archive:_4,ArchiveIcon:_4,ArchiveRestore:dE,ArchiveRestoreIcon:dE,ArchiveX:jR,ArchiveXIcon:jR,AreaChart:Eb,AreaChartIcon:Eb,Armchair:kR,ArmchairIcon:kR,ArrowBigDown:SR,ArrowBigDownDash:NR,ArrowBigDownDashIcon:NR,ArrowBigDownIcon:SR,ArrowBigLeft:MR,ArrowBigLeftDash:CR,ArrowBigLeftDashIcon:CR,ArrowBigLeftIcon:MR,ArrowBigRight:AR,ArrowBigRightDash:TR,ArrowBigRightDashIcon:TR,ArrowBigRightIcon:AR,ArrowBigUp:IR,ArrowBigUpDash:ER,ArrowBigUpDashIcon:ER,ArrowBigUpIcon:IR,ArrowDown:Ly,ArrowDown01:PR,ArrowDown01Icon:PR,ArrowDown10:LR,ArrowDown10Icon:LR,ArrowDownAZ:yb,ArrowDownAZIcon:yb,ArrowDownAz:yb,ArrowDownAzIcon:yb,ArrowDownCircle:Vb,ArrowDownCircleIcon:Vb,ArrowDownFromLine:DR,ArrowDownFromLineIcon:DR,ArrowDownIcon:Ly,ArrowDownLeft:OR,ArrowDownLeftFromCircle:Hb,ArrowDownLeftFromCircleIcon:Hb,ArrowDownLeftFromSquare:y2,ArrowDownLeftFromSquareIcon:y2,ArrowDownLeftIcon:OR,ArrowDownLeftSquare:f2,ArrowDownLeftSquareIcon:f2,ArrowDownNarrowWide:RR,ArrowDownNarrowWideIcon:RR,ArrowDownRight:FR,ArrowDownRightFromCircle:Wb,ArrowDownRightFromCircleIcon:Wb,ArrowDownRightFromSquare:v2,ArrowDownRightFromSquareIcon:v2,ArrowDownRightIcon:FR,ArrowDownRightSquare:p2,ArrowDownRightSquareIcon:p2,ArrowDownSquare:g2,ArrowDownSquareIcon:g2,ArrowDownToDot:zR,ArrowDownToDotIcon:zR,ArrowDownToLine:BR,ArrowDownToLineIcon:BR,ArrowDownUp:$R,ArrowDownUpIcon:$R,ArrowDownWideNarrow:vb,ArrowDownWideNarrowIcon:vb,ArrowDownZA:_b,ArrowDownZAIcon:_b,ArrowDownZa:_b,ArrowDownZaIcon:_b,ArrowLeft:gi,ArrowLeftCircle:qb,ArrowLeftCircleIcon:qb,ArrowLeftFromLine:UR,ArrowLeftFromLineIcon:UR,ArrowLeftIcon:gi,ArrowLeftRight:VR,ArrowLeftRightIcon:VR,ArrowLeftSquare:x2,ArrowLeftSquareIcon:x2,ArrowLeftToLine:qR,ArrowLeftToLineIcon:qR,ArrowRight:Ki,ArrowRightCircle:Zb,ArrowRightCircleIcon:Zb,ArrowRightFromLine:HR,ArrowRightFromLineIcon:HR,ArrowRightIcon:Ki,ArrowRightLeft:Dy,ArrowRightLeftIcon:Dy,ArrowRightSquare:w2,ArrowRightSquareIcon:w2,ArrowRightToLine:WR,ArrowRightToLineIcon:WR,ArrowUp:Pf,ArrowUp01:GR,ArrowUp01Icon:GR,ArrowUp10:KR,ArrowUp10Icon:KR,ArrowUpAZ:bb,ArrowUpAZIcon:bb,ArrowUpAz:bb,ArrowUpAzIcon:bb,ArrowUpCircle:Yb,ArrowUpCircleIcon:Yb,ArrowUpDown:eg,ArrowUpDownIcon:eg,ArrowUpFromDot:ZR,ArrowUpFromDotIcon:ZR,ArrowUpFromLine:YR,ArrowUpFromLineIcon:YR,ArrowUpIcon:Pf,ArrowUpLeft:XR,ArrowUpLeftFromCircle:Gb,ArrowUpLeftFromCircleIcon:Gb,ArrowUpLeftFromSquare:_2,ArrowUpLeftFromSquareIcon:_2,ArrowUpLeftIcon:XR,ArrowUpLeftSquare:j2,ArrowUpLeftSquareIcon:j2,ArrowUpNarrowWide:wb,ArrowUpNarrowWideIcon:wb,ArrowUpRight:QR,ArrowUpRightFromCircle:Kb,ArrowUpRightFromCircleIcon:Kb,ArrowUpRightFromSquare:b2,ArrowUpRightFromSquareIcon:b2,ArrowUpRightIcon:QR,ArrowUpRightSquare:k2,ArrowUpRightSquareIcon:k2,ArrowUpSquare:N2,ArrowUpSquareIcon:N2,ArrowUpToLine:JR,ArrowUpToLineIcon:JR,ArrowUpWideNarrow:eF,ArrowUpWideNarrowIcon:eF,ArrowUpZA:jb,ArrowUpZAIcon:jb,ArrowUpZa:jb,ArrowUpZaIcon:jb,ArrowsUpFromLine:tF,ArrowsUpFromLineIcon:tF,Asterisk:rF,AsteriskIcon:rF,AsteriskSquare:S2,AsteriskSquareIcon:S2,AtSign:sF,AtSignIcon:sF,Atom:nF,AtomIcon:nF,AudioLines:aF,AudioLinesIcon:aF,AudioWaveform:iF,AudioWaveformIcon:iF,Award:Yl,AwardIcon:Yl,Axe:oF,AxeIcon:oF,Axis3D:kb,Axis3DIcon:kb,Axis3d:kb,Axis3dIcon:kb,Baby:lF,BabyIcon:lF,Backpack:cF,BackpackIcon:cF,Badge:NF,BadgeAlert:dF,BadgeAlertIcon:dF,BadgeCent:uF,BadgeCentIcon:uF,BadgeCheck:Nb,BadgeCheckIcon:Nb,BadgeDollarSign:hF,BadgeDollarSignIcon:hF,BadgeEuro:mF,BadgeEuroIcon:mF,BadgeHelp:fF,BadgeHelpIcon:fF,BadgeIcon:NF,BadgeIndianRupee:pF,BadgeIndianRupeeIcon:pF,BadgeInfo:gF,BadgeInfoIcon:gF,BadgeJapaneseYen:xF,BadgeJapaneseYenIcon:xF,BadgeMinus:yF,BadgeMinusIcon:yF,BadgePercent:vF,BadgePercentIcon:vF,BadgePlus:_F,BadgePlusIcon:_F,BadgePoundSterling:bF,BadgePoundSterlingIcon:bF,BadgeRussianRuble:wF,BadgeRussianRubleIcon:wF,BadgeSwissFranc:jF,BadgeSwissFrancIcon:jF,BadgeX:kF,BadgeXIcon:kF,BaggageClaim:SF,BaggageClaimIcon:SF,Ban:CF,BanIcon:CF,Banana:MF,BananaIcon:MF,Bandage:TF,BandageIcon:TF,Banknote:AF,BanknoteIcon:AF,BarChart:Fb,BarChart2:zb,BarChart2Icon:zb,BarChart3:Rc,BarChart3Icon:Rc,BarChart4:Ob,BarChart4Icon:Ob,BarChartBig:Db,BarChartBigIcon:Db,BarChartHorizontal:Pb,BarChartHorizontalBig:Ib,BarChartHorizontalBigIcon:Ib,BarChartHorizontalIcon:Pb,BarChartIcon:Fb,Barcode:EF,BarcodeIcon:EF,Baseline:IF,BaselineIcon:IF,Bath:g1,BathIcon:g1,Battery:FF,BatteryCharging:PF,BatteryChargingIcon:PF,BatteryFull:LF,BatteryFullIcon:LF,BatteryIcon:FF,BatteryLow:DF,BatteryLowIcon:DF,BatteryMedium:OF,BatteryMediumIcon:OF,BatteryWarning:RF,BatteryWarningIcon:RF,Beaker:zF,BeakerIcon:zF,Bean:$F,BeanIcon:$F,BeanOff:BF,BeanOffIcon:BF,Bed:x1,BedDouble:UF,BedDoubleIcon:UF,BedIcon:x1,BedSingle:VF,BedSingleIcon:VF,Beef:qF,BeefIcon:qF,Beer:WF,BeerIcon:WF,BeerOff:HF,BeerOffIcon:HF,Bell:tg,BellDot:GF,BellDotIcon:GF,BellElectric:KF,BellElectricIcon:KF,BellIcon:tg,BellMinus:ZF,BellMinusIcon:ZF,BellOff:mk,BellOffIcon:mk,BellPlus:YF,BellPlusIcon:YF,BellRing:XF,BellRingIcon:XF,BetweenHorizonalEnd:Sb,BetweenHorizonalEndIcon:Sb,BetweenHorizonalStart:Cb,BetweenHorizonalStartIcon:Cb,BetweenHorizontalEnd:Sb,BetweenHorizontalEndIcon:Sb,BetweenHorizontalStart:Cb,BetweenHorizontalStartIcon:Cb,BetweenVerticalEnd:QF,BetweenVerticalEndIcon:QF,BetweenVerticalStart:JF,BetweenVerticalStartIcon:JF,BicepsFlexed:ez,BicepsFlexedIcon:ez,Bike:tz,BikeIcon:tz,Binary:rz,BinaryIcon:rz,Binoculars:sz,BinocularsIcon:sz,Biohazard:nz,BiohazardIcon:nz,Bird:az,BirdIcon:az,Bitcoin:iz,BitcoinIcon:iz,Blend:oz,BlendIcon:oz,Blinds:lz,BlindsIcon:lz,Blocks:cz,BlocksIcon:cz,Bluetooth:mz,BluetoothConnected:dz,BluetoothConnectedIcon:dz,BluetoothIcon:mz,BluetoothOff:uz,BluetoothOffIcon:uz,BluetoothSearching:hz,BluetoothSearchingIcon:hz,Bold:b4,BoldIcon:b4,Bolt:fz,BoltIcon:fz,Bomb:pz,BombIcon:pz,Bone:gz,BoneIcon:gz,Book:Fz,BookA:xz,BookAIcon:xz,BookAudio:yz,BookAudioIcon:yz,BookCheck:vz,BookCheckIcon:vz,BookCopy:_z,BookCopyIcon:_z,BookDashed:Mb,BookDashedIcon:Mb,BookDown:bz,BookDownIcon:bz,BookHeadphones:wz,BookHeadphonesIcon:wz,BookHeart:jz,BookHeartIcon:jz,BookIcon:Fz,BookImage:kz,BookImageIcon:kz,BookKey:Nz,BookKeyIcon:Nz,BookLock:Sz,BookLockIcon:Sz,BookMarked:Cz,BookMarkedIcon:Cz,BookMinus:Mz,BookMinusIcon:Mz,BookOpen:Oy,BookOpenCheck:Tz,BookOpenCheckIcon:Tz,BookOpenIcon:Oy,BookOpenText:Az,BookOpenTextIcon:Az,BookPlus:Ez,BookPlusIcon:Ez,BookTemplate:Mb,BookTemplateIcon:Mb,BookText:Iz,BookTextIcon:Iz,BookType:Pz,BookTypeIcon:Pz,BookUp:Dz,BookUp2:Lz,BookUp2Icon:Lz,BookUpIcon:Dz,BookUser:Oz,BookUserIcon:Oz,BookX:Rz,BookXIcon:Rz,Bookmark:rg,BookmarkCheck:zz,BookmarkCheckIcon:zz,BookmarkIcon:rg,BookmarkMinus:Bz,BookmarkMinusIcon:Bz,BookmarkPlus:uE,BookmarkPlusIcon:uE,BookmarkX:$z,BookmarkXIcon:$z,BoomBox:Uz,BoomBoxIcon:Uz,Bot:w4,BotIcon:w4,BotMessageSquare:Vz,BotMessageSquareIcon:Vz,BotOff:qz,BotOffIcon:qz,Box:Hz,BoxIcon:Hz,BoxSelect:O2,BoxSelectIcon:O2,Boxes:Wz,BoxesIcon:Wz,Braces:Tb,BracesIcon:Tb,Brackets:Gz,BracketsIcon:Gz,Brain:hE,BrainCircuit:Kz,BrainCircuitIcon:Kz,BrainCog:Zz,BrainCogIcon:Zz,BrainIcon:hE,BrickWall:Yz,BrickWallIcon:Yz,Briefcase:Pu,BriefcaseBusiness:Xz,BriefcaseBusinessIcon:Xz,BriefcaseConveyorBelt:Qz,BriefcaseConveyorBeltIcon:Qz,BriefcaseIcon:Pu,BriefcaseMedical:Jz,BriefcaseMedicalIcon:Jz,BringToFront:e7,BringToFrontIcon:e7,Brush:t7,BrushIcon:t7,Bug:n7,BugIcon:n7,BugOff:r7,BugOffIcon:r7,BugPlay:s7,BugPlayIcon:s7,Building:fk,Building2:Ni,Building2Icon:Ni,BuildingIcon:fk,Bus:i7,BusFront:a7,BusFrontIcon:a7,BusIcon:i7,Cable:l7,CableCar:o7,CableCarIcon:o7,CableIcon:l7,Cake:Lm,CakeIcon:Lm,CakeSlice:c7,CakeSliceIcon:c7,Calculator:d7,CalculatorIcon:d7,Calendar:An,Calendar1:u7,Calendar1Icon:u7,CalendarArrowDown:h7,CalendarArrowDownIcon:h7,CalendarArrowUp:m7,CalendarArrowUpIcon:m7,CalendarCheck:p7,CalendarCheck2:f7,CalendarCheck2Icon:f7,CalendarCheckIcon:p7,CalendarClock:mE,CalendarClockIcon:mE,CalendarCog:g7,CalendarCogIcon:g7,CalendarDays:sg,CalendarDaysIcon:sg,CalendarFold:x7,CalendarFoldIcon:x7,CalendarHeart:y7,CalendarHeartIcon:y7,CalendarIcon:An,CalendarMinus:_7,CalendarMinus2:v7,CalendarMinus2Icon:v7,CalendarMinusIcon:_7,CalendarOff:b7,CalendarOffIcon:b7,CalendarPlus:y1,CalendarPlus2:w7,CalendarPlus2Icon:w7,CalendarPlusIcon:y1,CalendarRange:j7,CalendarRangeIcon:j7,CalendarSearch:k7,CalendarSearchIcon:k7,CalendarSync:N7,CalendarSyncIcon:N7,CalendarX:C7,CalendarX2:S7,CalendarX2Icon:S7,CalendarXIcon:C7,Camera:ng,CameraIcon:ng,CameraOff:M7,CameraOffIcon:M7,CandlestickChart:Lb,CandlestickChartIcon:Lb,Candy:E7,CandyCane:T7,CandyCaneIcon:T7,CandyIcon:E7,CandyOff:A7,CandyOffIcon:A7,Cannabis:I7,CannabisIcon:I7,Captions:Ab,CaptionsIcon:Ab,CaptionsOff:P7,CaptionsOffIcon:P7,Car:O7,CarFront:L7,CarFrontIcon:L7,CarIcon:O7,CarTaxiFront:D7,CarTaxiFrontIcon:D7,Caravan:R7,CaravanIcon:R7,Carrot:F7,CarrotIcon:F7,CaseLower:z7,CaseLowerIcon:z7,CaseSensitive:B7,CaseSensitiveIcon:B7,CaseUpper:$7,CaseUpperIcon:$7,CassetteTape:U7,CassetteTapeIcon:U7,Cast:V7,CastIcon:V7,Castle:q7,CastleIcon:q7,Cat:H7,CatIcon:H7,Cctv:W7,CctvIcon:W7,ChartArea:Eb,ChartAreaIcon:Eb,ChartBar:Pb,ChartBarBig:Ib,ChartBarBigIcon:Ib,ChartBarDecreasing:G7,ChartBarDecreasingIcon:G7,ChartBarIcon:Pb,ChartBarIncreasing:K7,ChartBarIncreasingIcon:K7,ChartBarStacked:Z7,ChartBarStackedIcon:Z7,ChartCandlestick:Lb,ChartCandlestickIcon:Lb,ChartColumn:Rc,ChartColumnBig:Db,ChartColumnBigIcon:Db,ChartColumnDecreasing:Y7,ChartColumnDecreasingIcon:Y7,ChartColumnIcon:Rc,ChartColumnIncreasing:Ob,ChartColumnIncreasingIcon:Ob,ChartColumnStacked:X7,ChartColumnStackedIcon:X7,ChartGantt:Q7,ChartGanttIcon:Q7,ChartLine:Rb,ChartLineIcon:Rb,ChartNetwork:J7,ChartNetworkIcon:J7,ChartNoAxesColumn:zb,ChartNoAxesColumnDecreasing:eB,ChartNoAxesColumnDecreasingIcon:eB,ChartNoAxesColumnIcon:zb,ChartNoAxesColumnIncreasing:Fb,ChartNoAxesColumnIncreasingIcon:Fb,ChartNoAxesCombined:tB,ChartNoAxesCombinedIcon:tB,ChartNoAxesGantt:Bb,ChartNoAxesGanttIcon:Bb,ChartPie:$b,ChartPieIcon:$b,ChartScatter:Ub,ChartScatterIcon:Ub,ChartSpline:rB,ChartSplineIcon:rB,Check:mi,CheckCheck:sB,CheckCheckIcon:sB,CheckCircle:ui,CheckCircle2:Ri,CheckCircle2Icon:Ri,CheckCircleIcon:ui,CheckIcon:mi,CheckSquare:Nv,CheckSquare2:M2,CheckSquare2Icon:M2,CheckSquareIcon:Nv,ChefHat:nB,ChefHatIcon:nB,Cherry:aB,CherryIcon:aB,ChevronDown:ad,ChevronDownCircle:Xb,ChevronDownCircleIcon:Xb,ChevronDownIcon:ad,ChevronDownSquare:T2,ChevronDownSquareIcon:T2,ChevronFirst:iB,ChevronFirstIcon:iB,ChevronLast:oB,ChevronLastIcon:oB,ChevronLeft:jc,ChevronLeftCircle:Qb,ChevronLeftCircleIcon:Qb,ChevronLeftIcon:jc,ChevronLeftSquare:A2,ChevronLeftSquareIcon:A2,ChevronRight:Zi,ChevronRightCircle:Jb,ChevronRightCircleIcon:Jb,ChevronRightIcon:Zi,ChevronRightSquare:E2,ChevronRightSquareIcon:E2,ChevronUp:cx,ChevronUpCircle:ew,ChevronUpCircleIcon:ew,ChevronUpIcon:cx,ChevronUpSquare:I2,ChevronUpSquareIcon:I2,ChevronsDown:cB,ChevronsDownIcon:cB,ChevronsDownUp:lB,ChevronsDownUpIcon:lB,ChevronsLeft:hB,ChevronsLeftIcon:hB,ChevronsLeftRight:uB,ChevronsLeftRightEllipsis:dB,ChevronsLeftRightEllipsisIcon:dB,ChevronsLeftRightIcon:uB,ChevronsRight:fB,ChevronsRightIcon:fB,ChevronsRightLeft:mB,ChevronsRightLeftIcon:mB,ChevronsUp:pB,ChevronsUpDown:Ry,ChevronsUpDownIcon:Ry,ChevronsUpIcon:pB,Chrome:gB,ChromeIcon:gB,Church:xB,ChurchIcon:xB,Cigarette:vB,CigaretteIcon:vB,CigaretteOff:yB,CigaretteOffIcon:yB,Circle:vh,CircleAlert:kl,CircleAlertIcon:kl,CircleArrowDown:Vb,CircleArrowDownIcon:Vb,CircleArrowLeft:qb,CircleArrowLeftIcon:qb,CircleArrowOutDownLeft:Hb,CircleArrowOutDownLeftIcon:Hb,CircleArrowOutDownRight:Wb,CircleArrowOutDownRightIcon:Wb,CircleArrowOutUpLeft:Gb,CircleArrowOutUpLeftIcon:Gb,CircleArrowOutUpRight:Kb,CircleArrowOutUpRightIcon:Kb,CircleArrowRight:Zb,CircleArrowRightIcon:Zb,CircleArrowUp:Yb,CircleArrowUpIcon:Yb,CircleCheck:Ri,CircleCheckBig:ui,CircleCheckBigIcon:ui,CircleCheckIcon:Ri,CircleChevronDown:Xb,CircleChevronDownIcon:Xb,CircleChevronLeft:Qb,CircleChevronLeftIcon:Qb,CircleChevronRight:Jb,CircleChevronRightIcon:Jb,CircleChevronUp:ew,CircleChevronUpIcon:ew,CircleDashed:_B,CircleDashedIcon:_B,CircleDivide:tw,CircleDivideIcon:tw,CircleDollarSign:bB,CircleDollarSignIcon:bB,CircleDot:jB,CircleDotDashed:wB,CircleDotDashedIcon:wB,CircleDotIcon:jB,CircleEllipsis:kB,CircleEllipsisIcon:kB,CircleEqual:NB,CircleEqualIcon:NB,CircleFadingArrowUp:SB,CircleFadingArrowUpIcon:SB,CircleFadingPlus:CB,CircleFadingPlusIcon:CB,CircleGauge:rw,CircleGaugeIcon:rw,CircleHelp:by,CircleHelpIcon:by,CircleIcon:vh,CircleMinus:sw,CircleMinusIcon:sw,CircleOff:MB,CircleOffIcon:MB,CircleParking:aw,CircleParkingIcon:aw,CircleParkingOff:nw,CircleParkingOffIcon:nw,CirclePause:iw,CirclePauseIcon:iw,CirclePercent:ow,CirclePercentIcon:ow,CirclePlay:kf,CirclePlayIcon:kf,CirclePlus:lw,CirclePlusIcon:lw,CirclePower:cw,CirclePowerIcon:cw,CircleSlash:TB,CircleSlash2:dw,CircleSlash2Icon:dw,CircleSlashIcon:TB,CircleSlashed:dw,CircleSlashedIcon:dw,CircleStop:uw,CircleStopIcon:uw,CircleUser:mw,CircleUserIcon:mw,CircleUserRound:hw,CircleUserRoundIcon:hw,CircleX:Fc,CircleXIcon:Fc,CircuitBoard:AB,CircuitBoardIcon:AB,Citrus:EB,CitrusIcon:EB,Clapperboard:IB,ClapperboardIcon:IB,Clipboard:zB,ClipboardCheck:j4,ClipboardCheckIcon:j4,ClipboardCopy:PB,ClipboardCopyIcon:PB,ClipboardEdit:pw,ClipboardEditIcon:pw,ClipboardIcon:zB,ClipboardList:fE,ClipboardListIcon:fE,ClipboardMinus:LB,ClipboardMinusIcon:LB,ClipboardPaste:DB,ClipboardPasteIcon:DB,ClipboardPen:pw,ClipboardPenIcon:pw,ClipboardPenLine:fw,ClipboardPenLineIcon:fw,ClipboardPlus:OB,ClipboardPlusIcon:OB,ClipboardSignature:fw,ClipboardSignatureIcon:fw,ClipboardType:RB,ClipboardTypeIcon:RB,ClipboardX:FB,ClipboardXIcon:FB,Clock:Pa,Clock1:BB,Clock10:$B,Clock10Icon:$B,Clock11:UB,Clock11Icon:UB,Clock12:VB,Clock12Icon:VB,Clock1Icon:BB,Clock2:qB,Clock2Icon:qB,Clock3:HB,Clock3Icon:HB,Clock4:WB,Clock4Icon:WB,Clock5:GB,Clock5Icon:GB,Clock6:KB,Clock6Icon:KB,Clock7:ZB,Clock7Icon:ZB,Clock8:YB,Clock8Icon:YB,Clock9:XB,Clock9Icon:XB,ClockAlert:QB,ClockAlertIcon:QB,ClockArrowDown:JB,ClockArrowDownIcon:JB,ClockArrowUp:e9,ClockArrowUpIcon:e9,ClockIcon:Pa,Cloud:p9,CloudAlert:t9,CloudAlertIcon:t9,CloudCog:r9,CloudCogIcon:r9,CloudDownload:gw,CloudDownloadIcon:gw,CloudDrizzle:s9,CloudDrizzleIcon:s9,CloudFog:n9,CloudFogIcon:n9,CloudHail:a9,CloudHailIcon:a9,CloudIcon:p9,CloudLightning:i9,CloudLightningIcon:i9,CloudMoon:l9,CloudMoonIcon:l9,CloudMoonRain:o9,CloudMoonRainIcon:o9,CloudOff:c9,CloudOffIcon:c9,CloudRain:u9,CloudRainIcon:u9,CloudRainWind:d9,CloudRainWindIcon:d9,CloudSnow:h9,CloudSnowIcon:h9,CloudSun:f9,CloudSunIcon:f9,CloudSunRain:m9,CloudSunRainIcon:m9,CloudUpload:xw,CloudUploadIcon:xw,Cloudy:g9,CloudyIcon:g9,Clover:My,CloverIcon:My,Club:x9,ClubIcon:x9,Code:pk,Code2:yw,Code2Icon:yw,CodeIcon:pk,CodeSquare:P2,CodeSquareIcon:P2,CodeXml:yw,CodeXmlIcon:yw,Codepen:y9,CodepenIcon:y9,Codesandbox:v9,CodesandboxIcon:v9,Coffee:gk,CoffeeIcon:gk,Cog:_9,CogIcon:_9,Coins:b9,CoinsIcon:b9,Columns:vw,Columns2:vw,Columns2Icon:vw,Columns3:_w,Columns3Icon:_w,Columns4:w9,Columns4Icon:w9,ColumnsIcon:vw,Combine:j9,CombineIcon:j9,Command:k9,CommandIcon:k9,Compass:N9,CompassIcon:N9,Component:S9,ComponentIcon:S9,Computer:C9,ComputerIcon:C9,ConciergeBell:M9,ConciergeBellIcon:M9,Cone:T9,ConeIcon:T9,Construction:A9,ConstructionIcon:A9,Contact:xk,Contact2:bw,Contact2Icon:bw,ContactIcon:xk,ContactRound:bw,ContactRoundIcon:bw,Container:E9,ContainerIcon:E9,Contrast:I9,ContrastIcon:I9,Cookie:P9,CookieIcon:P9,CookingPot:L9,CookingPotIcon:L9,Copy:uo,CopyCheck:D9,CopyCheckIcon:D9,CopyIcon:uo,CopyMinus:O9,CopyMinusIcon:O9,CopyPlus:R9,CopyPlusIcon:R9,CopySlash:F9,CopySlashIcon:F9,CopyX:z9,CopyXIcon:z9,Copyleft:B9,CopyleftIcon:B9,Copyright:$9,CopyrightIcon:$9,CornerDownLeft:U9,CornerDownLeftIcon:U9,CornerDownRight:V9,CornerDownRightIcon:V9,CornerLeftDown:q9,CornerLeftDownIcon:q9,CornerLeftUp:H9,CornerLeftUpIcon:H9,CornerRightDown:W9,CornerRightDownIcon:W9,CornerRightUp:G9,CornerRightUpIcon:G9,CornerUpLeft:K9,CornerUpLeftIcon:K9,CornerUpRight:Z9,CornerUpRightIcon:Z9,Cpu:Y9,CpuIcon:Y9,CreativeCommons:X9,CreativeCommonsIcon:X9,CreditCard:Dm,CreditCardIcon:Dm,Croissant:Q9,CroissantIcon:Q9,Crop:J9,CropIcon:J9,Cross:e$,CrossIcon:e$,Crosshair:t$,CrosshairIcon:t$,Crown:_h,CrownIcon:_h,Cuboid:r$,CuboidIcon:r$,CupSoda:s$,CupSodaIcon:s$,CurlyBraces:Tb,CurlyBracesIcon:Tb,Currency:n$,CurrencyIcon:n$,Cylinder:a$,CylinderIcon:a$,Dam:i$,DamIcon:i$,Database:c$,DatabaseBackup:o$,DatabaseBackupIcon:o$,DatabaseIcon:c$,DatabaseZap:l$,DatabaseZapIcon:l$,Delete:d$,DeleteIcon:d$,Dessert:u$,DessertIcon:u$,Diameter:h$,DiameterIcon:h$,Diamond:p$,DiamondIcon:p$,DiamondMinus:m$,DiamondMinusIcon:m$,DiamondPercent:ww,DiamondPercentIcon:ww,DiamondPlus:f$,DiamondPlusIcon:f$,Dice1:g$,Dice1Icon:g$,Dice2:x$,Dice2Icon:x$,Dice3:y$,Dice3Icon:y$,Dice4:v$,Dice4Icon:v$,Dice5:_$,Dice5Icon:_$,Dice6:b$,Dice6Icon:b$,Dices:w$,DicesIcon:w$,Diff:j$,DiffIcon:j$,Disc:C$,Disc2:k$,Disc2Icon:k$,Disc3:N$,Disc3Icon:N$,DiscAlbum:S$,DiscAlbumIcon:S$,DiscIcon:C$,Divide:M$,DivideCircle:tw,DivideCircleIcon:tw,DivideIcon:M$,DivideSquare:R2,DivideSquareIcon:R2,Dna:A$,DnaIcon:A$,DnaOff:T$,DnaOffIcon:T$,Dock:E$,DockIcon:E$,Dog:I$,DogIcon:I$,DollarSign:Sd,DollarSignIcon:Sd,Donut:P$,DonutIcon:P$,DoorClosed:L$,DoorClosedIcon:L$,DoorOpen:Fy,DoorOpenIcon:Fy,Dot:D$,DotIcon:D$,DotSquare:F2,DotSquareIcon:F2,Download:Fi,DownloadCloud:gw,DownloadCloudIcon:gw,DownloadIcon:Fi,DraftingCompass:O$,DraftingCompassIcon:O$,Drama:R$,DramaIcon:R$,Dribbble:F$,DribbbleIcon:F$,Drill:z$,DrillIcon:z$,Droplet:B$,DropletIcon:B$,Droplets:dx,DropletsIcon:dx,Drum:$$,DrumIcon:$$,Drumstick:U$,DrumstickIcon:U$,Dumbbell:V$,DumbbellIcon:V$,Ear:H$,EarIcon:H$,EarOff:q$,EarOffIcon:q$,Earth:jw,EarthIcon:jw,EarthLock:W$,EarthLockIcon:W$,Eclipse:G$,EclipseIcon:G$,Edit:Lc,Edit2:kv,Edit2Icon:kv,Edit3:jv,Edit3Icon:jv,EditIcon:Lc,Egg:k4,EggFried:K$,EggFriedIcon:K$,EggIcon:k4,EggOff:Z$,EggOffIcon:Z$,Ellipsis:Nf,EllipsisIcon:Nf,EllipsisVertical:Qg,EllipsisVerticalIcon:Qg,Equal:Q$,EqualApproximately:Y$,EqualApproximatelyIcon:Y$,EqualIcon:Q$,EqualNot:X$,EqualNotIcon:X$,EqualSquare:z2,EqualSquareIcon:z2,Eraser:J$,EraserIcon:J$,EthernetPort:eU,EthernetPortIcon:eU,Euro:tU,EuroIcon:tU,Expand:rU,ExpandIcon:rU,ExternalLink:jn,ExternalLinkIcon:jn,Eye:Ii,EyeClosed:sU,EyeClosedIcon:sU,EyeIcon:Ii,EyeOff:Lf,EyeOffIcon:Lf,Facebook:fu,FacebookIcon:fu,Factory:nU,FactoryIcon:nU,Fan:aU,FanIcon:aU,FastForward:iU,FastForwardIcon:iU,Feather:oU,FeatherIcon:oU,Fence:lU,FenceIcon:lU,FerrisWheel:cU,FerrisWheelIcon:cU,Figma:dU,FigmaIcon:dU,File:N4,FileArchive:uU,FileArchiveIcon:uU,FileAudio:mU,FileAudio2:hU,FileAudio2Icon:hU,FileAudioIcon:mU,FileAxis3D:kw,FileAxis3DIcon:kw,FileAxis3d:kw,FileAxis3dIcon:kw,FileBadge:pU,FileBadge2:fU,FileBadge2Icon:fU,FileBadgeIcon:pU,FileBarChart:Nw,FileBarChart2:Sw,FileBarChart2Icon:Sw,FileBarChartIcon:Nw,FileBox:gU,FileBoxIcon:gU,FileChartColumn:Sw,FileChartColumnIcon:Sw,FileChartColumnIncreasing:Nw,FileChartColumnIncreasingIcon:Nw,FileChartLine:Cw,FileChartLineIcon:Cw,FileChartPie:Mw,FileChartPieIcon:Mw,FileCheck:yU,FileCheck2:xU,FileCheck2Icon:xU,FileCheckIcon:yU,FileClock:vU,FileClockIcon:vU,FileCode:bU,FileCode2:_U,FileCode2Icon:_U,FileCodeIcon:bU,FileCog:Tw,FileCog2:Tw,FileCog2Icon:Tw,FileCogIcon:Tw,FileDiff:wU,FileDiffIcon:wU,FileDigit:jU,FileDigitIcon:jU,FileDown:kU,FileDownIcon:kU,FileEdit:Ew,FileEditIcon:Ew,FileHeart:NU,FileHeartIcon:NU,FileIcon:N4,FileImage:v1,FileImageIcon:v1,FileInput:SU,FileInputIcon:SU,FileJson:MU,FileJson2:CU,FileJson2Icon:CU,FileJsonIcon:MU,FileKey:AU,FileKey2:TU,FileKey2Icon:TU,FileKeyIcon:AU,FileLineChart:Cw,FileLineChartIcon:Cw,FileLock:IU,FileLock2:EU,FileLock2Icon:EU,FileLockIcon:IU,FileMinus:LU,FileMinus2:PU,FileMinus2Icon:PU,FileMinusIcon:LU,FileMusic:DU,FileMusicIcon:DU,FileOutput:OU,FileOutputIcon:OU,FilePen:Ew,FilePenIcon:Ew,FilePenLine:Aw,FilePenLineIcon:Aw,FilePieChart:Mw,FilePieChartIcon:Mw,FilePlus:FU,FilePlus2:RU,FilePlus2Icon:RU,FilePlusIcon:FU,FileQuestion:zU,FileQuestionIcon:zU,FileScan:BU,FileScanIcon:BU,FileSearch:UU,FileSearch2:$U,FileSearch2Icon:$U,FileSearchIcon:UU,FileSignature:Aw,FileSignatureIcon:Aw,FileSliders:VU,FileSlidersIcon:VU,FileSpreadsheet:_1,FileSpreadsheetIcon:_1,FileStack:qU,FileStackIcon:qU,FileSymlink:HU,FileSymlinkIcon:HU,FileTerminal:WU,FileTerminalIcon:WU,FileText:ya,FileTextIcon:ya,FileType:KU,FileType2:GU,FileType2Icon:GU,FileTypeIcon:KU,FileUp:ZU,FileUpIcon:ZU,FileUser:YU,FileUserIcon:YU,FileVideo:QU,FileVideo2:XU,FileVideo2Icon:XU,FileVideoIcon:QU,FileVolume:eV,FileVolume2:JU,FileVolume2Icon:JU,FileVolumeIcon:eV,FileWarning:tV,FileWarningIcon:tV,FileX:sV,FileX2:rV,FileX2Icon:rV,FileXIcon:sV,Files:nV,FilesIcon:nV,Film:Ud,FilmIcon:Ud,Filter:b1,FilterIcon:b1,FilterX:aV,FilterXIcon:aV,Fingerprint:iV,FingerprintIcon:iV,FireExtinguisher:oV,FireExtinguisherIcon:oV,Fish:dV,FishIcon:dV,FishOff:lV,FishOffIcon:lV,FishSymbol:cV,FishSymbolIcon:cV,Flag:zy,FlagIcon:zy,FlagOff:uV,FlagOffIcon:uV,FlagTriangleLeft:hV,FlagTriangleLeftIcon:hV,FlagTriangleRight:mV,FlagTriangleRightIcon:mV,Flame:Om,FlameIcon:Om,FlameKindling:fV,FlameKindlingIcon:fV,Flashlight:gV,FlashlightIcon:gV,FlashlightOff:pV,FlashlightOffIcon:pV,FlaskConical:yk,FlaskConicalIcon:yk,FlaskConicalOff:xV,FlaskConicalOffIcon:xV,FlaskRound:yV,FlaskRoundIcon:yV,FlipHorizontal:_V,FlipHorizontal2:vV,FlipHorizontal2Icon:vV,FlipHorizontalIcon:_V,FlipVertical:wV,FlipVertical2:bV,FlipVertical2Icon:bV,FlipVerticalIcon:wV,Flower:jV,Flower2:Kp,Flower2Icon:Kp,FlowerIcon:jV,Focus:kV,FocusIcon:kV,FoldHorizontal:NV,FoldHorizontalIcon:NV,FoldVertical:SV,FoldVerticalIcon:SV,Folder:JV,FolderArchive:CV,FolderArchiveIcon:CV,FolderCheck:MV,FolderCheckIcon:MV,FolderClock:TV,FolderClockIcon:TV,FolderClosed:AV,FolderClosedIcon:AV,FolderCode:EV,FolderCodeIcon:EV,FolderCog:Iw,FolderCog2:Iw,FolderCog2Icon:Iw,FolderCogIcon:Iw,FolderDot:IV,FolderDotIcon:IV,FolderDown:PV,FolderDownIcon:PV,FolderEdit:Pw,FolderEditIcon:Pw,FolderGit:DV,FolderGit2:LV,FolderGit2Icon:LV,FolderGitIcon:DV,FolderHeart:OV,FolderHeartIcon:OV,FolderIcon:JV,FolderInput:RV,FolderInputIcon:RV,FolderKanban:FV,FolderKanbanIcon:FV,FolderKey:zV,FolderKeyIcon:zV,FolderLock:BV,FolderLockIcon:BV,FolderMinus:$V,FolderMinusIcon:$V,FolderOpen:Jh,FolderOpenDot:UV,FolderOpenDotIcon:UV,FolderOpenIcon:Jh,FolderOutput:VV,FolderOutputIcon:VV,FolderPen:Pw,FolderPenIcon:Pw,FolderPlus:qV,FolderPlusIcon:qV,FolderRoot:HV,FolderRootIcon:HV,FolderSearch:GV,FolderSearch2:WV,FolderSearch2Icon:WV,FolderSearchIcon:GV,FolderSymlink:KV,FolderSymlinkIcon:KV,FolderSync:ZV,FolderSyncIcon:ZV,FolderTree:YV,FolderTreeIcon:YV,FolderUp:XV,FolderUpIcon:XV,FolderX:QV,FolderXIcon:QV,Folders:eq,FoldersIcon:eq,Footprints:tq,FootprintsIcon:tq,ForkKnife:kj,ForkKnifeCrossed:jj,ForkKnifeCrossedIcon:jj,ForkKnifeIcon:kj,Forklift:rq,ForkliftIcon:rq,FormInput:a2,FormInputIcon:a2,Forward:sq,ForwardIcon:sq,Frame:nq,FrameIcon:nq,Framer:aq,FramerIcon:aq,Frown:iq,FrownIcon:iq,Fuel:oq,FuelIcon:oq,Fullscreen:lq,FullscreenIcon:lq,FunctionSquare:B2,FunctionSquareIcon:B2,GalleryHorizontal:dq,GalleryHorizontalEnd:cq,GalleryHorizontalEndIcon:cq,GalleryHorizontalIcon:dq,GalleryThumbnails:uq,GalleryThumbnailsIcon:uq,GalleryVertical:mq,GalleryVerticalEnd:hq,GalleryVerticalEndIcon:hq,GalleryVerticalIcon:mq,Gamepad:pq,Gamepad2:fq,Gamepad2Icon:fq,GamepadIcon:pq,GanttChart:Bb,GanttChartIcon:Bb,GanttChartSquare:Ug,GanttChartSquareIcon:Ug,Gauge:gq,GaugeCircle:rw,GaugeCircleIcon:rw,GaugeIcon:gq,Gavel:xq,GavelIcon:xq,Gem:yq,GemIcon:yq,Ghost:vk,GhostIcon:vk,Gift:po,GiftIcon:po,GitBranch:_q,GitBranchIcon:_q,GitBranchPlus:vq,GitBranchPlusIcon:vq,GitCommit:Lw,GitCommitHorizontal:Lw,GitCommitHorizontalIcon:Lw,GitCommitIcon:Lw,GitCommitVertical:bq,GitCommitVerticalIcon:bq,GitCompare:jq,GitCompareArrows:wq,GitCompareArrowsIcon:wq,GitCompareIcon:jq,GitFork:kq,GitForkIcon:kq,GitGraph:Nq,GitGraphIcon:Nq,GitMerge:Sq,GitMergeIcon:Sq,GitPullRequest:Iq,GitPullRequestArrow:Cq,GitPullRequestArrowIcon:Cq,GitPullRequestClosed:Mq,GitPullRequestClosedIcon:Mq,GitPullRequestCreate:Aq,GitPullRequestCreateArrow:Tq,GitPullRequestCreateArrowIcon:Tq,GitPullRequestCreateIcon:Aq,GitPullRequestDraft:Eq,GitPullRequestDraftIcon:Eq,GitPullRequestIcon:Iq,Github:Pq,GithubIcon:Pq,Gitlab:Lq,GitlabIcon:Lq,GlassWater:Dq,GlassWaterIcon:Dq,Glasses:Oq,GlassesIcon:Oq,Globe:ux,Globe2:jw,Globe2Icon:jw,GlobeIcon:ux,GlobeLock:Rq,GlobeLockIcon:Rq,Goal:Fq,GoalIcon:Fq,Grab:zq,GrabIcon:zq,GraduationCap:w1,GraduationCapIcon:w1,Grape:Bq,GrapeIcon:Bq,Grid:bm,Grid2X2:Ow,Grid2X2Icon:Ow,Grid2X2Plus:Dw,Grid2X2PlusIcon:Dw,Grid2x2:Ow,Grid2x2Check:$q,Grid2x2CheckIcon:$q,Grid2x2Icon:Ow,Grid2x2Plus:Dw,Grid2x2PlusIcon:Dw,Grid2x2X:Uq,Grid2x2XIcon:Uq,Grid3X3:bm,Grid3X3Icon:bm,Grid3x3:bm,Grid3x3Icon:bm,GridIcon:bm,Grip:qq,GripHorizontal:Vq,GripHorizontalIcon:Vq,GripIcon:qq,GripVertical:Df,GripVerticalIcon:Df,Group:Hq,GroupIcon:Hq,Guitar:Wq,GuitarIcon:Wq,Ham:Gq,HamIcon:Gq,Hammer:Kq,HammerIcon:Kq,Hand:pE,HandCoins:Zq,HandCoinsIcon:Zq,HandHeart:Yq,HandHeartIcon:Yq,HandHelping:Rw,HandHelpingIcon:Rw,HandIcon:pE,HandMetal:Xq,HandMetalIcon:Xq,HandPlatter:Qq,HandPlatterIcon:Qq,Handshake:Jq,HandshakeIcon:Jq,HardDrive:gE,HardDriveDownload:eH,HardDriveDownloadIcon:eH,HardDriveIcon:gE,HardDriveUpload:tH,HardDriveUploadIcon:tH,HardHat:rH,HardHatIcon:rH,Hash:S4,HashIcon:S4,Haze:sH,HazeIcon:sH,HdmiPort:nH,HdmiPortIcon:nH,Heading:cH,Heading1:xE,Heading1Icon:xE,Heading2:yE,Heading2Icon:yE,Heading3:aH,Heading3Icon:aH,Heading4:iH,Heading4Icon:iH,Heading5:oH,Heading5Icon:oH,Heading6:lH,Heading6Icon:lH,HeadingIcon:cH,HeadphoneOff:dH,HeadphoneOffIcon:dH,Headphones:uH,HeadphonesIcon:uH,Headset:hH,HeadsetIcon:hH,Heart:Ai,HeartCrack:mH,HeartCrackIcon:mH,HeartHandshake:fH,HeartHandshakeIcon:fH,HeartIcon:Ai,HeartOff:pH,HeartOffIcon:pH,HeartPulse:gH,HeartPulseIcon:gH,Heater:xH,HeaterIcon:xH,HelpCircle:by,HelpCircleIcon:by,HelpingHand:Rw,HelpingHandIcon:Rw,Hexagon:yH,HexagonIcon:yH,Highlighter:vH,HighlighterIcon:vH,History:C4,HistoryIcon:C4,Home:Vn,HomeIcon:Vn,Hop:bH,HopIcon:bH,HopOff:_H,HopOffIcon:_H,Hospital:wH,HospitalIcon:wH,Hotel:jH,HotelIcon:jH,Hourglass:kH,HourglassIcon:kH,House:Vn,HouseIcon:Vn,HousePlug:NH,HousePlugIcon:NH,HousePlus:SH,HousePlusIcon:SH,IceCream:zw,IceCream2:Fw,IceCream2Icon:Fw,IceCreamBowl:Fw,IceCreamBowlIcon:Fw,IceCreamCone:zw,IceCreamConeIcon:zw,IceCreamIcon:zw,Icon:aOe,IdCard:CH,IdCardIcon:CH,Image:Nl,ImageDown:MH,ImageDownIcon:MH,ImageIcon:Nl,ImageMinus:TH,ImageMinusIcon:TH,ImageOff:AH,ImageOffIcon:AH,ImagePlay:EH,ImagePlayIcon:EH,ImagePlus:j1,ImagePlusIcon:j1,ImageUp:IH,ImageUpIcon:IH,ImageUpscale:PH,ImageUpscaleIcon:PH,Images:LH,ImagesIcon:LH,Import:DH,ImportIcon:DH,Inbox:OH,InboxIcon:OH,Indent:$w,IndentDecrease:Bw,IndentDecreaseIcon:Bw,IndentIcon:$w,IndentIncrease:$w,IndentIncreaseIcon:$w,IndianRupee:RH,IndianRupeeIcon:RH,Infinity:FH,InfinityIcon:FH,Info:zH,InfoIcon:zH,Inspect:W2,InspectIcon:W2,InspectionPanel:BH,InspectionPanelIcon:BH,Instagram:Lu,InstagramIcon:Lu,Italic:M4,ItalicIcon:M4,IterationCcw:$H,IterationCcwIcon:$H,IterationCw:UH,IterationCwIcon:UH,JapaneseYen:VH,JapaneseYenIcon:VH,Joystick:qH,JoystickIcon:qH,Kanban:By,KanbanIcon:By,KanbanSquare:$2,KanbanSquareDashed:L2,KanbanSquareDashedIcon:L2,KanbanSquareIcon:$2,Key:Rm,KeyIcon:Rm,KeyRound:_k,KeyRoundIcon:_k,KeySquare:HH,KeySquareIcon:HH,Keyboard:KH,KeyboardIcon:KH,KeyboardMusic:WH,KeyboardMusicIcon:WH,KeyboardOff:GH,KeyboardOffIcon:GH,Lamp:eW,LampCeiling:ZH,LampCeilingIcon:ZH,LampDesk:YH,LampDeskIcon:YH,LampFloor:XH,LampFloorIcon:XH,LampIcon:eW,LampWallDown:QH,LampWallDownIcon:QH,LampWallUp:JH,LampWallUpIcon:JH,LandPlot:tW,LandPlotIcon:tW,Landmark:rW,LandmarkIcon:rW,Languages:sW,LanguagesIcon:sW,Laptop:aW,Laptop2:Uw,Laptop2Icon:Uw,LaptopIcon:aW,LaptopMinimal:Uw,LaptopMinimalCheck:nW,LaptopMinimalCheckIcon:nW,LaptopMinimalIcon:Uw,Lasso:oW,LassoIcon:oW,LassoSelect:iW,LassoSelectIcon:iW,Laugh:lW,LaughIcon:lW,Layers:uW,Layers2:cW,Layers2Icon:cW,Layers3:dW,Layers3Icon:dW,LayersIcon:uW,Layout:wv,LayoutDashboard:bk,LayoutDashboardIcon:bk,LayoutGrid:Of,LayoutGridIcon:Of,LayoutIcon:wv,LayoutList:hW,LayoutListIcon:hW,LayoutPanelLeft:mW,LayoutPanelLeftIcon:mW,LayoutPanelTop:fW,LayoutPanelTopIcon:fW,LayoutTemplate:wk,LayoutTemplateIcon:wk,Leaf:pW,LeafIcon:pW,LeafyGreen:gW,LeafyGreenIcon:gW,Lectern:xW,LecternIcon:xW,LetterText:yW,LetterTextIcon:yW,Library:T4,LibraryBig:vW,LibraryBigIcon:vW,LibraryIcon:T4,LibrarySquare:U2,LibrarySquareIcon:U2,LifeBuoy:A4,LifeBuoyIcon:A4,Ligature:_W,LigatureIcon:_W,Lightbulb:$y,LightbulbIcon:$y,LightbulbOff:bW,LightbulbOffIcon:bW,LineChart:Rb,LineChartIcon:Rb,Link:Lo,Link2:Fm,Link2Icon:Fm,Link2Off:wW,Link2OffIcon:wW,LinkIcon:Lo,Linkedin:zm,LinkedinIcon:zm,List:Rf,ListCheck:jW,ListCheckIcon:jW,ListChecks:kW,ListChecksIcon:kW,ListCollapse:NW,ListCollapseIcon:NW,ListEnd:SW,ListEndIcon:SW,ListFilter:CW,ListFilterIcon:CW,ListIcon:Rf,ListMinus:MW,ListMinusIcon:MW,ListMusic:TW,ListMusicIcon:TW,ListOrdered:E4,ListOrderedIcon:E4,ListPlus:AW,ListPlusIcon:AW,ListRestart:EW,ListRestartIcon:EW,ListStart:IW,ListStartIcon:IW,ListTodo:PW,ListTodoIcon:PW,ListTree:LW,ListTreeIcon:LW,ListVideo:DW,ListVideoIcon:DW,ListX:OW,ListXIcon:OW,Loader:FW,Loader2:$r,Loader2Icon:$r,LoaderCircle:$r,LoaderCircleIcon:$r,LoaderIcon:FW,LoaderPinwheel:RW,LoaderPinwheelIcon:RW,Locate:vE,LocateFixed:zW,LocateFixedIcon:zW,LocateIcon:vE,LocateOff:BW,LocateOffIcon:BW,Lock:Du,LockIcon:Du,LockKeyhole:$W,LockKeyholeIcon:$W,LockKeyholeOpen:Vw,LockKeyholeOpenIcon:Vw,LockOpen:qw,LockOpenIcon:qw,LogIn:I4,LogInIcon:I4,LogOut:P4,LogOutIcon:P4,Logs:UW,LogsIcon:UW,Lollipop:VW,LollipopIcon:VW,LucideAArrowDown:I8,LucideAArrowUp:P8,LucideALargeSmall:L8,LucideAccessibility:D8,LucideActivity:lx,LucideActivitySquare:m2,LucideAirVent:O8,LucideAirplay:R8,LucideAlarmCheck:pb,LucideAlarmClock:z8,LucideAlarmClockCheck:pb,LucideAlarmClockMinus:gb,LucideAlarmClockOff:F8,LucideAlarmClockPlus:xb,LucideAlarmMinus:gb,LucideAlarmPlus:xb,LucideAlarmSmoke:B8,LucideAlbum:$8,LucideAlertCircle:kl,LucideAlertOctagon:Gw,LucideAlertTriangle:ch,LucideAlignCenter:x4,LucideAlignCenterHorizontal:U8,LucideAlignCenterVertical:V8,LucideAlignEndHorizontal:q8,LucideAlignEndVertical:H8,LucideAlignHorizontalDistributeCenter:W8,LucideAlignHorizontalDistributeEnd:G8,LucideAlignHorizontalDistributeStart:K8,LucideAlignHorizontalJustifyCenter:Z8,LucideAlignHorizontalJustifyEnd:Y8,LucideAlignHorizontalJustifyStart:X8,LucideAlignHorizontalSpaceAround:Q8,LucideAlignHorizontalSpaceBetween:J8,LucideAlignJustify:eR,LucideAlignLeft:y4,LucideAlignRight:v4,LucideAlignStartHorizontal:tR,LucideAlignStartVertical:rR,LucideAlignVerticalDistributeCenter:sR,LucideAlignVerticalDistributeEnd:nR,LucideAlignVerticalDistributeStart:aR,LucideAlignVerticalJustifyCenter:iR,LucideAlignVerticalJustifyEnd:oR,LucideAlignVerticalJustifyStart:lR,LucideAlignVerticalSpaceAround:cR,LucideAlignVerticalSpaceBetween:dR,LucideAmbulance:uR,LucideAmpersand:hR,LucideAmpersands:mR,LucideAmphora:fR,LucideAnchor:pR,LucideAngry:gR,LucideAnnoyed:xR,LucideAntenna:yR,LucideAnvil:vR,LucideAperture:_R,LucideAppWindow:cE,LucideAppWindowMac:bR,LucideApple:wR,LucideArchive:_4,LucideArchiveRestore:dE,LucideArchiveX:jR,LucideAreaChart:Eb,LucideArmchair:kR,LucideArrowBigDown:SR,LucideArrowBigDownDash:NR,LucideArrowBigLeft:MR,LucideArrowBigLeftDash:CR,LucideArrowBigRight:AR,LucideArrowBigRightDash:TR,LucideArrowBigUp:IR,LucideArrowBigUpDash:ER,LucideArrowDown:Ly,LucideArrowDown01:PR,LucideArrowDown10:LR,LucideArrowDownAZ:yb,LucideArrowDownAz:yb,LucideArrowDownCircle:Vb,LucideArrowDownFromLine:DR,LucideArrowDownLeft:OR,LucideArrowDownLeftFromCircle:Hb,LucideArrowDownLeftFromSquare:y2,LucideArrowDownLeftSquare:f2,LucideArrowDownNarrowWide:RR,LucideArrowDownRight:FR,LucideArrowDownRightFromCircle:Wb,LucideArrowDownRightFromSquare:v2,LucideArrowDownRightSquare:p2,LucideArrowDownSquare:g2,LucideArrowDownToDot:zR,LucideArrowDownToLine:BR,LucideArrowDownUp:$R,LucideArrowDownWideNarrow:vb,LucideArrowDownZA:_b,LucideArrowDownZa:_b,LucideArrowLeft:gi,LucideArrowLeftCircle:qb,LucideArrowLeftFromLine:UR,LucideArrowLeftRight:VR,LucideArrowLeftSquare:x2,LucideArrowLeftToLine:qR,LucideArrowRight:Ki,LucideArrowRightCircle:Zb,LucideArrowRightFromLine:HR,LucideArrowRightLeft:Dy,LucideArrowRightSquare:w2,LucideArrowRightToLine:WR,LucideArrowUp:Pf,LucideArrowUp01:GR,LucideArrowUp10:KR,LucideArrowUpAZ:bb,LucideArrowUpAz:bb,LucideArrowUpCircle:Yb,LucideArrowUpDown:eg,LucideArrowUpFromDot:ZR,LucideArrowUpFromLine:YR,LucideArrowUpLeft:XR,LucideArrowUpLeftFromCircle:Gb,LucideArrowUpLeftFromSquare:_2,LucideArrowUpLeftSquare:j2,LucideArrowUpNarrowWide:wb,LucideArrowUpRight:QR,LucideArrowUpRightFromCircle:Kb,LucideArrowUpRightFromSquare:b2,LucideArrowUpRightSquare:k2,LucideArrowUpSquare:N2,LucideArrowUpToLine:JR,LucideArrowUpWideNarrow:eF,LucideArrowUpZA:jb,LucideArrowUpZa:jb,LucideArrowsUpFromLine:tF,LucideAsterisk:rF,LucideAsteriskSquare:S2,LucideAtSign:sF,LucideAtom:nF,LucideAudioLines:aF,LucideAudioWaveform:iF,LucideAward:Yl,LucideAxe:oF,LucideAxis3D:kb,LucideAxis3d:kb,LucideBaby:lF,LucideBackpack:cF,LucideBadge:NF,LucideBadgeAlert:dF,LucideBadgeCent:uF,LucideBadgeCheck:Nb,LucideBadgeDollarSign:hF,LucideBadgeEuro:mF,LucideBadgeHelp:fF,LucideBadgeIndianRupee:pF,LucideBadgeInfo:gF,LucideBadgeJapaneseYen:xF,LucideBadgeMinus:yF,LucideBadgePercent:vF,LucideBadgePlus:_F,LucideBadgePoundSterling:bF,LucideBadgeRussianRuble:wF,LucideBadgeSwissFranc:jF,LucideBadgeX:kF,LucideBaggageClaim:SF,LucideBan:CF,LucideBanana:MF,LucideBandage:TF,LucideBanknote:AF,LucideBarChart:Fb,LucideBarChart2:zb,LucideBarChart3:Rc,LucideBarChart4:Ob,LucideBarChartBig:Db,LucideBarChartHorizontal:Pb,LucideBarChartHorizontalBig:Ib,LucideBarcode:EF,LucideBaseline:IF,LucideBath:g1,LucideBattery:FF,LucideBatteryCharging:PF,LucideBatteryFull:LF,LucideBatteryLow:DF,LucideBatteryMedium:OF,LucideBatteryWarning:RF,LucideBeaker:zF,LucideBean:$F,LucideBeanOff:BF,LucideBed:x1,LucideBedDouble:UF,LucideBedSingle:VF,LucideBeef:qF,LucideBeer:WF,LucideBeerOff:HF,LucideBell:tg,LucideBellDot:GF,LucideBellElectric:KF,LucideBellMinus:ZF,LucideBellOff:mk,LucideBellPlus:YF,LucideBellRing:XF,LucideBetweenHorizonalEnd:Sb,LucideBetweenHorizonalStart:Cb,LucideBetweenHorizontalEnd:Sb,LucideBetweenHorizontalStart:Cb,LucideBetweenVerticalEnd:QF,LucideBetweenVerticalStart:JF,LucideBicepsFlexed:ez,LucideBike:tz,LucideBinary:rz,LucideBinoculars:sz,LucideBiohazard:nz,LucideBird:az,LucideBitcoin:iz,LucideBlend:oz,LucideBlinds:lz,LucideBlocks:cz,LucideBluetooth:mz,LucideBluetoothConnected:dz,LucideBluetoothOff:uz,LucideBluetoothSearching:hz,LucideBold:b4,LucideBolt:fz,LucideBomb:pz,LucideBone:gz,LucideBook:Fz,LucideBookA:xz,LucideBookAudio:yz,LucideBookCheck:vz,LucideBookCopy:_z,LucideBookDashed:Mb,LucideBookDown:bz,LucideBookHeadphones:wz,LucideBookHeart:jz,LucideBookImage:kz,LucideBookKey:Nz,LucideBookLock:Sz,LucideBookMarked:Cz,LucideBookMinus:Mz,LucideBookOpen:Oy,LucideBookOpenCheck:Tz,LucideBookOpenText:Az,LucideBookPlus:Ez,LucideBookTemplate:Mb,LucideBookText:Iz,LucideBookType:Pz,LucideBookUp:Dz,LucideBookUp2:Lz,LucideBookUser:Oz,LucideBookX:Rz,LucideBookmark:rg,LucideBookmarkCheck:zz,LucideBookmarkMinus:Bz,LucideBookmarkPlus:uE,LucideBookmarkX:$z,LucideBoomBox:Uz,LucideBot:w4,LucideBotMessageSquare:Vz,LucideBotOff:qz,LucideBox:Hz,LucideBoxSelect:O2,LucideBoxes:Wz,LucideBraces:Tb,LucideBrackets:Gz,LucideBrain:hE,LucideBrainCircuit:Kz,LucideBrainCog:Zz,LucideBrickWall:Yz,LucideBriefcase:Pu,LucideBriefcaseBusiness:Xz,LucideBriefcaseConveyorBelt:Qz,LucideBriefcaseMedical:Jz,LucideBringToFront:e7,LucideBrush:t7,LucideBug:n7,LucideBugOff:r7,LucideBugPlay:s7,LucideBuilding:fk,LucideBuilding2:Ni,LucideBus:i7,LucideBusFront:a7,LucideCable:l7,LucideCableCar:o7,LucideCake:Lm,LucideCakeSlice:c7,LucideCalculator:d7,LucideCalendar:An,LucideCalendar1:u7,LucideCalendarArrowDown:h7,LucideCalendarArrowUp:m7,LucideCalendarCheck:p7,LucideCalendarCheck2:f7,LucideCalendarClock:mE,LucideCalendarCog:g7,LucideCalendarDays:sg,LucideCalendarFold:x7,LucideCalendarHeart:y7,LucideCalendarMinus:_7,LucideCalendarMinus2:v7,LucideCalendarOff:b7,LucideCalendarPlus:y1,LucideCalendarPlus2:w7,LucideCalendarRange:j7,LucideCalendarSearch:k7,LucideCalendarSync:N7,LucideCalendarX:C7,LucideCalendarX2:S7,LucideCamera:ng,LucideCameraOff:M7,LucideCandlestickChart:Lb,LucideCandy:E7,LucideCandyCane:T7,LucideCandyOff:A7,LucideCannabis:I7,LucideCaptions:Ab,LucideCaptionsOff:P7,LucideCar:O7,LucideCarFront:L7,LucideCarTaxiFront:D7,LucideCaravan:R7,LucideCarrot:F7,LucideCaseLower:z7,LucideCaseSensitive:B7,LucideCaseUpper:$7,LucideCassetteTape:U7,LucideCast:V7,LucideCastle:q7,LucideCat:H7,LucideCctv:W7,LucideChartArea:Eb,LucideChartBar:Pb,LucideChartBarBig:Ib,LucideChartBarDecreasing:G7,LucideChartBarIncreasing:K7,LucideChartBarStacked:Z7,LucideChartCandlestick:Lb,LucideChartColumn:Rc,LucideChartColumnBig:Db,LucideChartColumnDecreasing:Y7,LucideChartColumnIncreasing:Ob,LucideChartColumnStacked:X7,LucideChartGantt:Q7,LucideChartLine:Rb,LucideChartNetwork:J7,LucideChartNoAxesColumn:zb,LucideChartNoAxesColumnDecreasing:eB,LucideChartNoAxesColumnIncreasing:Fb,LucideChartNoAxesCombined:tB,LucideChartNoAxesGantt:Bb,LucideChartPie:$b,LucideChartScatter:Ub,LucideChartSpline:rB,LucideCheck:mi,LucideCheckCheck:sB,LucideCheckCircle:ui,LucideCheckCircle2:Ri,LucideCheckSquare:Nv,LucideCheckSquare2:M2,LucideChefHat:nB,LucideCherry:aB,LucideChevronDown:ad,LucideChevronDownCircle:Xb,LucideChevronDownSquare:T2,LucideChevronFirst:iB,LucideChevronLast:oB,LucideChevronLeft:jc,LucideChevronLeftCircle:Qb,LucideChevronLeftSquare:A2,LucideChevronRight:Zi,LucideChevronRightCircle:Jb,LucideChevronRightSquare:E2,LucideChevronUp:cx,LucideChevronUpCircle:ew,LucideChevronUpSquare:I2,LucideChevronsDown:cB,LucideChevronsDownUp:lB,LucideChevronsLeft:hB,LucideChevronsLeftRight:uB,LucideChevronsLeftRightEllipsis:dB,LucideChevronsRight:fB,LucideChevronsRightLeft:mB,LucideChevronsUp:pB,LucideChevronsUpDown:Ry,LucideChrome:gB,LucideChurch:xB,LucideCigarette:vB,LucideCigaretteOff:yB,LucideCircle:vh,LucideCircleAlert:kl,LucideCircleArrowDown:Vb,LucideCircleArrowLeft:qb,LucideCircleArrowOutDownLeft:Hb,LucideCircleArrowOutDownRight:Wb,LucideCircleArrowOutUpLeft:Gb,LucideCircleArrowOutUpRight:Kb,LucideCircleArrowRight:Zb,LucideCircleArrowUp:Yb,LucideCircleCheck:Ri,LucideCircleCheckBig:ui,LucideCircleChevronDown:Xb,LucideCircleChevronLeft:Qb,LucideCircleChevronRight:Jb,LucideCircleChevronUp:ew,LucideCircleDashed:_B,LucideCircleDivide:tw,LucideCircleDollarSign:bB,LucideCircleDot:jB,LucideCircleDotDashed:wB,LucideCircleEllipsis:kB,LucideCircleEqual:NB,LucideCircleFadingArrowUp:SB,LucideCircleFadingPlus:CB,LucideCircleGauge:rw,LucideCircleHelp:by,LucideCircleMinus:sw,LucideCircleOff:MB,LucideCircleParking:aw,LucideCircleParkingOff:nw,LucideCirclePause:iw,LucideCirclePercent:ow,LucideCirclePlay:kf,LucideCirclePlus:lw,LucideCirclePower:cw,LucideCircleSlash:TB,LucideCircleSlash2:dw,LucideCircleSlashed:dw,LucideCircleStop:uw,LucideCircleUser:mw,LucideCircleUserRound:hw,LucideCircleX:Fc,LucideCircuitBoard:AB,LucideCitrus:EB,LucideClapperboard:IB,LucideClipboard:zB,LucideClipboardCheck:j4,LucideClipboardCopy:PB,LucideClipboardEdit:pw,LucideClipboardList:fE,LucideClipboardMinus:LB,LucideClipboardPaste:DB,LucideClipboardPen:pw,LucideClipboardPenLine:fw,LucideClipboardPlus:OB,LucideClipboardSignature:fw,LucideClipboardType:RB,LucideClipboardX:FB,LucideClock:Pa,LucideClock1:BB,LucideClock10:$B,LucideClock11:UB,LucideClock12:VB,LucideClock2:qB,LucideClock3:HB,LucideClock4:WB,LucideClock5:GB,LucideClock6:KB,LucideClock7:ZB,LucideClock8:YB,LucideClock9:XB,LucideClockAlert:QB,LucideClockArrowDown:JB,LucideClockArrowUp:e9,LucideCloud:p9,LucideCloudAlert:t9,LucideCloudCog:r9,LucideCloudDownload:gw,LucideCloudDrizzle:s9,LucideCloudFog:n9,LucideCloudHail:a9,LucideCloudLightning:i9,LucideCloudMoon:l9,LucideCloudMoonRain:o9,LucideCloudOff:c9,LucideCloudRain:u9,LucideCloudRainWind:d9,LucideCloudSnow:h9,LucideCloudSun:f9,LucideCloudSunRain:m9,LucideCloudUpload:xw,LucideCloudy:g9,LucideClover:My,LucideClub:x9,LucideCode:pk,LucideCode2:yw,LucideCodeSquare:P2,LucideCodeXml:yw,LucideCodepen:y9,LucideCodesandbox:v9,LucideCoffee:gk,LucideCog:_9,LucideCoins:b9,LucideColumns:vw,LucideColumns2:vw,LucideColumns3:_w,LucideColumns4:w9,LucideCombine:j9,LucideCommand:k9,LucideCompass:N9,LucideComponent:S9,LucideComputer:C9,LucideConciergeBell:M9,LucideCone:T9,LucideConstruction:A9,LucideContact:xk,LucideContact2:bw,LucideContactRound:bw,LucideContainer:E9,LucideContrast:I9,LucideCookie:P9,LucideCookingPot:L9,LucideCopy:uo,LucideCopyCheck:D9,LucideCopyMinus:O9,LucideCopyPlus:R9,LucideCopySlash:F9,LucideCopyX:z9,LucideCopyleft:B9,LucideCopyright:$9,LucideCornerDownLeft:U9,LucideCornerDownRight:V9,LucideCornerLeftDown:q9,LucideCornerLeftUp:H9,LucideCornerRightDown:W9,LucideCornerRightUp:G9,LucideCornerUpLeft:K9,LucideCornerUpRight:Z9,LucideCpu:Y9,LucideCreativeCommons:X9,LucideCreditCard:Dm,LucideCroissant:Q9,LucideCrop:J9,LucideCross:e$,LucideCrosshair:t$,LucideCrown:_h,LucideCuboid:r$,LucideCupSoda:s$,LucideCurlyBraces:Tb,LucideCurrency:n$,LucideCylinder:a$,LucideDam:i$,LucideDatabase:c$,LucideDatabaseBackup:o$,LucideDatabaseZap:l$,LucideDelete:d$,LucideDessert:u$,LucideDiameter:h$,LucideDiamond:p$,LucideDiamondMinus:m$,LucideDiamondPercent:ww,LucideDiamondPlus:f$,LucideDice1:g$,LucideDice2:x$,LucideDice3:y$,LucideDice4:v$,LucideDice5:_$,LucideDice6:b$,LucideDices:w$,LucideDiff:j$,LucideDisc:C$,LucideDisc2:k$,LucideDisc3:N$,LucideDiscAlbum:S$,LucideDivide:M$,LucideDivideCircle:tw,LucideDivideSquare:R2,LucideDna:A$,LucideDnaOff:T$,LucideDock:E$,LucideDog:I$,LucideDollarSign:Sd,LucideDonut:P$,LucideDoorClosed:L$,LucideDoorOpen:Fy,LucideDot:D$,LucideDotSquare:F2,LucideDownload:Fi,LucideDownloadCloud:gw,LucideDraftingCompass:O$,LucideDrama:R$,LucideDribbble:F$,LucideDrill:z$,LucideDroplet:B$,LucideDroplets:dx,LucideDrum:$$,LucideDrumstick:U$,LucideDumbbell:V$,LucideEar:H$,LucideEarOff:q$,LucideEarth:jw,LucideEarthLock:W$,LucideEclipse:G$,LucideEdit:Lc,LucideEdit2:kv,LucideEdit3:jv,LucideEgg:k4,LucideEggFried:K$,LucideEggOff:Z$,LucideEllipsis:Nf,LucideEllipsisVertical:Qg,LucideEqual:Q$,LucideEqualApproximately:Y$,LucideEqualNot:X$,LucideEqualSquare:z2,LucideEraser:J$,LucideEthernetPort:eU,LucideEuro:tU,LucideExpand:rU,LucideExternalLink:jn,LucideEye:Ii,LucideEyeClosed:sU,LucideEyeOff:Lf,LucideFacebook:fu,LucideFactory:nU,LucideFan:aU,LucideFastForward:iU,LucideFeather:oU,LucideFence:lU,LucideFerrisWheel:cU,LucideFigma:dU,LucideFile:N4,LucideFileArchive:uU,LucideFileAudio:mU,LucideFileAudio2:hU,LucideFileAxis3D:kw,LucideFileAxis3d:kw,LucideFileBadge:pU,LucideFileBadge2:fU,LucideFileBarChart:Nw,LucideFileBarChart2:Sw,LucideFileBox:gU,LucideFileChartColumn:Sw,LucideFileChartColumnIncreasing:Nw,LucideFileChartLine:Cw,LucideFileChartPie:Mw,LucideFileCheck:yU,LucideFileCheck2:xU,LucideFileClock:vU,LucideFileCode:bU,LucideFileCode2:_U,LucideFileCog:Tw,LucideFileCog2:Tw,LucideFileDiff:wU,LucideFileDigit:jU,LucideFileDown:kU,LucideFileEdit:Ew,LucideFileHeart:NU,LucideFileImage:v1,LucideFileInput:SU,LucideFileJson:MU,LucideFileJson2:CU,LucideFileKey:AU,LucideFileKey2:TU,LucideFileLineChart:Cw,LucideFileLock:IU,LucideFileLock2:EU,LucideFileMinus:LU,LucideFileMinus2:PU,LucideFileMusic:DU,LucideFileOutput:OU,LucideFilePen:Ew,LucideFilePenLine:Aw,LucideFilePieChart:Mw,LucideFilePlus:FU,LucideFilePlus2:RU,LucideFileQuestion:zU,LucideFileScan:BU,LucideFileSearch:UU,LucideFileSearch2:$U,LucideFileSignature:Aw,LucideFileSliders:VU,LucideFileSpreadsheet:_1,LucideFileStack:qU,LucideFileSymlink:HU,LucideFileTerminal:WU,LucideFileText:ya,LucideFileType:KU,LucideFileType2:GU,LucideFileUp:ZU,LucideFileUser:YU,LucideFileVideo:QU,LucideFileVideo2:XU,LucideFileVolume:eV,LucideFileVolume2:JU,LucideFileWarning:tV,LucideFileX:sV,LucideFileX2:rV,LucideFiles:nV,LucideFilm:Ud,LucideFilter:b1,LucideFilterX:aV,LucideFingerprint:iV,LucideFireExtinguisher:oV,LucideFish:dV,LucideFishOff:lV,LucideFishSymbol:cV,LucideFlag:zy,LucideFlagOff:uV,LucideFlagTriangleLeft:hV,LucideFlagTriangleRight:mV,LucideFlame:Om,LucideFlameKindling:fV,LucideFlashlight:gV,LucideFlashlightOff:pV,LucideFlaskConical:yk,LucideFlaskConicalOff:xV,LucideFlaskRound:yV,LucideFlipHorizontal:_V,LucideFlipHorizontal2:vV,LucideFlipVertical:wV,LucideFlipVertical2:bV,LucideFlower:jV,LucideFlower2:Kp,LucideFocus:kV,LucideFoldHorizontal:NV,LucideFoldVertical:SV,LucideFolder:JV,LucideFolderArchive:CV,LucideFolderCheck:MV,LucideFolderClock:TV,LucideFolderClosed:AV,LucideFolderCode:EV,LucideFolderCog:Iw,LucideFolderCog2:Iw,LucideFolderDot:IV,LucideFolderDown:PV,LucideFolderEdit:Pw,LucideFolderGit:DV,LucideFolderGit2:LV,LucideFolderHeart:OV,LucideFolderInput:RV,LucideFolderKanban:FV,LucideFolderKey:zV,LucideFolderLock:BV,LucideFolderMinus:$V,LucideFolderOpen:Jh,LucideFolderOpenDot:UV,LucideFolderOutput:VV,LucideFolderPen:Pw,LucideFolderPlus:qV,LucideFolderRoot:HV,LucideFolderSearch:GV,LucideFolderSearch2:WV,LucideFolderSymlink:KV,LucideFolderSync:ZV,LucideFolderTree:YV,LucideFolderUp:XV,LucideFolderX:QV,LucideFolders:eq,LucideFootprints:tq,LucideForkKnife:kj,LucideForkKnifeCrossed:jj,LucideForklift:rq,LucideFormInput:a2,LucideForward:sq,LucideFrame:nq,LucideFramer:aq,LucideFrown:iq,LucideFuel:oq,LucideFullscreen:lq,LucideFunctionSquare:B2,LucideGalleryHorizontal:dq,LucideGalleryHorizontalEnd:cq,LucideGalleryThumbnails:uq,LucideGalleryVertical:mq,LucideGalleryVerticalEnd:hq,LucideGamepad:pq,LucideGamepad2:fq,LucideGanttChart:Bb,LucideGanttChartSquare:Ug,LucideGauge:gq,LucideGaugeCircle:rw,LucideGavel:xq,LucideGem:yq,LucideGhost:vk,LucideGift:po,LucideGitBranch:_q,LucideGitBranchPlus:vq,LucideGitCommit:Lw,LucideGitCommitHorizontal:Lw,LucideGitCommitVertical:bq,LucideGitCompare:jq,LucideGitCompareArrows:wq,LucideGitFork:kq,LucideGitGraph:Nq,LucideGitMerge:Sq,LucideGitPullRequest:Iq,LucideGitPullRequestArrow:Cq,LucideGitPullRequestClosed:Mq,LucideGitPullRequestCreate:Aq,LucideGitPullRequestCreateArrow:Tq,LucideGitPullRequestDraft:Eq,LucideGithub:Pq,LucideGitlab:Lq,LucideGlassWater:Dq,LucideGlasses:Oq,LucideGlobe:ux,LucideGlobe2:jw,LucideGlobeLock:Rq,LucideGoal:Fq,LucideGrab:zq,LucideGraduationCap:w1,LucideGrape:Bq,LucideGrid:bm,LucideGrid2X2:Ow,LucideGrid2X2Plus:Dw,LucideGrid2x2:Ow,LucideGrid2x2Check:$q,LucideGrid2x2Plus:Dw,LucideGrid2x2X:Uq,LucideGrid3X3:bm,LucideGrid3x3:bm,LucideGrip:qq,LucideGripHorizontal:Vq,LucideGripVertical:Df,LucideGroup:Hq,LucideGuitar:Wq,LucideHam:Gq,LucideHammer:Kq,LucideHand:pE,LucideHandCoins:Zq,LucideHandHeart:Yq,LucideHandHelping:Rw,LucideHandMetal:Xq,LucideHandPlatter:Qq,LucideHandshake:Jq,LucideHardDrive:gE,LucideHardDriveDownload:eH,LucideHardDriveUpload:tH,LucideHardHat:rH,LucideHash:S4,LucideHaze:sH,LucideHdmiPort:nH,LucideHeading:cH,LucideHeading1:xE,LucideHeading2:yE,LucideHeading3:aH,LucideHeading4:iH,LucideHeading5:oH,LucideHeading6:lH,LucideHeadphoneOff:dH,LucideHeadphones:uH,LucideHeadset:hH,LucideHeart:Ai,LucideHeartCrack:mH,LucideHeartHandshake:fH,LucideHeartOff:pH,LucideHeartPulse:gH,LucideHeater:xH,LucideHelpCircle:by,LucideHelpingHand:Rw,LucideHexagon:yH,LucideHighlighter:vH,LucideHistory:C4,LucideHome:Vn,LucideHop:bH,LucideHopOff:_H,LucideHospital:wH,LucideHotel:jH,LucideHourglass:kH,LucideHouse:Vn,LucideHousePlug:NH,LucideHousePlus:SH,LucideIceCream:zw,LucideIceCream2:Fw,LucideIceCreamBowl:Fw,LucideIceCreamCone:zw,LucideIdCard:CH,LucideImage:Nl,LucideImageDown:MH,LucideImageMinus:TH,LucideImageOff:AH,LucideImagePlay:EH,LucideImagePlus:j1,LucideImageUp:IH,LucideImageUpscale:PH,LucideImages:LH,LucideImport:DH,LucideInbox:OH,LucideIndent:$w,LucideIndentDecrease:Bw,LucideIndentIncrease:$w,LucideIndianRupee:RH,LucideInfinity:FH,LucideInfo:zH,LucideInspect:W2,LucideInspectionPanel:BH,LucideInstagram:Lu,LucideItalic:M4,LucideIterationCcw:$H,LucideIterationCw:UH,LucideJapaneseYen:VH,LucideJoystick:qH,LucideKanban:By,LucideKanbanSquare:$2,LucideKanbanSquareDashed:L2,LucideKey:Rm,LucideKeyRound:_k,LucideKeySquare:HH,LucideKeyboard:KH,LucideKeyboardMusic:WH,LucideKeyboardOff:GH,LucideLamp:eW,LucideLampCeiling:ZH,LucideLampDesk:YH,LucideLampFloor:XH,LucideLampWallDown:QH,LucideLampWallUp:JH,LucideLandPlot:tW,LucideLandmark:rW,LucideLanguages:sW,LucideLaptop:aW,LucideLaptop2:Uw,LucideLaptopMinimal:Uw,LucideLaptopMinimalCheck:nW,LucideLasso:oW,LucideLassoSelect:iW,LucideLaugh:lW,LucideLayers:uW,LucideLayers2:cW,LucideLayers3:dW,LucideLayout:wv,LucideLayoutDashboard:bk,LucideLayoutGrid:Of,LucideLayoutList:hW,LucideLayoutPanelLeft:mW,LucideLayoutPanelTop:fW,LucideLayoutTemplate:wk,LucideLeaf:pW,LucideLeafyGreen:gW,LucideLectern:xW,LucideLetterText:yW,LucideLibrary:T4,LucideLibraryBig:vW,LucideLibrarySquare:U2,LucideLifeBuoy:A4,LucideLigature:_W,LucideLightbulb:$y,LucideLightbulbOff:bW,LucideLineChart:Rb,LucideLink:Lo,LucideLink2:Fm,LucideLink2Off:wW,LucideLinkedin:zm,LucideList:Rf,LucideListCheck:jW,LucideListChecks:kW,LucideListCollapse:NW,LucideListEnd:SW,LucideListFilter:CW,LucideListMinus:MW,LucideListMusic:TW,LucideListOrdered:E4,LucideListPlus:AW,LucideListRestart:EW,LucideListStart:IW,LucideListTodo:PW,LucideListTree:LW,LucideListVideo:DW,LucideListX:OW,LucideLoader:FW,LucideLoader2:$r,LucideLoaderCircle:$r,LucideLoaderPinwheel:RW,LucideLocate:vE,LucideLocateFixed:zW,LucideLocateOff:BW,LucideLock:Du,LucideLockKeyhole:$W,LucideLockKeyholeOpen:Vw,LucideLockOpen:qw,LucideLogIn:I4,LucideLogOut:P4,LucideLogs:UW,LucideLollipop:VW,LucideLuggage:qW,LucideMSquare:V2,LucideMagnet:HW,LucideMail:Vs,LucideMailCheck:WW,LucideMailMinus:GW,LucideMailOpen:KW,LucideMailPlus:ZW,LucideMailQuestion:YW,LucideMailSearch:XW,LucideMailWarning:QW,LucideMailX:_E,LucideMailbox:JW,LucideMails:eG,LucideMap:hG,LucideMapPin:Yi,LucideMapPinCheck:rG,LucideMapPinCheckInside:tG,LucideMapPinHouse:sG,LucideMapPinMinus:aG,LucideMapPinMinusInside:nG,LucideMapPinOff:iG,LucideMapPinPlus:lG,LucideMapPinPlusInside:oG,LucideMapPinX:dG,LucideMapPinXInside:cG,LucideMapPinned:uG,LucideMartini:mG,LucideMaximize:pG,LucideMaximize2:fG,LucideMedal:Uy,LucideMegaphone:ag,LucideMegaphoneOff:gG,LucideMeh:xG,LucideMemoryStick:yG,LucideMenu:bE,LucideMenuSquare:q2,LucideMerge:vG,LucideMessageCircle:Rl,LucideMessageCircleCode:_G,LucideMessageCircleDashed:bG,LucideMessageCircleHeart:L4,LucideMessageCircleMore:wG,LucideMessageCircleOff:jG,LucideMessageCirclePlus:kG,LucideMessageCircleQuestion:wE,LucideMessageCircleReply:NG,LucideMessageCircleWarning:SG,LucideMessageCircleX:CG,LucideMessageSquare:Vo,LucideMessageSquareCode:MG,LucideMessageSquareDashed:TG,LucideMessageSquareDiff:AG,LucideMessageSquareDot:EG,LucideMessageSquareHeart:jE,LucideMessageSquareLock:IG,LucideMessageSquareMore:PG,LucideMessageSquareOff:LG,LucideMessageSquarePlus:D4,LucideMessageSquareQuote:kE,LucideMessageSquareReply:DG,LucideMessageSquareShare:OG,LucideMessageSquareText:RG,LucideMessageSquareWarning:FG,LucideMessageSquareX:zG,LucideMessagesSquare:BG,LucideMic:NE,LucideMic2:Hw,LucideMicOff:$G,LucideMicVocal:Hw,LucideMicrochip:UG,LucideMicroscope:VG,LucideMicrowave:qG,LucideMilestone:HG,LucideMilk:GG,LucideMilkOff:WG,LucideMinimize:ZG,LucideMinimize2:KG,LucideMinus:k1,LucideMinusCircle:sw,LucideMinusSquare:H2,LucideMonitor:jk,LucideMonitorCheck:YG,LucideMonitorCog:XG,LucideMonitorDot:QG,LucideMonitorDown:JG,LucideMonitorOff:eK,LucideMonitorPause:tK,LucideMonitorPlay:rK,LucideMonitorSmartphone:sK,LucideMonitorSpeaker:nK,LucideMonitorStop:aK,LucideMonitorUp:iK,LucideMonitorX:oK,LucideMoon:cK,LucideMoonStar:lK,LucideMoreHorizontal:Nf,LucideMoreVertical:Qg,LucideMountain:uK,LucideMountainSnow:dK,LucideMouse:gK,LucideMouseOff:hK,LucideMousePointer:pK,LucideMousePointer2:mK,LucideMousePointerBan:fK,LucideMousePointerClick:N1,LucideMousePointerSquareDashed:D2,LucideMove:TK,LucideMove3D:Ww,LucideMove3d:Ww,LucideMoveDiagonal:yK,LucideMoveDiagonal2:xK,LucideMoveDown:bK,LucideMoveDownLeft:vK,LucideMoveDownRight:_K,LucideMoveHorizontal:wK,LucideMoveLeft:jK,LucideMoveRight:kK,LucideMoveUp:CK,LucideMoveUpLeft:NK,LucideMoveUpRight:SK,LucideMoveVertical:MK,LucideMusic:PK,LucideMusic2:AK,LucideMusic3:EK,LucideMusic4:IK,LucideNavigation:SE,LucideNavigation2:DK,LucideNavigation2Off:LK,LucideNavigationOff:OK,LucideNetwork:RK,LucideNewspaper:Vy,LucideNfc:FK,LucideNotebook:UK,LucideNotebookPen:zK,LucideNotebookTabs:BK,LucideNotebookText:$K,LucideNotepadText:qK,LucideNotepadTextDashed:VK,LucideNut:WK,LucideNutOff:HK,LucideOctagon:KK,LucideOctagonAlert:Gw,LucideOctagonMinus:GK,LucideOctagonPause:Kw,LucideOctagonX:Zw,LucideOmega:ZK,LucideOption:YK,LucideOrbit:XK,LucideOrigami:QK,LucideOutdent:Bw,LucidePackage:ec,LucidePackage2:JK,LucidePackageCheck:eZ,LucidePackageMinus:tZ,LucidePackageOpen:rZ,LucidePackagePlus:sZ,LucidePackageSearch:nZ,LucidePackageX:aZ,LucidePaintBucket:iZ,LucidePaintRoller:oZ,LucidePaintbrush:lZ,LucidePaintbrush2:Yw,LucidePaintbrushVertical:Yw,LucidePalette:id,LucidePalmtree:mj,LucidePanelBottom:uZ,LucidePanelBottomClose:cZ,LucidePanelBottomDashed:Xw,LucidePanelBottomInactive:Xw,LucidePanelBottomOpen:dZ,LucidePanelLeft:t2,LucidePanelLeftClose:Qw,LucidePanelLeftDashed:Jw,LucidePanelLeftInactive:Jw,LucidePanelLeftOpen:e2,LucidePanelRight:fZ,LucidePanelRightClose:hZ,LucidePanelRightDashed:r2,LucidePanelRightInactive:r2,LucidePanelRightOpen:mZ,LucidePanelTop:xZ,LucidePanelTopClose:pZ,LucidePanelTopDashed:s2,LucidePanelTopInactive:s2,LucidePanelTopOpen:gZ,LucidePanelsLeftBottom:yZ,LucidePanelsLeftRight:_w,LucidePanelsRightBottom:vZ,LucidePanelsTopBottom:l2,LucidePanelsTopLeft:wv,LucidePaperclip:kk,LucideParentheses:_Z,LucideParkingCircle:aw,LucideParkingCircleOff:nw,LucideParkingMeter:bZ,LucideParkingSquare:K2,LucideParkingSquareOff:G2,LucidePartyPopper:od,LucidePause:Bm,LucidePauseCircle:iw,LucidePauseOctagon:Kw,LucidePawPrint:wZ,LucidePcCase:jZ,LucidePen:kv,LucidePenBox:Lc,LucidePenLine:jv,LucidePenOff:kZ,LucidePenSquare:Lc,LucidePenTool:Nk,LucidePencil:Qa,LucidePencilLine:NZ,LucidePencilOff:SZ,LucidePencilRuler:CZ,LucidePentagon:MZ,LucidePercent:O4,LucidePercentCircle:ow,LucidePercentDiamond:ww,LucidePercentSquare:Z2,LucidePersonStanding:TZ,LucidePhilippinePeso:AZ,LucidePhone:fi,LucidePhoneCall:EZ,LucidePhoneForwarded:IZ,LucidePhoneIncoming:PZ,LucidePhoneMissed:LZ,LucidePhoneOff:DZ,LucidePhoneOutgoing:OZ,LucidePi:RZ,LucidePiSquare:Y2,LucidePiano:FZ,LucidePickaxe:zZ,LucidePictureInPicture:$Z,LucidePictureInPicture2:BZ,LucidePieChart:$b,LucidePiggyBank:UZ,LucidePilcrow:HZ,LucidePilcrowLeft:VZ,LucidePilcrowRight:qZ,LucidePilcrowSquare:X2,LucidePill:GZ,LucidePillBottle:WZ,LucidePin:S1,LucidePinOff:CE,LucidePipette:KZ,LucidePizza:ZZ,LucidePlane:QZ,LucidePlaneLanding:YZ,LucidePlaneTakeoff:XZ,LucidePlay:tc,LucidePlayCircle:kf,LucidePlaySquare:Q2,LucidePlug:ME,LucidePlug2:JZ,LucidePlugZap:n2,LucidePlugZap2:n2,LucidePlus:gs,LucidePlusCircle:lw,LucidePlusSquare:J2,LucidePocket:tY,LucidePocketKnife:eY,LucidePodcast:rY,LucidePointer:nY,LucidePointerOff:sY,LucidePopcorn:aY,LucidePopsicle:iY,LucidePoundSterling:oY,LucidePower:cY,LucidePowerCircle:cw,LucidePowerOff:lY,LucidePowerSquare:ej,LucidePresentation:Ff,LucidePrinter:TE,LucidePrinterCheck:dY,LucideProjector:uY,LucideProportions:hY,LucidePuzzle:mY,LucidePyramid:fY,LucideQrCode:Sk,LucideQuote:AE,LucideRabbit:pY,LucideRadar:gY,LucideRadiation:xY,LucideRadical:yY,LucideRadio:Ck,LucideRadioReceiver:vY,LucideRadioTower:_Y,LucideRadius:bY,LucideRailSymbol:wY,LucideRainbow:jY,LucideRat:kY,LucideRatio:NY,LucideReceipt:LY,LucideReceiptCent:SY,LucideReceiptEuro:CY,LucideReceiptIndianRupee:MY,LucideReceiptJapaneseYen:TY,LucideReceiptPoundSterling:AY,LucideReceiptRussianRuble:EY,LucideReceiptSwissFranc:IY,LucideReceiptText:PY,LucideRectangleEllipsis:a2,LucideRectangleHorizontal:DY,LucideRectangleVertical:OY,LucideRecycle:RY,LucideRedo:R4,LucideRedo2:FY,LucideRedoDot:zY,LucideRefreshCcw:$Y,LucideRefreshCcwDot:BY,LucideRefreshCw:Yo,LucideRefreshCwOff:UY,LucideRefrigerator:VY,LucideRegex:qY,LucideRemoveFormatting:HY,LucideRepeat:EE,LucideRepeat1:WY,LucideRepeat2:GY,LucideReplace:ZY,LucideReplaceAll:KY,LucideReply:IE,LucideReplyAll:YY,LucideRewind:XY,LucideRibbon:QY,LucideRocket:hx,LucideRockingChair:JY,LucideRollerCoaster:eX,LucideRotate3D:i2,LucideRotate3d:i2,LucideRotateCcw:Mk,LucideRotateCcwSquare:tX,LucideRotateCw:PE,LucideRotateCwSquare:rX,LucideRoute:nX,LucideRouteOff:sX,LucideRouter:aX,LucideRows:o2,LucideRows2:o2,LucideRows3:l2,LucideRows4:iX,LucideRss:oX,LucideRuler:lX,LucideRussianRuble:cX,LucideSailboat:dX,LucideSalad:uX,LucideSandwich:hX,LucideSatellite:fX,LucideSatelliteDish:mX,LucideSave:zf,LucideSaveAll:pX,LucideSaveOff:gX,LucideScale:xX,LucideScale3D:c2,LucideScale3d:c2,LucideScaling:yX,LucideScan:SX,LucideScanBarcode:vX,LucideScanEye:_X,LucideScanFace:bX,LucideScanLine:wX,LucideScanQrCode:jX,LucideScanSearch:kX,LucideScanText:NX,LucideScatterChart:Ub,LucideSchool:CX,LucideSchool2:pj,LucideScissors:TX,LucideScissorsLineDashed:MX,LucideScissorsSquare:tj,LucideScissorsSquareDashedBottom:C2,LucideScreenShare:EX,LucideScreenShareOff:AX,LucideScroll:PX,LucideScrollText:IX,LucideSearch:qn,LucideSearchCheck:LX,LucideSearchCode:DX,LucideSearchSlash:OX,LucideSearchX:RX,LucideSection:FX,LucideSend:ai,LucideSendHorizonal:d2,LucideSendHorizontal:d2,LucideSendToBack:zX,LucideSeparatorHorizontal:BX,LucideSeparatorVertical:$X,LucideServer:HX,LucideServerCog:UX,LucideServerCrash:VX,LucideServerOff:qX,LucideSettings:ld,LucideSettings2:WX,LucideShapes:GX,LucideShare:LE,LucideShare2:Uc,LucideSheet:KX,LucideShell:ZX,LucideShield:Ou,LucideShieldAlert:YX,LucideShieldBan:XX,LucideShieldCheck:DE,LucideShieldClose:u2,LucideShieldEllipsis:QX,LucideShieldHalf:JX,LucideShieldMinus:eQ,LucideShieldOff:tQ,LucideShieldPlus:rQ,LucideShieldQuestion:sQ,LucideShieldX:u2,LucideShip:aQ,LucideShipWheel:nQ,LucideShirt:iQ,LucideShoppingBag:mx,LucideShoppingBasket:oQ,LucideShoppingCart:Wh,LucideShovel:lQ,LucideShowerHead:cQ,LucideShrink:dQ,LucideShrub:uQ,LucideShuffle:hQ,LucideSidebar:t2,LucideSidebarClose:Qw,LucideSidebarOpen:e2,LucideSigma:mQ,LucideSigmaSquare:rj,LucideSignal:yQ,LucideSignalHigh:fQ,LucideSignalLow:pQ,LucideSignalMedium:gQ,LucideSignalZero:xQ,LucideSignature:vQ,LucideSignpost:bQ,LucideSignpostBig:_Q,LucideSiren:wQ,LucideSkipBack:jQ,LucideSkipForward:kQ,LucideSkull:NQ,LucideSlack:SQ,LucideSlash:CQ,LucideSlashSquare:sj,LucideSlice:MQ,LucideSliders:h2,LucideSlidersHorizontal:OE,LucideSlidersVertical:h2,LucideSmartphone:qy,LucideSmartphoneCharging:TQ,LucideSmartphoneNfc:AQ,LucideSmile:IQ,LucideSmilePlus:EQ,LucideSnail:PQ,LucideSnowflake:e1,LucideSofa:LQ,LucideSortAsc:wb,LucideSortDesc:vb,LucideSoup:DQ,LucideSpace:OQ,LucideSpade:RQ,LucideSparkle:FQ,LucideSparkles:bn,LucideSpeaker:zQ,LucideSpeech:BQ,LucideSpellCheck:UQ,LucideSpellCheck2:$Q,LucideSpline:VQ,LucideSplit:qQ,LucideSplitSquareHorizontal:nj,LucideSplitSquareVertical:aj,LucideSprayCan:HQ,LucideSprout:WQ,LucideSquare:fx,LucideSquareActivity:m2,LucideSquareArrowDown:g2,LucideSquareArrowDownLeft:f2,LucideSquareArrowDownRight:p2,LucideSquareArrowLeft:x2,LucideSquareArrowOutDownLeft:y2,LucideSquareArrowOutDownRight:v2,LucideSquareArrowOutUpLeft:_2,LucideSquareArrowOutUpRight:b2,LucideSquareArrowRight:w2,LucideSquareArrowUp:N2,LucideSquareArrowUpLeft:j2,LucideSquareArrowUpRight:k2,LucideSquareAsterisk:S2,LucideSquareBottomDashedScissors:C2,LucideSquareChartGantt:Ug,LucideSquareCheck:M2,LucideSquareCheckBig:Nv,LucideSquareChevronDown:T2,LucideSquareChevronLeft:A2,LucideSquareChevronRight:E2,LucideSquareChevronUp:I2,LucideSquareCode:P2,LucideSquareDashed:O2,LucideSquareDashedBottom:KQ,LucideSquareDashedBottomCode:GQ,LucideSquareDashedKanban:L2,LucideSquareDashedMousePointer:D2,LucideSquareDivide:R2,LucideSquareDot:F2,LucideSquareEqual:z2,LucideSquareFunction:B2,LucideSquareGanttChart:Ug,LucideSquareKanban:$2,LucideSquareLibrary:U2,LucideSquareM:V2,LucideSquareMenu:q2,LucideSquareMinus:H2,LucideSquareMousePointer:W2,LucideSquareParking:K2,LucideSquareParkingOff:G2,LucideSquarePen:Lc,LucideSquarePercent:Z2,LucideSquarePi:Y2,LucideSquarePilcrow:X2,LucideSquarePlay:Q2,LucideSquarePlus:J2,LucideSquarePower:ej,LucideSquareRadical:ZQ,LucideSquareScissors:tj,LucideSquareSigma:rj,LucideSquareSlash:sj,LucideSquareSplitHorizontal:nj,LucideSquareSplitVertical:aj,LucideSquareSquare:YQ,LucideSquareStack:XQ,LucideSquareTerminal:ij,LucideSquareUser:lj,LucideSquareUserRound:oj,LucideSquareX:cj,LucideSquircle:QQ,LucideSquirrel:JQ,LucideStamp:eJ,LucideStar:Dn,LucideStarHalf:tJ,LucideStarOff:rJ,LucideStars:bn,LucideStepBack:sJ,LucideStepForward:nJ,LucideStethoscope:aJ,LucideSticker:iJ,LucideStickyNote:oJ,LucideStopCircle:uw,LucideStore:lJ,LucideStretchHorizontal:cJ,LucideStretchVertical:dJ,LucideStrikethrough:uJ,LucideSubscript:hJ,LucideSubtitles:Ab,LucideSun:C1,LucideSunDim:mJ,LucideSunMedium:fJ,LucideSunMoon:pJ,LucideSunSnow:gJ,LucideSunrise:xJ,LucideSunset:yJ,LucideSuperscript:vJ,LucideSwatchBook:_J,LucideSwissFranc:bJ,LucideSwitchCamera:wJ,LucideSword:jJ,LucideSwords:kJ,LucideSyringe:NJ,LucideTable:IJ,LucideTable2:F4,LucideTableCellsMerge:SJ,LucideTableCellsSplit:CJ,LucideTableColumnsSplit:MJ,LucideTableOfContents:TJ,LucideTableProperties:AJ,LucideTableRowsSplit:EJ,LucideTablet:LJ,LucideTabletSmartphone:PJ,LucideTablets:DJ,LucideTag:px,LucideTags:OJ,LucideTally1:RJ,LucideTally2:FJ,LucideTally3:zJ,LucideTally4:BJ,LucideTally5:$J,LucideTangent:UJ,LucideTarget:Bf,LucideTelescope:VJ,LucideTent:HJ,LucideTentTree:qJ,LucideTerminal:WJ,LucideTerminalSquare:ij,LucideTestTube:GJ,LucideTestTube2:dj,LucideTestTubeDiagonal:dj,LucideTestTubes:KJ,LucideText:JJ,LucideTextCursor:YJ,LucideTextCursorInput:ZJ,LucideTextQuote:XJ,LucideTextSearch:QJ,LucideTextSelect:uj,LucideTextSelection:uj,LucideTheater:eee,LucideThermometer:see,LucideThermometerSnowflake:tee,LucideThermometerSun:ree,LucideThumbsDown:RE,LucideThumbsUp:Cd,LucideTicket:FE,LucideTicketCheck:nee,LucideTicketMinus:aee,LucideTicketPercent:iee,LucideTicketPlus:oee,LucideTicketSlash:lee,LucideTicketX:cee,LucideTickets:uee,LucideTicketsPlane:dee,LucideTimer:fee,LucideTimerOff:hee,LucideTimerReset:mee,LucideToggleLeft:pee,LucideToggleRight:gee,LucideToilet:xee,LucideTornado:yee,LucideTorus:vee,LucideTouchpad:bee,LucideTouchpadOff:_ee,LucideTowerControl:wee,LucideToyBrick:jee,LucideTractor:kee,LucideTrafficCone:Nee,LucideTrain:hj,LucideTrainFront:Cee,LucideTrainFrontTunnel:See,LucideTrainTrack:Mee,LucideTramFront:hj,LucideTrash:Tee,LucideTrash2:Os,LucideTreeDeciduous:Aee,LucideTreePalm:mj,LucideTreePine:M1,LucideTrees:Eee,LucideTrello:Iee,LucideTrendingDown:Tk,LucideTrendingUp:pu,LucideTrendingUpDown:Pee,LucideTriangle:Dee,LucideTriangleAlert:ch,LucideTriangleRight:Lee,LucideTrophy:go,LucideTruck:zE,LucideTurtle:Oee,LucideTv:Fee,LucideTv2:fj,LucideTvMinimal:fj,LucideTvMinimalPlay:Ree,LucideTwitch:zee,LucideTwitter:Bee,LucideType:Uee,LucideTypeOutline:$ee,LucideUmbrella:qee,LucideUmbrellaOff:Vee,LucideUnderline:Hee,LucideUndo:z4,LucideUndo2:Wee,LucideUndoDot:Gee,LucideUnfoldHorizontal:Kee,LucideUnfoldVertical:Zee,LucideUngroup:Yee,LucideUniversity:pj,LucideUnlink:BE,LucideUnlink2:Xee,LucideUnlock:qw,LucideUnlockKeyhole:Vw,LucideUnplug:Qee,LucideUpload:Xi,LucideUploadCloud:xw,LucideUsb:Jee,LucideUser:Fl,LucideUser2:bj,LucideUserCheck:Ak,LucideUserCheck2:gj,LucideUserCircle:mw,LucideUserCircle2:hw,LucideUserCog:$E,LucideUserCog2:xj,LucideUserMinus:UE,LucideUserMinus2:yj,LucideUserPen:ete,LucideUserPlus:Kd,LucideUserPlus2:vj,LucideUserRound:bj,LucideUserRoundCheck:gj,LucideUserRoundCog:xj,LucideUserRoundMinus:yj,LucideUserRoundPen:tte,LucideUserRoundPlus:vj,LucideUserRoundSearch:rte,LucideUserRoundX:_j,LucideUserSearch:ste,LucideUserSquare:lj,LucideUserSquare2:oj,LucideUserX:nte,LucideUserX2:_j,LucideUsers:ws,LucideUsers2:wj,LucideUsersRound:wj,LucideUtensils:kj,LucideUtensilsCrossed:jj,LucideUtilityPole:ate,LucideVariable:VE,LucideVault:ite,LucideVegan:ote,LucideVenetianMask:lte,LucideVerified:Nb,LucideVibrate:dte,LucideVibrateOff:cte,LucideVideo:ma,LucideVideoOff:ute,LucideVideotape:hte,LucideView:mte,LucideVoicemail:fte,LucideVolleyball:pte,LucideVolume:_te,LucideVolume1:gte,LucideVolume2:xte,LucideVolumeOff:yte,LucideVolumeX:vte,LucideVote:bte,LucideWallet:jte,LucideWallet2:Nj,LucideWalletCards:wte,LucideWalletMinimal:Nj,LucideWallpaper:kte,LucideWand:Nte,LucideWand2:Sj,LucideWandSparkles:Sj,LucideWarehouse:Ste,LucideWashingMachine:Cte,LucideWatch:Mte,LucideWaves:Tte,LucideWaypoints:Ate,LucideWebcam:Ete,LucideWebhook:Pte,LucideWebhookOff:Ite,LucideWeight:Lte,LucideWheat:Ote,LucideWheatOff:Dte,LucideWholeWord:Rte,LucideWifi:Ute,LucideWifiHigh:Fte,LucideWifiLow:zte,LucideWifiOff:Bte,LucideWifiZero:$te,LucideWind:qte,LucideWindArrowDown:Vte,LucideWine:Wte,LucideWineOff:Hte,LucideWorkflow:Gte,LucideWorm:Kte,LucideWrapText:Zte,LucideWrench:Hy,LucideX:Xs,LucideXCircle:Fc,LucideXOctagon:Zw,LucideXSquare:cj,LucideYoutube:Yte,LucideZap:gx,LucideZapOff:Xte,LucideZoomIn:B4,LucideZoomOut:$4,Luggage:qW,LuggageIcon:qW,MSquare:V2,MSquareIcon:V2,Magnet:HW,MagnetIcon:HW,Mail:Vs,MailCheck:WW,MailCheckIcon:WW,MailIcon:Vs,MailMinus:GW,MailMinusIcon:GW,MailOpen:KW,MailOpenIcon:KW,MailPlus:ZW,MailPlusIcon:ZW,MailQuestion:YW,MailQuestionIcon:YW,MailSearch:XW,MailSearchIcon:XW,MailWarning:QW,MailWarningIcon:QW,MailX:_E,MailXIcon:_E,Mailbox:JW,MailboxIcon:JW,Mails:eG,MailsIcon:eG,Map:hG,MapIcon:hG,MapPin:Yi,MapPinCheck:rG,MapPinCheckIcon:rG,MapPinCheckInside:tG,MapPinCheckInsideIcon:tG,MapPinHouse:sG,MapPinHouseIcon:sG,MapPinIcon:Yi,MapPinMinus:aG,MapPinMinusIcon:aG,MapPinMinusInside:nG,MapPinMinusInsideIcon:nG,MapPinOff:iG,MapPinOffIcon:iG,MapPinPlus:lG,MapPinPlusIcon:lG,MapPinPlusInside:oG,MapPinPlusInsideIcon:oG,MapPinX:dG,MapPinXIcon:dG,MapPinXInside:cG,MapPinXInsideIcon:cG,MapPinned:uG,MapPinnedIcon:uG,Martini:mG,MartiniIcon:mG,Maximize:pG,Maximize2:fG,Maximize2Icon:fG,MaximizeIcon:pG,Medal:Uy,MedalIcon:Uy,Megaphone:ag,MegaphoneIcon:ag,MegaphoneOff:gG,MegaphoneOffIcon:gG,Meh:xG,MehIcon:xG,MemoryStick:yG,MemoryStickIcon:yG,Menu:bE,MenuIcon:bE,MenuSquare:q2,MenuSquareIcon:q2,Merge:vG,MergeIcon:vG,MessageCircle:Rl,MessageCircleCode:_G,MessageCircleCodeIcon:_G,MessageCircleDashed:bG,MessageCircleDashedIcon:bG,MessageCircleHeart:L4,MessageCircleHeartIcon:L4,MessageCircleIcon:Rl,MessageCircleMore:wG,MessageCircleMoreIcon:wG,MessageCircleOff:jG,MessageCircleOffIcon:jG,MessageCirclePlus:kG,MessageCirclePlusIcon:kG,MessageCircleQuestion:wE,MessageCircleQuestionIcon:wE,MessageCircleReply:NG,MessageCircleReplyIcon:NG,MessageCircleWarning:SG,MessageCircleWarningIcon:SG,MessageCircleX:CG,MessageCircleXIcon:CG,MessageSquare:Vo,MessageSquareCode:MG,MessageSquareCodeIcon:MG,MessageSquareDashed:TG,MessageSquareDashedIcon:TG,MessageSquareDiff:AG,MessageSquareDiffIcon:AG,MessageSquareDot:EG,MessageSquareDotIcon:EG,MessageSquareHeart:jE,MessageSquareHeartIcon:jE,MessageSquareIcon:Vo,MessageSquareLock:IG,MessageSquareLockIcon:IG,MessageSquareMore:PG,MessageSquareMoreIcon:PG,MessageSquareOff:LG,MessageSquareOffIcon:LG,MessageSquarePlus:D4,MessageSquarePlusIcon:D4,MessageSquareQuote:kE,MessageSquareQuoteIcon:kE,MessageSquareReply:DG,MessageSquareReplyIcon:DG,MessageSquareShare:OG,MessageSquareShareIcon:OG,MessageSquareText:RG,MessageSquareTextIcon:RG,MessageSquareWarning:FG,MessageSquareWarningIcon:FG,MessageSquareX:zG,MessageSquareXIcon:zG,MessagesSquare:BG,MessagesSquareIcon:BG,Mic:NE,Mic2:Hw,Mic2Icon:Hw,MicIcon:NE,MicOff:$G,MicOffIcon:$G,MicVocal:Hw,MicVocalIcon:Hw,Microchip:UG,MicrochipIcon:UG,Microscope:VG,MicroscopeIcon:VG,Microwave:qG,MicrowaveIcon:qG,Milestone:HG,MilestoneIcon:HG,Milk:GG,MilkIcon:GG,MilkOff:WG,MilkOffIcon:WG,Minimize:ZG,Minimize2:KG,Minimize2Icon:KG,MinimizeIcon:ZG,Minus:k1,MinusCircle:sw,MinusCircleIcon:sw,MinusIcon:k1,MinusSquare:H2,MinusSquareIcon:H2,Monitor:jk,MonitorCheck:YG,MonitorCheckIcon:YG,MonitorCog:XG,MonitorCogIcon:XG,MonitorDot:QG,MonitorDotIcon:QG,MonitorDown:JG,MonitorDownIcon:JG,MonitorIcon:jk,MonitorOff:eK,MonitorOffIcon:eK,MonitorPause:tK,MonitorPauseIcon:tK,MonitorPlay:rK,MonitorPlayIcon:rK,MonitorSmartphone:sK,MonitorSmartphoneIcon:sK,MonitorSpeaker:nK,MonitorSpeakerIcon:nK,MonitorStop:aK,MonitorStopIcon:aK,MonitorUp:iK,MonitorUpIcon:iK,MonitorX:oK,MonitorXIcon:oK,Moon:cK,MoonIcon:cK,MoonStar:lK,MoonStarIcon:lK,MoreHorizontal:Nf,MoreHorizontalIcon:Nf,MoreVertical:Qg,MoreVerticalIcon:Qg,Mountain:uK,MountainIcon:uK,MountainSnow:dK,MountainSnowIcon:dK,Mouse:gK,MouseIcon:gK,MouseOff:hK,MouseOffIcon:hK,MousePointer:pK,MousePointer2:mK,MousePointer2Icon:mK,MousePointerBan:fK,MousePointerBanIcon:fK,MousePointerClick:N1,MousePointerClickIcon:N1,MousePointerIcon:pK,MousePointerSquareDashed:D2,MousePointerSquareDashedIcon:D2,Move:TK,Move3D:Ww,Move3DIcon:Ww,Move3d:Ww,Move3dIcon:Ww,MoveDiagonal:yK,MoveDiagonal2:xK,MoveDiagonal2Icon:xK,MoveDiagonalIcon:yK,MoveDown:bK,MoveDownIcon:bK,MoveDownLeft:vK,MoveDownLeftIcon:vK,MoveDownRight:_K,MoveDownRightIcon:_K,MoveHorizontal:wK,MoveHorizontalIcon:wK,MoveIcon:TK,MoveLeft:jK,MoveLeftIcon:jK,MoveRight:kK,MoveRightIcon:kK,MoveUp:CK,MoveUpIcon:CK,MoveUpLeft:NK,MoveUpLeftIcon:NK,MoveUpRight:SK,MoveUpRightIcon:SK,MoveVertical:MK,MoveVerticalIcon:MK,Music:PK,Music2:AK,Music2Icon:AK,Music3:EK,Music3Icon:EK,Music4:IK,Music4Icon:IK,MusicIcon:PK,Navigation:SE,Navigation2:DK,Navigation2Icon:DK,Navigation2Off:LK,Navigation2OffIcon:LK,NavigationIcon:SE,NavigationOff:OK,NavigationOffIcon:OK,Network:RK,NetworkIcon:RK,Newspaper:Vy,NewspaperIcon:Vy,Nfc:FK,NfcIcon:FK,Notebook:UK,NotebookIcon:UK,NotebookPen:zK,NotebookPenIcon:zK,NotebookTabs:BK,NotebookTabsIcon:BK,NotebookText:$K,NotebookTextIcon:$K,NotepadText:qK,NotepadTextDashed:VK,NotepadTextDashedIcon:VK,NotepadTextIcon:qK,Nut:WK,NutIcon:WK,NutOff:HK,NutOffIcon:HK,Octagon:KK,OctagonAlert:Gw,OctagonAlertIcon:Gw,OctagonIcon:KK,OctagonMinus:GK,OctagonMinusIcon:GK,OctagonPause:Kw,OctagonPauseIcon:Kw,OctagonX:Zw,OctagonXIcon:Zw,Omega:ZK,OmegaIcon:ZK,Option:YK,OptionIcon:YK,Orbit:XK,OrbitIcon:XK,Origami:QK,OrigamiIcon:QK,Outdent:Bw,OutdentIcon:Bw,Package:ec,Package2:JK,Package2Icon:JK,PackageCheck:eZ,PackageCheckIcon:eZ,PackageIcon:ec,PackageMinus:tZ,PackageMinusIcon:tZ,PackageOpen:rZ,PackageOpenIcon:rZ,PackagePlus:sZ,PackagePlusIcon:sZ,PackageSearch:nZ,PackageSearchIcon:nZ,PackageX:aZ,PackageXIcon:aZ,PaintBucket:iZ,PaintBucketIcon:iZ,PaintRoller:oZ,PaintRollerIcon:oZ,Paintbrush:lZ,Paintbrush2:Yw,Paintbrush2Icon:Yw,PaintbrushIcon:lZ,PaintbrushVertical:Yw,PaintbrushVerticalIcon:Yw,Palette:id,PaletteIcon:id,Palmtree:mj,PalmtreeIcon:mj,PanelBottom:uZ,PanelBottomClose:cZ,PanelBottomCloseIcon:cZ,PanelBottomDashed:Xw,PanelBottomDashedIcon:Xw,PanelBottomIcon:uZ,PanelBottomInactive:Xw,PanelBottomInactiveIcon:Xw,PanelBottomOpen:dZ,PanelBottomOpenIcon:dZ,PanelLeft:t2,PanelLeftClose:Qw,PanelLeftCloseIcon:Qw,PanelLeftDashed:Jw,PanelLeftDashedIcon:Jw,PanelLeftIcon:t2,PanelLeftInactive:Jw,PanelLeftInactiveIcon:Jw,PanelLeftOpen:e2,PanelLeftOpenIcon:e2,PanelRight:fZ,PanelRightClose:hZ,PanelRightCloseIcon:hZ,PanelRightDashed:r2,PanelRightDashedIcon:r2,PanelRightIcon:fZ,PanelRightInactive:r2,PanelRightInactiveIcon:r2,PanelRightOpen:mZ,PanelRightOpenIcon:mZ,PanelTop:xZ,PanelTopClose:pZ,PanelTopCloseIcon:pZ,PanelTopDashed:s2,PanelTopDashedIcon:s2,PanelTopIcon:xZ,PanelTopInactive:s2,PanelTopInactiveIcon:s2,PanelTopOpen:gZ,PanelTopOpenIcon:gZ,PanelsLeftBottom:yZ,PanelsLeftBottomIcon:yZ,PanelsLeftRight:_w,PanelsLeftRightIcon:_w,PanelsRightBottom:vZ,PanelsRightBottomIcon:vZ,PanelsTopBottom:l2,PanelsTopBottomIcon:l2,PanelsTopLeft:wv,PanelsTopLeftIcon:wv,Paperclip:kk,PaperclipIcon:kk,Parentheses:_Z,ParenthesesIcon:_Z,ParkingCircle:aw,ParkingCircleIcon:aw,ParkingCircleOff:nw,ParkingCircleOffIcon:nw,ParkingMeter:bZ,ParkingMeterIcon:bZ,ParkingSquare:K2,ParkingSquareIcon:K2,ParkingSquareOff:G2,ParkingSquareOffIcon:G2,PartyPopper:od,PartyPopperIcon:od,Pause:Bm,PauseCircle:iw,PauseCircleIcon:iw,PauseIcon:Bm,PauseOctagon:Kw,PauseOctagonIcon:Kw,PawPrint:wZ,PawPrintIcon:wZ,PcCase:jZ,PcCaseIcon:jZ,Pen:kv,PenBox:Lc,PenBoxIcon:Lc,PenIcon:kv,PenLine:jv,PenLineIcon:jv,PenOff:kZ,PenOffIcon:kZ,PenSquare:Lc,PenSquareIcon:Lc,PenTool:Nk,PenToolIcon:Nk,Pencil:Qa,PencilIcon:Qa,PencilLine:NZ,PencilLineIcon:NZ,PencilOff:SZ,PencilOffIcon:SZ,PencilRuler:CZ,PencilRulerIcon:CZ,Pentagon:MZ,PentagonIcon:MZ,Percent:O4,PercentCircle:ow,PercentCircleIcon:ow,PercentDiamond:ww,PercentDiamondIcon:ww,PercentIcon:O4,PercentSquare:Z2,PercentSquareIcon:Z2,PersonStanding:TZ,PersonStandingIcon:TZ,PhilippinePeso:AZ,PhilippinePesoIcon:AZ,Phone:fi,PhoneCall:EZ,PhoneCallIcon:EZ,PhoneForwarded:IZ,PhoneForwardedIcon:IZ,PhoneIcon:fi,PhoneIncoming:PZ,PhoneIncomingIcon:PZ,PhoneMissed:LZ,PhoneMissedIcon:LZ,PhoneOff:DZ,PhoneOffIcon:DZ,PhoneOutgoing:OZ,PhoneOutgoingIcon:OZ,Pi:RZ,PiIcon:RZ,PiSquare:Y2,PiSquareIcon:Y2,Piano:FZ,PianoIcon:FZ,Pickaxe:zZ,PickaxeIcon:zZ,PictureInPicture:$Z,PictureInPicture2:BZ,PictureInPicture2Icon:BZ,PictureInPictureIcon:$Z,PieChart:$b,PieChartIcon:$b,PiggyBank:UZ,PiggyBankIcon:UZ,Pilcrow:HZ,PilcrowIcon:HZ,PilcrowLeft:VZ,PilcrowLeftIcon:VZ,PilcrowRight:qZ,PilcrowRightIcon:qZ,PilcrowSquare:X2,PilcrowSquareIcon:X2,Pill:GZ,PillBottle:WZ,PillBottleIcon:WZ,PillIcon:GZ,Pin:S1,PinIcon:S1,PinOff:CE,PinOffIcon:CE,Pipette:KZ,PipetteIcon:KZ,Pizza:ZZ,PizzaIcon:ZZ,Plane:QZ,PlaneIcon:QZ,PlaneLanding:YZ,PlaneLandingIcon:YZ,PlaneTakeoff:XZ,PlaneTakeoffIcon:XZ,Play:tc,PlayCircle:kf,PlayCircleIcon:kf,PlayIcon:tc,PlaySquare:Q2,PlaySquareIcon:Q2,Plug:ME,Plug2:JZ,Plug2Icon:JZ,PlugIcon:ME,PlugZap:n2,PlugZap2:n2,PlugZap2Icon:n2,PlugZapIcon:n2,Plus:gs,PlusCircle:lw,PlusCircleIcon:lw,PlusIcon:gs,PlusSquare:J2,PlusSquareIcon:J2,Pocket:tY,PocketIcon:tY,PocketKnife:eY,PocketKnifeIcon:eY,Podcast:rY,PodcastIcon:rY,Pointer:nY,PointerIcon:nY,PointerOff:sY,PointerOffIcon:sY,Popcorn:aY,PopcornIcon:aY,Popsicle:iY,PopsicleIcon:iY,PoundSterling:oY,PoundSterlingIcon:oY,Power:cY,PowerCircle:cw,PowerCircleIcon:cw,PowerIcon:cY,PowerOff:lY,PowerOffIcon:lY,PowerSquare:ej,PowerSquareIcon:ej,Presentation:Ff,PresentationIcon:Ff,Printer:TE,PrinterCheck:dY,PrinterCheckIcon:dY,PrinterIcon:TE,Projector:uY,ProjectorIcon:uY,Proportions:hY,ProportionsIcon:hY,Puzzle:mY,PuzzleIcon:mY,Pyramid:fY,PyramidIcon:fY,QrCode:Sk,QrCodeIcon:Sk,Quote:AE,QuoteIcon:AE,Rabbit:pY,RabbitIcon:pY,Radar:gY,RadarIcon:gY,Radiation:xY,RadiationIcon:xY,Radical:yY,RadicalIcon:yY,Radio:Ck,RadioIcon:Ck,RadioReceiver:vY,RadioReceiverIcon:vY,RadioTower:_Y,RadioTowerIcon:_Y,Radius:bY,RadiusIcon:bY,RailSymbol:wY,RailSymbolIcon:wY,Rainbow:jY,RainbowIcon:jY,Rat:kY,RatIcon:kY,Ratio:NY,RatioIcon:NY,Receipt:LY,ReceiptCent:SY,ReceiptCentIcon:SY,ReceiptEuro:CY,ReceiptEuroIcon:CY,ReceiptIcon:LY,ReceiptIndianRupee:MY,ReceiptIndianRupeeIcon:MY,ReceiptJapaneseYen:TY,ReceiptJapaneseYenIcon:TY,ReceiptPoundSterling:AY,ReceiptPoundSterlingIcon:AY,ReceiptRussianRuble:EY,ReceiptRussianRubleIcon:EY,ReceiptSwissFranc:IY,ReceiptSwissFrancIcon:IY,ReceiptText:PY,ReceiptTextIcon:PY,RectangleEllipsis:a2,RectangleEllipsisIcon:a2,RectangleHorizontal:DY,RectangleHorizontalIcon:DY,RectangleVertical:OY,RectangleVerticalIcon:OY,Recycle:RY,RecycleIcon:RY,Redo:R4,Redo2:FY,Redo2Icon:FY,RedoDot:zY,RedoDotIcon:zY,RedoIcon:R4,RefreshCcw:$Y,RefreshCcwDot:BY,RefreshCcwDotIcon:BY,RefreshCcwIcon:$Y,RefreshCw:Yo,RefreshCwIcon:Yo,RefreshCwOff:UY,RefreshCwOffIcon:UY,Refrigerator:VY,RefrigeratorIcon:VY,Regex:qY,RegexIcon:qY,RemoveFormatting:HY,RemoveFormattingIcon:HY,Repeat:EE,Repeat1:WY,Repeat1Icon:WY,Repeat2:GY,Repeat2Icon:GY,RepeatIcon:EE,Replace:ZY,ReplaceAll:KY,ReplaceAllIcon:KY,ReplaceIcon:ZY,Reply:IE,ReplyAll:YY,ReplyAllIcon:YY,ReplyIcon:IE,Rewind:XY,RewindIcon:XY,Ribbon:QY,RibbonIcon:QY,Rocket:hx,RocketIcon:hx,RockingChair:JY,RockingChairIcon:JY,RollerCoaster:eX,RollerCoasterIcon:eX,Rotate3D:i2,Rotate3DIcon:i2,Rotate3d:i2,Rotate3dIcon:i2,RotateCcw:Mk,RotateCcwIcon:Mk,RotateCcwSquare:tX,RotateCcwSquareIcon:tX,RotateCw:PE,RotateCwIcon:PE,RotateCwSquare:rX,RotateCwSquareIcon:rX,Route:nX,RouteIcon:nX,RouteOff:sX,RouteOffIcon:sX,Router:aX,RouterIcon:aX,Rows:o2,Rows2:o2,Rows2Icon:o2,Rows3:l2,Rows3Icon:l2,Rows4:iX,Rows4Icon:iX,RowsIcon:o2,Rss:oX,RssIcon:oX,Ruler:lX,RulerIcon:lX,RussianRuble:cX,RussianRubleIcon:cX,Sailboat:dX,SailboatIcon:dX,Salad:uX,SaladIcon:uX,Sandwich:hX,SandwichIcon:hX,Satellite:fX,SatelliteDish:mX,SatelliteDishIcon:mX,SatelliteIcon:fX,Save:zf,SaveAll:pX,SaveAllIcon:pX,SaveIcon:zf,SaveOff:gX,SaveOffIcon:gX,Scale:xX,Scale3D:c2,Scale3DIcon:c2,Scale3d:c2,Scale3dIcon:c2,ScaleIcon:xX,Scaling:yX,ScalingIcon:yX,Scan:SX,ScanBarcode:vX,ScanBarcodeIcon:vX,ScanEye:_X,ScanEyeIcon:_X,ScanFace:bX,ScanFaceIcon:bX,ScanIcon:SX,ScanLine:wX,ScanLineIcon:wX,ScanQrCode:jX,ScanQrCodeIcon:jX,ScanSearch:kX,ScanSearchIcon:kX,ScanText:NX,ScanTextIcon:NX,ScatterChart:Ub,ScatterChartIcon:Ub,School:CX,School2:pj,School2Icon:pj,SchoolIcon:CX,Scissors:TX,ScissorsIcon:TX,ScissorsLineDashed:MX,ScissorsLineDashedIcon:MX,ScissorsSquare:tj,ScissorsSquareDashedBottom:C2,ScissorsSquareDashedBottomIcon:C2,ScissorsSquareIcon:tj,ScreenShare:EX,ScreenShareIcon:EX,ScreenShareOff:AX,ScreenShareOffIcon:AX,Scroll:PX,ScrollIcon:PX,ScrollText:IX,ScrollTextIcon:IX,Search:qn,SearchCheck:LX,SearchCheckIcon:LX,SearchCode:DX,SearchCodeIcon:DX,SearchIcon:qn,SearchSlash:OX,SearchSlashIcon:OX,SearchX:RX,SearchXIcon:RX,Section:FX,SectionIcon:FX,Send:ai,SendHorizonal:d2,SendHorizonalIcon:d2,SendHorizontal:d2,SendHorizontalIcon:d2,SendIcon:ai,SendToBack:zX,SendToBackIcon:zX,SeparatorHorizontal:BX,SeparatorHorizontalIcon:BX,SeparatorVertical:$X,SeparatorVerticalIcon:$X,Server:HX,ServerCog:UX,ServerCogIcon:UX,ServerCrash:VX,ServerCrashIcon:VX,ServerIcon:HX,ServerOff:qX,ServerOffIcon:qX,Settings:ld,Settings2:WX,Settings2Icon:WX,SettingsIcon:ld,Shapes:GX,ShapesIcon:GX,Share:LE,Share2:Uc,Share2Icon:Uc,ShareIcon:LE,Sheet:KX,SheetIcon:KX,Shell:ZX,ShellIcon:ZX,Shield:Ou,ShieldAlert:YX,ShieldAlertIcon:YX,ShieldBan:XX,ShieldBanIcon:XX,ShieldCheck:DE,ShieldCheckIcon:DE,ShieldClose:u2,ShieldCloseIcon:u2,ShieldEllipsis:QX,ShieldEllipsisIcon:QX,ShieldHalf:JX,ShieldHalfIcon:JX,ShieldIcon:Ou,ShieldMinus:eQ,ShieldMinusIcon:eQ,ShieldOff:tQ,ShieldOffIcon:tQ,ShieldPlus:rQ,ShieldPlusIcon:rQ,ShieldQuestion:sQ,ShieldQuestionIcon:sQ,ShieldX:u2,ShieldXIcon:u2,Ship:aQ,ShipIcon:aQ,ShipWheel:nQ,ShipWheelIcon:nQ,Shirt:iQ,ShirtIcon:iQ,ShoppingBag:mx,ShoppingBagIcon:mx,ShoppingBasket:oQ,ShoppingBasketIcon:oQ,ShoppingCart:Wh,ShoppingCartIcon:Wh,Shovel:lQ,ShovelIcon:lQ,ShowerHead:cQ,ShowerHeadIcon:cQ,Shrink:dQ,ShrinkIcon:dQ,Shrub:uQ,ShrubIcon:uQ,Shuffle:hQ,ShuffleIcon:hQ,Sidebar:t2,SidebarClose:Qw,SidebarCloseIcon:Qw,SidebarIcon:t2,SidebarOpen:e2,SidebarOpenIcon:e2,Sigma:mQ,SigmaIcon:mQ,SigmaSquare:rj,SigmaSquareIcon:rj,Signal:yQ,SignalHigh:fQ,SignalHighIcon:fQ,SignalIcon:yQ,SignalLow:pQ,SignalLowIcon:pQ,SignalMedium:gQ,SignalMediumIcon:gQ,SignalZero:xQ,SignalZeroIcon:xQ,Signature:vQ,SignatureIcon:vQ,Signpost:bQ,SignpostBig:_Q,SignpostBigIcon:_Q,SignpostIcon:bQ,Siren:wQ,SirenIcon:wQ,SkipBack:jQ,SkipBackIcon:jQ,SkipForward:kQ,SkipForwardIcon:kQ,Skull:NQ,SkullIcon:NQ,Slack:SQ,SlackIcon:SQ,Slash:CQ,SlashIcon:CQ,SlashSquare:sj,SlashSquareIcon:sj,Slice:MQ,SliceIcon:MQ,Sliders:h2,SlidersHorizontal:OE,SlidersHorizontalIcon:OE,SlidersIcon:h2,SlidersVertical:h2,SlidersVerticalIcon:h2,Smartphone:qy,SmartphoneCharging:TQ,SmartphoneChargingIcon:TQ,SmartphoneIcon:qy,SmartphoneNfc:AQ,SmartphoneNfcIcon:AQ,Smile:IQ,SmileIcon:IQ,SmilePlus:EQ,SmilePlusIcon:EQ,Snail:PQ,SnailIcon:PQ,Snowflake:e1,SnowflakeIcon:e1,Sofa:LQ,SofaIcon:LQ,SortAsc:wb,SortAscIcon:wb,SortDesc:vb,SortDescIcon:vb,Soup:DQ,SoupIcon:DQ,Space:OQ,SpaceIcon:OQ,Spade:RQ,SpadeIcon:RQ,Sparkle:FQ,SparkleIcon:FQ,Sparkles:bn,SparklesIcon:bn,Speaker:zQ,SpeakerIcon:zQ,Speech:BQ,SpeechIcon:BQ,SpellCheck:UQ,SpellCheck2:$Q,SpellCheck2Icon:$Q,SpellCheckIcon:UQ,Spline:VQ,SplineIcon:VQ,Split:qQ,SplitIcon:qQ,SplitSquareHorizontal:nj,SplitSquareHorizontalIcon:nj,SplitSquareVertical:aj,SplitSquareVerticalIcon:aj,SprayCan:HQ,SprayCanIcon:HQ,Sprout:WQ,SproutIcon:WQ,Square:fx,SquareActivity:m2,SquareActivityIcon:m2,SquareArrowDown:g2,SquareArrowDownIcon:g2,SquareArrowDownLeft:f2,SquareArrowDownLeftIcon:f2,SquareArrowDownRight:p2,SquareArrowDownRightIcon:p2,SquareArrowLeft:x2,SquareArrowLeftIcon:x2,SquareArrowOutDownLeft:y2,SquareArrowOutDownLeftIcon:y2,SquareArrowOutDownRight:v2,SquareArrowOutDownRightIcon:v2,SquareArrowOutUpLeft:_2,SquareArrowOutUpLeftIcon:_2,SquareArrowOutUpRight:b2,SquareArrowOutUpRightIcon:b2,SquareArrowRight:w2,SquareArrowRightIcon:w2,SquareArrowUp:N2,SquareArrowUpIcon:N2,SquareArrowUpLeft:j2,SquareArrowUpLeftIcon:j2,SquareArrowUpRight:k2,SquareArrowUpRightIcon:k2,SquareAsterisk:S2,SquareAsteriskIcon:S2,SquareBottomDashedScissors:C2,SquareBottomDashedScissorsIcon:C2,SquareChartGantt:Ug,SquareChartGanttIcon:Ug,SquareCheck:M2,SquareCheckBig:Nv,SquareCheckBigIcon:Nv,SquareCheckIcon:M2,SquareChevronDown:T2,SquareChevronDownIcon:T2,SquareChevronLeft:A2,SquareChevronLeftIcon:A2,SquareChevronRight:E2,SquareChevronRightIcon:E2,SquareChevronUp:I2,SquareChevronUpIcon:I2,SquareCode:P2,SquareCodeIcon:P2,SquareDashed:O2,SquareDashedBottom:KQ,SquareDashedBottomCode:GQ,SquareDashedBottomCodeIcon:GQ,SquareDashedBottomIcon:KQ,SquareDashedIcon:O2,SquareDashedKanban:L2,SquareDashedKanbanIcon:L2,SquareDashedMousePointer:D2,SquareDashedMousePointerIcon:D2,SquareDivide:R2,SquareDivideIcon:R2,SquareDot:F2,SquareDotIcon:F2,SquareEqual:z2,SquareEqualIcon:z2,SquareFunction:B2,SquareFunctionIcon:B2,SquareGanttChart:Ug,SquareGanttChartIcon:Ug,SquareIcon:fx,SquareKanban:$2,SquareKanbanIcon:$2,SquareLibrary:U2,SquareLibraryIcon:U2,SquareM:V2,SquareMIcon:V2,SquareMenu:q2,SquareMenuIcon:q2,SquareMinus:H2,SquareMinusIcon:H2,SquareMousePointer:W2,SquareMousePointerIcon:W2,SquareParking:K2,SquareParkingIcon:K2,SquareParkingOff:G2,SquareParkingOffIcon:G2,SquarePen:Lc,SquarePenIcon:Lc,SquarePercent:Z2,SquarePercentIcon:Z2,SquarePi:Y2,SquarePiIcon:Y2,SquarePilcrow:X2,SquarePilcrowIcon:X2,SquarePlay:Q2,SquarePlayIcon:Q2,SquarePlus:J2,SquarePlusIcon:J2,SquarePower:ej,SquarePowerIcon:ej,SquareRadical:ZQ,SquareRadicalIcon:ZQ,SquareScissors:tj,SquareScissorsIcon:tj,SquareSigma:rj,SquareSigmaIcon:rj,SquareSlash:sj,SquareSlashIcon:sj,SquareSplitHorizontal:nj,SquareSplitHorizontalIcon:nj,SquareSplitVertical:aj,SquareSplitVerticalIcon:aj,SquareSquare:YQ,SquareSquareIcon:YQ,SquareStack:XQ,SquareStackIcon:XQ,SquareTerminal:ij,SquareTerminalIcon:ij,SquareUser:lj,SquareUserIcon:lj,SquareUserRound:oj,SquareUserRoundIcon:oj,SquareX:cj,SquareXIcon:cj,Squircle:QQ,SquircleIcon:QQ,Squirrel:JQ,SquirrelIcon:JQ,Stamp:eJ,StampIcon:eJ,Star:Dn,StarHalf:tJ,StarHalfIcon:tJ,StarIcon:Dn,StarOff:rJ,StarOffIcon:rJ,Stars:bn,StarsIcon:bn,StepBack:sJ,StepBackIcon:sJ,StepForward:nJ,StepForwardIcon:nJ,Stethoscope:aJ,StethoscopeIcon:aJ,Sticker:iJ,StickerIcon:iJ,StickyNote:oJ,StickyNoteIcon:oJ,StopCircle:uw,StopCircleIcon:uw,Store:lJ,StoreIcon:lJ,StretchHorizontal:cJ,StretchHorizontalIcon:cJ,StretchVertical:dJ,StretchVerticalIcon:dJ,Strikethrough:uJ,StrikethroughIcon:uJ,Subscript:hJ,SubscriptIcon:hJ,Subtitles:Ab,SubtitlesIcon:Ab,Sun:C1,SunDim:mJ,SunDimIcon:mJ,SunIcon:C1,SunMedium:fJ,SunMediumIcon:fJ,SunMoon:pJ,SunMoonIcon:pJ,SunSnow:gJ,SunSnowIcon:gJ,Sunrise:xJ,SunriseIcon:xJ,Sunset:yJ,SunsetIcon:yJ,Superscript:vJ,SuperscriptIcon:vJ,SwatchBook:_J,SwatchBookIcon:_J,SwissFranc:bJ,SwissFrancIcon:bJ,SwitchCamera:wJ,SwitchCameraIcon:wJ,Sword:jJ,SwordIcon:jJ,Swords:kJ,SwordsIcon:kJ,Syringe:NJ,SyringeIcon:NJ,Table:IJ,Table2:F4,Table2Icon:F4,TableCellsMerge:SJ,TableCellsMergeIcon:SJ,TableCellsSplit:CJ,TableCellsSplitIcon:CJ,TableColumnsSplit:MJ,TableColumnsSplitIcon:MJ,TableIcon:IJ,TableOfContents:TJ,TableOfContentsIcon:TJ,TableProperties:AJ,TablePropertiesIcon:AJ,TableRowsSplit:EJ,TableRowsSplitIcon:EJ,Tablet:LJ,TabletIcon:LJ,TabletSmartphone:PJ,TabletSmartphoneIcon:PJ,Tablets:DJ,TabletsIcon:DJ,Tag:px,TagIcon:px,Tags:OJ,TagsIcon:OJ,Tally1:RJ,Tally1Icon:RJ,Tally2:FJ,Tally2Icon:FJ,Tally3:zJ,Tally3Icon:zJ,Tally4:BJ,Tally4Icon:BJ,Tally5:$J,Tally5Icon:$J,Tangent:UJ,TangentIcon:UJ,Target:Bf,TargetIcon:Bf,Telescope:VJ,TelescopeIcon:VJ,Tent:HJ,TentIcon:HJ,TentTree:qJ,TentTreeIcon:qJ,Terminal:WJ,TerminalIcon:WJ,TerminalSquare:ij,TerminalSquareIcon:ij,TestTube:GJ,TestTube2:dj,TestTube2Icon:dj,TestTubeDiagonal:dj,TestTubeDiagonalIcon:dj,TestTubeIcon:GJ,TestTubes:KJ,TestTubesIcon:KJ,Text:JJ,TextCursor:YJ,TextCursorIcon:YJ,TextCursorInput:ZJ,TextCursorInputIcon:ZJ,TextIcon:JJ,TextQuote:XJ,TextQuoteIcon:XJ,TextSearch:QJ,TextSearchIcon:QJ,TextSelect:uj,TextSelectIcon:uj,TextSelection:uj,TextSelectionIcon:uj,Theater:eee,TheaterIcon:eee,Thermometer:see,ThermometerIcon:see,ThermometerSnowflake:tee,ThermometerSnowflakeIcon:tee,ThermometerSun:ree,ThermometerSunIcon:ree,ThumbsDown:RE,ThumbsDownIcon:RE,ThumbsUp:Cd,ThumbsUpIcon:Cd,Ticket:FE,TicketCheck:nee,TicketCheckIcon:nee,TicketIcon:FE,TicketMinus:aee,TicketMinusIcon:aee,TicketPercent:iee,TicketPercentIcon:iee,TicketPlus:oee,TicketPlusIcon:oee,TicketSlash:lee,TicketSlashIcon:lee,TicketX:cee,TicketXIcon:cee,Tickets:uee,TicketsIcon:uee,TicketsPlane:dee,TicketsPlaneIcon:dee,Timer:fee,TimerIcon:fee,TimerOff:hee,TimerOffIcon:hee,TimerReset:mee,TimerResetIcon:mee,ToggleLeft:pee,ToggleLeftIcon:pee,ToggleRight:gee,ToggleRightIcon:gee,Toilet:xee,ToiletIcon:xee,Tornado:yee,TornadoIcon:yee,Torus:vee,TorusIcon:vee,Touchpad:bee,TouchpadIcon:bee,TouchpadOff:_ee,TouchpadOffIcon:_ee,TowerControl:wee,TowerControlIcon:wee,ToyBrick:jee,ToyBrickIcon:jee,Tractor:kee,TractorIcon:kee,TrafficCone:Nee,TrafficConeIcon:Nee,Train:hj,TrainFront:Cee,TrainFrontIcon:Cee,TrainFrontTunnel:See,TrainFrontTunnelIcon:See,TrainIcon:hj,TrainTrack:Mee,TrainTrackIcon:Mee,TramFront:hj,TramFrontIcon:hj,Trash:Tee,Trash2:Os,Trash2Icon:Os,TrashIcon:Tee,TreeDeciduous:Aee,TreeDeciduousIcon:Aee,TreePalm:mj,TreePalmIcon:mj,TreePine:M1,TreePineIcon:M1,Trees:Eee,TreesIcon:Eee,Trello:Iee,TrelloIcon:Iee,TrendingDown:Tk,TrendingDownIcon:Tk,TrendingUp:pu,TrendingUpDown:Pee,TrendingUpDownIcon:Pee,TrendingUpIcon:pu,Triangle:Dee,TriangleAlert:ch,TriangleAlertIcon:ch,TriangleIcon:Dee,TriangleRight:Lee,TriangleRightIcon:Lee,Trophy:go,TrophyIcon:go,Truck:zE,TruckIcon:zE,Turtle:Oee,TurtleIcon:Oee,Tv:Fee,Tv2:fj,Tv2Icon:fj,TvIcon:Fee,TvMinimal:fj,TvMinimalIcon:fj,TvMinimalPlay:Ree,TvMinimalPlayIcon:Ree,Twitch:zee,TwitchIcon:zee,Twitter:Bee,TwitterIcon:Bee,Type:Uee,TypeIcon:Uee,TypeOutline:$ee,TypeOutlineIcon:$ee,Umbrella:qee,UmbrellaIcon:qee,UmbrellaOff:Vee,UmbrellaOffIcon:Vee,Underline:Hee,UnderlineIcon:Hee,Undo:z4,Undo2:Wee,Undo2Icon:Wee,UndoDot:Gee,UndoDotIcon:Gee,UndoIcon:z4,UnfoldHorizontal:Kee,UnfoldHorizontalIcon:Kee,UnfoldVertical:Zee,UnfoldVerticalIcon:Zee,Ungroup:Yee,UngroupIcon:Yee,University:pj,UniversityIcon:pj,Unlink:BE,Unlink2:Xee,Unlink2Icon:Xee,UnlinkIcon:BE,Unlock:qw,UnlockIcon:qw,UnlockKeyhole:Vw,UnlockKeyholeIcon:Vw,Unplug:Qee,UnplugIcon:Qee,Upload:Xi,UploadCloud:xw,UploadCloudIcon:xw,UploadIcon:Xi,Usb:Jee,UsbIcon:Jee,User:Fl,User2:bj,User2Icon:bj,UserCheck:Ak,UserCheck2:gj,UserCheck2Icon:gj,UserCheckIcon:Ak,UserCircle:mw,UserCircle2:hw,UserCircle2Icon:hw,UserCircleIcon:mw,UserCog:$E,UserCog2:xj,UserCog2Icon:xj,UserCogIcon:$E,UserIcon:Fl,UserMinus:UE,UserMinus2:yj,UserMinus2Icon:yj,UserMinusIcon:UE,UserPen:ete,UserPenIcon:ete,UserPlus:Kd,UserPlus2:vj,UserPlus2Icon:vj,UserPlusIcon:Kd,UserRound:bj,UserRoundCheck:gj,UserRoundCheckIcon:gj,UserRoundCog:xj,UserRoundCogIcon:xj,UserRoundIcon:bj,UserRoundMinus:yj,UserRoundMinusIcon:yj,UserRoundPen:tte,UserRoundPenIcon:tte,UserRoundPlus:vj,UserRoundPlusIcon:vj,UserRoundSearch:rte,UserRoundSearchIcon:rte,UserRoundX:_j,UserRoundXIcon:_j,UserSearch:ste,UserSearchIcon:ste,UserSquare:lj,UserSquare2:oj,UserSquare2Icon:oj,UserSquareIcon:lj,UserX:nte,UserX2:_j,UserX2Icon:_j,UserXIcon:nte,Users:ws,Users2:wj,Users2Icon:wj,UsersIcon:ws,UsersRound:wj,UsersRoundIcon:wj,Utensils:kj,UtensilsCrossed:jj,UtensilsCrossedIcon:jj,UtensilsIcon:kj,UtilityPole:ate,UtilityPoleIcon:ate,Variable:VE,VariableIcon:VE,Vault:ite,VaultIcon:ite,Vegan:ote,VeganIcon:ote,VenetianMask:lte,VenetianMaskIcon:lte,Verified:Nb,VerifiedIcon:Nb,Vibrate:dte,VibrateIcon:dte,VibrateOff:cte,VibrateOffIcon:cte,Video:ma,VideoIcon:ma,VideoOff:ute,VideoOffIcon:ute,Videotape:hte,VideotapeIcon:hte,View:mte,ViewIcon:mte,Voicemail:fte,VoicemailIcon:fte,Volleyball:pte,VolleyballIcon:pte,Volume:_te,Volume1:gte,Volume1Icon:gte,Volume2:xte,Volume2Icon:xte,VolumeIcon:_te,VolumeOff:yte,VolumeOffIcon:yte,VolumeX:vte,VolumeXIcon:vte,Vote:bte,VoteIcon:bte,Wallet:jte,Wallet2:Nj,Wallet2Icon:Nj,WalletCards:wte,WalletCardsIcon:wte,WalletIcon:jte,WalletMinimal:Nj,WalletMinimalIcon:Nj,Wallpaper:kte,WallpaperIcon:kte,Wand:Nte,Wand2:Sj,Wand2Icon:Sj,WandIcon:Nte,WandSparkles:Sj,WandSparklesIcon:Sj,Warehouse:Ste,WarehouseIcon:Ste,WashingMachine:Cte,WashingMachineIcon:Cte,Watch:Mte,WatchIcon:Mte,Waves:Tte,WavesIcon:Tte,Waypoints:Ate,WaypointsIcon:Ate,Webcam:Ete,WebcamIcon:Ete,Webhook:Pte,WebhookIcon:Pte,WebhookOff:Ite,WebhookOffIcon:Ite,Weight:Lte,WeightIcon:Lte,Wheat:Ote,WheatIcon:Ote,WheatOff:Dte,WheatOffIcon:Dte,WholeWord:Rte,WholeWordIcon:Rte,Wifi:Ute,WifiHigh:Fte,WifiHighIcon:Fte,WifiIcon:Ute,WifiLow:zte,WifiLowIcon:zte,WifiOff:Bte,WifiOffIcon:Bte,WifiZero:$te,WifiZeroIcon:$te,Wind:qte,WindArrowDown:Vte,WindArrowDownIcon:Vte,WindIcon:qte,Wine:Wte,WineIcon:Wte,WineOff:Hte,WineOffIcon:Hte,Workflow:Gte,WorkflowIcon:Gte,Worm:Kte,WormIcon:Kte,WrapText:Zte,WrapTextIcon:Zte,Wrench:Hy,WrenchIcon:Hy,X:Xs,XCircle:Fc,XCircleIcon:Fc,XIcon:Xs,XOctagon:Zw,XOctagonIcon:Zw,XSquare:cj,XSquareIcon:cj,Youtube:Yte,YoutubeIcon:Yte,Zap:gx,ZapIcon:gx,ZapOff:Xte,ZapOffIcon:Xte,ZoomIn:B4,ZoomInIcon:B4,ZoomOut:$4,ZoomOutIcon:$4,createLucideIcon:H,icons:Lnt},Symbol.toStringTag,{value:"Module"})),E0e="-",Dnt=e=>{const t=Rnt(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:l=>{const i=l.split(E0e);return i[0]===""&&i.length!==1&&i.shift(),oOe(i,t)||Ont(l)},getConflictingClassGroupIds:(l,i)=>{const d=s[l]||[];return i&&n[l]?[...d,...n[l]]:d}}},oOe=(e,t)=>{var l;if(e.length===0)return t.classGroupId;const s=e[0],n=t.nextPart.get(s),a=n?oOe(e.slice(1),n):void 0;if(a)return a;if(t.validators.length===0)return;const o=e.join(E0e);return(l=t.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},ISe=/^\[(.+)\]$/,Ont=e=>{if(ISe.test(e)){const t=ISe.exec(e)[1],s=t==null?void 0:t.substring(0,t.indexOf(":"));if(s)return"arbitrary.."+s}},Rnt=e=>{const{theme:t,prefix:s}=e,n={nextPart:new Map,validators:[]};return znt(Object.entries(e.classGroups),s).forEach(([o,l])=>{yfe(l,n,o,t)}),n},yfe=(e,t,s,n)=>{e.forEach(a=>{if(typeof a=="string"){const o=a===""?t:PSe(t,a);o.classGroupId=s;return}if(typeof a=="function"){if(Fnt(a)){yfe(a(n),t,s,n);return}t.validators.push({validator:a,classGroupId:s});return}Object.entries(a).forEach(([o,l])=>{yfe(l,PSe(t,o),s,n)})})},PSe=(e,t)=>{let s=e;return t.split(E0e).forEach(n=>{s.nextPart.has(n)||s.nextPart.set(n,{nextPart:new Map,validators:[]}),s=s.nextPart.get(n)}),s},Fnt=e=>e.isThemeGetter,znt=(e,t)=>t?e.map(([s,n])=>{const a=n.map(o=>typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([l,i])=>[t+l,i])):o);return[s,a]}):e,Bnt=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=new Map,n=new Map;const a=(o,l)=>{s.set(o,l),t++,t>e&&(t=0,n=s,s=new Map)};return{get(o){let l=s.get(o);if(l!==void 0)return l;if((l=n.get(o))!==void 0)return a(o,l),l},set(o,l){s.has(o)?s.set(o,l):a(o,l)}}},lOe="!",$nt=e=>{const{separator:t,experimentalParseClassName:s}=e,n=t.length===1,a=t[0],o=t.length,l=i=>{const d=[];let m=0,p=0,g;for(let S=0;Sp?g-p:void 0;return{modifiers:d,hasImportantModifier:_,baseClassName:k,maybePostfixModifierPosition:w}};return s?i=>s({className:i,parseClassName:l}):l},Unt=e=>{if(e.length<=1)return e;const t=[];let s=[];return e.forEach(n=>{n[0]==="["?(t.push(...s.sort(),n),s=[]):s.push(n)}),t.push(...s.sort()),t},Vnt=e=>({cache:Bnt(e.cacheSize),parseClassName:$nt(e),...Dnt(e)}),qnt=/\s+/,Hnt=(e,t)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:a}=t,o=[],l=e.trim().split(qnt);let i="";for(let d=l.length-1;d>=0;d-=1){const m=l[d],{modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:_}=s(m);let k=!!_,w=n(k?v.substring(0,_):v);if(!w){if(!k){i=m+(i.length>0?" "+i:i);continue}if(w=n(v),!w){i=m+(i.length>0?" "+i:i);continue}k=!1}const S=Unt(p).join(":"),T=g?S+lOe:S,C=T+w;if(o.includes(C))continue;o.push(C);const I=a(w,k);for(let R=0;R0?" "+i:i)}return i};function Wnt(){let e=0,t,s,n="";for(;e{if(typeof e=="string")return e;let t,s="";for(let n=0;ng(p),e());return s=Vnt(m),n=s.cache.get,a=s.cache.set,o=i,i(d)}function i(d){const m=n(d);if(m)return m;const p=Hnt(d,s);return a(d,p),p}return function(){return o(Wnt.apply(null,arguments))}}const vl=e=>{const t=s=>s[e]||[];return t.isThemeGetter=!0,t},dOe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Knt=/^\d+\/\d+$/,Znt=new Set(["px","full","screen"]),Ynt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Xnt=/\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$/,Qnt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Jnt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,eat=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,iy=e=>U4(e)||Znt.has(e)||Knt.test(e),lv=e=>b3(e,"length",lat),U4=e=>!!e&&!Number.isNaN(Number(e)),Qde=e=>b3(e,"number",U4),oA=e=>!!e&&Number.isInteger(Number(e)),tat=e=>e.endsWith("%")&&U4(e.slice(0,-1)),ji=e=>dOe.test(e),cv=e=>Ynt.test(e),rat=new Set(["length","size","percentage"]),sat=e=>b3(e,rat,uOe),nat=e=>b3(e,"position",uOe),aat=new Set(["image","url"]),iat=e=>b3(e,aat,dat),oat=e=>b3(e,"",cat),lA=()=>!0,b3=(e,t,s)=>{const n=dOe.exec(e);return n?n[1]?typeof t=="string"?n[1]===t:t.has(n[1]):s(n[2]):!1},lat=e=>Xnt.test(e)&&!Qnt.test(e),uOe=()=>!1,cat=e=>Jnt.test(e),dat=e=>eat.test(e),uat=()=>{const e=vl("colors"),t=vl("spacing"),s=vl("blur"),n=vl("brightness"),a=vl("borderColor"),o=vl("borderRadius"),l=vl("borderSpacing"),i=vl("borderWidth"),d=vl("contrast"),m=vl("grayscale"),p=vl("hueRotate"),g=vl("invert"),v=vl("gap"),_=vl("gradientColorStops"),k=vl("gradientColorStopPositions"),w=vl("inset"),S=vl("margin"),T=vl("opacity"),C=vl("padding"),I=vl("saturate"),R=vl("scale"),D=vl("sepia"),B=vl("skew"),$=vl("space"),q=vl("translate"),W=()=>["auto","contain","none"],K=()=>["auto","hidden","clip","visible","scroll"],re=()=>["auto",ji,t],ae=()=>[ji,t],oe=()=>["",iy,lv],se=()=>["auto",U4,ji],pe=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],de=()=>["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",ji],Te=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_e=()=>[U4,ji];return{cacheSize:500,separator:":",theme:{colors:[lA],spacing:[iy,lv],blur:["none","",cv,ji],brightness:_e(),borderColor:[e],borderRadius:["none","","full",cv,ji],borderSpacing:ae(),borderWidth:oe(),contrast:_e(),grayscale:ge(),hueRotate:_e(),invert:ge(),gap:ae(),gradientColorStops:[e],gradientColorStopPositions:[tat,lv],inset:re(),margin:re(),opacity:_e(),padding:ae(),saturate:_e(),scale:_e(),sepia:ge(),skew:_e(),space:ae(),translate:ae()},classGroups:{aspect:[{aspect:["auto","square","video",ji]}],container:["container"],columns:[{columns:[cv]}],"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:[...pe(),ji]}],overflow:[{overflow:K()}],"overflow-x":[{"overflow-x":K()}],"overflow-y":[{"overflow-y":K()}],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",oA,ji]}],basis:[{basis:re()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ji]}],grow:[{grow:ge()}],shrink:[{shrink:ge()}],order:[{order:["first","last","none",oA,ji]}],"grid-cols":[{"grid-cols":[lA]}],"col-start-end":[{col:["auto",{span:["full",oA,ji]},ji]}],"col-start":[{"col-start":se()}],"col-end":[{"col-end":se()}],"grid-rows":[{"grid-rows":[lA]}],"row-start-end":[{row:["auto",{span:[oA,ji]},ji]}],"row-start":[{"row-start":se()}],"row-end":[{"row-end":se()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ji]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ji]}],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:[C]}],px:[{px:[C]}],py:[{py:[C]}],ps:[{ps:[C]}],pe:[{pe:[C]}],pt:[{pt:[C]}],pr:[{pr:[C]}],pb:[{pb:[C]}],pl:[{pl:[C]}],m:[{m:[S]}],mx:[{mx:[S]}],my:[{my:[S]}],ms:[{ms:[S]}],me:[{me:[S]}],mt:[{mt:[S]}],mr:[{mr:[S]}],mb:[{mb:[S]}],ml:[{ml:[S]}],"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",ji,t]}],"min-w":[{"min-w":[ji,t,"min","max","fit"]}],"max-w":[{"max-w":[ji,t,"none","full","min","max","fit","prose",{screen:[cv]},cv]}],h:[{h:[ji,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ji,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ji,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ji,t,"auto","min","max","fit"]}],"font-size":[{text:["base",cv,lv]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Qde]}],"font-family":[{font:[lA]}],"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",ji]}],"line-clamp":[{"line-clamp":["none",U4,Qde]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",iy,ji]}],"list-image":[{"list-image":["none",ji]}],"list-style-type":[{list:["none","disc","decimal",ji]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[T]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[T]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",iy,lv]}],"underline-offset":[{"underline-offset":["auto",iy,ji]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:ae()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ji]}],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",ji]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[T]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...pe(),nat]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",sat]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},iat]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"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":[T]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[T]}],"divide-style":[{divide:ie()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[iy,ji]}],"outline-w":[{outline:[iy,lv]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[T]}],"ring-offset-w":[{"ring-offset":[iy,lv]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",cv,oat]}],"shadow-color":[{shadow:[lA]}],opacity:[{opacity:[T]}],"mix-blend":[{"mix-blend":[...de(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":de()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[n]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",cv,ji]}],grayscale:[{grayscale:[m]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[g]}],saturate:[{saturate:[I]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[m]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[T]}],"backdrop-saturate":[{"backdrop-saturate":[I]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"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",ji]}],duration:[{duration:_e()}],ease:[{ease:["linear","in","out","in-out",ji]}],delay:[{delay:_e()}],animate:[{animate:["none","spin","ping","pulse","bounce",ji]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[R]}],"scale-x":[{"scale-x":[R]}],"scale-y":[{"scale-y":[R]}],rotate:[{rotate:[oA,ji]}],"translate-x":[{"translate-x":[q]}],"translate-y":[{"translate-y":[q]}],"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",ji]}],accent:[{accent:["auto",e]}],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",ji]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":ae()}],"scroll-mx":[{"scroll-mx":ae()}],"scroll-my":[{"scroll-my":ae()}],"scroll-ms":[{"scroll-ms":ae()}],"scroll-me":[{"scroll-me":ae()}],"scroll-mt":[{"scroll-mt":ae()}],"scroll-mr":[{"scroll-mr":ae()}],"scroll-mb":[{"scroll-mb":ae()}],"scroll-ml":[{"scroll-ml":ae()}],"scroll-p":[{"scroll-p":ae()}],"scroll-px":[{"scroll-px":ae()}],"scroll-py":[{"scroll-py":ae()}],"scroll-ps":[{"scroll-ps":ae()}],"scroll-pe":[{"scroll-pe":ae()}],"scroll-pt":[{"scroll-pt":ae()}],"scroll-pr":[{"scroll-pr":ae()}],"scroll-pb":[{"scroll-pb":ae()}],"scroll-pl":[{"scroll-pl":ae()}],"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",ji]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[iy,lv,Qde]}],stroke:[{stroke:[e,"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"]}}},hat=Gnt(uat);function Vt(...e){return hat(ki(e))}function du(e,t=!1){return t&&e>=1e6?`$${(e/1e6).toFixed(1)}M`:t&&e>=1e3?`$${(e/1e3).toFixed(0)}K`:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(e)}function LSe(e){const t=new Date(e);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(t)}function Zae(e){return e?e.replace(/<[^>]*>/g,""):""}const mat=Ent,hOe=A.forwardRef(({className:e,...t},s)=>r.jsx(XDe,{ref:s,className:Vt("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]",e),...t}));hOe.displayName=XDe.displayName;const fat=_3("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"}}),mOe=A.forwardRef(({className:e,variant:t,...s},n)=>r.jsx(QDe,{ref:n,className:Vt(fat({variant:t}),e),...s}));mOe.displayName=QDe.displayName;const pat=A.forwardRef(({className:e,...t},s)=>r.jsx(tOe,{ref:s,className:Vt("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",e),...t}));pat.displayName=tOe.displayName;const fOe=A.forwardRef(({className:e,...t},s)=>r.jsx(rOe,{ref:s,className:Vt("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",e),"toast-close":"",...t,children:r.jsx(Xs,{className:"h-4 w-4"})}));fOe.displayName=rOe.displayName;const pOe=A.forwardRef(({className:e,...t},s)=>r.jsx(JDe,{ref:s,className:Vt("text-sm font-semibold",e),...t}));pOe.displayName=JDe.displayName;const gOe=A.forwardRef(({className:e,...t},s)=>r.jsx(eOe,{ref:s,className:Vt("text-sm opacity-90",e),...t}));gOe.displayName=eOe.displayName;function gat(){const{toasts:e}=_i();return r.jsxs(mat,{children:[e.map(function({id:t,title:s,description:n,action:a,...o}){return r.jsxs(mOe,{...o,children:[r.jsxs("div",{className:"grid gap-1",children:[s&&r.jsx(pOe,{children:s}),n&&r.jsx(gOe,{children:n})]}),a,r.jsx(fOe,{})]},t)}),r.jsx(hOe,{})]})}var DSe=["light","dark"],xat="(prefers-color-scheme: dark)",yat=A.createContext(void 0),vat={setTheme:e=>{},themes:[]},_at=()=>{var e;return(e=A.useContext(yat))!=null?e:vat};A.memo(({forcedTheme:e,storageKey:t,attribute:s,enableSystem:n,enableColorScheme:a,defaultTheme:o,value:l,attrs:i,nonce:d})=>{let m=o==="system",p=s==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${i.map(k=>`'${k}'`).join(",")})`};`:`var d=document.documentElement,n='${s}',s='setAttribute';`,g=a?DSe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",v=(k,w=!1,S=!0)=>{let T=l?l[k]:k,C=w?k+"|| ''":`'${T}'`,I="";return a&&S&&!w&&DSe.includes(k)&&(I+=`d.style.colorScheme = '${k}';`),s==="class"?w||T?I+=`c.add(${C})`:I+="null":T&&(I+=`d[s](n,${C})`),I},_=e?`!function(){${p}${v(e)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${m})){var t='${xat}',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)}}${m?"":"else{"+v(o,!1,!1)+"}"}${g}}catch(e){}}()`:`!function(){try{${p}var e=localStorage.getItem('${t}');if(e){${l?`var x=${JSON.stringify(l)};`:""}${v(l?"x[e]":"e",!0)}}else{${v(o,!1,!1)};}${g}}catch(t){}}();`;return A.createElement("script",{nonce:d,dangerouslySetInnerHTML:{__html:_}})});var bat=e=>{switch(e){case"success":return kat;case"info":return Sat;case"warning":return Nat;case"error":return Cat;default:return null}},wat=Array(12).fill(0),jat=({visible:e,className:t})=>lt.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},lt.createElement("div",{className:"sonner-spinner"},wat.map((s,n)=>lt.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),kat=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"})),Nat=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"})),Sat=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"})),Cat=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"})),Mat=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"})),Tat=()=>{let[e,t]=lt.useState(document.hidden);return lt.useEffect(()=>{let s=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",s),()=>window.removeEventListener("visibilitychange",s)},[]),e},vfe=1,Aat=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:s,...n}=e,a=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:vfe++,o=this.toasts.find(i=>i.id===a),l=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),o?this.toasts=this.toasts.map(i=>i.id===a?(this.publish({...i,...e,id:a,title:s}),{...i,...e,id:a,dismissible:l,title:s}):i):this.addToast({title:s,...n,dismissible:l,id:a}),a},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(s=>s({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let s;t.loading!==void 0&&(s=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let n=e instanceof Promise?e:e(),a=s!==void 0,o,l=n.then(async d=>{if(o=["resolve",d],lt.isValidElement(d))a=!1,this.create({id:s,type:"default",message:d});else if(Iat(d)&&!d.ok){a=!1;let m=typeof t.error=="function"?await t.error(`HTTP error! status: ${d.status}`):t.error,p=typeof t.description=="function"?await t.description(`HTTP error! status: ${d.status}`):t.description;this.create({id:s,type:"error",message:m,description:p})}else if(t.success!==void 0){a=!1;let m=typeof t.success=="function"?await t.success(d):t.success,p=typeof t.description=="function"?await t.description(d):t.description;this.create({id:s,type:"success",message:m,description:p})}}).catch(async d=>{if(o=["reject",d],t.error!==void 0){a=!1;let m=typeof t.error=="function"?await t.error(d):t.error,p=typeof t.description=="function"?await t.description(d):t.description;this.create({id:s,type:"error",message:m,description:p})}}).finally(()=>{var d;a&&(this.dismiss(s),s=void 0),(d=t.finally)==null||d.call(t)}),i=()=>new Promise((d,m)=>l.then(()=>o[0]==="reject"?m(o[1]):d(o[1])).catch(m));return typeof s!="string"&&typeof s!="number"?{unwrap:i}:Object.assign(s,{unwrap:i})},this.custom=(e,t)=>{let s=(t==null?void 0:t.id)||vfe++;return this.create({jsx:e(s),id:s,...t}),s},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Bh=new Aat,Eat=(e,t)=>{let s=(t==null?void 0:t.id)||vfe++;return Bh.addToast({title:e,...t,id:s}),s},Iat=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Pat=Eat,Lat=()=>Bh.toasts,Dat=()=>Bh.getActiveToasts(),we=Object.assign(Pat,{success:Bh.success,info:Bh.info,warning:Bh.warning,error:Bh.error,custom:Bh.custom,message:Bh.message,promise:Bh.promise,dismiss:Bh.dismiss,loading:Bh.loading},{getHistory:Lat,getToasts:Dat});function Oat(e,{insertAt:t}={}){if(typeof document>"u")return;let s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t==="top"&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}Oat(`: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(e){return e.label!==void 0}var Rat=3,Fat="32px",zat="16px",OSe=4e3,Bat=356,$at=14,Uat=20,Vat=200;function Cp(...e){return e.filter(Boolean).join(" ")}function qat(e){let[t,s]=e.split("-"),n=[];return t&&n.push(t),s&&n.push(s),n}var Hat=e=>{var t,s,n,a,o,l,i,d,m,p,g;let{invert:v,toast:_,unstyled:k,interacting:w,setHeights:S,visibleToasts:T,heights:C,index:I,toasts:R,expanded:D,removeToast:B,defaultRichColors:$,closeButton:q,style:W,cancelButtonStyle:K,actionButtonStyle:re,className:ae="",descriptionClassName:oe="",duration:se,position:pe,gap:ie,loadingIcon:de,expandByDefault:ce,classNames:ge,icons:Te,closeButtonAriaLabel:_e="Close toast",pauseWhenPageIsHidden:ve}=e,[Me,Ze]=lt.useState(null),[Ae,Le]=lt.useState(null),[Ue,Ve]=lt.useState(!1),[Ie,We]=lt.useState(!1),[wt,Pe]=lt.useState(!1),[st,ue]=lt.useState(!1),[$e,tt]=lt.useState(!1),[rt,je]=lt.useState(0),[it,Se]=lt.useState(0),et=lt.useRef(_.duration||se||OSe),Qe=lt.useRef(null),He=lt.useRef(null),ot=I===0,ut=I+1<=T,ft=_.type,ct=_.dismissible!==!1,Tt=_.className||"",Ot=_.descriptionClassName||"",rr=lt.useMemo(()=>C.findIndex(rn=>rn.toastId===_.id)||0,[C,_.id]),Lr=lt.useMemo(()=>{var rn;return(rn=_.closeButton)!=null?rn:q},[_.closeButton,q]),cr=lt.useMemo(()=>_.duration||se||OSe,[_.duration,se]),Mr=lt.useRef(0),As=lt.useRef(0),Et=lt.useRef(0),Pt=lt.useRef(null),[Sr,fs]=pe.split("-"),Ws=lt.useMemo(()=>C.reduce((rn,Wn,Yn)=>Yn>=rr?rn:rn+Wn.height,0),[C,rr]),tn=Tat(),xi=_.invert||v,La=ft==="loading";As.current=lt.useMemo(()=>rr*ie+Ws,[rr,Ws]),lt.useEffect(()=>{et.current=cr},[cr]),lt.useEffect(()=>{Ve(!0)},[]),lt.useEffect(()=>{let rn=He.current;if(rn){let Wn=rn.getBoundingClientRect().height;return Se(Wn),S(Yn=>[{toastId:_.id,height:Wn,position:_.position},...Yn]),()=>S(Yn=>Yn.filter(Pi=>Pi.toastId!==_.id))}},[S,_.id]),lt.useLayoutEffect(()=>{if(!Ue)return;let rn=He.current,Wn=rn.style.height;rn.style.height="auto";let Yn=rn.getBoundingClientRect().height;rn.style.height=Wn,Se(Yn),S(Pi=>Pi.find(dr=>dr.toastId===_.id)?Pi.map(dr=>dr.toastId===_.id?{...dr,height:Yn}:dr):[{toastId:_.id,height:Yn,position:_.position},...Pi])},[Ue,_.title,_.description,S,_.id]);let un=lt.useCallback(()=>{We(!0),je(As.current),S(rn=>rn.filter(Wn=>Wn.toastId!==_.id)),setTimeout(()=>{B(_)},Vat)},[_,B,S,As]);lt.useEffect(()=>{if(_.promise&&ft==="loading"||_.duration===1/0||_.type==="loading")return;let rn;return D||w||ve&&tn?(()=>{if(Et.current{var Wn;(Wn=_.onAutoClose)==null||Wn.call(_,_),un()},et.current)),()=>clearTimeout(rn)},[D,w,_,ft,ve,tn,un]),lt.useEffect(()=>{_.delete&&un()},[un,_.delete]);function ia(){var rn,Wn,Yn;return Te!=null&&Te.loading?lt.createElement("div",{className:Cp(ge==null?void 0:ge.loader,(rn=_==null?void 0:_.classNames)==null?void 0:rn.loader,"sonner-loader"),"data-visible":ft==="loading"},Te.loading):de?lt.createElement("div",{className:Cp(ge==null?void 0:ge.loader,(Wn=_==null?void 0:_.classNames)==null?void 0:Wn.loader,"sonner-loader"),"data-visible":ft==="loading"},de):lt.createElement(jat,{className:Cp(ge==null?void 0:ge.loader,(Yn=_==null?void 0:_.classNames)==null?void 0:Yn.loader),visible:ft==="loading"})}return lt.createElement("li",{tabIndex:0,ref:He,className:Cp(ae,Tt,ge==null?void 0:ge.toast,(t=_==null?void 0:_.classNames)==null?void 0:t.toast,ge==null?void 0:ge.default,ge==null?void 0:ge[ft],(s=_==null?void 0:_.classNames)==null?void 0:s[ft]),"data-sonner-toast":"","data-rich-colors":(n=_.richColors)!=null?n:$,"data-styled":!(_.jsx||_.unstyled||k),"data-mounted":Ue,"data-promise":!!_.promise,"data-swiped":$e,"data-removed":Ie,"data-visible":ut,"data-y-position":Sr,"data-x-position":fs,"data-index":I,"data-front":ot,"data-swiping":wt,"data-dismissible":ct,"data-type":ft,"data-invert":xi,"data-swipe-out":st,"data-swipe-direction":Ae,"data-expanded":!!(D||ce&&Ue),style:{"--index":I,"--toasts-before":I,"--z-index":R.length-I,"--offset":`${Ie?rt:As.current}px`,"--initial-height":ce?"auto":`${it}px`,...W,..._.style},onDragEnd:()=>{Pe(!1),Ze(null),Pt.current=null},onPointerDown:rn=>{La||!ct||(Qe.current=new Date,je(As.current),rn.target.setPointerCapture(rn.pointerId),rn.target.tagName!=="BUTTON"&&(Pe(!0),Pt.current={x:rn.clientX,y:rn.clientY}))},onPointerUp:()=>{var rn,Wn,Yn,Pi;if(st||!ct)return;Pt.current=null;let dr=Number(((rn=He.current)==null?void 0:rn.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),$a=Number(((Wn=He.current)==null?void 0:Wn.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),xo=new Date().getTime()-((Yn=Qe.current)==null?void 0:Yn.getTime()),Ei=Me==="x"?dr:$a,Qs=Math.abs(Ei)/xo;if(Math.abs(Ei)>=Uat||Qs>.11){je(As.current),(Pi=_.onDismiss)==null||Pi.call(_,_),Le(Me==="x"?dr>0?"right":"left":$a>0?"down":"up"),un(),ue(!0),tt(!1);return}Pe(!1),Ze(null)},onPointerMove:rn=>{var Wn,Yn,Pi,dr;if(!Pt.current||!ct||((Wn=window.getSelection())==null?void 0:Wn.toString().length)>0)return;let $a=rn.clientY-Pt.current.y,xo=rn.clientX-Pt.current.x,Ei=(Yn=e.swipeDirections)!=null?Yn:qat(pe);!Me&&(Math.abs(xo)>1||Math.abs($a)>1)&&Ze(Math.abs(xo)>Math.abs($a)?"x":"y");let Qs={x:0,y:0};Me==="y"?(Ei.includes("top")||Ei.includes("bottom"))&&(Ei.includes("top")&&$a<0||Ei.includes("bottom")&&$a>0)&&(Qs.y=$a):Me==="x"&&(Ei.includes("left")||Ei.includes("right"))&&(Ei.includes("left")&&xo<0||Ei.includes("right")&&xo>0)&&(Qs.x=xo),(Math.abs(Qs.x)>0||Math.abs(Qs.y)>0)&&tt(!0),(Pi=He.current)==null||Pi.style.setProperty("--swipe-amount-x",`${Qs.x}px`),(dr=He.current)==null||dr.style.setProperty("--swipe-amount-y",`${Qs.y}px`)}},Lr&&!_.jsx?lt.createElement("button",{"aria-label":_e,"data-disabled":La,"data-close-button":!0,onClick:La||!ct?()=>{}:()=>{var rn;un(),(rn=_.onDismiss)==null||rn.call(_,_)},className:Cp(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:Mat):null,_.jsx||A.isValidElement(_.title)?_.jsx?_.jsx:typeof _.title=="function"?_.title():_.title:lt.createElement(lt.Fragment,null,ft||_.icon||_.promise?lt.createElement("div",{"data-icon":"",className:Cp(ge==null?void 0:ge.icon,(l=_==null?void 0:_.classNames)==null?void 0:l.icon)},_.promise||_.type==="loading"&&!_.icon?_.icon||ia():null,_.type!=="loading"?_.icon||(Te==null?void 0:Te[ft])||bat(ft):null):null,lt.createElement("div",{"data-content":"",className:Cp(ge==null?void 0:ge.content,(i=_==null?void 0:_.classNames)==null?void 0:i.content)},lt.createElement("div",{"data-title":"",className:Cp(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:Cp(oe,Ot,ge==null?void 0:ge.description,(m=_==null?void 0:_.classNames)==null?void 0:m.description)},typeof _.description=="function"?_.description():_.description):null),A.isValidElement(_.cancel)?_.cancel:_.cancel&&mO(_.cancel)?lt.createElement("button",{"data-button":!0,"data-cancel":!0,style:_.cancelButtonStyle||K,onClick:rn=>{var Wn,Yn;mO(_.cancel)&&ct&&((Yn=(Wn=_.cancel).onClick)==null||Yn.call(Wn,rn),un())},className:Cp(ge==null?void 0:ge.cancelButton,(p=_==null?void 0:_.classNames)==null?void 0:p.cancelButton)},_.cancel.label):null,A.isValidElement(_.action)?_.action:_.action&&mO(_.action)?lt.createElement("button",{"data-button":!0,"data-action":!0,style:_.actionButtonStyle||re,onClick:rn=>{var Wn,Yn;mO(_.action)&&((Yn=(Wn=_.action).onClick)==null||Yn.call(Wn,rn),!rn.defaultPrevented&&un())},className:Cp(ge==null?void 0:ge.actionButton,(g=_==null?void 0:_.classNames)==null?void 0:g.actionButton)},_.action.label):null))};function RSe(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Wat(e,t){let s={};return[e,t].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?zat:Fat;function d(m){["top","right","bottom","left"].forEach(p=>{s[`${l}-${p}`]=typeof m=="number"?`${m}px`:m})}typeof n=="number"||typeof n=="string"?d(n):typeof n=="object"?["top","right","bottom","left"].forEach(m=>{n[m]===void 0?s[`${l}-${m}`]=i:s[`${l}-${m}`]=typeof n[m]=="number"?`${n[m]}px`:n[m]}):d(i)}),s}var Gat=A.forwardRef(function(e,t){let{invert:s,position:n="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:l,className:i,offset:d,mobileOffset:m,theme:p="light",richColors:g,duration:v,style:_,visibleToasts:k=Rat,toastOptions:w,dir:S=RSe(),gap:T=$at,loadingIcon:C,icons:I,containerAriaLabel:R="Notifications",pauseWhenPageIsHidden:D}=e,[B,$]=lt.useState([]),q=lt.useMemo(()=>Array.from(new Set([n].concat(B.filter(ve=>ve.position).map(ve=>ve.position)))),[B,n]),[W,K]=lt.useState([]),[re,ae]=lt.useState(!1),[oe,se]=lt.useState(!1),[pe,ie]=lt.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),de=lt.useRef(null),ce=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),ge=lt.useRef(null),Te=lt.useRef(!1),_e=lt.useCallback(ve=>{$(Me=>{var Ze;return(Ze=Me.find(Ae=>Ae.id===ve.id))!=null&&Ze.delete||Bh.dismiss(ve.id),Me.filter(({id:Ae})=>Ae!==ve.id)})},[]);return lt.useEffect(()=>Bh.subscribe(ve=>{if(ve.dismiss){$(Me=>Me.map(Ze=>Ze.id===ve.id?{...Ze,delete:!0}:Ze));return}setTimeout(()=>{N0e.flushSync(()=>{$(Me=>{let Ze=Me.findIndex(Ae=>Ae.id===ve.id);return Ze!==-1?[...Me.slice(0,Ze),{...Me[Ze],...ve},...Me.slice(Ze+1)]:[ve,...Me]})})})}),[]),lt.useEffect(()=>{if(p!=="system"){ie(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?ie("dark"):ie("light")),typeof window>"u")return;let ve=window.matchMedia("(prefers-color-scheme: dark)");try{ve.addEventListener("change",({matches:Me})=>{ie(Me?"dark":"light")})}catch{ve.addListener(({matches:Ze})=>{try{ie(Ze?"dark":"light")}catch(Ae){console.error(Ae)}})}},[p]),lt.useEffect(()=>{B.length<=1&&ae(!1)},[B]),lt.useEffect(()=>{let ve=Me=>{var Ze,Ae;a.every(Le=>Me[Le]||Me.code===Le)&&(ae(!0),(Ze=de.current)==null||Ze.focus()),Me.code==="Escape"&&(document.activeElement===de.current||(Ae=de.current)!=null&&Ae.contains(document.activeElement))&&ae(!1)};return document.addEventListener("keydown",ve),()=>document.removeEventListener("keydown",ve)},[a]),lt.useEffect(()=>{if(de.current)return()=>{ge.current&&(ge.current.focus({preventScroll:!0}),ge.current=null,Te.current=!1)}},[de.current]),lt.createElement("section",{ref:t,"aria-label":`${R} ${ce}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((ve,Me)=>{var Ze;let[Ae,Le]=ve.split("-");return B.length?lt.createElement("ol",{key:ve,dir:S==="auto"?RSe():S,tabIndex:-1,ref:de,className:i,"data-sonner-toaster":!0,"data-theme":pe,"data-y-position":Ae,"data-lifted":re&&B.length>1&&!o,"data-x-position":Le,style:{"--front-toast-height":`${((Ze=W[0])==null?void 0:Ze.height)||0}px`,"--width":`${Bat}px`,"--gap":`${T}px`,..._,...Wat(d,m)},onBlur:Ue=>{Te.current&&!Ue.currentTarget.contains(Ue.relatedTarget)&&(Te.current=!1,ge.current&&(ge.current.focus({preventScroll:!0}),ge.current=null))},onFocus:Ue=>{Ue.target instanceof HTMLElement&&Ue.target.dataset.dismissible==="false"||Te.current||(Te.current=!0,ge.current=Ue.relatedTarget)},onMouseEnter:()=>ae(!0),onMouseMove:()=>ae(!0),onMouseLeave:()=>{oe||ae(!1)},onDragEnd:()=>ae(!1),onPointerDown:Ue=>{Ue.target instanceof HTMLElement&&Ue.target.dataset.dismissible==="false"||se(!0)},onPointerUp:()=>se(!1)},B.filter(Ue=>!Ue.position&&Me===0||Ue.position===ve).map((Ue,Ve)=>{var Ie,We;return lt.createElement(Hat,{key:Ue.id,icons:I,index:Ve,toast:Ue,defaultRichColors:g,duration:(Ie=w==null?void 0:w.duration)!=null?Ie:v,className:w==null?void 0:w.className,descriptionClassName:w==null?void 0:w.descriptionClassName,invert:s,visibleToasts:k,closeButton:(We=w==null?void 0:w.closeButton)!=null?We:l,interacting:oe,position:ve,style:w==null?void 0:w.style,unstyled:w==null?void 0:w.unstyled,classNames:w==null?void 0:w.classNames,cancelButtonStyle:w==null?void 0:w.cancelButtonStyle,actionButtonStyle:w==null?void 0:w.actionButtonStyle,removeToast:_e,toasts:B.filter(wt=>wt.position==Ue.position),heights:W.filter(wt=>wt.position==Ue.position),setHeights:K,expandByDefault:o,gap:T,loadingIcon:C,expanded:re,pauseWhenPageIsHidden:D,swipeDirections:e.swipeDirections})})):null}))});const Kat=({...e})=>{const{theme:t="system"}=_at();return r.jsx(Gat,{theme:t,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"}},...e})};var Zat=Lye[" useId ".trim().toString()]||(()=>{}),Yat=0;function Md(e){const[t,s]=A.useState(Zat());return kc(()=>{s(n=>n??String(Yat++))},[e]),t?`radix-${t}`:""}const Xat=["top","right","bottom","left"],U1=Math.min,Nm=Math.max,Kre=Math.round,fO=Math.floor,xx=e=>({x:e,y:e}),Qat={left:"right",right:"left",bottom:"top",top:"bottom"},Jat={start:"end",end:"start"};function _fe(e,t,s){return Nm(e,U1(t,s))}function r0(e,t){return typeof e=="function"?e(t):e}function s0(e){return e.split("-")[0]}function w3(e){return e.split("-")[1]}function I0e(e){return e==="x"?"y":"x"}function P0e(e){return e==="y"?"height":"width"}const eit=new Set(["top","bottom"]);function rx(e){return eit.has(s0(e))?"y":"x"}function L0e(e){return I0e(rx(e))}function tit(e,t,s){s===void 0&&(s=!1);const n=w3(e),a=L0e(e),o=P0e(a);let l=a==="x"?n===(s?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(l=Zre(l)),[l,Zre(l)]}function rit(e){const t=Zre(e);return[bfe(e),t,bfe(t)]}function bfe(e){return e.replace(/start|end/g,t=>Jat[t])}const FSe=["left","right"],zSe=["right","left"],sit=["top","bottom"],nit=["bottom","top"];function ait(e,t,s){switch(e){case"top":case"bottom":return s?t?zSe:FSe:t?FSe:zSe;case"left":case"right":return t?sit:nit;default:return[]}}function iit(e,t,s,n){const a=w3(e);let o=ait(s0(e),s==="start",n);return a&&(o=o.map(l=>l+"-"+a),t&&(o=o.concat(o.map(bfe)))),o}function Zre(e){return e.replace(/left|right|bottom|top/g,t=>Qat[t])}function oit(e){return{top:0,right:0,bottom:0,left:0,...e}}function xOe(e){return typeof e!="number"?oit(e):{top:e,right:e,bottom:e,left:e}}function Yre(e){const{x:t,y:s,width:n,height:a}=e;return{width:n,height:a,top:s,left:t,right:t+n,bottom:s+a,x:t,y:s}}function BSe(e,t,s){let{reference:n,floating:a}=e;const o=rx(t),l=L0e(t),i=P0e(l),d=s0(t),m=o==="y",p=n.x+n.width/2-a.width/2,g=n.y+n.height/2-a.height/2,v=n[i]/2-a[i]/2;let _;switch(d){case"top":_={x:p,y:n.y-a.height};break;case"bottom":_={x:p,y:n.y+n.height};break;case"right":_={x:n.x+n.width,y:g};break;case"left":_={x:n.x-a.width,y:g};break;default:_={x:n.x,y:n.y}}switch(w3(t)){case"start":_[l]-=v*(s&&m?-1:1);break;case"end":_[l]+=v*(s&&m?-1:1);break}return _}const lit=async(e,t,s)=>{const{placement:n="bottom",strategy:a="absolute",middleware:o=[],platform:l}=s,i=o.filter(Boolean),d=await(l.isRTL==null?void 0:l.isRTL(t));let m=await l.getElementRects({reference:e,floating:t,strategy:a}),{x:p,y:g}=BSe(m,n,d),v=n,_={},k=0;for(let w=0;w({name:"arrow",options:e,async fn(t){const{x:s,y:n,placement:a,rects:o,platform:l,elements:i,middlewareData:d}=t,{element:m,padding:p=0}=r0(e,t)||{};if(m==null)return{};const g=xOe(p),v={x:s,y:n},_=L0e(a),k=P0e(_),w=await l.getDimensions(m),S=_==="y",T=S?"top":"left",C=S?"bottom":"right",I=S?"clientHeight":"clientWidth",R=o.reference[k]+o.reference[_]-v[_]-o.floating[k],D=v[_]-o.reference[_],B=await(l.getOffsetParent==null?void 0:l.getOffsetParent(m));let $=B?B[I]:0;(!$||!await(l.isElement==null?void 0:l.isElement(B)))&&($=i.floating[I]||o.floating[k]);const q=R/2-D/2,W=$/2-w[k]/2-1,K=U1(g[T],W),re=U1(g[C],W),ae=K,oe=$-w[k]-re,se=$/2-w[k]/2+q,pe=_fe(ae,se,oe),ie=!d.arrow&&w3(a)!=null&&se!==pe&&o.reference[k]/2-(sese<=0)){var re,ae;const se=(((re=o.flip)==null?void 0:re.index)||0)+1,pe=$[se];if(pe&&(!(g==="alignment"?C!==rx(pe):!1)||K.every(ce=>ce.overflows[0]>0&&rx(ce.placement)===C)))return{data:{index:se,overflows:K},reset:{placement:pe}};let ie=(ae=K.filter(de=>de.overflows[0]<=0).sort((de,ce)=>de.overflows[1]-ce.overflows[1])[0])==null?void 0:ae.placement;if(!ie)switch(_){case"bestFit":{var oe;const de=(oe=K.filter(ce=>{if(B){const ge=rx(ce.placement);return ge===C||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:oe[0];de&&(ie=de);break}case"initialPlacement":ie=i;break}if(a!==ie)return{reset:{placement:ie}}}return{}}}};function $Se(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function USe(e){return Xat.some(t=>e[t]>=0)}const uit=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:s}=t,{strategy:n="referenceHidden",...a}=r0(e,t);switch(n){case"referenceHidden":{const o=await FI(t,{...a,elementContext:"reference"}),l=$Se(o,s.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:USe(l)}}}case"escaped":{const o=await FI(t,{...a,altBoundary:!0}),l=$Se(o,s.floating);return{data:{escapedOffsets:l,escaped:USe(l)}}}default:return{}}}}},yOe=new Set(["left","top"]);async function hit(e,t){const{placement:s,platform:n,elements:a}=e,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=s0(s),i=w3(s),d=rx(s)==="y",m=yOe.has(l)?-1:1,p=o&&d?-1:1,g=r0(t,e);let{mainAxis:v,crossAxis:_,alignmentAxis:k}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return i&&typeof k=="number"&&(_=i==="end"?k*-1:k),d?{x:_*p,y:v*m}:{x:v*m,y:_*p}}const mit=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var s,n;const{x:a,y:o,placement:l,middlewareData:i}=t,d=await hit(t,e);return l===((s=i.offset)==null?void 0:s.placement)&&(n=i.arrow)!=null&&n.alignmentOffset?{}:{x:a+d.x,y:o+d.y,data:{...d,placement:l}}}}},fit=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:s,y:n,placement:a}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:S=>{let{x:T,y:C}=S;return{x:T,y:C}}},...d}=r0(e,t),m={x:s,y:n},p=await FI(t,d),g=rx(s0(a)),v=I0e(g);let _=m[v],k=m[g];if(o){const S=v==="y"?"top":"left",T=v==="y"?"bottom":"right",C=_+p[S],I=_-p[T];_=_fe(C,_,I)}if(l){const S=g==="y"?"top":"left",T=g==="y"?"bottom":"right",C=k+p[S],I=k-p[T];k=_fe(C,k,I)}const w=i.fn({...t,[v]:_,[g]:k});return{...w,data:{x:w.x-s,y:w.y-n,enabled:{[v]:o,[g]:l}}}}}},pit=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:s,y:n,placement:a,rects:o,middlewareData:l}=t,{offset:i=0,mainAxis:d=!0,crossAxis:m=!0}=r0(e,t),p={x:s,y:n},g=rx(a),v=I0e(g);let _=p[v],k=p[g];const w=r0(i,t),S=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(d){const I=v==="y"?"height":"width",R=o.reference[v]-o.floating[I]+S.mainAxis,D=o.reference[v]+o.reference[I]-S.mainAxis;_D&&(_=D)}if(m){var T,C;const I=v==="y"?"width":"height",R=yOe.has(s0(a)),D=o.reference[g]-o.floating[I]+(R&&((T=l.offset)==null?void 0:T[g])||0)+(R?0:S.crossAxis),B=o.reference[g]+o.reference[I]+(R?0:((C=l.offset)==null?void 0:C[g])||0)-(R?S.crossAxis:0);kB&&(k=B)}return{[v]:_,[g]:k}}}},git=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var s,n;const{placement:a,rects:o,platform:l,elements:i}=t,{apply:d=()=>{},...m}=r0(e,t),p=await FI(t,m),g=s0(a),v=w3(a),_=rx(a)==="y",{width:k,height:w}=o.floating;let S,T;g==="top"||g==="bottom"?(S=g,T=v===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(T=g,S=v==="end"?"top":"bottom");const C=w-p.top-p.bottom,I=k-p.left-p.right,R=U1(w-p[S],C),D=U1(k-p[T],I),B=!t.middlewareData.shift;let $=R,q=D;if((s=t.middlewareData.shift)!=null&&s.enabled.x&&(q=I),(n=t.middlewareData.shift)!=null&&n.enabled.y&&($=C),B&&!v){const K=Nm(p.left,0),re=Nm(p.right,0),ae=Nm(p.top,0),oe=Nm(p.bottom,0);_?q=k-2*(K!==0||re!==0?K+re:Nm(p.left,p.right)):$=w-2*(ae!==0||oe!==0?ae+oe:Nm(p.top,p.bottom))}await d({...t,availableWidth:q,availableHeight:$});const W=await l.getDimensions(i.floating);return k!==W.width||w!==W.height?{reset:{rects:!0}}:{}}}};function Yae(){return typeof window<"u"}function j3(e){return vOe(e)?(e.nodeName||"").toLowerCase():"#document"}function $m(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ex(e){var t;return(t=(vOe(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function vOe(e){return Yae()?e instanceof Node||e instanceof $m(e).Node:!1}function ug(e){return Yae()?e instanceof Element||e instanceof $m(e).Element:!1}function wx(e){return Yae()?e instanceof HTMLElement||e instanceof $m(e).HTMLElement:!1}function VSe(e){return!Yae()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $m(e).ShadowRoot}const xit=new Set(["inline","contents"]);function f6(e){const{overflow:t,overflowX:s,overflowY:n,display:a}=hg(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+s)&&!xit.has(a)}const yit=new Set(["table","td","th"]);function vit(e){return yit.has(j3(e))}const _it=[":popover-open",":modal"];function Xae(e){return _it.some(t=>{try{return e.matches(t)}catch{return!1}})}const bit=["transform","translate","scale","rotate","perspective"],wit=["transform","translate","scale","rotate","perspective","filter"],jit=["paint","layout","strict","content"];function D0e(e){const t=O0e(),s=ug(e)?hg(e):e;return bit.some(n=>s[n]?s[n]!=="none":!1)||(s.containerType?s.containerType!=="normal":!1)||!t&&(s.backdropFilter?s.backdropFilter!=="none":!1)||!t&&(s.filter?s.filter!=="none":!1)||wit.some(n=>(s.willChange||"").includes(n))||jit.some(n=>(s.contain||"").includes(n))}function kit(e){let t=V1(e);for(;wx(t)&&!S5(t);){if(D0e(t))return t;if(Xae(t))return null;t=V1(t)}return null}function O0e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Nit=new Set(["html","body","#document"]);function S5(e){return Nit.has(j3(e))}function hg(e){return $m(e).getComputedStyle(e)}function Qae(e){return ug(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function V1(e){if(j3(e)==="html")return e;const t=e.assignedSlot||e.parentNode||VSe(e)&&e.host||Ex(e);return VSe(t)?t.host:t}function _Oe(e){const t=V1(e);return S5(t)?e.ownerDocument?e.ownerDocument.body:e.body:wx(t)&&f6(t)?t:_Oe(t)}function zI(e,t,s){var n;t===void 0&&(t=[]),s===void 0&&(s=!0);const a=_Oe(e),o=a===((n=e.ownerDocument)==null?void 0:n.body),l=$m(a);if(o){const i=wfe(l);return t.concat(l,l.visualViewport||[],f6(a)?a:[],i&&s?zI(i):[])}return t.concat(a,zI(a,[],s))}function wfe(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bOe(e){const t=hg(e);let s=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const a=wx(e),o=a?e.offsetWidth:s,l=a?e.offsetHeight:n,i=Kre(s)!==o||Kre(n)!==l;return i&&(s=o,n=l),{width:s,height:n,$:i}}function R0e(e){return ug(e)?e:e.contextElement}function V4(e){const t=R0e(e);if(!wx(t))return xx(1);const s=t.getBoundingClientRect(),{width:n,height:a,$:o}=bOe(t);let l=(o?Kre(s.width):s.width)/n,i=(o?Kre(s.height):s.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const Sit=xx(0);function wOe(e){const t=$m(e);return!O0e()||!t.visualViewport?Sit:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Cit(e,t,s){return t===void 0&&(t=!1),!s||t&&s!==$m(e)?!1:t}function Gk(e,t,s,n){t===void 0&&(t=!1),s===void 0&&(s=!1);const a=e.getBoundingClientRect(),o=R0e(e);let l=xx(1);t&&(n?ug(n)&&(l=V4(n)):l=V4(e));const i=Cit(o,s,n)?wOe(o):xx(0);let d=(a.left+i.x)/l.x,m=(a.top+i.y)/l.y,p=a.width/l.x,g=a.height/l.y;if(o){const v=$m(o),_=n&&ug(n)?$m(n):n;let k=v,w=wfe(k);for(;w&&n&&_!==k;){const S=V4(w),T=w.getBoundingClientRect(),C=hg(w),I=T.left+(w.clientLeft+parseFloat(C.paddingLeft))*S.x,R=T.top+(w.clientTop+parseFloat(C.paddingTop))*S.y;d*=S.x,m*=S.y,p*=S.x,g*=S.y,d+=I,m+=R,k=$m(w),w=wfe(k)}}return Yre({width:p,height:g,x:d,y:m})}function F0e(e,t){const s=Qae(e).scrollLeft;return t?t.left+s:Gk(Ex(e)).left+s}function jOe(e,t,s){s===void 0&&(s=!1);const n=e.getBoundingClientRect(),a=n.left+t.scrollLeft-(s?0:F0e(e,n)),o=n.top+t.scrollTop;return{x:a,y:o}}function Mit(e){let{elements:t,rect:s,offsetParent:n,strategy:a}=e;const o=a==="fixed",l=Ex(n),i=t?Xae(t.floating):!1;if(n===l||i&&o)return s;let d={scrollLeft:0,scrollTop:0},m=xx(1);const p=xx(0),g=wx(n);if((g||!g&&!o)&&((j3(n)!=="body"||f6(l))&&(d=Qae(n)),wx(n))){const _=Gk(n);m=V4(n),p.x=_.x+n.clientLeft,p.y=_.y+n.clientTop}const v=l&&!g&&!o?jOe(l,d,!0):xx(0);return{width:s.width*m.x,height:s.height*m.y,x:s.x*m.x-d.scrollLeft*m.x+p.x+v.x,y:s.y*m.y-d.scrollTop*m.y+p.y+v.y}}function Tit(e){return Array.from(e.getClientRects())}function Ait(e){const t=Ex(e),s=Qae(e),n=e.ownerDocument.body,a=Nm(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),o=Nm(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let l=-s.scrollLeft+F0e(e);const i=-s.scrollTop;return hg(n).direction==="rtl"&&(l+=Nm(t.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Eit(e,t){const s=$m(e),n=Ex(e),a=s.visualViewport;let o=n.clientWidth,l=n.clientHeight,i=0,d=0;if(a){o=a.width,l=a.height;const m=O0e();(!m||m&&t==="fixed")&&(i=a.offsetLeft,d=a.offsetTop)}return{width:o,height:l,x:i,y:d}}const Iit=new Set(["absolute","fixed"]);function Pit(e,t){const s=Gk(e,!0,t==="fixed"),n=s.top+e.clientTop,a=s.left+e.clientLeft,o=wx(e)?V4(e):xx(1),l=e.clientWidth*o.x,i=e.clientHeight*o.y,d=a*o.x,m=n*o.y;return{width:l,height:i,x:d,y:m}}function qSe(e,t,s){let n;if(t==="viewport")n=Eit(e,s);else if(t==="document")n=Ait(Ex(e));else if(ug(t))n=Pit(t,s);else{const a=wOe(e);n={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Yre(n)}function kOe(e,t){const s=V1(e);return s===t||!ug(s)||S5(s)?!1:hg(s).position==="fixed"||kOe(s,t)}function Lit(e,t){const s=t.get(e);if(s)return s;let n=zI(e,[],!1).filter(i=>ug(i)&&j3(i)!=="body"),a=null;const o=hg(e).position==="fixed";let l=o?V1(e):e;for(;ug(l)&&!S5(l);){const i=hg(l),d=D0e(l);!d&&i.position==="fixed"&&(a=null),(o?!d&&!a:!d&&i.position==="static"&&!!a&&Iit.has(a.position)||f6(l)&&!d&&kOe(e,l))?n=n.filter(p=>p!==l):a=i,l=V1(l)}return t.set(e,n),n}function Dit(e){let{element:t,boundary:s,rootBoundary:n,strategy:a}=e;const l=[...s==="clippingAncestors"?Xae(t)?[]:Lit(t,this._c):[].concat(s),n],i=l[0],d=l.reduce((m,p)=>{const g=qSe(t,p,a);return m.top=Nm(g.top,m.top),m.right=U1(g.right,m.right),m.bottom=U1(g.bottom,m.bottom),m.left=Nm(g.left,m.left),m},qSe(t,i,a));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Oit(e){const{width:t,height:s}=bOe(e);return{width:t,height:s}}function Rit(e,t,s){const n=wx(t),a=Ex(t),o=s==="fixed",l=Gk(e,!0,o,t);let i={scrollLeft:0,scrollTop:0};const d=xx(0);function m(){d.x=F0e(a)}if(n||!n&&!o)if((j3(t)!=="body"||f6(a))&&(i=Qae(t)),n){const _=Gk(t,!0,o,t);d.x=_.x+t.clientLeft,d.y=_.y+t.clientTop}else a&&m();o&&!n&&a&&m();const p=a&&!n&&!o?jOe(a,i):xx(0),g=l.left+i.scrollLeft-d.x-p.x,v=l.top+i.scrollTop-d.y-p.y;return{x:g,y:v,width:l.width,height:l.height}}function Jde(e){return hg(e).position==="static"}function HSe(e,t){if(!wx(e)||hg(e).position==="fixed")return null;if(t)return t(e);let s=e.offsetParent;return Ex(e)===s&&(s=s.ownerDocument.body),s}function NOe(e,t){const s=$m(e);if(Xae(e))return s;if(!wx(e)){let a=V1(e);for(;a&&!S5(a);){if(ug(a)&&!Jde(a))return a;a=V1(a)}return s}let n=HSe(e,t);for(;n&&vit(n)&&Jde(n);)n=HSe(n,t);return n&&S5(n)&&Jde(n)&&!D0e(n)?s:n||kit(e)||s}const Fit=async function(e){const t=this.getOffsetParent||NOe,s=this.getDimensions,n=await s(e.floating);return{reference:Rit(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function zit(e){return hg(e).direction==="rtl"}const Bit={convertOffsetParentRelativeRectToViewportRelativeRect:Mit,getDocumentElement:Ex,getClippingRect:Dit,getOffsetParent:NOe,getElementRects:Fit,getClientRects:Tit,getDimensions:Oit,getScale:V4,isElement:ug,isRTL:zit};function SOe(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $it(e,t){let s=null,n;const a=Ex(e);function o(){var i;clearTimeout(n),(i=s)==null||i.disconnect(),s=null}function l(i,d){i===void 0&&(i=!1),d===void 0&&(d=1),o();const m=e.getBoundingClientRect(),{left:p,top:g,width:v,height:_}=m;if(i||t(),!v||!_)return;const k=fO(g),w=fO(a.clientWidth-(p+v)),S=fO(a.clientHeight-(g+_)),T=fO(p),I={rootMargin:-k+"px "+-w+"px "+-S+"px "+-T+"px",threshold:Nm(0,U1(1,d))||1};let R=!0;function D(B){const $=B[0].intersectionRatio;if($!==d){if(!R)return l();$?l(!1,$):n=setTimeout(()=>{l(!1,1e-7)},1e3)}$===1&&!SOe(m,e.getBoundingClientRect())&&l(),R=!1}try{s=new IntersectionObserver(D,{...I,root:a.ownerDocument})}catch{s=new IntersectionObserver(D,I)}s.observe(e)}return l(!0),o}function Uit(e,t,s,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,m=R0e(e),p=a||o?[...m?zI(m):[],...zI(t)]:[];p.forEach(T=>{a&&T.addEventListener("scroll",s,{passive:!0}),o&&T.addEventListener("resize",s)});const g=m&&i?$it(m,s):null;let v=-1,_=null;l&&(_=new ResizeObserver(T=>{let[C]=T;C&&C.target===m&&_&&(_.unobserve(t),cancelAnimationFrame(v),v=requestAnimationFrame(()=>{var I;(I=_)==null||I.observe(t)})),s()}),m&&!d&&_.observe(m),_.observe(t));let k,w=d?Gk(e):null;d&&S();function S(){const T=Gk(e);w&&!SOe(w,T)&&s(),w=T,k=requestAnimationFrame(S)}return s(),()=>{var T;p.forEach(C=>{a&&C.removeEventListener("scroll",s),o&&C.removeEventListener("resize",s)}),g==null||g(),(T=_)==null||T.disconnect(),_=null,d&&cancelAnimationFrame(k)}}const Vit=mit,qit=fit,Hit=dit,Wit=git,Git=uit,WSe=cit,Kit=pit,Zit=(e,t,s)=>{const n=new Map,a={platform:Bit,...s},o={...a.platform,_c:n};return lit(e,t,{...a,platform:o})};var Yit=typeof document<"u",Xit=function(){},Qte=Yit?A.useLayoutEffect:Xit;function Xre(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let s,n,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==t.length)return!1;for(n=s;n--!==0;)if(!Xre(e[n],t[n]))return!1;return!0}if(a=Object.keys(e),s=a.length,s!==Object.keys(t).length)return!1;for(n=s;n--!==0;)if(!{}.hasOwnProperty.call(t,a[n]))return!1;for(n=s;n--!==0;){const o=a[n];if(!(o==="_owner"&&e.$$typeof)&&!Xre(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function COe(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function GSe(e,t){const s=COe(e);return Math.round(t*s)/s}function eue(e){const t=A.useRef(e);return Qte(()=>{t.current=e}),t}function Qit(e){e===void 0&&(e={});const{placement:t="bottom",strategy:s="absolute",middleware:n=[],platform:a,elements:{reference:o,floating:l}={},transform:i=!0,whileElementsMounted:d,open:m}=e,[p,g]=A.useState({x:0,y:0,strategy:s,placement:t,middlewareData:{},isPositioned:!1}),[v,_]=A.useState(n);Xre(v,n)||_(n);const[k,w]=A.useState(null),[S,T]=A.useState(null),C=A.useCallback(ce=>{ce!==B.current&&(B.current=ce,w(ce))},[]),I=A.useCallback(ce=>{ce!==$.current&&($.current=ce,T(ce))},[]),R=o||k,D=l||S,B=A.useRef(null),$=A.useRef(null),q=A.useRef(p),W=d!=null,K=eue(d),re=eue(a),ae=eue(m),oe=A.useCallback(()=>{if(!B.current||!$.current)return;const ce={placement:t,strategy:s,middleware:v};re.current&&(ce.platform=re.current),Zit(B.current,$.current,ce).then(ge=>{const Te={...ge,isPositioned:ae.current!==!1};se.current&&!Xre(q.current,Te)&&(q.current=Te,Hh.flushSync(()=>{g(Te)}))})},[v,t,s,re,ae]);Qte(()=>{m===!1&&q.current.isPositioned&&(q.current.isPositioned=!1,g(ce=>({...ce,isPositioned:!1})))},[m]);const se=A.useRef(!1);Qte(()=>(se.current=!0,()=>{se.current=!1}),[]),Qte(()=>{if(R&&(B.current=R),D&&($.current=D),R&&D){if(K.current)return K.current(R,D,oe);oe()}},[R,D,oe,K,W]);const pe=A.useMemo(()=>({reference:B,floating:$,setReference:C,setFloating:I}),[C,I]),ie=A.useMemo(()=>({reference:R,floating:D}),[R,D]),de=A.useMemo(()=>{const ce={position:s,left:0,top:0};if(!ie.floating)return ce;const ge=GSe(ie.floating,p.x),Te=GSe(ie.floating,p.y);return i?{...ce,transform:"translate("+ge+"px, "+Te+"px)",...COe(ie.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:ge,top:Te}},[s,i,ie.floating,p.x,p.y]);return A.useMemo(()=>({...p,update:oe,refs:pe,elements:ie,floatingStyles:de}),[p,oe,pe,ie,de])}const Jit=e=>{function t(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:n,padding:a}=typeof e=="function"?e(s):e;return n&&t(n)?n.current!=null?WSe({element:n.current,padding:a}).fn(s):{}:n?WSe({element:n,padding:a}).fn(s):{}}}},eot=(e,t)=>({...Vit(e),options:[e,t]}),tot=(e,t)=>({...qit(e),options:[e,t]}),rot=(e,t)=>({...Kit(e),options:[e,t]}),sot=(e,t)=>({...Hit(e),options:[e,t]}),not=(e,t)=>({...Wit(e),options:[e,t]}),aot=(e,t)=>({...Git(e),options:[e,t]}),iot=(e,t)=>({...Jit(e),options:[e,t]});var oot="Arrow",MOe=A.forwardRef((e,t)=>{const{children:s,width:n=10,height:a=5,...o}=e;return r.jsx(Hs.svg,{...o,ref:t,width:n,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});MOe.displayName=oot;var lot=MOe;function p6(e){const[t,s]=A.useState(void 0);return kc(()=>{if(e){s({width:e.offsetWidth,height:e.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,m=Array.isArray(d)?d[0]:d;l=m.inlineSize,i=m.blockSize}else l=e.offsetWidth,i=e.offsetHeight;s({width:l,height:i})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else s(void 0)},[e]),t}var z0e="Popper",[TOe,Ix]=Sc(z0e),[cot,AOe]=TOe(z0e),EOe=e=>{const{__scopePopper:t,children:s}=e,[n,a]=A.useState(null);return r.jsx(cot,{scope:t,anchor:n,onAnchorChange:a,children:s})};EOe.displayName=z0e;var IOe="PopperAnchor",POe=A.forwardRef((e,t)=>{const{__scopePopper:s,virtualRef:n,...a}=e,o=AOe(IOe,s),l=A.useRef(null),i=va(t,l);return A.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:r.jsx(Hs.div,{...a,ref:i})});POe.displayName=IOe;var B0e="PopperContent",[dot,uot]=TOe(B0e),LOe=A.forwardRef((e,t)=>{var Ue,Ve,Ie,We,wt,Pe;const{__scopePopper:s,side:n="bottom",sideOffset:a=0,align:o="center",alignOffset:l=0,arrowPadding:i=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:p=0,sticky:g="partial",hideWhenDetached:v=!1,updatePositionStrategy:_="optimized",onPlaced:k,...w}=e,S=AOe(B0e,s),[T,C]=A.useState(null),I=va(t,st=>C(st)),[R,D]=A.useState(null),B=p6(R),$=(B==null?void 0:B.width)??0,q=(B==null?void 0:B.height)??0,W=n+(o!=="center"?"-"+o:""),K=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},re=Array.isArray(m)?m:[m],ae=re.length>0,oe={padding:K,boundary:re.filter(mot),altBoundary:ae},{refs:se,floatingStyles:pe,placement:ie,isPositioned:de,middlewareData:ce}=Qit({strategy:"fixed",placement:W,whileElementsMounted:(...st)=>Uit(...st,{animationFrame:_==="always"}),elements:{reference:S.anchor},middleware:[eot({mainAxis:a+q,alignmentAxis:l}),d&&tot({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?rot():void 0,...oe}),d&&sot({...oe}),not({...oe,apply:({elements:st,rects:ue,availableWidth:$e,availableHeight:tt})=>{const{width:rt,height:je}=ue.reference,it=st.floating.style;it.setProperty("--radix-popper-available-width",`${$e}px`),it.setProperty("--radix-popper-available-height",`${tt}px`),it.setProperty("--radix-popper-anchor-width",`${rt}px`),it.setProperty("--radix-popper-anchor-height",`${je}px`)}}),R&&iot({element:R,padding:i}),fot({arrowWidth:$,arrowHeight:q}),v&&aot({strategy:"referenceHidden",...oe})]}),[ge,Te]=ROe(ie),_e=gc(k);kc(()=>{de&&(_e==null||_e())},[de,_e]);const ve=(Ue=ce.arrow)==null?void 0:Ue.x,Me=(Ve=ce.arrow)==null?void 0:Ve.y,Ze=((Ie=ce.arrow)==null?void 0:Ie.centerOffset)!==0,[Ae,Le]=A.useState();return kc(()=>{T&&Le(window.getComputedStyle(T).zIndex)},[T]),r.jsx("div",{ref:se.setFloating,"data-radix-popper-content-wrapper":"",style:{...pe,transform:de?pe.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ae,"--radix-popper-transform-origin":[(We=ce.transformOrigin)==null?void 0:We.x,(wt=ce.transformOrigin)==null?void 0:wt.y].join(" "),...((Pe=ce.hide)==null?void 0:Pe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(dot,{scope:s,placedSide:ge,onArrowChange:D,arrowX:ve,arrowY:Me,shouldHideArrow:Ze,children:r.jsx(Hs.div,{"data-side":ge,"data-align":Te,...w,ref:I,style:{...w.style,animation:de?void 0:"none"}})})})});LOe.displayName=B0e;var DOe="PopperArrow",hot={top:"bottom",right:"left",bottom:"top",left:"right"},OOe=A.forwardRef(function(t,s){const{__scopePopper:n,...a}=t,o=uot(DOe,n),l=hot[o.placedSide];return r.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:r.jsx(lot,{...a,ref:s,style:{...a.style,display:"block"}})})});OOe.displayName=DOe;function mot(e){return e!==null}var fot=e=>({name:"transformOrigin",options:e,fn(t){var S,T,C;const{placement:s,rects:n,middlewareData:a}=t,l=((S=a.arrow)==null?void 0:S.centerOffset)!==0,i=l?0:e.arrowWidth,d=l?0:e.arrowHeight,[m,p]=ROe(s),g={start:"0%",center:"50%",end:"100%"}[p],v=(((T=a.arrow)==null?void 0:T.x)??0)+i/2,_=(((C=a.arrow)==null?void 0:C.y)??0)+d/2;let k="",w="";return m==="bottom"?(k=l?g:`${v}px`,w=`${-d}px`):m==="top"?(k=l?g:`${v}px`,w=`${n.floating.height+d}px`):m==="right"?(k=`${-d}px`,w=l?g:`${_}px`):m==="left"&&(k=`${n.floating.width+d}px`,w=l?g:`${_}px`),{data:{x:k,y:w}}}});function ROe(e){const[t,s="center"]=e.split("-");return[t,s]}var g6=EOe,k3=POe,x6=LOe,y6=OOe,[Jae]=Sc("Tooltip",[Ix]),eie=Ix(),FOe="TooltipProvider",pot=700,jfe="tooltip.open",[got,$0e]=Jae(FOe),zOe=e=>{const{__scopeTooltip:t,delayDuration:s=pot,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=e,l=A.useRef(!0),i=A.useRef(!1),d=A.useRef(0);return A.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),r.jsx(got,{scope:t,isOpenDelayedRef:l,delayDuration:s,onOpen:A.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:A.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:A.useCallback(m=>{i.current=m},[]),disableHoverableContent:a,children:o})};zOe.displayName=FOe;var BI="Tooltip",[xot,tie]=Jae(BI),BOe=e=>{const{__scopeTooltip:t,children:s,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=e,d=$0e(BI,e.__scopeTooltip),m=eie(t),[p,g]=A.useState(null),v=Md(),_=A.useRef(0),k=l??d.disableHoverableContent,w=i??d.delayDuration,S=A.useRef(!1),[T,C]=bh({prop:n,defaultProp:a??!1,onChange:$=>{$?(d.onOpen(),document.dispatchEvent(new CustomEvent(jfe))):d.onClose(),o==null||o($)},caller:BI}),I=A.useMemo(()=>T?S.current?"delayed-open":"instant-open":"closed",[T]),R=A.useCallback(()=>{window.clearTimeout(_.current),_.current=0,S.current=!1,C(!0)},[C]),D=A.useCallback(()=>{window.clearTimeout(_.current),_.current=0,C(!1)},[C]),B=A.useCallback(()=>{window.clearTimeout(_.current),_.current=window.setTimeout(()=>{S.current=!0,C(!0),_.current=0},w)},[w,C]);return A.useEffect(()=>()=>{_.current&&(window.clearTimeout(_.current),_.current=0)},[]),r.jsx(g6,{...m,children:r.jsx(xot,{scope:t,contentId:v,open:T,stateAttribute:I,trigger:p,onTriggerChange:g,onTriggerEnter:A.useCallback(()=>{d.isOpenDelayedRef.current?B():R()},[d.isOpenDelayedRef,B,R]),onTriggerLeave:A.useCallback(()=>{k?D():(window.clearTimeout(_.current),_.current=0)},[D,k]),onOpen:R,onClose:D,disableHoverableContent:k,children:s})})};BOe.displayName=BI;var kfe="TooltipTrigger",$Oe=A.forwardRef((e,t)=>{const{__scopeTooltip:s,...n}=e,a=tie(kfe,s),o=$0e(kfe,s),l=eie(s),i=A.useRef(null),d=va(t,i,a.onTriggerChange),m=A.useRef(!1),p=A.useRef(!1),g=A.useCallback(()=>m.current=!1,[]);return A.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),r.jsx(k3,{asChild:!0,...l,children:r.jsx(Hs.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:d,onPointerMove:bs(e.onPointerMove,v=>{v.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:bs(e.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:bs(e.onPointerDown,()=>{a.open&&a.onClose(),m.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:bs(e.onFocus,()=>{m.current||a.onOpen()}),onBlur:bs(e.onBlur,a.onClose),onClick:bs(e.onClick,a.onClose)})})});$Oe.displayName=kfe;var yot="TooltipPortal",[qmr,vot]=Jae(yot,{forceMount:void 0}),C5="TooltipContent",UOe=A.forwardRef((e,t)=>{const s=vot(C5,e.__scopeTooltip),{forceMount:n=s.forceMount,side:a="top",...o}=e,l=tie(C5,e.__scopeTooltip);return r.jsx(Wc,{present:n||l.open,children:l.disableHoverableContent?r.jsx(VOe,{side:a,...o,ref:t}):r.jsx(_ot,{side:a,...o,ref:t})})}),_ot=A.forwardRef((e,t)=>{const s=tie(C5,e.__scopeTooltip),n=$0e(C5,e.__scopeTooltip),a=A.useRef(null),o=va(t,a),[l,i]=A.useState(null),{trigger:d,onClose:m}=s,p=a.current,{onPointerInTransitChange:g}=n,v=A.useCallback(()=>{i(null),g(!1)},[g]),_=A.useCallback((k,w)=>{const S=k.currentTarget,T={x:k.clientX,y:k.clientY},C=Not(T,S.getBoundingClientRect()),I=Sot(T,C),R=Cot(w.getBoundingClientRect()),D=Tot([...I,...R]);i(D),g(!0)},[g]);return A.useEffect(()=>()=>v(),[v]),A.useEffect(()=>{if(d&&p){const k=S=>_(S,p),w=S=>_(S,d);return d.addEventListener("pointerleave",k),p.addEventListener("pointerleave",w),()=>{d.removeEventListener("pointerleave",k),p.removeEventListener("pointerleave",w)}}},[d,p,_,v]),A.useEffect(()=>{if(l){const k=w=>{const S=w.target,T={x:w.clientX,y:w.clientY},C=(d==null?void 0:d.contains(S))||(p==null?void 0:p.contains(S)),I=!Mot(T,l);C?v():I&&(v(),m())};return document.addEventListener("pointermove",k),()=>document.removeEventListener("pointermove",k)}},[d,p,l,m,v]),r.jsx(VOe,{...e,ref:o})}),[bot,wot]=Jae(BI,{isInside:!1}),jot=PDe("TooltipContent"),VOe=A.forwardRef((e,t)=>{const{__scopeTooltip:s,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=e,d=tie(C5,s),m=eie(s),{onClose:p}=d;return A.useEffect(()=>(document.addEventListener(jfe,p),()=>document.removeEventListener(jfe,p)),[p]),A.useEffect(()=>{if(d.trigger){const g=v=>{const _=v.target;_!=null&&_.contains(d.trigger)&&p()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[d.trigger,p]),r.jsx(J1,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:g=>g.preventDefault(),onDismiss:p,children:r.jsxs(x6,{"data-state":d.stateAttribute,...m,...i,ref:t,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:[r.jsx(jot,{children:n}),r.jsx(bot,{scope:s,isInside:!0,children:r.jsx(mnt,{id:d.contentId,role:"tooltip",children:a||n})})]})})});UOe.displayName=C5;var qOe="TooltipArrow",kot=A.forwardRef((e,t)=>{const{__scopeTooltip:s,...n}=e,a=eie(s);return wot(qOe,s).isInside?null:r.jsx(y6,{...a,...n,ref:t})});kot.displayName=qOe;function Not(e,t){const s=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(s,n,a,o)){case o:return"left";case a:return"right";case s:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function Sot(e,t,s=5){const n=[];switch(t){case"top":n.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":n.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":n.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":n.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return n}function Cot(e){const{top:t,right:s,bottom:n,left:a}=e;return[{x:a,y:t},{x:s,y:t},{x:s,y:n},{x:a,y:n}]}function Mot(e,t){const{x:s,y:n}=e;let a=!1;for(let o=0,l=t.length-1;on!=v>n&&s<(g-m)*(n-p)/(v-p)+m&&(a=!a)}return a}function Tot(e){const t=e.slice();return t.sort((s,n)=>s.xn.x?1:s.yn.y?1:0),Aot(t)}function Aot(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n=2;){const o=t[t.length-1],l=t[t.length-2];if((o.x-l.x)*(a.y-l.y)>=(o.y-l.y)*(a.x-l.x))t.pop();else break}t.push(a)}t.pop();const s=[];for(let n=e.length-1;n>=0;n--){const a=e[n];for(;s.length>=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)}return s.pop(),t.length===1&&s.length===1&&t[0].x===s[0].x&&t[0].y===s[0].y?t:t.concat(s)}var Eot=zOe,Iot=BOe,Pot=$Oe,HOe=UOe;const xN=Eot,Gh=Iot,Kh=Pot,dh=A.forwardRef(({className:e,sideOffset:t=4,...s},n)=>r.jsx(HOe,{ref:n,sideOffset:t,className:Vt("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",e),...s}));dh.displayName=HOe.displayName;var N3=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Kk=typeof window>"u"||"Deno"in globalThis;function oh(){}function Lot(e,t){return typeof e=="function"?e(t):e}function Nfe(e){return typeof e=="number"&&e>=0&&e!==1/0}function WOe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function T1(e,t){return typeof e=="function"?e(t):e}function vf(e,t){return typeof e=="function"?e(t):e}function KSe(e,t){const{type:s="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=e;if(l){if(n){if(t.queryHash!==U0e(l,t.options))return!1}else if(!$I(t.queryKey,l))return!1}if(s!=="all"){const d=t.isActive();if(s==="active"&&!d||s==="inactive"&&d)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||a&&a!==t.state.fetchStatus||o&&!o(t))}function ZSe(e,t){const{exact:s,status:n,predicate:a,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(s){if(Zk(t.options.mutationKey)!==Zk(o))return!1}else if(!$I(t.options.mutationKey,o))return!1}return!(n&&t.state.status!==n||a&&!a(t))}function U0e(e,t){return((t==null?void 0:t.queryKeyHashFn)||Zk)(e)}function Zk(e){return JSON.stringify(e,(t,s)=>Sfe(s)?Object.keys(s).sort().reduce((n,a)=>(n[a]=s[a],n),{}):s)}function $I(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>$I(e[s],t[s])):!1}function GOe(e,t){if(e===t)return e;const s=YSe(e)&&YSe(t);if(s||Sfe(e)&&Sfe(t)){const n=s?e:Object.keys(e),a=n.length,o=s?t:Object.keys(t),l=o.length,i=s?[]:{},d=new Set(n);let m=0;for(let p=0;p{setTimeout(t,e)})}function Cfe(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?GOe(e,t):t}function Oot(e,t,s=0){const n=[...e,t];return s&&n.length>s?n.slice(1):n}function Rot(e,t,s=0){const n=[t,...e];return s&&n.length>s?n.slice(0,-1):n}var V0e=Symbol();function KOe(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===V0e?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ZOe(e,t){return typeof e=="function"?e(...t):!!e}var tk,Uv,o5,l6e,Fot=(l6e=class extends N3{constructor(){super();Sa(this,tk);Sa(this,Uv);Sa(this,o5);Mn(this,o5,t=>{if(!Kk&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){ar(this,Uv)||this.setEventListener(ar(this,o5))}onUnsubscribe(){var t;this.hasListeners()||((t=ar(this,Uv))==null||t.call(this),Mn(this,Uv,void 0))}setEventListener(t){var s;Mn(this,o5,t),(s=ar(this,Uv))==null||s.call(this),Mn(this,Uv,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){ar(this,tk)!==t&&(Mn(this,tk,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof ar(this,tk)=="boolean"?ar(this,tk):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},tk=new WeakMap,Uv=new WeakMap,o5=new WeakMap,l6e),q0e=new Fot,l5,Vv,c5,c6e,zot=(c6e=class extends N3{constructor(){super();Sa(this,l5,!0);Sa(this,Vv);Sa(this,c5);Mn(this,c5,t=>{if(!Kk&&window.addEventListener){const s=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",n)}}})}onSubscribe(){ar(this,Vv)||this.setEventListener(ar(this,c5))}onUnsubscribe(){var t;this.hasListeners()||((t=ar(this,Vv))==null||t.call(this),Mn(this,Vv,void 0))}setEventListener(t){var s;Mn(this,c5,t),(s=ar(this,Vv))==null||s.call(this),Mn(this,Vv,t(this.setOnline.bind(this)))}setOnline(t){ar(this,l5)!==t&&(Mn(this,l5,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return ar(this,l5)}},l5=new WeakMap,Vv=new WeakMap,c5=new WeakMap,c6e),Jre=new zot;function Mfe(){let e,t;const s=new Promise((a,o)=>{e=a,t=o});s.status="pending",s.catch(()=>{});function n(a){Object.assign(s,a),delete s.resolve,delete s.reject}return s.resolve=a=>{n({status:"fulfilled",value:a}),e(a)},s.reject=a=>{n({status:"rejected",reason:a}),t(a)},s}function Bot(e){return Math.min(1e3*2**e,3e4)}function YOe(e){return(e??"online")==="online"?Jre.isOnline():!0}var XOe=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function tue(e){return e instanceof XOe}function QOe(e){let t=!1,s=0,n=!1,a;const o=Mfe(),l=w=>{var S;n||(v(new XOe(w)),(S=e.abort)==null||S.call(e))},i=()=>{t=!0},d=()=>{t=!1},m=()=>q0e.isFocused()&&(e.networkMode==="always"||Jre.isOnline())&&e.canRun(),p=()=>YOe(e.networkMode)&&e.canRun(),g=w=>{var S;n||(n=!0,(S=e.onSuccess)==null||S.call(e,w),a==null||a(),o.resolve(w))},v=w=>{var S;n||(n=!0,(S=e.onError)==null||S.call(e,w),a==null||a(),o.reject(w))},_=()=>new Promise(w=>{var S;a=T=>{(n||m())&&w(T)},(S=e.onPause)==null||S.call(e)}).then(()=>{var w;a=void 0,n||(w=e.onContinue)==null||w.call(e)}),k=()=>{if(n)return;let w;const S=s===0?e.initialPromise:void 0;try{w=S??e.fn()}catch(T){w=Promise.reject(T)}Promise.resolve(w).then(g).catch(T=>{var B;if(n)return;const C=e.retry??(Kk?0:3),I=e.retryDelay??Bot,R=typeof I=="function"?I(s,T):I,D=C===!0||typeof C=="number"&&sm()?void 0:_()).then(()=>{t?v(T):k()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:d,canStart:p,start:()=>(p()?k():_().then(k),o)}}var $ot=e=>setTimeout(e,0);function Uot(){let e=[],t=0,s=i=>{i()},n=i=>{i()},a=$ot;const o=i=>{t?e.push(i):a(()=>{s(i)})},l=()=>{const i=e;e=[],i.length&&a(()=>{n(()=>{i.forEach(d=>{s(d)})})})};return{batch:i=>{let d;t++;try{d=i()}finally{t--,t||l()}return d},batchCalls:i=>(...d)=>{o(()=>{i(...d)})},schedule:o,setNotifyFunction:i=>{s=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{a=i}}}var wd=Uot(),rk,d6e,JOe=(d6e=class{constructor(){Sa(this,rk)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Nfe(this.gcTime)&&Mn(this,rk,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Kk?1/0:5*60*1e3))}clearGcTimeout(){ar(this,rk)&&(clearTimeout(ar(this,rk)),Mn(this,rk,void 0))}},rk=new WeakMap,d6e),d5,sk,yf,nk,Su,s6,ak,Rp,my,u6e,Vot=(u6e=class extends JOe{constructor(t){super();Sa(this,Rp);Sa(this,d5);Sa(this,sk);Sa(this,yf);Sa(this,nk);Sa(this,Su);Sa(this,s6);Sa(this,ak);Mn(this,ak,!1),Mn(this,s6,t.defaultOptions),this.setOptions(t.options),this.observers=[],Mn(this,nk,t.client),Mn(this,yf,ar(this,nk).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Mn(this,d5,qot(this.options)),this.state=t.state??ar(this,d5),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=ar(this,Su))==null?void 0:t.promise}setOptions(t){this.options={...ar(this,s6),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ar(this,yf).remove(this)}setData(t,s){const n=Cfe(this.state.data,t,this.options);return Ci(this,Rp,my).call(this,{data:n,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),n}setState(t,s){Ci(this,Rp,my).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var n,a;const s=(n=ar(this,Su))==null?void 0:n.promise;return(a=ar(this,Su))==null||a.cancel(t),s?s.then(oh).catch(oh):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ar(this,d5))}isActive(){return this.observers.some(t=>vf(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===V0e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>T1(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!WOe(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=ar(this,Su))==null||s.continue()}onOnline(){var s;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=ar(this,Su))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),ar(this,yf).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(ar(this,Su)&&(ar(this,ak)?ar(this,Su).cancel({revert:!0}):ar(this,Su).cancelRetry()),this.scheduleGc()),ar(this,yf).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ci(this,Rp,my).call(this,{type:"invalidate"})}fetch(t,s){var m,p,g;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(ar(this,Su))return ar(this,Su).continueRetry(),ar(this,Su).promise}if(t&&this.setOptions(t),!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:()=>(Mn(this,ak,!0),n.signal)})},o=()=>{const v=KOe(this.options,s),k=(()=>{const w={client:ar(this,nk),queryKey:this.queryKey,meta:this.meta};return a(w),w})();return Mn(this,ak,!1),this.options.persister?this.options.persister(v,k,this):v(k)},i=(()=>{const v={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:ar(this,nk),state:this.state,fetchFn:o};return a(v),v})();(m=this.options.behavior)==null||m.onFetch(i,this),Mn(this,sk,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Ci(this,Rp,my).call(this,{type:"fetch",meta:(g=i.fetchOptions)==null?void 0:g.meta});const d=v=>{var _,k,w,S;tue(v)&&v.silent||Ci(this,Rp,my).call(this,{type:"error",error:v}),tue(v)||((k=(_=ar(this,yf).config).onError)==null||k.call(_,v,this),(S=(w=ar(this,yf).config).onSettled)==null||S.call(w,this.state.data,v,this)),this.scheduleGc()};return Mn(this,Su,QOe({initialPromise:s==null?void 0:s.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:v=>{var _,k,w,S;if(v===void 0){d(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(v)}catch(T){d(T);return}(k=(_=ar(this,yf).config).onSuccess)==null||k.call(_,v,this),(S=(w=ar(this,yf).config).onSettled)==null||S.call(w,v,this.state.error,this),this.scheduleGc()},onError:d,onFail:(v,_)=>{Ci(this,Rp,my).call(this,{type:"failed",failureCount:v,error:_})},onPause:()=>{Ci(this,Rp,my).call(this,{type:"pause"})},onContinue:()=>{Ci(this,Rp,my).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),ar(this,Su).start()}},d5=new WeakMap,sk=new WeakMap,yf=new WeakMap,nk=new WeakMap,Su=new WeakMap,s6=new WeakMap,ak=new WeakMap,Rp=new WeakSet,my=function(t){const s=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...e8e(n.data,this.options),fetchMeta:t.meta??null};case"success":return Mn(this,sk,void 0),{...n,data:t.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=t.error;return tue(a)&&a.revert&&ar(this,sk)?{...ar(this,sk),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,...t.state}}};this.state=s(this.state),wd.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ar(this,yf).notify({query:this,type:"updated",action:t})})},u6e);function e8e(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:YOe(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function qot(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,n=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var Zg,h6e,Hot=(h6e=class extends N3{constructor(t={}){super();Sa(this,Zg);this.config=t,Mn(this,Zg,new Map)}build(t,s,n){const a=s.queryKey,o=s.queryHash??U0e(a,s);let l=this.get(o);return l||(l=new Vot({client:t,queryKey:a,queryHash:o,options:t.defaultQueryOptions(s),state:n,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){ar(this,Zg).has(t.queryHash)||(ar(this,Zg).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=ar(this,Zg).get(t.queryHash);s&&(t.destroy(),s===t&&ar(this,Zg).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){wd.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ar(this,Zg).get(t)}getAll(){return[...ar(this,Zg).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(n=>KSe(s,n))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(n=>KSe(t,n)):s}notify(t){wd.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){wd.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){wd.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Zg=new WeakMap,h6e),Yg,nh,ik,Xg,fv,m6e,Wot=(m6e=class extends JOe{constructor(t){super();Sa(this,Xg);Sa(this,Yg);Sa(this,nh);Sa(this,ik);this.mutationId=t.mutationId,Mn(this,nh,t.mutationCache),Mn(this,Yg,[]),this.state=t.state||t8e(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ar(this,Yg).includes(t)||(ar(this,Yg).push(t),this.clearGcTimeout(),ar(this,nh).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Mn(this,Yg,ar(this,Yg).filter(s=>s!==t)),this.scheduleGc(),ar(this,nh).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ar(this,Yg).length||(this.state.status==="pending"?this.scheduleGc():ar(this,nh).remove(this))}continue(){var t;return((t=ar(this,ik))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,l,i,d,m,p,g,v,_,k,w,S,T,C,I,R,D,B,$,q;const s=()=>{Ci(this,Xg,fv).call(this,{type:"continue"})};Mn(this,ik,QOe({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(W,K)=>{Ci(this,Xg,fv).call(this,{type:"failed",failureCount:W,error:K})},onPause:()=>{Ci(this,Xg,fv).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ar(this,nh).canRun(this)}));const n=this.state.status==="pending",a=!ar(this,ik).canStart();try{if(n)s();else{Ci(this,Xg,fv).call(this,{type:"pending",variables:t,isPaused:a}),await((l=(o=ar(this,nh).config).onMutate)==null?void 0:l.call(o,t,this));const K=await((d=(i=this.options).onMutate)==null?void 0:d.call(i,t));K!==this.state.context&&Ci(this,Xg,fv).call(this,{type:"pending",context:K,variables:t,isPaused:a})}const W=await ar(this,ik).start();return await((p=(m=ar(this,nh).config).onSuccess)==null?void 0:p.call(m,W,t,this.state.context,this)),await((v=(g=this.options).onSuccess)==null?void 0:v.call(g,W,t,this.state.context)),await((k=(_=ar(this,nh).config).onSettled)==null?void 0:k.call(_,W,null,this.state.variables,this.state.context,this)),await((S=(w=this.options).onSettled)==null?void 0:S.call(w,W,null,t,this.state.context)),Ci(this,Xg,fv).call(this,{type:"success",data:W}),W}catch(W){try{throw await((C=(T=ar(this,nh).config).onError)==null?void 0:C.call(T,W,t,this.state.context,this)),await((R=(I=this.options).onError)==null?void 0:R.call(I,W,t,this.state.context)),await((B=(D=ar(this,nh).config).onSettled)==null?void 0:B.call(D,void 0,W,this.state.variables,this.state.context,this)),await((q=($=this.options).onSettled)==null?void 0:q.call($,void 0,W,t,this.state.context)),W}finally{Ci(this,Xg,fv).call(this,{type:"error",error:W})}}finally{ar(this,nh).runNext(this)}}},Yg=new WeakMap,nh=new WeakMap,ik=new WeakMap,Xg=new WeakSet,fv=function(t){const s=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),wd.batch(()=>{ar(this,Yg).forEach(n=>{n.onMutationUpdate(t)}),ar(this,nh).notify({mutation:this,type:"updated",action:t})})},m6e);function t8e(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var wy,Fp,n6,f6e,Got=(f6e=class extends N3{constructor(t={}){super();Sa(this,wy);Sa(this,Fp);Sa(this,n6);this.config=t,Mn(this,wy,new Set),Mn(this,Fp,new Map),Mn(this,n6,0)}build(t,s,n){const a=new Wot({mutationCache:this,mutationId:++GD(this,n6)._,options:t.defaultMutationOptions(s),state:n});return this.add(a),a}add(t){ar(this,wy).add(t);const s=pO(t);if(typeof s=="string"){const n=ar(this,Fp).get(s);n?n.push(t):ar(this,Fp).set(s,[t])}this.notify({type:"added",mutation:t})}remove(t){if(ar(this,wy).delete(t)){const s=pO(t);if(typeof s=="string"){const n=ar(this,Fp).get(s);if(n)if(n.length>1){const a=n.indexOf(t);a!==-1&&n.splice(a,1)}else n[0]===t&&ar(this,Fp).delete(s)}}this.notify({type:"removed",mutation:t})}canRun(t){const s=pO(t);if(typeof s=="string"){const n=ar(this,Fp).get(s),a=n==null?void 0:n.find(o=>o.state.status==="pending");return!a||a===t}else return!0}runNext(t){var n;const s=pO(t);if(typeof s=="string"){const a=(n=ar(this,Fp).get(s))==null?void 0:n.find(o=>o!==t&&o.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){wd.batch(()=>{ar(this,wy).forEach(t=>{this.notify({type:"removed",mutation:t})}),ar(this,wy).clear(),ar(this,Fp).clear()})}getAll(){return Array.from(ar(this,wy))}find(t){const s={exact:!0,...t};return this.getAll().find(n=>ZSe(s,n))}findAll(t={}){return this.getAll().filter(s=>ZSe(t,s))}notify(t){wd.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return wd.batch(()=>Promise.all(t.map(s=>s.continue().catch(oh))))}},wy=new WeakMap,Fp=new WeakMap,n6=new WeakMap,f6e);function pO(e){var t;return(t=e.options.scope)==null?void 0:t.id}function ese(e){return{onFetch:(t,s)=>{var p,g,v,_,k;const n=t.options,a=(v=(g=(p=t.fetchOptions)==null?void 0:p.meta)==null?void 0:g.fetchMore)==null?void 0:v.direction,o=((_=t.state.data)==null?void 0:_.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let i={pages:[],pageParams:[]},d=0;const m=async()=>{let w=!1;const S=I=>{Object.defineProperty(I,"signal",{enumerable:!0,get:()=>(t.signal.aborted?w=!0:t.signal.addEventListener("abort",()=>{w=!0}),t.signal)})},T=KOe(t.options,t.fetchOptions),C=async(I,R,D)=>{if(w)return Promise.reject();if(R==null&&I.pages.length)return Promise.resolve(I);const $=(()=>{const re={client:t.client,queryKey:t.queryKey,pageParam:R,direction:D?"backward":"forward",meta:t.options.meta};return S(re),re})(),q=await T($),{maxPages:W}=t.options,K=D?Rot:Oot;return{pages:K(I.pages,q,W),pageParams:K(I.pageParams,R,W)}};if(a&&o.length){const I=a==="backward",R=I?r8e:Tfe,D={pages:o,pageParams:l},B=R(n,D);i=await C(D,B,I)}else{const I=e??o.length;do{const R=d===0?l[0]??n.initialPageParam:Tfe(n,i);if(d>0&&R==null)break;i=await C(i,R),d++}while(d{var w,S;return(S=(w=t.options).persister)==null?void 0:S.call(w,m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=m}}}function Tfe(e,{pages:t,pageParams:s}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,s[n],s):void 0}function r8e(e,{pages:t,pageParams:s}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,s[0],s):void 0}function Kot(e,t){return t?Tfe(e,t)!=null:!1}function Zot(e,t){return!t||!e.getPreviousPageParam?!1:r8e(e,t)!=null}var oc,qv,Hv,u5,h5,Wv,m5,f5,p6e,Yot=(p6e=class{constructor(e={}){Sa(this,oc);Sa(this,qv);Sa(this,Hv);Sa(this,u5);Sa(this,h5);Sa(this,Wv);Sa(this,m5);Sa(this,f5);Mn(this,oc,e.queryCache||new Hot),Mn(this,qv,e.mutationCache||new Got),Mn(this,Hv,e.defaultOptions||{}),Mn(this,u5,new Map),Mn(this,h5,new Map),Mn(this,Wv,0)}mount(){GD(this,Wv)._++,ar(this,Wv)===1&&(Mn(this,m5,q0e.subscribe(async e=>{e&&(await this.resumePausedMutations(),ar(this,oc).onFocus())})),Mn(this,f5,Jre.subscribe(async e=>{e&&(await this.resumePausedMutations(),ar(this,oc).onOnline())})))}unmount(){var e,t;GD(this,Wv)._--,ar(this,Wv)===0&&((e=ar(this,m5))==null||e.call(this),Mn(this,m5,void 0),(t=ar(this,f5))==null||t.call(this),Mn(this,f5,void 0))}isFetching(e){return ar(this,oc).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ar(this,qv).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=ar(this,oc).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=ar(this,oc).build(this,t),n=s.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(T1(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return ar(this,oc).findAll(e).map(({queryKey:t,state:s})=>{const n=s.data;return[t,n]})}setQueryData(e,t,s){const n=this.defaultQueryOptions({queryKey:e}),a=ar(this,oc).get(n.queryHash),o=a==null?void 0:a.state.data,l=Lot(t,o);if(l!==void 0)return ar(this,oc).build(this,n).setData(l,{...s,manual:!0})}setQueriesData(e,t,s){return wd.batch(()=>ar(this,oc).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=ar(this,oc).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=ar(this,oc);wd.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=ar(this,oc);return wd.batch(()=>(s.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},n=wd.batch(()=>ar(this,oc).findAll(e).map(a=>a.cancel(s)));return Promise.all(n).then(oh).catch(oh)}invalidateQueries(e,t={}){return wd.batch(()=>(ar(this,oc).findAll(e).forEach(s=>{s.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},n=wd.batch(()=>ar(this,oc).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,s);return s.throwOnError||(o=o.catch(oh)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(oh)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=ar(this,oc).build(this,t);return s.isStaleByTime(T1(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(oh).catch(oh)}fetchInfiniteQuery(e){return e.behavior=ese(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(oh).catch(oh)}ensureInfiniteQueryData(e){return e.behavior=ese(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Jre.isOnline()?ar(this,qv).resumePausedMutations():Promise.resolve()}getQueryCache(){return ar(this,oc)}getMutationCache(){return ar(this,qv)}getDefaultOptions(){return ar(this,Hv)}setDefaultOptions(e){Mn(this,Hv,e)}setQueryDefaults(e,t){ar(this,u5).set(Zk(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ar(this,u5).values()],s={};return t.forEach(n=>{$I(e,n.queryKey)&&Object.assign(s,n.defaultOptions)}),s}setMutationDefaults(e,t){ar(this,h5).set(Zk(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ar(this,h5).values()],s={};return t.forEach(n=>{$I(e,n.mutationKey)&&Object.assign(s,n.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...ar(this,Hv).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=U0e(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===V0e&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ar(this,Hv).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ar(this,oc).clear(),ar(this,qv).clear()}},oc=new WeakMap,qv=new WeakMap,Hv=new WeakMap,u5=new WeakMap,h5=new WeakMap,Wv=new WeakMap,m5=new WeakMap,f5=new WeakMap,p6e),Rh,lo,a6,ah,ok,p5,Gv,Kv,i6,g5,x5,lk,ck,Zv,y5,Po,$A,Afe,Efe,Ife,Pfe,Lfe,Dfe,Ofe,n8e,g6e,s8e=(g6e=class extends N3{constructor(t,s){super();Sa(this,Po);Sa(this,Rh);Sa(this,lo);Sa(this,a6);Sa(this,ah);Sa(this,ok);Sa(this,p5);Sa(this,Gv);Sa(this,Kv);Sa(this,i6);Sa(this,g5);Sa(this,x5);Sa(this,lk);Sa(this,ck);Sa(this,Zv);Sa(this,y5,new Set);this.options=s,Mn(this,Rh,t),Mn(this,Kv,null),Mn(this,Gv,Mfe()),this.options.experimental_prefetchInRender||ar(this,Gv).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ar(this,lo).addObserver(this),QSe(ar(this,lo),this.options)?Ci(this,Po,$A).call(this):this.updateResult(),Ci(this,Po,Pfe).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Rfe(ar(this,lo),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Rfe(ar(this,lo),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ci(this,Po,Lfe).call(this),Ci(this,Po,Dfe).call(this),ar(this,lo).removeObserver(this)}setOptions(t){const s=this.options,n=ar(this,lo);if(this.options=ar(this,Rh).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof vf(this.options.enabled,ar(this,lo))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ci(this,Po,Ofe).call(this),ar(this,lo).setOptions(this.options),s._defaulted&&!Qre(this.options,s)&&ar(this,Rh).getQueryCache().notify({type:"observerOptionsUpdated",query:ar(this,lo),observer:this});const a=this.hasListeners();a&&JSe(ar(this,lo),n,this.options,s)&&Ci(this,Po,$A).call(this),this.updateResult(),a&&(ar(this,lo)!==n||vf(this.options.enabled,ar(this,lo))!==vf(s.enabled,ar(this,lo))||T1(this.options.staleTime,ar(this,lo))!==T1(s.staleTime,ar(this,lo)))&&Ci(this,Po,Afe).call(this);const o=Ci(this,Po,Efe).call(this);a&&(ar(this,lo)!==n||vf(this.options.enabled,ar(this,lo))!==vf(s.enabled,ar(this,lo))||o!==ar(this,Zv))&&Ci(this,Po,Ife).call(this,o)}getOptimisticResult(t){const s=ar(this,Rh).getQueryCache().build(ar(this,Rh),t),n=this.createResult(s,t);return Qot(this,n)&&(Mn(this,ah,n),Mn(this,p5,this.options),Mn(this,ok,ar(this,lo).state)),n}getCurrentResult(){return ar(this,ah)}trackResult(t,s){return new Proxy(t,{get:(n,a)=>(this.trackProp(a),s==null||s(a),Reflect.get(n,a))})}trackProp(t){ar(this,y5).add(t)}getCurrentQuery(){return ar(this,lo)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=ar(this,Rh).defaultQueryOptions(t),n=ar(this,Rh).getQueryCache().build(ar(this,Rh),s);return n.fetch().then(()=>this.createResult(n,s))}fetch(t){return Ci(this,Po,$A).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ar(this,ah)))}createResult(t,s){var W;const n=ar(this,lo),a=this.options,o=ar(this,ah),l=ar(this,ok),i=ar(this,p5),m=t!==n?t.state:ar(this,a6),{state:p}=t;let g={...p},v=!1,_;if(s._optimisticResults){const K=this.hasListeners(),re=!K&&QSe(t,s),ae=K&&JSe(t,n,s,a);(re||ae)&&(g={...g,...e8e(p.data,t.options)}),s._optimisticResults==="isRestoring"&&(g.fetchStatus="idle")}let{error:k,errorUpdatedAt:w,status:S}=g;_=g.data;let T=!1;if(s.placeholderData!==void 0&&_===void 0&&S==="pending"){let K;o!=null&&o.isPlaceholderData&&s.placeholderData===(i==null?void 0:i.placeholderData)?(K=o.data,T=!0):K=typeof s.placeholderData=="function"?s.placeholderData((W=ar(this,x5))==null?void 0:W.state.data,ar(this,x5)):s.placeholderData,K!==void 0&&(S="success",_=Cfe(o==null?void 0:o.data,K,s),v=!0)}if(s.select&&_!==void 0&&!T)if(o&&_===(l==null?void 0:l.data)&&s.select===ar(this,i6))_=ar(this,g5);else try{Mn(this,i6,s.select),_=s.select(_),_=Cfe(o==null?void 0:o.data,_,s),Mn(this,g5,_),Mn(this,Kv,null)}catch(K){Mn(this,Kv,K)}ar(this,Kv)&&(k=ar(this,Kv),_=ar(this,g5),w=Date.now(),S="error");const C=g.fetchStatus==="fetching",I=S==="pending",R=S==="error",D=I&&C,B=_!==void 0,q={status:S,fetchStatus:g.fetchStatus,isPending:I,isSuccess:S==="success",isError:R,isInitialLoading:D,isLoading:D,data:_,dataUpdatedAt:g.dataUpdatedAt,error:k,errorUpdatedAt:w,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>m.dataUpdateCount||g.errorUpdateCount>m.errorUpdateCount,isFetching:C,isRefetching:C&&!I,isLoadingError:R&&!B,isPaused:g.fetchStatus==="paused",isPlaceholderData:v,isRefetchError:R&&B,isStale:H0e(t,s),refetch:this.refetch,promise:ar(this,Gv),isEnabled:vf(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const K=oe=>{q.status==="error"?oe.reject(q.error):q.data!==void 0&&oe.resolve(q.data)},re=()=>{const oe=Mn(this,Gv,q.promise=Mfe());K(oe)},ae=ar(this,Gv);switch(ae.status){case"pending":t.queryHash===n.queryHash&&K(ae);break;case"fulfilled":(q.status==="error"||q.data!==ae.value)&&re();break;case"rejected":(q.status!=="error"||q.error!==ae.reason)&&re();break}}return q}updateResult(){const t=ar(this,ah),s=this.createResult(ar(this,lo),this.options);if(Mn(this,ok,ar(this,lo).state),Mn(this,p5,this.options),ar(this,ok).data!==void 0&&Mn(this,x5,ar(this,lo)),Qre(s,t))return;Mn(this,ah,s);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!ar(this,y5).size)return!0;const l=new Set(o??ar(this,y5));return this.options.throwOnError&&l.add("error"),Object.keys(ar(this,ah)).some(i=>{const d=i;return ar(this,ah)[d]!==t[d]&&l.has(d)})};Ci(this,Po,n8e).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ci(this,Po,Pfe).call(this)}},Rh=new WeakMap,lo=new WeakMap,a6=new WeakMap,ah=new WeakMap,ok=new WeakMap,p5=new WeakMap,Gv=new WeakMap,Kv=new WeakMap,i6=new WeakMap,g5=new WeakMap,x5=new WeakMap,lk=new WeakMap,ck=new WeakMap,Zv=new WeakMap,y5=new WeakMap,Po=new WeakSet,$A=function(t){Ci(this,Po,Ofe).call(this);let s=ar(this,lo).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(oh)),s},Afe=function(){Ci(this,Po,Lfe).call(this);const t=T1(this.options.staleTime,ar(this,lo));if(Kk||ar(this,ah).isStale||!Nfe(t))return;const n=WOe(ar(this,ah).dataUpdatedAt,t)+1;Mn(this,lk,setTimeout(()=>{ar(this,ah).isStale||this.updateResult()},n))},Efe=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ar(this,lo)):this.options.refetchInterval)??!1},Ife=function(t){Ci(this,Po,Dfe).call(this),Mn(this,Zv,t),!(Kk||vf(this.options.enabled,ar(this,lo))===!1||!Nfe(ar(this,Zv))||ar(this,Zv)===0)&&Mn(this,ck,setInterval(()=>{(this.options.refetchIntervalInBackground||q0e.isFocused())&&Ci(this,Po,$A).call(this)},ar(this,Zv)))},Pfe=function(){Ci(this,Po,Afe).call(this),Ci(this,Po,Ife).call(this,Ci(this,Po,Efe).call(this))},Lfe=function(){ar(this,lk)&&(clearTimeout(ar(this,lk)),Mn(this,lk,void 0))},Dfe=function(){ar(this,ck)&&(clearInterval(ar(this,ck)),Mn(this,ck,void 0))},Ofe=function(){const t=ar(this,Rh).getQueryCache().build(ar(this,Rh),this.options);if(t===ar(this,lo))return;const s=ar(this,lo);Mn(this,lo,t),Mn(this,a6,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},n8e=function(t){wd.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(ar(this,ah))}),ar(this,Rh).getQueryCache().notify({query:ar(this,lo),type:"observerResultsUpdated"})})},g6e);function Xot(e,t){return vf(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function QSe(e,t){return Xot(e,t)||e.state.data!==void 0&&Rfe(e,t,t.refetchOnMount)}function Rfe(e,t,s){if(vf(t.enabled,e)!==!1&&T1(t.staleTime,e)!=="static"){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&H0e(e,t)}return!1}function JSe(e,t,s,n){return(e!==t||vf(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&H0e(e,s)}function H0e(e,t){return vf(t.enabled,e)!==!1&&e.isStaleByTime(T1(t.staleTime,e))}function Qot(e,t){return!Qre(e.getCurrentResult(),t)}var Jot=class extends s8e{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:ese()})}getOptimisticResult(e){return e.behavior=ese(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var k,w;const{state:s}=e,n=super.createResult(e,t),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,d=(w=(k=s.fetchMeta)==null?void 0:k.fetchMore)==null?void 0:w.direction,m=l&&d==="forward",p=a&&d==="forward",g=l&&d==="backward",v=a&&d==="backward";return{...n,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Kot(t,s.data),hasPreviousPage:Zot(t,s.data),isFetchNextPageError:m,isFetchingNextPage:p,isFetchPreviousPageError:g,isFetchingPreviousPage:v,isRefetchError:i&&!m&&!g,isRefetching:o&&!p&&!v}}},Yv,Xv,Fh,jy,Yy,Jte,Ffe,x6e,elt=(x6e=class extends N3{constructor(s,n){super();Sa(this,Yy);Sa(this,Yv);Sa(this,Xv);Sa(this,Fh);Sa(this,jy);Mn(this,Yv,s),this.setOptions(n),this.bindMethods(),Ci(this,Yy,Jte).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(s){var a;const n=this.options;this.options=ar(this,Yv).defaultMutationOptions(s),Qre(this.options,n)||ar(this,Yv).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ar(this,Fh),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Zk(n.mutationKey)!==Zk(this.options.mutationKey)?this.reset():((a=ar(this,Fh))==null?void 0:a.state.status)==="pending"&&ar(this,Fh).setOptions(this.options)}onUnsubscribe(){var s;this.hasListeners()||(s=ar(this,Fh))==null||s.removeObserver(this)}onMutationUpdate(s){Ci(this,Yy,Jte).call(this),Ci(this,Yy,Ffe).call(this,s)}getCurrentResult(){return ar(this,Xv)}reset(){var s;(s=ar(this,Fh))==null||s.removeObserver(this),Mn(this,Fh,void 0),Ci(this,Yy,Jte).call(this),Ci(this,Yy,Ffe).call(this)}mutate(s,n){var a;return Mn(this,jy,n),(a=ar(this,Fh))==null||a.removeObserver(this),Mn(this,Fh,ar(this,Yv).getMutationCache().build(ar(this,Yv),this.options)),ar(this,Fh).addObserver(this),ar(this,Fh).execute(s)}},Yv=new WeakMap,Xv=new WeakMap,Fh=new WeakMap,jy=new WeakMap,Yy=new WeakSet,Jte=function(){var n;const s=((n=ar(this,Fh))==null?void 0:n.state)??t8e();Mn(this,Xv,{...s,isPending:s.status==="pending",isSuccess:s.status==="success",isError:s.status==="error",isIdle:s.status==="idle",mutate:this.mutate,reset:this.reset})},Ffe=function(s){wd.batch(()=>{var n,a,o,l,i,d,m,p;if(ar(this,jy)&&this.hasListeners()){const g=ar(this,Xv).variables,v=ar(this,Xv).context;(s==null?void 0:s.type)==="success"?((a=(n=ar(this,jy)).onSuccess)==null||a.call(n,s.data,g,v),(l=(o=ar(this,jy)).onSettled)==null||l.call(o,s.data,null,g,v)):(s==null?void 0:s.type)==="error"&&((d=(i=ar(this,jy)).onError)==null||d.call(i,s.error,g,v),(p=(m=ar(this,jy)).onSettled)==null||p.call(m,void 0,s.error,g,v))}this.listeners.forEach(g=>{g(ar(this,Xv))})})},x6e),a8e=A.createContext(void 0),Rr=e=>{const t=A.useContext(a8e);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},tlt=({client:e,children:t})=>(A.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),r.jsx(a8e.Provider,{value:e,children:t})),i8e=A.createContext(!1),rlt=()=>A.useContext(i8e);i8e.Provider;function slt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var nlt=A.createContext(slt()),alt=()=>A.useContext(nlt),ilt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},olt=e=>{A.useEffect(()=>{e.clearReset()},[e])},llt=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(a&&e.data===void 0||ZOe(s,[e.error,n])),clt=e=>{if(e.suspense){const t=n=>n==="static"?n:Math.max(n??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...n)=>t(s(...n)):t(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},dlt=(e,t)=>e.isLoading&&e.isFetching&&!t,ult=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,eCe=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function o8e(e,t,s){var g,v,_,k,w;const n=rlt(),a=alt(),o=Rr(),l=o.defaultQueryOptions(e);(v=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||v.call(g,l),l._optimisticResults=n?"isRestoring":"optimistic",clt(l),ilt(l,a),olt(a);const i=!o.getQueryCache().get(l.queryHash),[d]=A.useState(()=>new t(o,l)),m=d.getOptimisticResult(l),p=!n&&e.subscribed!==!1;if(A.useSyncExternalStore(A.useCallback(S=>{const T=p?d.subscribe(wd.batchCalls(S)):oh;return d.updateResult(),T},[d,p]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),A.useEffect(()=>{d.setOptions(l)},[l,d]),ult(l,m))throw eCe(l,d,a);if(llt({result:m,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw m.error;if((k=(_=o.getDefaultOptions().queries)==null?void 0:_._experimental_afterQuery)==null||k.call(_,l,m),l.experimental_prefetchInRender&&!Kk&&dlt(m,n)){const S=i?eCe(l,d,a):(w=o.getQueryCache().get(l.queryHash))==null?void 0:w.promise;S==null||S.catch(oh).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?m:d.trackResult(m)}function Ht(e,t){return o8e(e,s8e)}function Qt(e,t){const s=Rr(),[n]=A.useState(()=>new elt(s,e));A.useEffect(()=>{n.setOptions(e)},[n,e]);const a=A.useSyncExternalStore(A.useCallback(l=>n.subscribe(wd.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=A.useCallback((l,i)=>{n.mutate(l,i).catch(oh)},[n]);if(a.error&&ZOe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function hlt(e,t){return o8e(e,Jot)}/** * @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 UI(){return UI=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function l8e(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function flt(){return Math.random().toString(36).substr(2,8)}function rCe(e,t){return{usr:e.state,key:e.key,idx:t}}function zfe(e,t,s,n){return s===void 0&&(s=null),UI({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?S3(t):t,{state:s,key:t&&t.key||n||flt()})}function tse(e){let{pathname:t="/",search:s="",hash:n=""}=e;return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function S3(e){let t={};if(e){let s=e.indexOf("#");s>=0&&(t.hash=e.substr(s),e=e.substr(0,s));let n=e.indexOf("?");n>=0&&(t.search=e.substr(n),e=e.substr(0,n)),e&&(t.pathname=e)}return t}function plt(e,t,s,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=t1.Pop,d=null,m=p();m==null&&(m=0,l.replaceState(UI({},l.state,{idx:m}),""));function p(){return(l.state||{idx:null}).idx}function g(){i=t1.Pop;let S=p(),T=S==null?null:S-m;m=S,d&&d({action:i,location:w.location,delta:T})}function v(S,T){i=t1.Push;let C=zfe(w.location,S,T);m=p()+1;let I=rCe(C,m),R=w.createHref(C);try{l.pushState(I,"",R)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;a.location.assign(R)}o&&d&&d({action:i,location:w.location,delta:1})}function _(S,T){i=t1.Replace;let C=zfe(w.location,S,T);m=p();let I=rCe(C,m),R=w.createHref(C);l.replaceState(I,"",R),o&&d&&d({action:i,location:w.location,delta:0})}function k(S){let T=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof S=="string"?S:tse(S);return C=C.replace(/ $/,"%20"),Vc(T,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,T)}let w={get action(){return i},get location(){return e(a,l)},listen(S){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(tCe,g),d=S,()=>{a.removeEventListener(tCe,g),d=null}},createHref(S){return t(a,S)},createURL:k,encodeLocation(S){let T=k(S);return{pathname:T.pathname,search:T.search,hash:T.hash}},push:v,replace:_,go(S){return l.go(S)}};return w}var sCe;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(sCe||(sCe={}));function glt(e,t,s){return s===void 0&&(s="/"),xlt(e,t,s)}function xlt(e,t,s,n){let a=typeof t=="string"?S3(t):t,o=W0e(a.pathname||"/",s);if(o==null)return null;let l=c8e(e);ylt(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("/")&&(Vc(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 m=A1([n,d.relativePath]),p=s.concat(d);o.children&&o.children.length>0&&(Vc(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+m+'".')),c8e(o.children,t,p,m)),!(o.path==null&&!o.index)&&t.push({path:m,score:Nlt(m,o.index),routesMeta:p})};return e.forEach((o,l)=>{var i;if(o.path===""||!((i=o.path)!=null&&i.includes("?")))a(o,l);else for(let d of d8e(o.path))a(o,l,d)}),t}function d8e(e){let t=e.split("/");if(t.length===0)return[];let[s,...n]=t,a=s.endsWith("?"),o=s.replace(/\?$/,"");if(n.length===0)return a?[o,""]:[o];let l=d8e(n.join("/")),i=[];return i.push(...l.map(d=>d===""?o:[o,d].join("/"))),a&&i.push(...l),i.map(d=>e.startsWith("/")&&d===""?"/":d)}function ylt(e){e.sort((t,s)=>t.score!==s.score?s.score-t.score:Slt(t.routesMeta.map(n=>n.childrenIndex),s.routesMeta.map(n=>n.childrenIndex)))}const vlt=/^:[\w-]+$/,_lt=3,blt=2,wlt=1,jlt=10,klt=-2,nCe=e=>e==="*";function Nlt(e,t){let s=e.split("/"),n=s.length;return s.some(nCe)&&(n+=klt),t&&(n+=blt),s.filter(a=>!nCe(a)).reduce((a,o)=>a+(vlt.test(o)?_lt:o===""?wlt:jlt),n)}function Slt(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function Clt(e,t,s){let{routesMeta:n}=e,a={},o="/",l=[];for(let i=0;i{let{paramName:v,isOptional:_}=p;if(v==="*"){let w=i[g]||"";l=o.slice(0,o.length-w.length).replace(/(.)\/+$/,"$1")}const k=i[g];return _&&!k?m[v]=void 0:m[v]=(k||"").replace(/%2F/g,"/"),m},{}),pathname:o,pathnameBase:l,pattern:e}}function Tlt(e,t,s){t===void 0&&(t=!1),s===void 0&&(s=!0),l8e(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,i,d)=>(n.push({paramName:i,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function Alt(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return l8e(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function W0e(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let s=t.endsWith("/")?t.length-1:t.length,n=e.charAt(s);return n&&n!=="/"?null:e.slice(s)||"/"}function Elt(e,t){t===void 0&&(t="/");let{pathname:s,search:n="",hash:a=""}=typeof e=="string"?S3(e):e;return{pathname:s?s.startsWith("/")?s:Ilt(s,t):t,search:Dlt(n),hash:Olt(a)}}function Ilt(e,t){let s=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?s.length>1&&s.pop():a!=="."&&s.push(a)}),s.length>1?s.join("/"):"/"}function rue(e,t,s,n){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+s+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Plt(e){return e.filter((t,s)=>s===0||t.route.path&&t.route.path.length>0)}function G0e(e,t){let s=Plt(e);return t?s.map((n,a)=>a===s.length-1?n.pathname:n.pathnameBase):s.map(n=>n.pathnameBase)}function K0e(e,t,s,n){n===void 0&&(n=!1);let a;typeof e=="string"?a=S3(e):(a=UI({},e),Vc(!a.pathname||!a.pathname.includes("?"),rue("?","pathname","search",a)),Vc(!a.pathname||!a.pathname.includes("#"),rue("#","pathname","hash",a)),Vc(!a.search||!a.search.includes("#"),rue("#","search","hash",a)));let o=e===""||a.pathname==="",l=o?"/":a.pathname,i;if(l==null)i=s;else{let g=t.length-1;if(!n&&l.startsWith("..")){let v=l.split("/");for(;v[0]==="..";)v.shift(),g-=1;a.pathname=v.join("/")}i=g>=0?t[g]:"/"}let d=Elt(a,i),m=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&s.endsWith("/");return!d.pathname.endsWith("/")&&(m||p)&&(d.pathname+="/"),d}const A1=e=>e.join("/").replace(/\/\/+/g,"/"),Llt=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Dlt=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Olt=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Rlt(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const u8e=["post","put","patch","delete"];new Set(u8e);const Flt=["get",...u8e];new Set(Flt);/** * 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 VI(){return VI=Object.assign?Object.assign.bind():function(e){for(var t=1;t{i.current=!0}),A.useCallback(function(m,p){if(p===void 0&&(p={}),!i.current)return;if(typeof m=="number"){n.go(m);return}let g=K0e(m,JSON.parse(l),o,p.relative==="path");e==null&&t!=="/"&&(g.pathname=g.pathname==="/"?t:A1([t,g.pathname])),(p.replace?n.replace:n.push)(g,p.state,p)},[t,n,l,o,e])}const Ult=A.createContext(null);function Vlt(e){let t=A.useContext(Px).outlet;return t&&A.createElement(Ult.Provider,{value:e},t)}function Bl(){let{matches:e}=A.useContext(Px),t=e[e.length-1];return t?t.params:{}}function f8e(e,t){let{relative:s}=t===void 0?{}:t,{future:n}=A.useContext(e_),{matches:a}=A.useContext(Px),{pathname:o}=sm(),l=JSON.stringify(G0e(a,n.v7_relativeSplatPath));return A.useMemo(()=>K0e(e,JSON.parse(l),o,s==="path"),[e,l,o,s])}function qlt(e,t){return Hlt(e,t)}function Hlt(e,t,s,n){C3()||Vc(!1);let{navigator:a}=A.useContext(e_),{matches:o}=A.useContext(Px),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let d=l?l.pathnameBase:"/";l&&l.route;let m=sm(),p;if(t){var g;let S=typeof t=="string"?S3(t):t;d==="/"||(g=S.pathname)!=null&&g.startsWith(d)||Vc(!1),p=S}else p=m;let v=p.pathname||"/",_=v;if(d!=="/"){let S=d.replace(/^\//,"").split("/");_="/"+v.replace(/^\//,"").split("/").slice(S.length).join("/")}let k=glt(e,{pathname:_}),w=Ylt(k&&k.map(S=>Object.assign({},S,{params:Object.assign({},i,S.params),pathname:A1([d,a.encodeLocation?a.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:A1([d,a.encodeLocation?a.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),o,s,n);return t&&w?A.createElement(rie.Provider,{value:{location:VI({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:t1.Pop}},w):w}function Wlt(){let e=ect(),t=Rlt(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),s=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return A.createElement(A.Fragment,null,A.createElement("h2",null,"Unexpected Application Error!"),A.createElement("h3",{style:{fontStyle:"italic"}},t),s?A.createElement("pre",{style:a},s):null,null)}const Glt=A.createElement(Wlt,null);class Klt extends A.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){console.error("React Router caught the following error during render",t,s)}render(){return this.state.error!==void 0?A.createElement(Px.Provider,{value:this.props.routeContext},A.createElement(h8e.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Zlt(e){let{routeContext:t,match:s,children:n}=e,a=A.useContext(Z0e);return a&&a.static&&a.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=s.route.id),A.createElement(Px.Provider,{value:t},n)}function Ylt(e,t,s,n){var a;if(t===void 0&&(t=[]),s===void 0&&(s=null),n===void 0&&(n=null),e==null){var o;if(!s)return null;if(s.errors)e=s.matches;else if((o=n)!=null&&o.v7_partialHydration&&t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let l=e,i=(a=s)==null?void 0:a.errors;if(i!=null){let p=l.findIndex(g=>g.route.id&&(i==null?void 0:i[g.route.id])!==void 0);p>=0||Vc(!1),l=l.slice(0,Math.min(l.length,p+1))}let d=!1,m=-1;if(s&&n&&n.v7_partialHydration)for(let p=0;p=0?l=l.slice(0,m+1):l=[l[0]];break}}}return l.reduceRight((p,g,v)=>{let _,k=!1,w=null,S=null;s&&(_=i&&g.route.id?i[g.route.id]:void 0,w=g.route.errorElement||Glt,d&&(m<0&&v===0?(rct("route-fallback"),k=!0,S=null):m===v&&(k=!0,S=g.route.hydrateFallbackElement||null)));let T=t.concat(l.slice(0,v+1)),C=()=>{let I;return _?I=w:k?I=S:g.route.Component?I=A.createElement(g.route.Component,null):g.route.element?I=g.route.element:I=p,A.createElement(Zlt,{match:g,routeContext:{outlet:p,matches:T,isDataRoute:s!=null},children:I})};return s&&(g.route.ErrorBoundary||g.route.errorElement||v===0)?A.createElement(Klt,{location:s.location,revalidation:s.revalidation,component:w,error:_,children:C(),routeContext:{outlet:null,matches:T,isDataRoute:!0}}):C()},null)}var p8e=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(p8e||{}),g8e=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(g8e||{});function Xlt(e){let t=A.useContext(Z0e);return t||Vc(!1),t}function Qlt(e){let t=A.useContext(zlt);return t||Vc(!1),t}function Jlt(e){let t=A.useContext(Px);return t||Vc(!1),t}function x8e(e){let t=Jlt(),s=t.matches[t.matches.length-1];return s.route.id||Vc(!1),s.route.id}function ect(){var e;let t=A.useContext(h8e),s=Qlt(),n=x8e();return t!==void 0?t:(e=s.errors)==null?void 0:e[n]}function tct(){let{router:e}=Xlt(p8e.UseNavigateStable),t=x8e(g8e.UseNavigateStable),s=A.useRef(!1);return m8e(()=>{s.current=!0}),A.useCallback(function(a,o){o===void 0&&(o={}),s.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,VI({fromRouteId:t},o)))},[e,t])}const aCe={};function rct(e,t,s){aCe[e]||(aCe[e]=!0)}function sct(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function sue(e){let{to:t,replace:s,state:n,relative:a}=e;C3()||Vc(!1);let{future:o,static:l}=A.useContext(e_),{matches:i}=A.useContext(Px),{pathname:d}=sm(),m=Ks(),p=K0e(t,G0e(i,o.v7_relativeSplatPath),d,a==="path"),g=JSON.stringify(p);return A.useEffect(()=>m(JSON.parse(g),{replace:s,state:n,relative:a}),[m,g,a,s,n]),null}function nct(e){return Vlt(e.context)}function es(e){Vc(!1)}function act(e){let{basename:t="/",children:s=null,location:n,navigationType:a=t1.Pop,navigator:o,static:l=!1,future:i}=e;C3()&&Vc(!1);let d=t.replace(/^\/*/,"/"),m=A.useMemo(()=>({basename:d,navigator:o,static:l,future:VI({v7_relativeSplatPath:!1},i)}),[d,i,o,l]);typeof n=="string"&&(n=S3(n));let{pathname:p="/",search:g="",hash:v="",state:_=null,key:k="default"}=n,w=A.useMemo(()=>{let S=W0e(p,d);return S==null?null:{location:{pathname:S,search:g,hash:v,state:_,key:k},navigationType:a}},[d,p,g,v,_,k,a]);return w==null?null:A.createElement(e_.Provider,{value:m},A.createElement(rie.Provider,{children:s,value:w}))}function y8e(e){let{children:t,location:s}=e;return qlt(Bfe(t),s)}new Promise(()=>{});function Bfe(e,t){t===void 0&&(t=[]);let s=[];return A.Children.forEach(e,(n,a)=>{if(!A.isValidElement(n))return;let o=[...t,a];if(n.type===A.Fragment){s.push.apply(s,Bfe(n.props.children,o));return}n.type!==es&&Vc(!1),!n.props.index||!n.props.children||Vc(!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=Bfe(n.props.children,o)),s.push(l)}),s}/** * 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 $fe(){return $fe=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(s[a]=e[a]);return s}function oct(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function lct(e,t){return e.button===0&&(!t||t==="_self")&&!oct(e)}function Ufe(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,s)=>{let n=e[s];return t.concat(Array.isArray(n)?n.map(a=>[s,a]):[[s,n]])},[]))}function cct(e,t){let s=Ufe(e);return t&&t.forEach((n,a)=>{s.has(a)||t.getAll(a).forEach(o=>{s.append(a,o)})}),s}const dct=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],uct="6";try{window.__reactRouterVersion=uct}catch{}const hct="startTransition",iCe=Lye[hct];function mct(e){let{basename:t,children:s,future:n,window:a}=e,o=A.useRef();o.current==null&&(o.current=mlt({window:a,v5Compat:!0}));let l=o.current,[i,d]=A.useState({action:l.action,location:l.location}),{v7_startTransition:m}=n||{},p=A.useCallback(g=>{m&&iCe?iCe(()=>d(g)):d(g)},[d,m]);return A.useLayoutEffect(()=>l.listen(p),[l,p]),A.useEffect(()=>sct(n),[n]),A.createElement(act,{basename:t,children:s,location:i.location,navigationType:i.action,navigator:l,future:n})}const fct=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",pct=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,vo=A.forwardRef(function(t,s){let{onClick:n,relative:a,reloadDocument:o,replace:l,state:i,target:d,to:m,preventScrollReset:p,viewTransition:g}=t,v=ict(t,dct),{basename:_}=A.useContext(e_),k,w=!1;if(typeof m=="string"&&pct.test(m)&&(k=m,fct))try{let I=new URL(window.location.href),R=m.startsWith("//")?new URL(I.protocol+m):new URL(m),D=W0e(R.pathname,_);R.origin===I.origin&&D!=null?m=D+R.search+R.hash:w=!0}catch{}let S=Blt(m,{relative:a}),T=gct(m,{replace:l,state:i,target:d,preventScrollReset:p,relative:a,viewTransition:g});function C(I){n&&n(I),I.defaultPrevented||T(I)}return A.createElement("a",$fe({},v,{href:k||S,onClick:w||o?n:C,ref:s,target:d}))});var oCe;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(oCe||(oCe={}));var lCe;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(lCe||(lCe={}));function gct(e,t){let{target:s,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=t===void 0?{}:t,d=Ks(),m=sm(),p=f8e(e,{relative:l});return A.useCallback(g=>{if(lct(g,s)){g.preventDefault();let v=n!==void 0?n:tse(m)===tse(p);d(e,{replace:v,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[m,d,p,n,a,s,e,o,l,i])}function Cc(e){let t=A.useRef(Ufe(e)),s=A.useRef(!1),n=sm(),a=A.useMemo(()=>cct(n.search,s.current?null:t.current),[n.search]),o=Ks(),l=A.useCallback((i,d)=>{const m=Ufe(typeof i=="function"?i(a):i);s.current=!0,o("?"+m,d)},[o,a]);return[a,l]}var xct=typeof Element<"u",yct=typeof Map=="function",vct=typeof Set=="function",_ct=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function ere(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var s,n,a;if(Array.isArray(e)){if(s=e.length,s!=t.length)return!1;for(n=s;n--!==0;)if(!ere(e[n],t[n]))return!1;return!0}var o;if(yct&&e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(o=e.entries();!(n=o.next()).done;)if(!t.has(n.value[0]))return!1;for(o=e.entries();!(n=o.next()).done;)if(!ere(n.value[1],t.get(n.value[0])))return!1;return!0}if(vct&&e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(o=e.entries();!(n=o.next()).done;)if(!t.has(n.value[0]))return!1;return!0}if(_ct&&ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(s=e.length,s!=t.length)return!1;for(n=s;n--!==0;)if(e[n]!==t[n])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&typeof e.valueOf=="function"&&typeof t.valueOf=="function")return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&typeof e.toString=="function"&&typeof t.toString=="function")return e.toString()===t.toString();if(a=Object.keys(e),s=a.length,s!==Object.keys(t).length)return!1;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(t,a[n]))return!1;if(xct&&e instanceof Element)return!1;for(n=s;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&e.$$typeof)&&!ere(e[a[n]],t[a[n]]))return!1;return!0}return e!==e&&t!==t}var bct=function(t,s){try{return ere(t,s)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const wct=ho(bct);var jct=function(e,t,s,n,a,o,l,i){if(!e){var d;if(t===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 m=[s,n,a,o,l,i],p=0;d=new Error(t.replace(/%s/g,function(){return m[p++]})),d.name="Invariant Violation"}throw d.framesToPop=1,d}},kct=jct;const cCe=ho(kct);var Nct=function(t,s,n,a){var o=n?n.call(a,t,s):void 0;if(o!==void 0)return!!o;if(t===s)return!0;if(typeof t!="object"||!t||typeof s!="object"||!s)return!1;var l=Object.keys(t),i=Object.keys(s);if(l.length!==i.length)return!1;for(var d=Object.prototype.hasOwnProperty.bind(s),m=0;m(e.BASE="base",e.BODY="body",e.HEAD="head",e.HTML="html",e.LINK="link",e.META="meta",e.NOSCRIPT="noscript",e.SCRIPT="script",e.STYLE="style",e.TITLE="title",e.FRAGMENT="Symbol(react.fragment)",e))(v8e||{}),nue={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"]}},dCe=Object.values(v8e),Y0e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},Cct=Object.entries(Y0e).reduce((e,[t,s])=>(e[s]=t,e),{}),Zp="data-rh",q4={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},H4=(e,t)=>{for(let s=e.length-1;s>=0;s-=1){const n=e[s];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},Mct=e=>{let t=H4(e,"title");const s=H4(e,q4.TITLE_TEMPLATE);if(Array.isArray(t)&&(t=t.join("")),s&&t)return s.replace(/%s/g,()=>t);const n=H4(e,q4.DEFAULT_TITLE);return t||n||void 0},Tct=e=>H4(e,q4.ON_CHANGE_CLIENT_STATE)||(()=>{}),aue=(e,t)=>t.filter(s=>typeof s[e]<"u").map(s=>s[e]).reduce((s,n)=>({...s,...n}),{}),Act=(e,t)=>t.filter(s=>typeof s.base<"u").map(s=>s.base).reverse().reduce((s,n)=>{if(!s.length){const a=Object.keys(n);for(let o=0;oconsole&&typeof console.warn=="function"&&console.warn(e),cA=(e,t,s)=>{const n={};return s.filter(a=>Array.isArray(a[e])?!0:(typeof a[e]<"u"&&Ect(`Helmet: ${e} should be of type "Array". Instead found type "${typeof a[e]}"`),!1)).map(a=>a[e]).reverse().reduce((a,o)=>{const l={};o.filter(d=>{let m;const p=Object.keys(d);for(let v=0;va.push(d));const i=Object.keys(l);for(let d=0;d{if(Array.isArray(e)&&e.length){for(let s=0;s({baseTag:Act(["href"],e),bodyAttributes:aue("bodyAttributes",e),defer:H4(e,q4.DEFER),encode:H4(e,q4.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:aue("htmlAttributes",e),linkTags:cA("link",["rel","href"],e),metaTags:cA("meta",["name","charset","http-equiv","property","itemprop"],e),noscriptTags:cA("noscript",["innerHTML"],e),onChangeClientState:Tct(e),scriptTags:cA("script",["src","innerHTML"],e),styleTags:cA("style",["cssText"],e),title:Mct(e),titleAttributes:aue("titleAttributes",e),prioritizeSeoTags:Ict(e,q4.PRIORITIZE_SEO_TAGS)}),_8e=e=>Array.isArray(e)?e.join(""):e,Lct=(e,t)=>{const s=Object.keys(e);for(let n=0;nArray.isArray(e)?e.reduce((s,n)=>(Lct(n,t)?s.priority.push(n):s.default.push(n),s),{priority:[],default:[]}):{default:e,priority:[]},uCe=(e,t)=>({...e,[t]:void 0}),Dct=["noscript","script","style"],Vfe=(e,t=!0)=>t===!1?String(e):String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),b8e=e=>Object.keys(e).reduce((t,s)=>{const n=typeof e[s]<"u"?`${s}="${e[s]}"`:`${s}`;return t?`${t} ${n}`:n},""),Oct=(e,t,s,n)=>{const a=b8e(s),o=_8e(t);return a?`<${e} ${Zp}="true" ${a}>${Vfe(o,n)}`:`<${e} ${Zp}="true">${Vfe(o,n)}`},Rct=(e,t,s=!0)=>t.reduce((n,a)=>{const o=a,l=Object.keys(o).filter(m=>!(m==="innerHTML"||m==="cssText")).reduce((m,p)=>{const g=typeof o[p]>"u"?p:`${p}="${Vfe(o[p],s)}"`;return m?`${m} ${g}`:g},""),i=o.innerHTML||o.cssText||"",d=Dct.indexOf(e)===-1;return`${n}<${e} ${Zp}="true" ${l}${d?"/>":`>${i}`}`},""),w8e=(e,t={})=>Object.keys(e).reduce((s,n)=>{const a=Y0e[n];return s[a||n]=e[n],s},t),Fct=(e,t,s)=>{const n={key:t,[Zp]:!0},a=w8e(s,n);return[lt.createElement("title",a,t)]},tre=(e,t)=>t.map((s,n)=>{const a={key:n,[Zp]:!0};return Object.keys(s).forEach(o=>{const i=Y0e[o]||o;if(i==="innerHTML"||i==="cssText"){const d=s.innerHTML||s.cssText;a.dangerouslySetInnerHTML={__html:d}}else a[i]=s[o]}),lt.createElement(e,a)}),xf=(e,t,s=!0)=>{switch(e){case"title":return{toComponent:()=>Fct(e,t.title,t.titleAttributes),toString:()=>Oct(e,t.title,t.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>w8e(t),toString:()=>b8e(t)};default:return{toComponent:()=>tre(e,t),toString:()=>Rct(e,t,s)}}},zct=({metaTags:e,linkTags:t,scriptTags:s,encode:n})=>{const a=iue(e,nue.meta),o=iue(t,nue.link),l=iue(s,nue.script);return{priorityMethods:{toComponent:()=>[...tre("meta",a.priority),...tre("link",o.priority),...tre("script",l.priority)],toString:()=>`${xf("meta",a.priority,n)} ${xf("link",o.priority,n)} ${xf("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},Bct=e=>{const{baseTag:t,bodyAttributes:s,encode:n=!0,htmlAttributes:a,noscriptTags:o,styleTags:l,title:i="",titleAttributes:d,prioritizeSeoTags:m}=e;let{linkTags:p,metaTags:g,scriptTags:v}=e,_={toComponent:()=>{},toString:()=>""};return m&&({priorityMethods:_,linkTags:p,metaTags:g,scriptTags:v}=zct(e)),{priority:_,base:xf("base",t,n),bodyAttributes:xf("bodyAttributes",s,n),htmlAttributes:xf("htmlAttributes",a,n),link:xf("link",p,n),meta:xf("meta",g,n),noscript:xf("noscript",o,n),script:xf("script",v,n),style:xf("style",l,n),title:xf("title",{title:i,titleAttributes:d},n)}},qfe=Bct,gO=[],j8e=!!(typeof window<"u"&&window.document&&window.document.createElement),Hfe=class{constructor(e,t){on(this,"instances",[]);on(this,"canUseDOM",j8e);on(this,"context");on(this,"value",{setHelmet:e=>{this.context.helmet=e},helmetInstances:{get:()=>this.canUseDOM?gO:this.instances,add:e=>{(this.canUseDOM?gO:this.instances).push(e)},remove:e=>{const t=(this.canUseDOM?gO:this.instances).indexOf(e);(this.canUseDOM?gO:this.instances).splice(t,1)}}});this.context=e,this.canUseDOM=t||!1,t||(e.helmet=qfe({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},$ct={},k8e=lt.createContext($ct),dk,N8e=(dk=class extends A.Component{constructor(s){super(s);on(this,"helmetData");this.helmetData=new Hfe(this.props.context||{},dk.canUseDOM)}render(){return lt.createElement(k8e.Provider,{value:this.helmetData.value},this.props.children)}},on(dk,"canUseDOM",j8e),dk),uC=(e,t)=>{const s=document.head||document.querySelector("head"),n=s.querySelectorAll(`${e}[${Zp}]`),a=[].slice.call(n),o=[];let l;return t&&t.length&&t.forEach(i=>{const d=document.createElement(e);for(const m in i)if(Object.prototype.hasOwnProperty.call(i,m))if(m==="innerHTML")d.innerHTML=i.innerHTML;else if(m==="cssText")d.styleSheet?d.styleSheet.cssText=i.cssText:d.appendChild(document.createTextNode(i.cssText));else{const p=m,g=typeof i[p]>"u"?"":i[p];d.setAttribute(m,g)}d.setAttribute(Zp,"true"),a.some((m,p)=>(l=p,d.isEqualNode(m)))?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=>s.appendChild(i)),{oldTags:a,newTags:o}},Wfe=(e,t)=>{const s=document.getElementsByTagName(e)[0];if(!s)return;const n=s.getAttribute(Zp),a=n?n.split(","):[],o=[...a],l=Object.keys(t);for(const i of l){const d=t[i]||"";s.getAttribute(i)!==d&&s.setAttribute(i,d),a.indexOf(i)===-1&&a.push(i);const m=o.indexOf(i);m!==-1&&o.splice(m,1)}for(let i=o.length-1;i>=0;i-=1)s.removeAttribute(o[i]);a.length===o.length?s.removeAttribute(Zp):s.getAttribute(Zp)!==l.join(",")&&s.setAttribute(Zp,l.join(","))},Uct=(e,t)=>{typeof e<"u"&&document.title!==e&&(document.title=_8e(e)),Wfe("title",t)},hCe=(e,t)=>{const{baseTag:s,bodyAttributes:n,htmlAttributes:a,linkTags:o,metaTags:l,noscriptTags:i,onChangeClientState:d,scriptTags:m,styleTags:p,title:g,titleAttributes:v}=e;Wfe("body",n),Wfe("html",a),Uct(g,v);const _={baseTag:uC("base",s),linkTags:uC("link",o),metaTags:uC("meta",l),noscriptTags:uC("noscript",i),scriptTags:uC("script",m),styleTags:uC("style",p)},k={},w={};Object.keys(_).forEach(S=>{const{newTags:T,oldTags:C}=_[S];T.length&&(k[S]=T),C.length&&(w[S]=_[S].oldTags)}),t&&t(),d(e,k,w)},dA=null,Vct=e=>{dA&&cancelAnimationFrame(dA),e.defer?dA=requestAnimationFrame(()=>{hCe(e,()=>{dA=null})}):(hCe(e),dA=null)},qct=Vct,mCe=class extends A.Component{constructor(){super(...arguments);on(this,"rendered",!1)}shouldComponentUpdate(t){return!Sct(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:s}=this.props.context;let n=null;const a=Pct(t.get().map(o=>{const l={...o.props};return delete l.context,l}));N8e.canUseDOM?qct(a):qfe&&(n=qfe(a)),s(n)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},bme,nm=(bme=class extends A.Component{shouldComponentUpdate(e){return!wct(uCe(this.props,"helmetData"),uCe(e,"helmetData"))}mapNestedChildrenToProps(e,t){if(!t)return null;switch(e.type){case"script":case"noscript":return{innerHTML:t};case"style":return{cssText:t};default:throw new Error(`<${e.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(e,t,s,n){return{...t,[e.type]:[...t[e.type]||[],{...s,...this.mapNestedChildrenToProps(e,n)}]}}mapObjectTypeChildren(e,t,s,n){switch(e.type){case"title":return{...t,[e.type]:n,titleAttributes:{...s}};case"body":return{...t,bodyAttributes:{...s}};case"html":return{...t,htmlAttributes:{...s}};default:return{...t,[e.type]:{...s}}}}mapArrayTypeChildrenToProps(e,t){let s={...t};return Object.keys(e).forEach(n=>{s={...s,[n]:e[n]}}),s}warnOnInvalidChildren(e,t){return cCe(dCe.some(s=>e.type===s),typeof e.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 ${dCe.join(", ")} are allowed. Helmet does not support rendering <${e.type}> elements. Refer to our API for more information.`),cCe(!t||typeof t=="string"||Array.isArray(t)&&!t.some(s=>typeof s!="string"),`Helmet expects a string as a child of <${e.type}>. Did you forget to wrap your children in braces? ( <${e.type}>{\`\`} ) Refer to our API for more information.`),!0}mapChildrenToProps(e,t){let s={};return lt.Children.forEach(e,n=>{if(!n||!n.props)return;const{children:a,...o}=n.props,l=Object.keys(o).reduce((d,m)=>(d[Cct[m]||m]=o[m],d),{});let{type:i}=n;switch(typeof i=="symbol"?i=i.toString():this.warnOnInvalidChildren(n,a),i){case"Symbol(react.fragment)":t=this.mapChildrenToProps(a,t);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(n,s,l,a);break;default:t=this.mapObjectTypeChildren(n,t,l,a);break}}),this.mapArrayTypeChildrenToProps(s,t)}render(){const{children:e,...t}=this.props;let s={...t},{helmetData:n}=t;if(e&&(s=this.mapChildrenToProps(e,s)),n&&!(n instanceof Hfe)){const a=n;n=new Hfe(a.context,!0),delete s.helmetData}return n?lt.createElement(mCe,{...s,context:n.value}):lt.createElement(k8e.Consumer,null,a=>lt.createElement(mCe,{...s,context:a}))}},on(bme,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),bme),Gfe=function(e,t){return Gfe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(s,n){s.__proto__=n}||function(s,n){for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(s[a]=n[a])},Gfe(e,t)};function S8e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Gfe(e,t);function s(){this.constructor=e}e.prototype=t===null?Object.create(t):(s.prototype=t.prototype,new s)}var Sf=function(){return Sf=Object.assign||function(t){for(var s,n=1,a=arguments.length;n=0;i--)(l=e[i])&&(o=(a<3?l(o):a>3?l(t,s,o):l(t,s))||o);return a>3&&o&&Object.defineProperty(t,s,o),o}function M8e(e,t){return function(s,n){t(s,n,e)}}function T8e(e,t,s,n,a,o){function l(T){if(T!==void 0&&typeof T!="function")throw new TypeError("Function expected");return T}for(var i=n.kind,d=i==="getter"?"get":i==="setter"?"set":"value",m=!t&&e?n.static?e:e.prototype:null,p=t||(m?Object.getOwnPropertyDescriptor(m,n.name):{}),g,v=!1,_=s.length-1;_>=0;_--){var k={};for(var w in n)k[w]=w==="access"?{}:n[w];for(var w in n.access)k.access[w]=n.access[w];k.addInitializer=function(T){if(v)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(T||null))};var S=(0,s[_])(i==="accessor"?{get:p.get,set:p.set}:p[d],k);if(i==="accessor"){if(S===void 0)continue;if(S===null||typeof S!="object")throw new TypeError("Object expected");(g=l(S.get))&&(p.get=g),(g=l(S.set))&&(p.set=g),(g=l(S.init))&&a.unshift(g)}else(g=l(S))&&(i==="field"?a.unshift(g):p[d]=g)}m&&Object.defineProperty(m,n.name,p),v=!0}function A8e(e,t,s){for(var n=arguments.length>2,a=0;a0&&o[o.length-1])&&(m[0]===6||m[0]===2)){s=0;continue}if(m[0]===3&&(!o||m[1]>o[0]&&m[1]=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function X0e(e,t){var s=typeof Symbol=="function"&&e[Symbol.iterator];if(!s)return e;var n=s.call(e),a,o=[],l;try{for(;(t===void 0||t-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(i){l={error:i}}finally{try{a&&!a.done&&(s=n.return)&&s.call(n)}finally{if(l)throw l.error}}return o}function O8e(){for(var e=[],t=0;t1||d(_,w)})},k&&(a[_]=k(a[_])))}function d(_,k){try{m(n[_](k))}catch(w){v(o[0][3],w)}}function m(_){_.value instanceof M5?Promise.resolve(_.value.v).then(p,g):v(o[0][2],_)}function p(_){d("next",_)}function g(_){d("throw",_)}function v(_,k){_(k),o.shift(),o.length&&d(o[0][0],o[0][1])}}function z8e(e){var t,s;return t={},n("next"),n("throw",function(a){throw a}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(a,o){t[a]=e[a]?function(l){return(s=!s)?{value:M5(e[a](l)),done:!1}:o?o(l):l}:o}}function B8e(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],s;return t?t.call(e):(e=typeof rse=="function"?rse(e):e[Symbol.iterator](),s={},n("next"),n("throw"),n("return"),s[Symbol.asyncIterator]=function(){return this},s);function n(o){s[o]=e[o]&&function(l){return new Promise(function(i,d){l=e[o](l),a(i,d,l.done,l.value)})}}function a(o,l,i,d){Promise.resolve(d).then(function(m){o({value:m,done:i})},l)}}function $8e(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var Hct=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},Kfe=function(e){return Kfe=Object.getOwnPropertyNames||function(t){var s=[];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[s.length]=n);return s},Kfe(e)};function U8e(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var s=Kfe(e),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(s.map(d=>{if(d=Yct(d),d in fCe)return;fCe[d]=!0;const m=d.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":Zct,m||(g.as="script"),g.crossOrigin="",g.href=d,i&&g.setAttribute("nonce",i),document.head.appendChild(g),m)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 t().catch(o)})},Xct=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...s)=>M3(async()=>{const{default:n}=await Promise.resolve().then(()=>yN);return{default:n}},void 0).then(({default:n})=>n(...s)):t=fetch,(...s)=>t(...s)};class J0e extends Error{constructor(t,s="FunctionsError",n){super(t),this.name=s,this.context=n}}class pCe extends J0e{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class gCe extends J0e{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class xCe extends J0e{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var Zfe;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(Zfe||(Zfe={}));class Qct{constructor(t,{headers:s={},customFetch:n,region:a=Zfe.Any}={}){this.url=t,this.headers=s,this.region=a,this.fetch=Xct(n)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t){return ea(this,arguments,void 0,function*(s,n={}){var a;try{const{headers:o,method:l,body:i,signal:d}=n;let m={},{region:p}=n;p||(p=this.region);const g=new URL(`${this.url}/${s}`);p&&p!=="any"&&(m["x-region"]=p,g.searchParams.set("forceFunctionRegion",p));let v;i&&(o&&!Object.prototype.hasOwnProperty.call(o,"Content-Type")||!o)?typeof Blob<"u"&&i instanceof Blob||i instanceof ArrayBuffer?(m["Content-Type"]="application/octet-stream",v=i):typeof i=="string"?(m["Content-Type"]="text/plain",v=i):typeof FormData<"u"&&i instanceof FormData?v=i:(m["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({},m),this.headers),o),body:v,signal:d}).catch(T=>{throw T.name==="AbortError"?T:new pCe(T)}),k=_.headers.get("x-relay-error");if(k&&k==="true")throw new gCe(_);if(!_.ok)throw new xCe(_);let w=((a=_.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),S;return w==="application/json"?S=yield _.json():w==="application/octet-stream"||w==="application/pdf"?S=yield _.blob():w==="text/event-stream"?S=_:w==="multipart/form-data"?S=yield _.formData():S=yield _.text(),{data:S,error:null,response:_}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new pCe(o)}:{data:null,error:o,response:o instanceof xCe||o instanceof gCe?o.context:void 0}}})}}var Uh={};const T3=y6e(Kct);var xO={},yO={},vO={},_O={},bO={},Jct=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")},T5=Jct();const edt=T5.fetch,Y8e=T5.fetch.bind(T5),X8e=T5.Headers,tdt=T5.Request,rdt=T5.Response,yN=Object.freeze(Object.defineProperty({__proto__:null,Headers:X8e,Request:tdt,Response:rdt,default:Y8e,fetch:edt},Symbol.toStringTag,{value:"Module"})),sdt=y6e(yN);var wO={},yCe;function Q8e(){if(yCe)return wO;yCe=1,Object.defineProperty(wO,"__esModule",{value:!0});class e extends Error{constructor(s){super(s.message),this.name="PostgrestError",this.details=s.details,this.hint=s.hint,this.code=s.code}}return wO.default=e,wO}var vCe;function J8e(){if(vCe)return bO;vCe=1,Object.defineProperty(bO,"__esModule",{value:!0});const e=T3,t=e.__importDefault(sdt),s=e.__importDefault(Q8e());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=t.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 m=>{var p,g,v,_;let k=null,w=null,S=null,T=m.status,C=m.statusText;if(m.ok){if(this.method!=="HEAD"){const B=await m.text();B===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((p=this.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?w=B:w=JSON.parse(B))}const R=(g=this.headers.get("Prefer"))===null||g===void 0?void 0:g.match(/count=(exact|planned|estimated)/),D=(v=m.headers.get("content-range"))===null||v===void 0?void 0:v.split("/");R&&D&&D.length>1&&(S=parseInt(D[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(w)&&(w.length>1?(k={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,S=null,T=406,C="Not Acceptable"):w.length===1?w=w[0]:w=null)}else{const R=await m.text();try{k=JSON.parse(R),Array.isArray(k)&&m.status===404&&(w=[],k=null,T=200,C="OK")}catch{m.status===404&&R===""?(T=204,C="No Content"):k={message:R}}if(k&&this.isMaybeSingle&&(!((_=k==null?void 0:k.details)===null||_===void 0)&&_.includes("0 rows"))&&(k=null,T=200,C="OK"),k&&this.shouldThrowOnError)throw new s.default(k)}return{error:k,data:w,count:S,status:T,statusText:C}});return this.shouldThrowOnError||(d=d.catch(m=>{var p,g,v;return{error:{message:`${(p=m==null?void 0:m.name)!==null&&p!==void 0?p:"FetchError"}: ${m==null?void 0:m.message}`,details:`${(g=m==null?void 0:m.stack)!==null&&g!==void 0?g:""}`,hint:"",code:`${(v=m==null?void 0:m.code)!==null&&v!==void 0?v:""}`},data:null,count:null,status:0,statusText:""}})),d.then(o,l)}returns(){return this}overrideTypes(){return this}}return bO.default=n,bO}var _Ce;function eRe(){if(_Ce)return _O;_Ce=1,Object.defineProperty(_O,"__esModule",{value:!0});const t=T3.__importDefault(J8e());class s extends t.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 m=d?`${d}.order`:"order",p=this.url.searchParams.get(m);return this.url.searchParams.set(m,`${p?`${p},`:""}${a}.${o?"asc":"desc"}${l===void 0?"":l?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:o,referencedTable:l=o}={}){const i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,o,{foreignTable:l,referencedTable:i=l}={}){const d=typeof i>"u"?"offset":`${i}.offset`,m=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(d,`${a}`),this.url.searchParams.set(m,`${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:m="text"}={}){var p;const g=[a?"analyze":null,o?"verbose":null,l?"settings":null,i?"buffers":null,d?"wal":null].filter(Boolean).join("|"),v=(p=this.headers.get("Accept"))!==null&&p!==void 0?p:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${m}; for="${v}"; options=${g};`),m==="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 _O.default=s,_O}var bCe;function eve(){if(bCe)return vO;bCe=1,Object.defineProperty(vO,"__esModule",{value:!0});const t=T3.__importDefault(eRe()),s=new RegExp("[,()]");class n extends t.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"&&s.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 m="";d==="plain"?m="pl":d==="phrase"?m="ph":d==="websearch"&&(m="w");const p=i===void 0?"":`(${i})`;return this.url.searchParams.append(o,`${m}fts${p}.${l}`),this}match(o){return Object.entries(o).forEach(([l,i])=>{this.url.searchParams.append(l,`eq.${i}`)}),this}not(o,l,i){return this.url.searchParams.append(o,`not.${l}.${i}`),this}or(o,{foreignTable:l,referencedTable:i=l}={}){const d=i?`${i}.or`:"or";return this.url.searchParams.append(d,`(${o})`),this}filter(o,l,i){return this.url.searchParams.append(o,`${l}.${i}`),this}}return vO.default=n,vO}var wCe;function tRe(){if(wCe)return yO;wCe=1,Object.defineProperty(yO,"__esModule",{value:!0});const t=T3.__importDefault(eve());class s{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 m=!1;const p=(a??"*").split("").map(g=>/\s/.test(g)&&!m?"":(g==='"'&&(m=!m),g)).join("");return this.url.searchParams.set("select",p),i&&this.headers.append("Prefer",`count=${i}`),new t.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 m=a.reduce((p,g)=>p.concat(Object.keys(g)),[]);if(m.length>0){const p=[...new Set(m)].map(g=>`"${g}"`);this.url.searchParams.set("columns",p.join(","))}}return new t.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 m;const p="POST";if(this.headers.append("Prefer",`resolution=${l?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),i&&this.headers.append("Prefer",`count=${i}`),d||this.headers.append("Prefer","missing=default"),Array.isArray(a)){const g=a.reduce((v,_)=>v.concat(Object.keys(_)),[]);if(g.length>0){const v=[...new Set(g)].map(_=>`"${_}"`);this.url.searchParams.set("columns",v.join(","))}}return new t.default({method:p,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(m=this.fetch)!==null&&m!==void 0?m:fetch})}update(a,{count:o}={}){var l;const i="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new t.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 t.default({method:l,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}}return yO.default=s,yO}var jCe;function ndt(){if(jCe)return xO;jCe=1,Object.defineProperty(xO,"__esModule",{value:!0});const e=T3,t=e.__importDefault(tRe()),s=e.__importDefault(eve());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 t.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:m}={}){var p;let g;const v=new URL(`${this.url}/rpc/${o}`);let _;i||d?(g=i?"HEAD":"GET",Object.entries(l).filter(([w,S])=>S!==void 0).map(([w,S])=>[w,Array.isArray(S)?`{${S.join(",")}}`:`${S}`]).forEach(([w,S])=>{v.searchParams.append(w,S)})):(g="POST",_=l);const k=new Headers(this.headers);return m&&k.set("Prefer",`count=${m}`),new s.default({method:g,url:v,headers:k,schema:this.schemaName,body:_,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return xO.default=n,xO}Object.defineProperty(Uh,"__esModule",{value:!0});var rRe=Uh.PostgrestError=hRe=Uh.PostgrestBuilder=dRe=Uh.PostgrestTransformBuilder=lRe=Uh.PostgrestFilterBuilder=iRe=Uh.PostgrestQueryBuilder=nRe=Uh.PostgrestClient=void 0;const A3=T3,sRe=A3.__importDefault(ndt());var nRe=Uh.PostgrestClient=sRe.default;const aRe=A3.__importDefault(tRe());var iRe=Uh.PostgrestQueryBuilder=aRe.default;const oRe=A3.__importDefault(eve());var lRe=Uh.PostgrestFilterBuilder=oRe.default;const cRe=A3.__importDefault(eRe());var dRe=Uh.PostgrestTransformBuilder=cRe.default;const uRe=A3.__importDefault(J8e());var hRe=Uh.PostgrestBuilder=uRe.default;const mRe=A3.__importDefault(Q8e());rRe=Uh.PostgrestError=mRe.default;var fRe=Uh.default={PostgrestClient:sRe.default,PostgrestQueryBuilder:aRe.default,PostgrestFilterBuilder:oRe.default,PostgrestTransformBuilder:cRe.default,PostgrestBuilder:uRe.default,PostgrestError:mRe.default};const adt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return hRe},get PostgrestClient(){return nRe},get PostgrestError(){return rRe},get PostgrestFilterBuilder(){return lRe},get PostgrestQueryBuilder(){return iRe},get PostgrestTransformBuilder(){return dRe},default:fRe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:idt,PostgrestQueryBuilder:Wmr,PostgrestFilterBuilder:Gmr,PostgrestTransformBuilder:Kmr,PostgrestBuilder:Zmr,PostgrestError:Ymr}=fRe||adt;class odt{static detectEnvironment(){var t;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"&&(!((t=navigator.userAgent)===null||t===void 0)&&t.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 s=process.versions;if(s&&s.node){const n=s.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 t=this.detectEnvironment();if(t.constructor)return t.constructor;let s=t.error||"WebSocket not supported in this environment.";throw t.workaround&&(s+=` Suggested solution: ${t.workaround}`),new Error(s)}static createWebSocket(t,s){const n=this.getWebSocketConstructor();return new n(t,s)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return t.type==="native"||t.type==="ws"}catch{return!1}}}const ldt="2.78.0",cdt=`realtime-js/${ldt}`,ddt="1.0.0",Yfe=1e4,udt=1e3,hdt=100;var qE;(function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"})(qE||(qE={}));var xd;(function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"})(xd||(xd={}));var Bp;(function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"})(Bp||(Bp={}));var Xfe;(function(e){e.websocket="websocket"})(Xfe||(Xfe={}));var Pj;(function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"})(Pj||(Pj={}));class mdt{constructor(){this.HEADER_LENGTH=1}decode(t,s){return t.constructor===ArrayBuffer?s(this._binaryDecode(t)):s(typeof t=="string"?JSON.parse(t):{})}_binaryDecode(t){const s=new DataView(t),n=new TextDecoder;return this._decodeBroadcast(t,s,n)}_decodeBroadcast(t,s,n){const a=s.getUint8(1),o=s.getUint8(2);let l=this.HEADER_LENGTH+2;const i=n.decode(t.slice(l,l+a));l=l+a;const d=n.decode(t.slice(l,l+o));l=l+o;const m=JSON.parse(n.decode(t.slice(l,t.byteLength)));return{ref:null,topic:i,event:d,payload:m}}}class pRe{constructor(t,s){this.callback=t,this.timerCalc=s,this.timer=void 0,this.tries=0,this.callback=t,this.timerCalc=s}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 ol;(function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"})(ol||(ol={}));const kCe=(e,t,s={})=>{var n;const a=(n=s.skipTypes)!==null&&n!==void 0?n:[];return t?Object.keys(t).reduce((o,l)=>(o[l]=fdt(l,e,t,a),o),{}):{}},fdt=(e,t,s,n)=>{const a=t.find(i=>i.name===e),o=a==null?void 0:a.type,l=s[e];return o&&!n.includes(o)?gRe(o,l):Qfe(l)},gRe=(e,t)=>{if(e.charAt(0)==="_"){const s=e.slice(1,e.length);return ydt(t,s)}switch(e){case ol.bool:return pdt(t);case ol.float4:case ol.float8:case ol.int2:case ol.int4:case ol.int8:case ol.numeric:case ol.oid:return gdt(t);case ol.json:case ol.jsonb:return xdt(t);case ol.timestamp:return vdt(t);case ol.abstime:case ol.date:case ol.daterange:case ol.int4range:case ol.int8range:case ol.money:case ol.reltime:case ol.text:case ol.time:case ol.timestamptz:case ol.timetz:case ol.tsrange:case ol.tstzrange:return Qfe(t);default:return Qfe(t)}},Qfe=e=>e,pdt=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},gdt=e=>{if(typeof e=="string"){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},xdt=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch(t){return console.log(`JSON parse error: ${t}`),e}return e},ydt=(e,t)=>{if(typeof e!="string")return e;const s=e.length-1,n=e[s];if(e[0]==="{"&&n==="}"){let o;const l=e.slice(1,s);try{o=JSON.parse("["+l+"]")}catch{o=l?l.split(","):[]}return o.map(i=>gRe(t,i))}return e},vdt=e=>typeof e=="string"?e.replace(" ","T"):e,xRe=e=>{const t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),t.pathname===""||t.pathname==="/"?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};class oue{constructor(t,s,n={},a=Yfe){this.channel=t,this.event=s,this.payload=n,this.timeout=a,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(t){this.timeout=t,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(t){this.payload=Object.assign(Object.assign({},this.payload),t)}receive(t,s){var n;return this._hasReceived(t)&&s((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:t,callback:s}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const t=s=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=s,this._matchReceive(s)};this.channel._on(this.refEvent,{},t),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(t,s){this.refEvent&&this.channel._trigger(this.refEvent,{status:t,response:s})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:t,response:s}){this.recHooks.filter(n=>n.status===t).forEach(n=>n.callback(s))}_hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}}var NCe;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(NCe||(NCe={}));class HE{constructor(t,s){this.channel=t,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(s==null?void 0:s.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=HE.syncState(this.state,a,o,l),this.pendingDiffs.forEach(d=>{this.state=HE.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=HE.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(t,s,n,a){const o=this.cloneDeep(t),l=this.transformState(s),i={},d={};return this.map(o,(m,p)=>{l[m]||(d[m]=p)}),this.map(l,(m,p)=>{const g=o[m];if(g){const v=p.map(S=>S.presence_ref),_=g.map(S=>S.presence_ref),k=p.filter(S=>_.indexOf(S.presence_ref)<0),w=g.filter(S=>v.indexOf(S.presence_ref)<0);k.length>0&&(i[m]=k),w.length>0&&(d[m]=w)}else i[m]=p}),this.syncDiff(o,{joins:i,leaves:d},n,a)}static syncDiff(t,s,n,a){const{joins:o,leaves:l}={joins:this.transformState(s.joins),leaves:this.transformState(s.leaves)};return n||(n=()=>{}),a||(a=()=>{}),this.map(o,(i,d)=>{var m;const p=(m=t[i])!==null&&m!==void 0?m:[];if(t[i]=this.cloneDeep(d),p.length>0){const g=t[i].map(_=>_.presence_ref),v=p.filter(_=>g.indexOf(_.presence_ref)<0);t[i].unshift(...v)}n(i,p,d)}),this.map(l,(i,d)=>{let m=t[i];if(!m)return;const p=d.map(g=>g.presence_ref);m=m.filter(g=>p.indexOf(g.presence_ref)<0),t[i]=m,a(i,m,d),m.length===0&&delete t[i]}),t}static map(t,s){return Object.getOwnPropertyNames(t).map(n=>s(n,t[n]))}static transformState(t){return t=this.cloneDeep(t),Object.getOwnPropertyNames(t).reduce((s,n)=>{const a=t[n];return"metas"in a?s[n]=a.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):s[n]=a,s},{})}static cloneDeep(t){return JSON.parse(JSON.stringify(t))}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var SCe;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(SCe||(SCe={}));var WE;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"})(WE||(WE={}));var xy;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(xy||(xy={}));class tve{constructor(t,s={config:{}},n){var a,o;if(this.topic=t,this.params=s,this.socket=n,this.bindings={},this.state=xd.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},s.config),this.timeout=this.socket.timeout,this.joinPush=new oue(this,Bp.join,this.params,this.timeout),this.rejoinTimer=new pRe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=xd.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=xd.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=xd.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=xd.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=xd.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Bp.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new HE(this),this.broadcastEndpointURL=xRe(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(t,s=this.timeout){var n,a,o;if(this.socket.isConnected()||this.socket.connect(),this.state==xd.closed){const{config:{broadcast:l,presence:i,private:d}}=this.params,m=(a=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(_=>_.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[WE.PRESENCE]&&this.bindings[WE.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,g={},v={broadcast:l,presence:Object.assign(Object.assign({},i),{enabled:p}),postgres_changes:m,private:d};this.socket.accessTokenValue&&(g.access_token=this.socket.accessTokenValue),this._onError(_=>t==null?void 0:t(xy.CHANNEL_ERROR,_)),this._onClose(()=>t==null?void 0:t(xy.CLOSED)),this.updateJoinPayload(Object.assign({config:v},g)),this.joinedOnce=!0,this._rejoin(s),this.joinPush.receive("ok",async({postgres_changes:_})=>{var k;if(this.socket.setAuth(),_===void 0){t==null||t(xy.SUBSCRIBED);return}else{const w=this.bindings.postgres_changes,S=(k=w==null?void 0:w.length)!==null&&k!==void 0?k:0,T=[];for(let C=0;C{this.state=xd.errored,t==null||t(xy.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(_).join(", ")||"error")))}).receive("timeout",()=>{t==null||t(xy.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(t,s={}){return await this.send({type:"presence",event:"track",payload:t},s.timeout||this.timeout)}async untrack(t={}){return await this.send({type:"presence",event:"untrack"},t)}on(t,s,n){return this.state===xd.joined&&t===WE.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(t,s,n)}async httpSend(t,s,n={}){var a;const o=this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"";if(s==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:t,payload:s,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 m=await i.json();d=m.error||m.message||d}catch{}return Promise.reject(new Error(d))}async send(t,s={}){var n,a;if(!this._canPush()&&t.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}=t,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 m=await this._fetchWithTimeout(this.broadcastEndpointURL,d,(n=s.timeout)!==null&&n!==void 0?n:this.timeout);return await((a=m.body)===null||a===void 0?void 0:a.cancel()),m.ok?"ok":"error"}catch(m){return m.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var l,i,d;const m=this._push(t.type,t,s.timeout||this.timeout);t.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"),m.receive("ok",()=>o("ok")),m.receive("error",()=>o("error")),m.receive("timeout",()=>o("timed out"))})}updateJoinPayload(t){this.joinPush.updatePayload(t)}unsubscribe(t=this.timeout){this.state=xd.leaving;const s=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Bp.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new oue(this,Bp.leave,{},t),n.receive("ok",()=>{s(),a("ok")}).receive("timeout",()=>{s(),a("timed out")}).receive("error",()=>{a("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=xd.closed,this.bindings={}}async _fetchWithTimeout(t,s,n){const a=new AbortController,o=setTimeout(()=>a.abort(),n),l=await this.socket.fetch(t,Object.assign(Object.assign({},s),{signal:a.signal}));return clearTimeout(o),l}_push(t,s,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${t}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let a=new oue(this,t,s,n);return this._canPush()?a.send():this._addToPushBuffer(a),a}_addToPushBuffer(t){if(t.startTimeout(),this.pushBuffer.push(t),this.pushBuffer.length>hdt){const s=this.pushBuffer.shift();s&&(s.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${s.event}`,s.payload))}}_onMessage(t,s,n){return s}_isMember(t){return this.topic===t}_joinRef(){return this.joinPush.ref}_trigger(t,s,n){var a,o;const l=t.toLocaleLowerCase(),{close:i,error:d,leave:m,join:p}=Bp;if(n&&[i,d,m,p].indexOf(l)>=0&&n!==this._joinRef())return;let v=this._onMessage(l,s,n);if(s&&!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 k,w,S;return((k=_.filter)===null||k===void 0?void 0:k.event)==="*"||((S=(w=_.filter)===null||w===void 0?void 0:w.event)===null||S===void 0?void 0:S.toLocaleLowerCase())===l}).map(_=>_.callback(v,n)):(o=this.bindings[l])===null||o===void 0||o.filter(_=>{var k,w,S,T,C,I;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in _){const R=_.id,D=(k=_.filter)===null||k===void 0?void 0:k.event;return R&&((w=s.ids)===null||w===void 0?void 0:w.includes(R))&&(D==="*"||(D==null?void 0:D.toLocaleLowerCase())===((S=s.data)===null||S===void 0?void 0:S.type.toLocaleLowerCase()))}else{const R=(C=(T=_==null?void 0:_.filter)===null||T===void 0?void 0:T.event)===null||C===void 0?void 0:C.toLocaleLowerCase();return R==="*"||R===((I=s==null?void 0:s.event)===null||I===void 0?void 0:I.toLocaleLowerCase())}else return _.type.toLocaleLowerCase()===l}).map(_=>{if(typeof v=="object"&&"ids"in v){const k=v.data,{schema:w,table:S,commit_timestamp:T,type:C,errors:I}=k;v=Object.assign(Object.assign({},{schema:w,table:S,commit_timestamp:T,eventType:C,new:{},old:{},errors:I}),this._getPayloadRecords(k))}_.callback(v,n)})}_isClosed(){return this.state===xd.closed}_isJoined(){return this.state===xd.joined}_isJoining(){return this.state===xd.joining}_isLeaving(){return this.state===xd.leaving}_replyEventName(t){return`chan_reply_${t}`}_on(t,s,n){const a=t.toLocaleLowerCase(),o={type:a,filter:s,callback:n};return this.bindings[a]?this.bindings[a].push(o):this.bindings[a]=[o],this}_off(t,s){const n=t.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&&tve.isEqual(a.filter,s))})),this}static isEqual(t,s){if(Object.keys(t).length!==Object.keys(s).length)return!1;for(const n in t)if(t[n]!==s[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(t){this._on(Bp.close,{},t)}_onError(t){this._on(Bp.error,{},s=>t(s))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(t=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=xd.joining,this.joinPush.resend(t))}_getPayloadRecords(t){const s={new:{},old:{}};return(t.type==="INSERT"||t.type==="UPDATE")&&(s.new=kCe(t.columns,t.record)),(t.type==="UPDATE"||t.type==="DELETE")&&(s.old=kCe(t.columns,t.old_record)),s}}const lue=()=>{},jO={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},_dt=[1e3,2e3,5e3,1e4],bdt=1e4,wdt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class jdt{constructor(t,s){var n;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=Yfe,this.transport=null,this.heartbeatIntervalMs=jO.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=lue,this.ref=0,this.reconnectTimer=null,this.logger=lue,this.conn=null,this.sendBuffer=[],this.serializer=new mdt,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)=>M3(async()=>{const{default:i}=await Promise.resolve().then(()=>yN);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=s==null?void 0:s.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=s.params.apikey,this.endPoint=`${t}/${Xfe.websocket}`,this.httpEndpoint=xRe(t),this._initializeOptions(s),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(s==null?void 0:s.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=odt.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");const s=t.message;throw s.includes("Node.js")?new Error(`${s} 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: ${s}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:ddt}))}disconnect(t,s){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")},t?this.conn.close(t,s??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(t){const s=await t.unsubscribe();return this.channels.length===0&&this.disconnect(),s}async removeAllChannels(){const t=await Promise.all(this.channels.map(s=>s.unsubscribe()));return this.channels=[],this.disconnect(),t}log(t,s,n){this.logger(t,s,n)}connectionState(){switch(this.conn&&this.conn.readyState){case qE.connecting:return Pj.Connecting;case qE.open:return Pj.Open;case qE.closing:return Pj.Closing;default:return Pj.Closed}}isConnected(){return this.connectionState()===Pj.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(t,s={config:{}}){const n=`realtime:${t}`,a=this.getChannels().find(o=>o.topic===n);if(a)return a;{const o=new tve(`realtime:${t}`,s,this);return this.channels.push(o),o}}push(t){const{topic:s,event:n,payload:a,ref:o}=t,l=()=>{this.encode(t,i=>{var d;(d=this.conn)===null||d===void 0||d.send(i)})};this.log("push",`${s} ${n} (${o})`,a),this.isConnected()?l():this.sendBuffer.push(l)}async setAuth(t=null){this._authPromise=this._performAuth(t);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var t;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(s){this.log("error","error in heartbeat callback",s)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(s){this.log("error","error in heartbeat callback",s)}this._wasManualDisconnect=!1,(t=this.conn)===null||t===void 0||t.close(udt,"heartbeat timeout"),setTimeout(()=>{var s;this.isConnected()||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout()},jO.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(s){this.log("error","error in heartbeat callback",s)}this._setAuthSafely("heartbeat")}onHeartbeat(t){this.heartbeatCallback=t}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}_makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}_leaveOpenTopic(t){let s=this.channels.find(n=>n.topic===t&&(n._isJoined()||n._isJoining()));s&&(this.log("transport",`leaving duplicate topic "${t}"`),s.unsubscribe())}_remove(t){this.channels=this.channels.filter(s=>s.topic!==t.topic)}_onConnMessage(t){this.decode(t.data,s=>{if(s.topic==="phoenix"&&s.event==="phx_reply")try{this.heartbeatCallback(s.payload.status==="ok"?"ok":"error")}catch(m){this.log("error","error in heartbeat callback",m)}s.ref&&s.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:a,payload:o,ref:l}=s,i=l?`(${l})`:"",d=o.status||"";this.log("receive",`${d} ${n} ${a} ${i}`.trim(),o),this.channels.filter(m=>m._isMember(n)).forEach(m=>m._trigger(a,o,l)),this._triggerStateCallbacks("message",s)})}_clearTimer(t){var s;t==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):t==="reconnect"&&((s=this.reconnectTimer)===null||s===void 0||s.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=t=>this._onConnError(t),this.conn.onmessage=t=>this._onConnMessage(t),this.conn.onclose=t=>this._onConnClose(t))}_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(t=>t.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 t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=s=>{this.log("worker","worker error",s.message),this.workerRef.terminate()},this.workerRef.onmessage=s=>{s.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(t){var s;this._setConnectionState("disconnected"),this.log("transport","close",t),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(s=this.reconnectTimer)===null||s===void 0||s.scheduleTimeout(),this._triggerStateCallbacks("close",t)}_onConnError(t){this._setConnectionState("disconnected"),this.log("transport",`${t}`),this._triggerChanError(),this._triggerStateCallbacks("error",t)}_triggerChanError(){this.channels.forEach(t=>t._trigger(Bp.error))}_appendParams(t,s){if(Object.keys(s).length===0)return t;const n=t.match(/\?/)?"&":"?",a=new URLSearchParams(s);return`${t}${n}${a}`}_workerObjectUrl(t){let s;if(t)s=t;else{const n=new Blob([wdt],{type:"application/javascript"});s=URL.createObjectURL(n)}return s}_setConnectionState(t,s=!1){this._connectionState=t,t==="connecting"?this._wasManualDisconnect=!1:t==="disconnecting"&&(this._wasManualDisconnect=s)}async _performAuth(t=null){let s;t?s=t:this.accessToken?s=await this.accessToken():s=this.accessTokenValue,this.accessTokenValue!=s&&(this.accessTokenValue=s,this.channels.forEach(n=>{const a={access_token:s,version:cdt};s&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Bp.access_token,{access_token:s})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(t="general"){this.setAuth().catch(s=>{this.log("error",`error setting auth in ${t}`,s)})}_triggerStateCallbacks(t,s){try{this.stateChangeCallbacks[t].forEach(n=>{try{n(s)}catch(a){this.log("error",`error in ${t} callback`,a)}})}catch(n){this.log("error",`error triggering ${t} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new pRe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},jO.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(t){var s,n,a,o,l,i,d,m,p;if(this.transport=(s=t==null?void 0:t.transport)!==null&&s!==void 0?s:null,this.timeout=(n=t==null?void 0:t.timeout)!==null&&n!==void 0?n:Yfe,this.heartbeatIntervalMs=(a=t==null?void 0:t.heartbeatIntervalMs)!==null&&a!==void 0?a:jO.HEARTBEAT_INTERVAL,this.worker=(o=t==null?void 0:t.worker)!==null&&o!==void 0?o:!1,this.accessToken=(l=t==null?void 0:t.accessToken)!==null&&l!==void 0?l:null,this.heartbeatCallback=(i=t==null?void 0:t.heartbeatCallback)!==null&&i!==void 0?i:lue,t!=null&&t.params&&(this.params=t.params),t!=null&&t.logger&&(this.logger=t.logger),(t!=null&&t.logLevel||t!=null&&t.log_level)&&(this.logLevel=t.logLevel||t.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(d=t==null?void 0:t.reconnectAfterMs)!==null&&d!==void 0?d:g=>_dt[g-1]||bdt,this.encode=(m=t==null?void 0:t.encode)!==null&&m!==void 0?m:(g,v)=>v(JSON.stringify(g)),this.decode=(p=t==null?void 0:t.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=t==null?void 0:t.workerUrl}}}class rve extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}}function Wl(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}class kdt extends rve{constructor(t,s,n){super(t),this.name="StorageApiError",this.status=s,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class Jfe extends rve{constructor(t,s){super(t),this.name="StorageUnknownError",this.originalError=s}}const sve=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...s)=>M3(async()=>{const{default:n}=await Promise.resolve().then(()=>yN);return{default:n}},void 0).then(({default:n})=>n(...s)):t=fetch,(...s)=>t(...s)},Ndt=()=>ea(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield M3(()=>Promise.resolve().then(()=>yN),void 0)).Response:Response}),epe=e=>{if(Array.isArray(e))return e.map(s=>epe(s));if(typeof e=="function"||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([s,n])=>{const a=s.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));t[a]=epe(n)}),t},Sdt=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},cue=e=>{var t;return e.msg||e.message||e.error_description||(typeof e.error=="string"?e.error:(t=e.error)===null||t===void 0?void 0:t.message)||JSON.stringify(e)},Cdt=(e,t,s)=>ea(void 0,void 0,void 0,function*(){const n=yield Ndt();e instanceof n&&!(s!=null&&s.noResolveJson)?e.json().then(a=>{const o=e.status||500,l=(a==null?void 0:a.statusCode)||o+"";t(new kdt(cue(a),o,l))}).catch(a=>{t(new Jfe(cue(a),a))}):t(new Jfe(cue(e),e))}),Mdt=(e,t,s,n)=>{const a={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"||!n?a:(Sdt(n)?(a.headers=Object.assign({"Content-Type":"application/json"},t==null?void 0:t.headers),a.body=JSON.stringify(n)):a.body=n,t!=null&&t.duplex&&(a.duplex=t.duplex),Object.assign(Object.assign({},a),s))};function v6(e,t,s,n,a,o){return ea(this,void 0,void 0,function*(){return new Promise((l,i)=>{e(s,Mdt(t,n,a,o)).then(d=>{if(!d.ok)throw d;return n!=null&&n.noResolveJson?d:d.json()}).then(d=>l(d)).catch(d=>Cdt(d,i,n))})})}function qI(e,t,s,n){return ea(this,void 0,void 0,function*(){return v6(e,"GET",t,s,n)})}function Op(e,t,s,n,a){return ea(this,void 0,void 0,function*(){return v6(e,"POST",t,n,a,s)})}function tpe(e,t,s,n,a){return ea(this,void 0,void 0,function*(){return v6(e,"PUT",t,n,a,s)})}function Tdt(e,t,s,n){return ea(this,void 0,void 0,function*(){return v6(e,"HEAD",t,Object.assign(Object.assign({},s),{noResolveJson:!0}),n)})}function nve(e,t,s,n,a){return ea(this,void 0,void 0,function*(){return v6(e,"DELETE",t,n,a,s)})}class Adt{constructor(t,s){this.downloadFn=t,this.shouldThrowOnError=s}then(t,s){return this.execute().then(t,s)}execute(){return ea(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(Wl(t))return{data:null,error:t};throw t}})}}var yRe;class Edt{constructor(t,s){this.downloadFn=t,this.shouldThrowOnError=s,this[yRe]="BlobDownloadBuilder",this.promise=null}asStream(){return new Adt(this.downloadFn,this.shouldThrowOnError)}then(t,s){return this.getPromise().then(t,s)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}execute(){return ea(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(Wl(t))return{data:null,error:t};throw t}})}}yRe=Symbol.toStringTag;const Idt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},CCe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Pdt{constructor(t,s={},n,a){this.shouldThrowOnError=!1,this.url=t,this.headers=s,this.bucketId=n,this.fetch=sve(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(t,s,n,a){return ea(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},CCe),a);let i=Object.assign(Object.assign({},this.headers),t==="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 m=this._removeEmptyFolders(s),p=this._getFinalPath(m),g=yield(t=="PUT"?tpe:Op)(this.fetch,`${this.url}/object/${p}`,o,Object.assign({headers:i},l!=null&&l.duplex?{duplex:l.duplex}:{}));return{data:{path:m,id:g.Id,fullPath:g.Key},error:null}}catch(o){if(this.shouldThrowOnError)throw o;if(Wl(o))return{data:null,error:o};throw o}})}upload(t,s,n){return ea(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",t,s,n)})}uploadToSignedUrl(t,s,n,a){return ea(this,void 0,void 0,function*(){const o=this._removeEmptyFolders(t),l=this._getFinalPath(o),i=new URL(this.url+`/object/upload/sign/${l}`);i.searchParams.set("token",s);try{let d;const m=Object.assign({upsert:CCe.upsert},a),p=Object.assign(Object.assign({},this.headers),{"x-upsert":String(m.upsert)});typeof Blob<"u"&&n instanceof Blob?(d=new FormData,d.append("cacheControl",m.cacheControl),d.append("",n)):typeof FormData<"u"&&n instanceof FormData?(d=n,d.append("cacheControl",m.cacheControl)):(d=n,p["cache-control"]=`max-age=${m.cacheControl}`,p["content-type"]=m.contentType);const g=yield tpe(this.fetch,i.toString(),d,{headers:p});return{data:{path:o,fullPath:g.Key},error:null}}catch(d){if(this.shouldThrowOnError)throw d;if(Wl(d))return{data:null,error:d};throw d}})}createSignedUploadUrl(t,s){return ea(this,void 0,void 0,function*(){try{let n=this._getFinalPath(t);const a=Object.assign({},this.headers);s!=null&&s.upsert&&(a["x-upsert"]="true");const o=yield Op(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 rve("No token returned by API");return{data:{signedUrl:l.toString(),path:t,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Wl(n))return{data:null,error:n};throw n}})}update(t,s,n){return ea(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",t,s,n)})}move(t,s,n){return ea(this,void 0,void 0,function*(){try{return{data:yield Op(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:t,destinationKey:s,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Wl(a))return{data:null,error:a};throw a}})}copy(t,s,n){return ea(this,void 0,void 0,function*(){try{return{data:{path:(yield Op(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:t,destinationKey:s,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Wl(a))return{data:null,error:a};throw a}})}createSignedUrl(t,s,n){return ea(this,void 0,void 0,function*(){try{let a=this._getFinalPath(t),o=yield Op(this.fetch,`${this.url}/object/sign/${a}`,Object.assign({expiresIn:s},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(Wl(a))return{data:null,error:a};throw a}})}createSignedUrls(t,s,n){return ea(this,void 0,void 0,function*(){try{const a=yield Op(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:s,paths:t},{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(Wl(a))return{data:null,error:a};throw a}})}download(t,s){const a=typeof(s==null?void 0:s.transform)<"u"?"render/image/authenticated":"object",o=this.transformOptsToQueryString((s==null?void 0:s.transform)||{}),l=o?`?${o}`:"",i=this._getFinalPath(t),d=()=>qI(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new Edt(d,this.shouldThrowOnError)}info(t){return ea(this,void 0,void 0,function*(){const s=this._getFinalPath(t);try{const n=yield qI(this.fetch,`${this.url}/object/info/${s}`,{headers:this.headers});return{data:epe(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Wl(n))return{data:null,error:n};throw n}})}exists(t){return ea(this,void 0,void 0,function*(){const s=this._getFinalPath(t);try{return yield Tdt(this.fetch,`${this.url}/object/${s}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Wl(n)&&n instanceof Jfe){const a=n.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:n}}throw n}})}getPublicUrl(t,s){const n=this._getFinalPath(t),a=[],o=s!=null&&s.download?`download=${s.download===!0?"":s.download}`:"";o!==""&&a.push(o);const i=typeof(s==null?void 0:s.transform)<"u"?"render/image":"object",d=this.transformOptsToQueryString((s==null?void 0:s.transform)||{});d!==""&&a.push(d);let m=a.join("&");return m!==""&&(m=`?${m}`),{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${n}${m}`)}}}remove(t){return ea(this,void 0,void 0,function*(){try{return{data:yield nve(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:t},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}list(t,s,n){return ea(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Idt),s),{prefix:t||""});return{data:yield Op(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Wl(a))return{data:null,error:a};throw a}})}listV2(t,s){return ea(this,void 0,void 0,function*(){try{const n=Object.assign({},t);return{data:yield Op(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},s),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Wl(n))return{data:null,error:n};throw n}})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const s=[];return t.width&&s.push(`width=${t.width}`),t.height&&s.push(`height=${t.height}`),t.resize&&s.push(`resize=${t.resize}`),t.format&&s.push(`format=${t.format}`),t.quality&&s.push(`quality=${t.quality}`),s.join("&")}}const vRe="2.78.0",_Re={"X-Client-Info":`storage-js/${vRe}`};class Ldt{constructor(t,s={},n,a){this.shouldThrowOnError=!1;const o=new URL(t);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({},_Re),s),this.fetch=sve(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(t){return ea(this,void 0,void 0,function*(){try{const s=this.listBucketOptionsToQueryString(t);return{data:yield qI(this.fetch,`${this.url}/bucket${s}`,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}getBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:yield qI(this.fetch,`${this.url}/bucket/${t}`,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}createBucket(t){return ea(this,arguments,void 0,function*(s,n={public:!1}){try{return{data:yield Op(this.fetch,`${this.url}/bucket`,{id:s,name:s,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(Wl(a))return{data:null,error:a};throw a}})}updateBucket(t,s){return ea(this,void 0,void 0,function*(){try{return{data:yield tpe(this.fetch,`${this.url}/bucket/${t}`,{id:t,name:t,public:s.public,file_size_limit:s.fileSizeLimit,allowed_mime_types:s.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Wl(n))return{data:null,error:n};throw n}})}emptyBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:yield Op(this.fetch,`${this.url}/bucket/${t}/empty`,{},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}deleteBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:yield nve(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}listBucketOptionsToQueryString(t){const s={};return t&&("limit"in t&&(s.limit=String(t.limit)),"offset"in t&&(s.offset=String(t.offset)),t.search&&(s.search=t.search),t.sortColumn&&(s.sortColumn=t.sortColumn),t.sortOrder&&(s.sortOrder=t.sortOrder)),Object.keys(s).length>0?"?"+new URLSearchParams(s).toString():""}}class Ddt{constructor(t,s={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},_Re),s),this.fetch=sve(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:yield Op(this.fetch,`${this.url}/bucket`,{name:t},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}listBuckets(t){return ea(this,void 0,void 0,function*(){try{const s=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&s.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&s.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&s.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&s.set("sortOrder",t.sortOrder),t!=null&&t.search&&s.set("search",t.search);const n=s.toString(),a=n?`${this.url}/bucket?${n}`:`${this.url}/bucket`;return{data:yield qI(this.fetch,a,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}deleteBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:yield nve(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Wl(s))return{data:null,error:s};throw s}})}}const ave={"X-Client-Info":`storage-js/${vRe}`,"Content-Type":"application/json"};class bRe extends Error{constructor(t){super(t),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function Sm(e){return typeof e=="object"&&e!==null&&"__isStorageVectorsError"in e}class due extends bRe{constructor(t,s,n){super(t),this.name="StorageVectorsApiError",this.status=s,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class Odt extends bRe{constructor(t,s){super(t),this.name="StorageVectorsUnknownError",this.originalError=s}}var MCe;(function(e){e.InternalError="InternalError",e.S3VectorConflictException="S3VectorConflictException",e.S3VectorNotFoundException="S3VectorNotFoundException",e.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",e.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",e.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(MCe||(MCe={}));const ive=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...s)=>M3(async()=>{const{default:n}=await Promise.resolve().then(()=>yN);return{default:n}},void 0).then(({default:n})=>n(...s)):t=fetch,(...s)=>t(...s)},Rdt=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},TCe=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),Fdt=(e,t,s)=>ea(void 0,void 0,void 0,function*(){if(e&&typeof e=="object"&&"status"in e&&"ok"in e&&typeof e.status=="number"&&!(s!=null&&s.noResolveJson)){const a=e.status||500,o=e;if(typeof o.json=="function")o.json().then(l=>{const i=(l==null?void 0:l.statusCode)||(l==null?void 0:l.code)||a+"";t(new due(TCe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;t(new due(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;t(new due(i,a,l))}}else t(new Odt(TCe(e),e))}),zdt=(e,t,s,n)=>{const a={method:e,headers:(t==null?void 0:t.headers)||{}};return n?(Rdt(n)?(a.headers=Object.assign({"Content-Type":"application/json"},t==null?void 0:t.headers),a.body=JSON.stringify(n)):a.body=n,Object.assign(Object.assign({},a),s)):a};function Bdt(e,t,s,n,a,o){return ea(this,void 0,void 0,function*(){return new Promise((l,i)=>{e(s,zdt(t,n,a,o)).then(d=>{if(!d.ok)throw d;if(n!=null&&n.noResolveJson)return d;const m=d.headers.get("content-type");return!m||!m.includes("application/json")?{}:d.json()}).then(d=>l(d)).catch(d=>Fdt(d,i,n))})})}function Cm(e,t,s,n,a){return ea(this,void 0,void 0,function*(){return Bdt(e,"POST",t,n,a,s)})}class $dt{constructor(t,s={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},ave),s),this.fetch=ive(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(t){return ea(this,void 0,void 0,function*(){try{return{data:(yield Cm(this.fetch,`${this.url}/CreateIndex`,t,{headers:this.headers}))||{},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}getIndex(t,s){return ea(this,void 0,void 0,function*(){try{return{data:yield Cm(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:t,indexName:s},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Sm(n))return{data:null,error:n};throw n}})}listIndexes(t){return ea(this,void 0,void 0,function*(){try{return{data:yield Cm(this.fetch,`${this.url}/ListIndexes`,t,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}deleteIndex(t,s){return ea(this,void 0,void 0,function*(){try{return{data:(yield Cm(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:t,indexName:s},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Sm(n))return{data:null,error:n};throw n}})}}class Udt{constructor(t,s={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},ave),s),this.fetch=ive(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(t){return ea(this,void 0,void 0,function*(){try{if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:(yield Cm(this.fetch,`${this.url}/PutVectors`,t,{headers:this.headers}))||{},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}getVectors(t){return ea(this,void 0,void 0,function*(){try{return{data:yield Cm(this.fetch,`${this.url}/GetVectors`,t,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}listVectors(t){return ea(this,void 0,void 0,function*(){try{if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return{data:yield Cm(this.fetch,`${this.url}/ListVectors`,t,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}queryVectors(t){return ea(this,void 0,void 0,function*(){try{return{data:yield Cm(this.fetch,`${this.url}/QueryVectors`,t,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}deleteVectors(t){return ea(this,void 0,void 0,function*(){try{if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:(yield Cm(this.fetch,`${this.url}/DeleteVectors`,t,{headers:this.headers}))||{},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}}class Vdt{constructor(t,s={},n){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},ave),s),this.fetch=ive(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:(yield Cm(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:this.headers}))||{},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}getBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:yield Cm(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:t},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}listBuckets(){return ea(this,arguments,void 0,function*(t={}){try{return{data:yield Cm(this.fetch,`${this.url}/ListVectorBuckets`,t,{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}deleteBucket(t){return ea(this,void 0,void 0,function*(){try{return{data:(yield Cm(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:this.headers}))||{},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Sm(s))return{data:null,error:s};throw s}})}}class qdt extends Vdt{constructor(t,s={}){super(t,s.headers||{},s.fetch)}from(t){return new Hdt(this.url,this.headers,t,this.fetch)}}class Hdt extends $dt{constructor(t,s,n,a){super(t,s,a),this.vectorBucketName=n}createIndex(t){const s=Object.create(null,{createIndex:{get:()=>super.createIndex}});return ea(this,void 0,void 0,function*(){return s.createIndex.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName}))})}listIndexes(){const t=Object.create(null,{listIndexes:{get:()=>super.listIndexes}});return ea(this,arguments,void 0,function*(s={}){return t.listIndexes.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName}))})}getIndex(t){const s=Object.create(null,{getIndex:{get:()=>super.getIndex}});return ea(this,void 0,void 0,function*(){return s.getIndex.call(this,this.vectorBucketName,t)})}deleteIndex(t){const s=Object.create(null,{deleteIndex:{get:()=>super.deleteIndex}});return ea(this,void 0,void 0,function*(){return s.deleteIndex.call(this,this.vectorBucketName,t)})}index(t){return new Wdt(this.url,this.headers,this.vectorBucketName,t,this.fetch)}}class Wdt extends Udt{constructor(t,s,n,a,o){super(t,s,o),this.vectorBucketName=n,this.indexName=a}putVectors(t){const s=Object.create(null,{putVectors:{get:()=>super.putVectors}});return ea(this,void 0,void 0,function*(){return s.putVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}getVectors(t){const s=Object.create(null,{getVectors:{get:()=>super.getVectors}});return ea(this,void 0,void 0,function*(){return s.getVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}listVectors(){const t=Object.create(null,{listVectors:{get:()=>super.listVectors}});return ea(this,arguments,void 0,function*(s={}){return t.listVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}queryVectors(t){const s=Object.create(null,{queryVectors:{get:()=>super.queryVectors}});return ea(this,void 0,void 0,function*(){return s.queryVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}deleteVectors(t){const s=Object.create(null,{deleteVectors:{get:()=>super.deleteVectors}});return ea(this,void 0,void 0,function*(){return s.deleteVectors.call(this,Object.assign(Object.assign({},t),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Gdt extends Ldt{constructor(t,s={},n,a){super(t,s,n,a)}from(t){return new Pdt(this.url,this.headers,t,this.fetch)}get vectors(){return new qdt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Ddt(this.url+"/iceberg",this.headers,this.fetch)}}const Kdt="2.78.0";let UA="";typeof Deno<"u"?UA="deno":typeof document<"u"?UA="web":typeof navigator<"u"&&navigator.product==="ReactNative"?UA="react-native":UA="node";const Zdt={"X-Client-Info":`supabase-js-${UA}/${Kdt}`},Ydt={headers:Zdt},Xdt={schema:"public"},Qdt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Jdt={},eut=e=>{let t;return e?t=e:typeof fetch>"u"?t=Y8e:t=fetch,(...s)=>t(...s)},tut=()=>typeof Headers>"u"?X8e:Headers,rut=(e,t,s)=>{const n=eut(s),a=tut();return async(o,l)=>{var i;const d=(i=await t())!==null&&i!==void 0?i:e;let m=new a(l==null?void 0:l.headers);return m.has("apikey")||m.set("apikey",e),m.has("Authorization")||m.set("Authorization",`Bearer ${d}`),n(o,Object.assign(Object.assign({},l),{headers:m}))}};function sut(e){return e.endsWith("/")?e:e+"/"}function nut(e,t){var s,n;const{db:a,auth:o,realtime:l,global:i}=e,{db:d,auth:m,realtime:p,global:g}=t,v={db:Object.assign(Object.assign({},d),a),auth:Object.assign(Object.assign({},m),o),realtime:Object.assign(Object.assign({},p),l),storage:{},global:Object.assign(Object.assign(Object.assign({},g),i),{headers:Object.assign(Object.assign({},(s=g==null?void 0:g.headers)!==null&&s!==void 0?s:{}),(n=i==null?void 0:i.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return e.accessToken?v.accessToken=e.accessToken:delete v.accessToken,v}function aut(e){const t=e==null?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(sut(t))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const wRe="2.78.0",EC=30*1e3,rpe=3,uue=rpe*EC,iut="http://localhost:9999",out="supabase.auth.token",lut={"X-Client-Info":`gotrue-js/${wRe}`},spe="X-Supabase-Api-Version",jRe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},cut=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,dut=10*60*1e3;class HI extends Error{constructor(t,s,n){super(t),this.__isAuthError=!0,this.name="AuthError",this.status=s,this.code=n}}function ga(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class uut extends HI{constructor(t,s,n){super(t,s,n),this.name="AuthApiError",this.status=s,this.code=n}}function hut(e){return ga(e)&&e.name==="AuthApiError"}class Lj extends HI{constructor(t,s){super(t),this.name="AuthUnknownError",this.originalError=s}}class r_ extends HI{constructor(t,s,n,a){super(t,n,a),this.name=s,this.status=n}}class Ap extends r_{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function mut(e){return ga(e)&&e.name==="AuthSessionMissingError"}class hC extends r_{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class kO extends r_{constructor(t){super(t,"AuthInvalidCredentialsError",400,void 0)}}class NO extends r_{constructor(t,s=null){super(t,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=s}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function fut(e){return ga(e)&&e.name==="AuthImplicitGrantRedirectError"}class ACe extends r_{constructor(t,s=null){super(t,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=s}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class npe extends r_{constructor(t,s){super(t,"AuthRetryableFetchError",s,void 0)}}function hue(e){return ga(e)&&e.name==="AuthRetryableFetchError"}class ECe extends r_{constructor(t,s,n){super(t,"AuthWeakPasswordError",s,"weak_password"),this.reasons=n}}class ape extends r_{constructor(t){super(t,"AuthInvalidJwtError",400,"invalid_jwt")}}const sse="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),ICe=` \r=`.split(""),put=(()=>{const e=new Array(128);for(let t=0;t=6;){const n=t.queue>>t.queuedBits-6&63;s(sse[n]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const n=t.queue>>t.queuedBits-6&63;s(sse[n]),t.queuedBits-=6}}function kRe(e,t,s){const n=put[e];if(n>-1)for(t.queue=t.queue<<6|n,t.queuedBits+=6;t.queuedBits>=8;)s(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function LCe(e){const t=[],s=l=>{t.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{yut(l,n,s)};for(let l=0;l>6),t(128|e&63);return}else if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|e&63);return}else if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function xut(e,t){for(let s=0;s55295&&n<=56319){const a=(n-55296)*1024&65535;n=(e.charCodeAt(s+1)-56320&65535|a)+65536,s+=1}gut(n,t)}}function yut(e,t,s){if(t.utf8seq===0){if(e<=127){s(e);return}for(let n=1;n<6;n+=1)if(!(e>>7-n&1)){t.utf8seq=n;break}if(t.utf8seq===2)t.codepoint=e&31;else if(t.utf8seq===3)t.codepoint=e&15;else if(t.utf8seq===4)t.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|e&63,t.utf8seq-=1,t.utf8seq===0&&s(t.codepoint)}}function W4(e){const t=[],s={queue:0,queuedBits:0},n=a=>{t.push(a)};for(let a=0;at.push(s)),new Uint8Array(t)}function Uj(e){const t=[],s={queue:0,queuedBits:0},n=a=>{t.push(a)};return e.forEach(a=>PCe(a,s,n)),PCe(null,s,n),t.join("")}function _ut(e){return Math.round(Date.now()/1e3)+e}function but(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}const sh=()=>typeof window<"u"&&typeof document<"u",ab={tested:!1,writable:!1},NRe=()=>{if(!sh())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(ab.tested)return ab.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),ab.tested=!0,ab.writable=!0}catch{ab.tested=!0,ab.writable=!1}return ab.writable};function wut(e){const t={},s=new URL(e);if(s.hash&&s.hash[0]==="#")try{new URLSearchParams(s.hash.substring(1)).forEach((a,o)=>{t[o]=a})}catch{}return s.searchParams.forEach((n,a)=>{t[a]=n}),t}const SRe=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...s)=>M3(async()=>{const{default:n}=await Promise.resolve().then(()=>yN);return{default:n}},void 0).then(({default:n})=>n(...s)):t=fetch,(...s)=>t(...s)},jut=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",IC=async(e,t,s)=>{await e.setItem(t,JSON.stringify(s))},ib=async(e,t)=>{const s=await e.getItem(t);if(!s)return null;try{return JSON.parse(s)}catch{return s}},dv=async(e,t)=>{await e.removeItem(t)};class nie{constructor(){this.promise=new nie.promiseConstructor((t,s)=>{this.resolve=t,this.reject=s})}}nie.promiseConstructor=Promise;function mue(e){const t=e.split(".");if(t.length!==3)throw new ape("Invalid JWT structure");for(let n=0;n{setTimeout(()=>t(null),e)})}function Nut(e,t){return new Promise((n,a)=>{(async()=>{for(let o=0;o<1/0;o++)try{const l=await e(o);if(!t(o,null,l)){n(l);return}}catch(l){if(!t(o,l)){a(l);return}}})()})}function Sut(e){return("0"+e.toString(16)).substr(-2)}function Cut(){const t=new Uint32Array(56);if(typeof crypto>"u"){const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=s.length;let a="";for(let o=0;o<56;o++)a+=s.charAt(Math.floor(Math.random()*n));return a}return crypto.getRandomValues(t),Array.from(t,Sut).join("")}async function Mut(e){const s=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",s),a=new Uint8Array(n);return Array.from(a).map(o=>String.fromCharCode(o)).join("")}async function Tut(e){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."),e;const s=await Mut(e);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function mC(e,t,s=!1){const n=Cut();let a=n;s&&(a+="/PASSWORD_RECOVERY"),await IC(e,`${t}-code-verifier`,a);const o=await Tut(n);return[o,n===o?"plain":"s256"]}const Aut=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function Eut(e){const t=e.headers.get(spe);if(!t||!t.match(Aut))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch{return null}}function Iut(e){if(!e)throw new Error("Missing exp claim");const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error("JWT has expired")}function Put(e){switch(e){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 Lut=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function fC(e){if(!Lut.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function fue(){const e={};return new Proxy(e,{get:(t,s)=>{if(s==="__isUserNotAvailableProxy")return!0;if(typeof s=="symbol"){const n=s.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 "${s}" property of the session object is not supported. Please use getUser() instead.`)},set:(t,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(t,s)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${s}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function Dut(e,t){return new Proxy(e,{get:(s,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(s,n,a)}return!t.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."),t.value=!0),Reflect.get(s,n,a)}})}function DCe(e){return JSON.parse(JSON.stringify(e))}const Cj=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),Out=[502,503,504];async function OCe(e){var t;if(!jut(e))throw new npe(Cj(e),0);if(Out.includes(e.status))throw new npe(Cj(e),e.status);let s;try{s=await e.json()}catch(o){throw new Lj(Cj(o),o)}let n;const a=Eut(e);if(a&&a.getTime()>=jRe["2024-01-01"].timestamp&&typeof s=="object"&&s&&typeof s.code=="string"?n=s.code:typeof s=="object"&&s&&typeof s.error_code=="string"&&(n=s.error_code),n){if(n==="weak_password")throw new ECe(Cj(s),e.status,((t=s.weak_password)===null||t===void 0?void 0:t.reasons)||[]);if(n==="session_not_found")throw new Ap}else if(typeof s=="object"&&s&&typeof s.weak_password=="object"&&s.weak_password&&Array.isArray(s.weak_password.reasons)&&s.weak_password.reasons.length&&s.weak_password.reasons.reduce((o,l)=>o&&typeof l=="string",!0))throw new ECe(Cj(s),e.status,s.weak_password.reasons);throw new uut(Cj(s),e.status||500,n)}const Rut=(e,t,s,n)=>{const a={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},t==null?void 0:t.headers),a.body=JSON.stringify(n),Object.assign(Object.assign({},a),s))};async function Ga(e,t,s,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[spe]||(o[spe]=jRe["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 Fut(e,t,s+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 Fut(e,t,s,n,a,o){const l=Rut(t,n,a,o);let i;try{i=await e(s,Object.assign({},l))}catch(d){throw console.error(d),new npe(Cj(d),0)}if(i.ok||await OCe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(d){await OCe(d)}}function Ep(e){var t;let s=null;$ut(e)&&(s=Object.assign({},e),e.expires_at||(s.expires_at=_ut(e.expires_in)));const n=(t=e.user)!==null&&t!==void 0?t:e;return{data:{session:s,user:n},error:null}}function RCe(e){const t=Ep(e);return!t.error&&e.weak_password&&typeof e.weak_password=="object"&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&typeof e.weak_password.message=="string"&&e.weak_password.reasons.reduce((s,n)=>s&&typeof n=="string",!0)&&(t.data.weak_password=e.weak_password),t}function Rv(e){var t;return{data:{user:(t=e.user)!==null&&t!==void 0?t:e},error:null}}function zut(e){return{data:e,error:null}}function But(e){const{action_link:t,email_otp:s,hashed_token:n,redirect_to:a,verification_type:o}=e,l=t_(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),i={action_link:t,email_otp:s,hashed_token:n,redirect_to:a,verification_type:o},d=Object.assign({},l);return{data:{properties:i,user:d},error:null}}function FCe(e){return e}function $ut(e){return e.access_token&&e.refresh_token&&e.expires_in}const pue=["global","local","others"];class Uut{constructor({url:t="",headers:s={},fetch:n}){this.url=t,this.headers=s,this.fetch=SRe(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(t,s=pue[0]){if(pue.indexOf(s)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${pue.join(", ")}`);try{return await Ga(this.fetch,"POST",`${this.url}/logout?scope=${s}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(n){if(ga(n))return{data:null,error:n};throw n}}async inviteUserByEmail(t,s={}){try{return await Ga(this.fetch,"POST",`${this.url}/invite`,{body:{email:t,data:s.data},headers:this.headers,redirectTo:s.redirectTo,xform:Rv})}catch(n){if(ga(n))return{data:{user:null},error:n};throw n}}async generateLink(t){try{const{options:s}=t,n=t_(t,["options"]),a=Object.assign(Object.assign({},n),s);return"newEmail"in n&&(a.new_email=n==null?void 0:n.newEmail,delete a.newEmail),await Ga(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:But,redirectTo:s==null?void 0:s.redirectTo})}catch(s){if(ga(s))return{data:{properties:null,user:null},error:s};throw s}}async createUser(t){try{return await Ga(this.fetch,"POST",`${this.url}/admin/users`,{body:t,headers:this.headers,xform:Rv})}catch(s){if(ga(s))return{data:{user:null},error:s};throw s}}async listUsers(t){var s,n,a,o,l,i,d;try{const m={nextPage:null,lastPage:0,total:0},p=await Ga(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(s=t==null?void 0:t.page)===null||s===void 0?void 0:s.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=t==null?void 0:t.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:FCe});if(p.error)throw p.error;const g=await p.json(),v=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(k=>{const w=parseInt(k.split(";")[0].split("=")[1].substring(0,1)),S=JSON.parse(k.split(";")[1].split("=")[1]);m[`${S}Page`]=w}),m.total=parseInt(v)),{data:Object.assign(Object.assign({},g),m),error:null}}catch(m){if(ga(m))return{data:{users:[]},error:m};throw m}}async getUserById(t){fC(t);try{return await Ga(this.fetch,"GET",`${this.url}/admin/users/${t}`,{headers:this.headers,xform:Rv})}catch(s){if(ga(s))return{data:{user:null},error:s};throw s}}async updateUserById(t,s){fC(t);try{return await Ga(this.fetch,"PUT",`${this.url}/admin/users/${t}`,{body:s,headers:this.headers,xform:Rv})}catch(n){if(ga(n))return{data:{user:null},error:n};throw n}}async deleteUser(t,s=!1){fC(t);try{return await Ga(this.fetch,"DELETE",`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:s},xform:Rv})}catch(n){if(ga(n))return{data:{user:null},error:n};throw n}}async _listFactors(t){fC(t.userId);try{const{data:s,error:n}=await Ga(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:s,error:n}}catch(s){if(ga(s))return{data:null,error:s};throw s}}async _deleteFactor(t){fC(t.userId),fC(t.id);try{return{data:await Ga(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(s){if(ga(s))return{data:null,error:s};throw s}}async _listOAuthClients(t){var s,n,a,o,l,i,d;try{const m={nextPage:null,lastPage:0,total:0},p=await Ga(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(s=t==null?void 0:t.page)===null||s===void 0?void 0:s.toString())!==null&&n!==void 0?n:"",per_page:(o=(a=t==null?void 0:t.perPage)===null||a===void 0?void 0:a.toString())!==null&&o!==void 0?o:""},xform:FCe});if(p.error)throw p.error;const g=await p.json(),v=(l=p.headers.get("x-total-count"))!==null&&l!==void 0?l:0,_=(d=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&d!==void 0?d:[];return _.length>0&&(_.forEach(k=>{const w=parseInt(k.split(";")[0].split("=")[1].substring(0,1)),S=JSON.parse(k.split(";")[1].split("=")[1]);m[`${S}Page`]=w}),m.total=parseInt(v)),{data:Object.assign(Object.assign({},g),m),error:null}}catch(m){if(ga(m))return{data:{clients:[]},error:m};throw m}}async _createOAuthClient(t){try{return await Ga(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:t,headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(ga(s))return{data:null,error:s};throw s}}async _getOAuthClient(t){try{return await Ga(this.fetch,"GET",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(ga(s))return{data:null,error:s};throw s}}async _updateOAuthClient(t,s){try{return await Ga(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${t}`,{body:s,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(ga(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(t){try{return await Ga(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${t}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(s){if(ga(s))return{data:null,error:s};throw s}}async _regenerateOAuthClientSecret(t){try{return await Ga(this.fetch,"POST",`${this.url}/admin/oauth/clients/${t}/regenerate_secret`,{headers:this.headers,xform:s=>({data:s,error:null})})}catch(s){if(ga(s))return{data:null,error:s};throw s}}}function zCe(e={}){return{getItem:t=>e[t]||null,setItem:(t,s)=>{e[t]=s},removeItem:t=>{delete e[t]}}}const pC={debug:!!(globalThis&&NRe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class CRe extends Error{constructor(t){super(t),this.isAcquireTimeout=!0}}class Vut extends CRe{}async function qut(e,t,s){pC.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const n=new globalThis.AbortController;return t>0&&setTimeout(()=>{n.abort(),pC.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,t===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async a=>{if(a){pC.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,a.name);try{return await s()}finally{pC.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,a.name)}}else{if(t===0)throw pC.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new Vut(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(pC.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 s()}}))}function Hut(){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 MRe(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw new Error(`@supabase/auth-js: Address "${e}" is invalid.`);return e.toLowerCase()}function Wut(e){return parseInt(e,16)}function Gut(e){const t=new TextEncoder().encode(e);return"0x"+Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function Kut(e){var t;const{chainId:s,domain:n,expirationTime:a,issuedAt:o=new Date,nonce:l,notBefore:i,requestId:d,resources:m,scheme:p,uri:g,version:v}=e;{if(!Number.isInteger(s))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${s}`);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(!((t=e.statement)===null||t===void 0)&&t.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`)}const _=MRe(e.address),k=p?`${p}://${n}`:n,w=e.statement?`${e.statement} `:"",S=`${k} wants you to sign in with your Ethereum account: ${_} ${w}`;let T=`URI: ${g} Version: ${v} Chain ID: ${s}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(T+=` Expiration Time: ${a.toISOString()}`),i&&(T+=` Not Before: ${i.toISOString()}`),d&&(T+=` Request ID: ${d}`),m){let C=` Resources:`;for(const I of m){if(!I||typeof I!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${I}`);C+=` - ${I}`}T+=C}return`${S} ${T}`}class ed extends Error{constructor({message:t,code:s,cause:n,name:a}){var o;super(t,{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=s}}class nse extends ed{constructor(t,s){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s,message:t}),this.name="WebAuthnUnknownError",this.originalError=s}}function Zut({error:e,options:t}){var s,n,a;const{publicKey:o}=t;if(!o)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new ed({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if(e.name==="ConstraintError"){if(((s=o.authenticatorSelection)===null||s===void 0?void 0:s.requireResidentKey)===!0)return new ed({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});if(t.mediation==="conditional"&&((n=o.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new ed({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});if(((a=o.authenticatorSelection)===null||a===void 0?void 0:a.userVerification)==="required")return new ed({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else{if(e.name==="InvalidStateError")return new ed({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});if(e.name==="NotAllowedError")return new ed({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="NotSupportedError")return o.pubKeyCredParams.filter(i=>i.type==="public-key").length===0?new ed({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}):new ed({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});if(e.name==="SecurityError"){const l=window.location.hostname;if(TRe(l)){if(o.rp.id!==l)return new ed({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new ed({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="TypeError"){if(o.user.id.byteLength<1||o.user.id.byteLength>64)return new ed({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if(e.name==="UnknownError")return new ed({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new ed({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}function Yut({error:e,options:t}){const{publicKey:s}=t;if(!s)throw Error("options was missing required publicKey property");if(e.name==="AbortError"){if(t.signal instanceof AbortSignal)return new ed({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else{if(e.name==="NotAllowedError")return new ed({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});if(e.name==="SecurityError"){const n=window.location.hostname;if(TRe(n)){if(s.rpId!==n)return new ed({message:`The RP ID "${s.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else return new ed({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e})}else if(e.name==="UnknownError")return new ed({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e})}return new ed({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}class Xut{createNewAbortSignal(){if(this.controller){const s=new Error("Cancelling existing WebAuthn API call for new one");s.name="AbortError",this.controller.abort(s)}const t=new AbortController;return this.controller=t,t.signal}cancelCeremony(){if(this.controller){const t=new Error("Manually cancelling existing WebAuthn API call");t.name="AbortError",this.controller.abort(t),this.controller=void 0}}}const Qut=new Xut;function Jut(e){if(!e)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(e);const{challenge:t,user:s,excludeCredentials:n}=e,a=t_(e,["challenge","user","excludeCredentials"]),o=W4(t).buffer,l=Object.assign(Object.assign({},s),{id:W4(s.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(s.length);for(let l=0;la!==null&&typeof a=="object"&&!Array.isArray(a),s=a=>a instanceof ArrayBuffer||ArrayBuffer.isView(a),n={};for(const a of e)if(a)for(const o in a){const l=a[o];if(l!==void 0)if(Array.isArray(l))n[o]=l;else if(s(l))n[o]=l;else if(t(l)){const i=n[o];t(i)?n[o]=ase(i,l):n[o]=ase(l)}else n[o]=l}return n}function oht(e,t){return ase(aht,e,t||{})}function lht(e,t){return ase(iht,e,t||{})}class cht{constructor(t){this.client=t,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(t){return this.client.mfa.enroll(Object.assign(Object.assign({},t),{factorType:"webauthn"}))}async _challenge({factorId:t,webauthn:s,friendlyName:n,signal:a},o){try{const{data:l,error:i}=await this.client.mfa.challenge({factorId:t,webauthn:s});if(!l)return{data:null,error:i};const d=a??Qut.createNewAbortSignal();if(l.webauthn.type==="create"){const{user:m}=l.webauthn.credential_options.publicKey;m.name||(m.name=`${m.id}:${n}`),m.displayName||(m.displayName=m.name)}switch(l.webauthn.type){case"create":{const m=oht(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:g}=await sht({publicKey:m,signal:d});return p?{data:{factorId:t,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:g}}case"request":{const m=lht(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:g}=await nht(Object.assign(Object.assign({},l.webauthn.credential_options),{publicKey:m,signal:d}));return p?{data:{factorId:t,challengeId:l.id,webauthn:{type:l.webauthn.type,credential_response:p}},error:null}:{data:null,error:g}}}}catch(l){return ga(l)?{data:null,error:l}:{data:null,error:new Lj("Unexpected error in challenge",l)}}}async _verify({challengeId:t,factorId:s,webauthn:n}){return this.client.mfa.verify({factorId:s,challengeId:t,webauthn:n})}async _authenticate({factorId:t,webauthn:{rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a}},o){if(!s)return{data:null,error:new HI("rpId is required for WebAuthn authentication")};try{if(!BCe())return{data:null,error:new Lj("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this.challenge({factorId:t,webauthn:{rpId:s,rpOrigins:n},signal:a},{request:o});if(!l)return{data:null,error:i};const{webauthn:d}=l;return this._verify({factorId:t,challengeId:l.challengeId,webauthn:{type:d.type,rpId:s,rpOrigins:n,credential_response:d.credential_response}})}catch(l){return ga(l)?{data:null,error:l}:{data:null,error:new Lj("Unexpected error in authenticate",l)}}}async _register({friendlyName:t,rpId:s=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:a},o){if(!s)return{data:null,error:new HI("rpId is required for WebAuthn registration")};try{if(!BCe())return{data:null,error:new Lj("Browser does not support WebAuthn",null)};const{data:l,error:i}=await this._enroll({friendlyName:t});if(!l)return await this.client.mfa.listFactors().then(p=>{var g;return(g=p.data)===null||g===void 0?void 0:g.all.find(v=>v.factor_type==="webauthn"&&v.friendly_name===t&&v.status!=="unverified")}).then(p=>p?this.client.mfa.unenroll({factorId:p==null?void 0:p.id}):void 0),{data:null,error:i};const{data:d,error:m}=await this._challenge({factorId:l.id,friendlyName:l.friendly_name,webauthn:{rpId:s,rpOrigins:n},signal:a},{create:o});return d?this._verify({factorId:l.id,challengeId:d.challengeId,webauthn:{rpId:s,rpOrigins:n,type:d.webauthn.type,credential_response:d.webauthn.credential_response}}):{data:null,error:m}}catch(l){return ga(l)?{data:null,error:l}:{data:null,error:new Lj("Unexpected error in register",l)}}}}Hut();const dht={url:iut,storageKey:out,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:lut,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function $Ce(e,t,s){return await s()}const gC={};class WI{get jwks(){var t,s;return(s=(t=gC[this.storageKey])===null||t===void 0?void 0:t.jwks)!==null&&s!==void 0?s:{keys:[]}}set jwks(t){gC[this.storageKey]=Object.assign(Object.assign({},gC[this.storageKey]),{jwks:t})}get jwks_cached_at(){var t,s;return(s=(t=gC[this.storageKey])===null||t===void 0?void 0:t.cachedAt)!==null&&s!==void 0?s:Number.MIN_SAFE_INTEGER}set jwks_cached_at(t){gC[this.storageKey]=Object.assign(Object.assign({},gC[this.storageKey]),{cachedAt:t})}constructor(t){var s,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=WI.nextInstanceID,WI.nextInstanceID+=1,this.instanceID>0&&sh()&&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({},dht),t);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 Uut({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=SRe(a.fetch),this.lock=a.lock||$Ce,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:sh()&&(!((s=globalThis==null?void 0:globalThis.navigator)===null||s===void 0)&&s.locks)?this.lock=qut:this.lock=$Ce,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 cht(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:NRe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=zCe(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=zCe(this.memoryStorage)),sh()&&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(...t){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${wRe}) ${new Date().toISOString()}`,...t),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 t;try{const s=wut(window.location.href);let n="none";if(this._isImplicitGrantCallback(s)?n="implicit":await this._isPKCECallback(s)&&(n="pkce"),sh()&&this.detectSessionInUrl&&n!=="none"){const{data:a,error:o}=await this._getSessionFromURL(s,n);if(o){if(this._debug("#_initialize()","error detecting session from URL",o),fut(o)){const d=(t=o.details)===null||t===void 0?void 0:t.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(s){return ga(s)?{error:s}:{error:new Lj("Unexpected error during initialization",s)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(t){var s,n,a;try{const o=await Ga(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(s=t==null?void 0:t.options)===null||s===void 0?void 0:s.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(a=t==null?void 0:t.options)===null||a===void 0?void 0:a.captchaToken}},xform:Ep}),{data:l,error:i}=o;if(i||!l)return{data:{user:null,session:null},error:i};const d=l.session,m=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:m,session:d},error:null}}catch(o){if(ga(o))return{data:{user:null,session:null},error:o};throw o}}async signUp(t){var s,n,a;try{let o;if("email"in t){const{email:p,password:g,options:v}=t;let _=null,k=null;this.flowType==="pkce"&&([_,k]=await mC(this.storage,this.storageKey)),o=await Ga(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:v==null?void 0:v.emailRedirectTo,body:{email:p,password:g,data:(s=v==null?void 0:v.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:v==null?void 0:v.captchaToken},code_challenge:_,code_challenge_method:k},xform:Ep})}else if("phone"in t){const{phone:p,password:g,options:v}=t;o=await Ga(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:p,password:g,data:(n=v==null?void 0:v.data)!==null&&n!==void 0?n:{},channel:(a=v==null?void 0:v.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:v==null?void 0:v.captchaToken}},xform:Ep})}else throw new kO("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,m=l.user;return l.session&&(await this._saveSession(l.session),await this._notifyAllSubscribers("SIGNED_IN",d)),{data:{user:m,session:d},error:null}}catch(o){if(ga(o))return{data:{user:null,session:null},error:o};throw o}}async signInWithPassword(t){try{let s;if("email"in t){const{email:o,password:l,options:i}=t;s=await Ga(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:RCe})}else if("phone"in t){const{phone:o,password:l,options:i}=t;s=await Ga(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:RCe})}else throw new kO("You must provide either an email or phone number and a password");const{data:n,error:a}=s;return a?{data:{user:null,session:null},error:a}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new hC}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:a})}catch(s){if(ga(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithOAuth(t){var s,n,a,o;return await this._handleProviderSignIn(t.provider,{redirectTo:(s=t.options)===null||s===void 0?void 0:s.redirectTo,scopes:(n=t.options)===null||n===void 0?void 0:n.scopes,queryParams:(a=t.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(o=t.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(t){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(t))}async signInWithWeb3(t){const{chain:s}=t;switch(s){case"ethereum":return await this.signInWithEthereum(t);case"solana":return await this.signInWithSolana(t);default:throw new Error(`@supabase/auth-js: Unsupported chain "${s}"`)}}async signInWithEthereum(t){var s,n,a,o,l,i,d,m,p,g,v;let _,k;if("message"in t)_=t.message,k=t.signature;else{const{chain:w,wallet:S,statement:T,options:C}=t;let I;if(sh())if(typeof S=="object")I=S;else{const W=window;if("ethereum"in W&&typeof W.ethereum=="object"&&"request"in W.ethereum&&typeof W.ethereum.request=="function")I=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 S!="object"||!(C!=null&&C.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");I=S}const R=new URL((s=C==null?void 0:C.url)!==null&&s!==void 0?s:window.location.href),D=await I.request({method:"eth_requestAccounts"}).then(W=>W).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!D||D.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const B=MRe(D[0]);let $=(n=C==null?void 0:C.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!$){const W=await I.request({method:"eth_chainId"});$=Wut(W)}const q={domain:R.host,address:B,statement:T,uri:R.href,version:"1",chainId:$,nonce:(a=C==null?void 0:C.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=C==null?void 0:C.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=C==null?void 0:C.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(d=C==null?void 0:C.signInWithEthereum)===null||d===void 0?void 0:d.notBefore,requestId:(m=C==null?void 0:C.signInWithEthereum)===null||m===void 0?void 0:m.requestId,resources:(p=C==null?void 0:C.signInWithEthereum)===null||p===void 0?void 0:p.resources};_=Kut(q),k=await I.request({method:"personal_sign",params:[Gut(_),B]})}try{const{data:w,error:S}=await Ga(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:_,signature:k},!((g=t.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(v=t.options)===null||v===void 0?void 0:v.captchaToken}}:null),xform:Ep});if(S)throw S;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new hC}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:S})}catch(w){if(ga(w))return{data:{user:null,session:null},error:w};throw w}}async signInWithSolana(t){var s,n,a,o,l,i,d,m,p,g,v,_;let k,w;if("message"in t)k=t.message,w=t.signature;else{const{chain:S,wallet:T,statement:C,options:I}=t;let R;if(sh())if(typeof T=="object")R=T;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"))R=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 T!="object"||!(I!=null&&I.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");R=T}const D=new URL((s=I==null?void 0:I.url)!==null&&s!==void 0?s:window.location.href);if("signIn"in R&&R.signIn){const B=await R.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},I==null?void 0:I.signInWithSolana),{version:"1",domain:D.host,uri:D.href}),C?{statement:C}: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)k=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 R)||typeof R.signMessage!="function"||!("publicKey"in R)||typeof R!="object"||!R.publicKey||!("toBase58"in R.publicKey)||typeof R.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");k=[`${D.host} wants you to sign in with your Solana account:`,R.publicKey.toBase58(),...C?["",C,""]:[""],"Version: 1",`URI: ${D.href}`,`Issued At: ${(a=(n=I==null?void 0:I.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((o=I==null?void 0:I.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${I.signInWithSolana.notBefore}`]:[],...!((l=I==null?void 0:I.signInWithSolana)===null||l===void 0)&&l.expirationTime?[`Expiration Time: ${I.signInWithSolana.expirationTime}`]:[],...!((i=I==null?void 0:I.signInWithSolana)===null||i===void 0)&&i.chainId?[`Chain ID: ${I.signInWithSolana.chainId}`]:[],...!((d=I==null?void 0:I.signInWithSolana)===null||d===void 0)&&d.nonce?[`Nonce: ${I.signInWithSolana.nonce}`]:[],...!((m=I==null?void 0:I.signInWithSolana)===null||m===void 0)&&m.requestId?[`Request ID: ${I.signInWithSolana.requestId}`]:[],...!((g=(p=I==null?void 0:I.signInWithSolana)===null||p===void 0?void 0:p.resources)===null||g===void 0)&&g.length?["Resources",...I.signInWithSolana.resources.map($=>`- ${$}`)]:[]].join(` `);const B=await R.signMessage(new TextEncoder().encode(k),"utf8");if(!B||!(B instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");w=B}}try{const{data:S,error:T}=await Ga(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:k,signature:Uj(w)},!((v=t.options)===null||v===void 0)&&v.captchaToken?{gotrue_meta_security:{captcha_token:(_=t.options)===null||_===void 0?void 0:_.captchaToken}}:null),xform:Ep});if(T)throw T;return!S||!S.session||!S.user?{data:{user:null,session:null},error:new hC}:(S.session&&(await this._saveSession(S.session),await this._notifyAllSubscribers("SIGNED_IN",S.session)),{data:Object.assign({},S),error:T})}catch(S){if(ga(S))return{data:{user:null,session:null},error:S};throw S}}async _exchangeCodeForSession(t){const s=await ib(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(s??"").split("/");try{const{data:o,error:l}=await Ga(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:t,code_verifier:n},xform:Ep});if(await dv(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new hC}:(o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),{data:Object.assign(Object.assign({},o),{redirectType:a??null}),error:l})}catch(o){if(ga(o))return{data:{user:null,session:null,redirectType:null},error:o};throw o}}async signInWithIdToken(t){try{const{options:s,provider:n,token:a,access_token:o,nonce:l}=t,i=await Ga(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:s==null?void 0:s.captchaToken}},xform:Ep}),{data:d,error:m}=i;return m?{data:{user:null,session:null},error:m}:!d||!d.session||!d.user?{data:{user:null,session:null},error:new hC}:(d.session&&(await this._saveSession(d.session),await this._notifyAllSubscribers("SIGNED_IN",d.session)),{data:d,error:m})}catch(s){if(ga(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithOtp(t){var s,n,a,o,l;try{if("email"in t){const{email:i,options:d}=t;let m=null,p=null;this.flowType==="pkce"&&([m,p]=await mC(this.storage,this.storageKey));const{error:g}=await Ga(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:i,data:(s=d==null?void 0:d.data)!==null&&s!==void 0?s:{},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:m,code_challenge_method:p},redirectTo:d==null?void 0:d.emailRedirectTo});return{data:{user:null,session:null},error:g}}if("phone"in t){const{phone:i,options:d}=t,{data:m,error:p}=await Ga(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:m==null?void 0:m.message_id},error:p}}throw new kO("You must provide either an email or phone number.")}catch(i){if(ga(i))return{data:{user:null,session:null},error:i};throw i}}async verifyOtp(t){var s,n;try{let a,o;"options"in t&&(a=(s=t.options)===null||s===void 0?void 0:s.redirectTo,o=(n=t.options)===null||n===void 0?void 0:n.captchaToken);const{data:l,error:i}=await Ga(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},t),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:Ep});if(i)throw i;if(!l)throw new Error("An error occurred on token verification.");const d=l.session,m=l.user;return d!=null&&d.access_token&&(await this._saveSession(d),await this._notifyAllSubscribers(t.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",d)),{data:{user:m,session:d},error:null}}catch(a){if(ga(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithSSO(t){var s,n,a;try{let o=null,l=null;return this.flowType==="pkce"&&([o,l]=await mC(this.storage,this.storageKey)),await Ga(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in t?{provider_id:t.providerId}:null),"domain"in t?{domain:t.domain}:null),{redirect_to:(n=(s=t.options)===null||s===void 0?void 0:s.redirectTo)!==null&&n!==void 0?n:void 0}),!((a=t==null?void 0:t.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:t.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:o,code_challenge_method:l}),headers:this.headers,xform:zut})}catch(o){if(ga(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 t=>{const{data:{session:s},error:n}=t;if(n)throw n;if(!s)throw new Ap;const{error:a}=await Ga(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:s.access_token});return{data:{user:null,session:null},error:a}})}catch(t){if(ga(t))return{data:{user:null,session:null},error:t};throw t}}async resend(t){try{const s=`${this.url}/resend`;if("email"in t){const{email:n,type:a,options:o}=t,{error:l}=await Ga(this.fetch,"POST",s,{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 t){const{phone:n,type:a,options:o}=t,{data:l,error:i}=await Ga(this.fetch,"POST",s,{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 kO("You must provide either an email or phone number and a type")}catch(s){if(ga(s))return{data:{user:null,session:null},error:s};throw s}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async s=>s))}async _acquireLock(t,s){this._debug("#_acquireLock","begin",t);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),a=(async()=>(await n,await s()))();return this.pendingInLock.push((async()=>{try{await a}catch{}})()),a}return await this.lock(`lock:${this.storageKey}`,t,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=s();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(t){this._debug("#_useSession","begin");try{const s=await this.__loadSession();return await t(s)}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 t=null;const s=await ib(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",s),s!==null&&(this._isValidSession(s)?t=s:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!t)return{data:{session:null},error:null};const n=t.expires_at?t.expires_at*1e3-Date.now()await this._getUser()))}async _getUser(t){try{return t?await Ga(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:t,xform:Rv}):await this._useSession(async s=>{var n,a,o;const{data:l,error:i}=s;if(i)throw i;return!(!((n=l.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Ap}:await Ga(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:Rv})})}catch(s){if(ga(s))return mut(s)&&(await this._removeSession(),await dv(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:s};throw s}}async updateUser(t,s={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(t,s))}async _updateUser(t,s={}){try{return await this._useSession(async n=>{const{data:a,error:o}=n;if(o)throw o;if(!a.session)throw new Ap;const l=a.session;let i=null,d=null;this.flowType==="pkce"&&t.email!=null&&([i,d]=await mC(this.storage,this.storageKey));const{data:m,error:p}=await Ga(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:s==null?void 0:s.emailRedirectTo,body:Object.assign(Object.assign({},t),{code_challenge:i,code_challenge_method:d}),jwt:l.access_token,xform:Rv});if(p)throw p;return l.user=m.user,await this._saveSession(l),await this._notifyAllSubscribers("USER_UPDATED",l),{data:{user:l.user},error:null}})}catch(n){if(ga(n))return{data:{user:null},error:n};throw n}}async setSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(t))}async _setSession(t){try{if(!t.access_token||!t.refresh_token)throw new Ap;const s=Date.now()/1e3;let n=s,a=!0,o=null;const{payload:l}=mue(t.access_token);if(l.exp&&(n=l.exp,a=n<=s),a){const{data:i,error:d}=await this._callRefreshToken(t.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(t.access_token);if(d)throw d;o={access_token:t.access_token,refresh_token:t.refresh_token,user:i.user,token_type:"bearer",expires_in:n-s,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return{data:{user:o.user,session:o},error:null}}catch(s){if(ga(s))return{data:{session:null,user:null},error:s};throw s}}async refreshSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(t))}async _refreshSession(t){try{return await this._useSession(async s=>{var n;if(!t){const{data:l,error:i}=s;if(i)throw i;t=(n=l.session)!==null&&n!==void 0?n:void 0}if(!(t!=null&&t.refresh_token))throw new Ap;const{data:a,error:o}=await this._callRefreshToken(t.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(s){if(ga(s))return{data:{user:null,session:null},error:s};throw s}}async _getSessionFromURL(t,s){try{if(!sh())throw new NO("No browser detected.");if(t.error||t.error_description||t.error_code)throw new NO(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});switch(s){case"implicit":if(this.flowType==="pkce")throw new ACe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new NO("Not a valid implicit grant flow url.");break;default:}if(s==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!t.code)throw new ACe("No code detected.");const{data:C,error:I}=await this._exchangeCodeForSession(t.code);if(I)throw I;const R=new URL(window.location.href);return R.searchParams.delete("code"),window.history.replaceState(window.history.state,"",R.toString()),{data:{session:C.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:a,access_token:o,refresh_token:l,expires_in:i,expires_at:d,token_type:m}=t;if(!o||!i||!l||!m)throw new NO("No session defined in URL");const p=Math.round(Date.now()/1e3),g=parseInt(i);let v=p+g;d&&(v=parseInt(d));const _=v-p;_*1e3<=EC&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${_}s, should have been closer to ${g}s`);const k=v-g;p-k>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",k,v,p):p-k<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",k,v,p);const{data:w,error:S}=await this._getUser(o);if(S)throw S;const T={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:g,expires_at:v,refresh_token:l,token_type:m,user:w.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:T,redirectType:t.type},error:null}}catch(n){if(ga(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(t){return!!(t.access_token||t.error_description)}async _isPKCECallback(t){const s=await ib(this.storage,`${this.storageKey}-code-verifier`);return!!(t.code&&s)}async signOut(t={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(t))}async _signOut({scope:t}={scope:"global"}){return await this._useSession(async s=>{var n;const{data:a,error:o}=s;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,t);if(i&&!(hut(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return t!=="others"&&(await this._removeSession(),await dv(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(t){const s=but(),n={id:s,callback:t,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",s),this.stateChangeEmitters.delete(s)}};return this._debug("#onAuthStateChange()","registered callback with id",s),this.stateChangeEmitters.set(s,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(s)})))(),{data:{subscription:n}}}async _emitInitialSession(t){return await this._useSession(async s=>{var n,a;try{const{data:{session:o},error:l}=s;if(l)throw l;await((n=this.stateChangeEmitters.get(t))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",t,"session",o)}catch(o){await((a=this.stateChangeEmitters.get(t))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",t,"error",o),console.error(o)}})}async resetPasswordForEmail(t,s={}){let n=null,a=null;this.flowType==="pkce"&&([n,a]=await mC(this.storage,this.storageKey,!0));try{return await Ga(this.fetch,"POST",`${this.url}/recover`,{body:{email:t,code_challenge:n,code_challenge_method:a,gotrue_meta_security:{captcha_token:s.captchaToken}},headers:this.headers,redirectTo:s.redirectTo})}catch(o){if(ga(o))return{data:null,error:o};throw o}}async getUserIdentities(){var t;try{const{data:s,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(t=s.user.identities)!==null&&t!==void 0?t:[]},error:null}}catch(s){if(ga(s))return{data:null,error:s};throw s}}async linkIdentity(t){return"token"in t?this.linkIdentityIdToken(t):this.linkIdentityOAuth(t)}async linkIdentityOAuth(t){var s;try{const{data:n,error:a}=await this._useSession(async o=>{var l,i,d,m,p;const{data:g,error:v}=o;if(v)throw v;const _=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,t.provider,{redirectTo:(l=t.options)===null||l===void 0?void 0:l.redirectTo,scopes:(i=t.options)===null||i===void 0?void 0:i.scopes,queryParams:(d=t.options)===null||d===void 0?void 0:d.queryParams,skipBrowserRedirect:!0});return await Ga(this.fetch,"GET",_,{headers:this.headers,jwt:(p=(m=g.session)===null||m===void 0?void 0:m.access_token)!==null&&p!==void 0?p:void 0})});if(a)throw a;return sh()&&!(!((s=t.options)===null||s===void 0)&&s.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:t.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(ga(n))return{data:{provider:t.provider,url:null},error:n};throw n}}async linkIdentityIdToken(t){return await this._useSession(async s=>{var n;try{const{error:a,data:{session:o}}=s;if(a)throw a;const{options:l,provider:i,token:d,access_token:m,nonce:p}=t,g=await Ga(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:m,nonce:p,link_identity:!0,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:Ep}),{data:v,error:_}=g;return _?{data:{user:null,session:null},error:_}:!v||!v.session||!v.user?{data:{user:null,session:null},error:new hC}:(v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("USER_UPDATED",v.session)),{data:v,error:_})}catch(a){if(ga(a))return{data:{user:null,session:null},error:a};throw a}})}async unlinkIdentity(t){try{return await this._useSession(async s=>{var n,a;const{data:o,error:l}=s;if(l)throw l;return await Ga(this.fetch,"DELETE",`${this.url}/user/identities/${t.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(s){if(ga(s))return{data:null,error:s};throw s}}async _refreshAccessToken(t){const s=`#_refreshAccessToken(${t.substring(0,5)}...)`;this._debug(s,"begin");try{const n=Date.now();return await Nut(async a=>(a>0&&await kut(200*Math.pow(2,a-1)),this._debug(s,"refreshing attempt",a),await Ga(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:t},headers:this.headers,xform:Ep})),(a,o)=>{const l=200*Math.pow(2,a);return o&&hue(o)&&Date.now()+l-n{try{await i.callback(t,s)}catch(d){o.push(d)}});if(await Promise.all(l),o.length>0){for(let i=0;ithis._autoRefreshTokenTick(),EC);this.autoRefreshTicker=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const t=this.autoRefreshTicker;this.autoRefreshTicker=null,t&&clearInterval(t)}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 t=Date.now();try{return await this._useSession(async s=>{const{data:{session:n}}=s;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const a=Math.floor((n.expires_at*1e3-t)/EC);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${EC}ms, refresh threshold is ${rpe} ticks`),a<=rpe&&await this._callRefreshToken(n.refresh_token)})}catch(s){console.error("Auto refresh tick failed with error. This is likely a transient error.",s)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(t){if(t.isAcquireTimeout||t instanceof CRe)this._debug("auto refresh token tick lock not available");else throw t}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!sh()||!(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(t){console.error("_handleVisibilityChange",t)}}async _onVisibilityChanged(t){const s=`#_onVisibilityChanged(${t})`;this._debug(s,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),t||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(s,"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(t,s,n){const a=[`provider=${encodeURIComponent(s)}`];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 mC(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}`),`${t}?${a.join("&")}`}async _unenroll(t){try{return await this._useSession(async s=>{var n;const{data:a,error:o}=s;return o?{data:null,error:o}:await Ga(this.fetch,"DELETE",`${this.url}/factors/${t.factorId}`,{headers:this.headers,jwt:(n=a==null?void 0:a.session)===null||n===void 0?void 0:n.access_token})})}catch(s){if(ga(s))return{data:null,error:s};throw s}}async _enroll(t){try{return await this._useSession(async s=>{var n,a;const{data:o,error:l}=s;if(l)return{data:null,error:l};const i=Object.assign({friendly_name:t.friendlyName,factor_type:t.factorType},t.factorType==="phone"?{phone:t.phone}:t.factorType==="totp"?{issuer:t.issuer}:{}),{data:d,error:m}=await Ga(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 m?{data:null,error:m}:(t.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(s){if(ga(s))return{data:null,error:s};throw s}}async _verify(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async s=>{var n;const{data:a,error:o}=s;if(o)return{data:null,error:o};const l=Object.assign({challenge_id:t.challengeId},"webauthn"in t?{webauthn:Object.assign(Object.assign({},t.webauthn),{credential_response:t.webauthn.type==="create"?tht(t.webauthn.credential_response):rht(t.webauthn.credential_response)})}:{code:t.code}),{data:i,error:d}=await Ga(this.fetch,"POST",`${this.url}/factors/${t.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(s){if(ga(s))return{data:null,error:s};throw s}})}async _challenge(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async s=>{var n;const{data:a,error:o}=s;if(o)return{data:null,error:o};const l=await Ga(this.fetch,"POST",`${this.url}/factors/${t.factorId}/challenge`,{body:t,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:Jut(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(s){if(ga(s))return{data:null,error:s};throw s}})}async _challengeAndVerify(t){const{data:s,error:n}=await this._challenge({factorId:t.factorId});return n?{data:null,error:n}:await this._verify({factorId:t.factorId,challengeId:s.id,code:t.code})}async _listFactors(){var t;const{data:{user:s},error:n}=await this.getUser();if(n)return{data:null,error:n};const a={all:[],phone:[],totp:[],webauthn:[]};for(const o of(t=s==null?void 0:s.factors)!==null&&t!==void 0?t:[])a.all.push(o),o.status==="verified"&&a[o.factor_type].push(o);return{data:a,error:null}}async _getAuthenticatorAssuranceLevel(){var t,s;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}=mue(n.access_token);let l=null;o.aal&&(l=o.aal);let i=l;((s=(t=n.user.factors)===null||t===void 0?void 0:t.filter(p=>p.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(i="aal2");const m=o.amr||[];return{data:{currentLevel:l,nextLevel:i,currentAuthenticationMethods:m},error:null}}async _getAuthorizationDetails(t){try{return await this._useSession(async s=>{const{data:{session:n},error:a}=s;return a?{data:null,error:a}:n?await Ga(this.fetch,"GET",`${this.url}/oauth/authorizations/${t}`,{headers:this.headers,jwt:n.access_token,xform:o=>({data:o,error:null})}):{data:null,error:new Ap}})}catch(s){if(ga(s))return{data:null,error:s};throw s}}async _approveAuthorization(t,s){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 Ap};const l=await Ga(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"approve"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&sh()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(ga(n))return{data:null,error:n};throw n}}async _denyAuthorization(t,s){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 Ap};const l=await Ga(this.fetch,"POST",`${this.url}/oauth/authorizations/${t}/consent`,{headers:this.headers,jwt:a.access_token,body:{action:"deny"},xform:i=>({data:i,error:null})});return l.data&&l.data.redirect_url&&sh()&&!(s!=null&&s.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(ga(n))return{data:null,error:n};throw n}}async fetchJwk(t,s={keys:[]}){let n=s.keys.find(i=>i.kid===t);if(n)return n;const a=Date.now();if(n=this.jwks.keys.find(i=>i.kid===t),n&&this.jwks_cached_at+dut>a)return n;const{data:o,error:l}=await Ga(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===t),!n)?null:n}async getClaims(t,s={}){try{let n=t;if(!n){const{data:_,error:k}=await this.getSession();if(k||!_.session)return{data:null,error:k};n=_.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:d}}=mue(n);s!=null&&s.allowExpired||Iut(o.exp);const m=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,s!=null&&s.keys?{keys:s.keys}:s==null?void 0:s.jwks);if(!m){const{error:_}=await this.getUser(n);if(_)throw _;return{data:{claims:o,header:a,signature:l},error:null}}const p=Put(a.alg),g=await crypto.subtle.importKey("jwk",m,p,!0,["verify"]);if(!await crypto.subtle.verify(p,g,l,vut(`${i}.${d}`)))throw new ape("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(ga(n))return{data:null,error:n};throw n}}}WI.nextInstanceID=0;const uht=WI;class hht extends uht{constructor(t){super(t)}}class mht{constructor(t,s,n){var a,o,l;this.supabaseUrl=t,this.supabaseKey=s;const i=aut(t);if(!s)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`,m={db:Xdt,realtime:Jdt,auth:Object.assign(Object.assign({},Qdt),{storageKey:d}),global:Ydt},p=nut(n??{},m);this.storageKey=(a=p.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(o=p.global.headers)!==null&&o!==void 0?o:{},p.accessToken?(this.accessToken=p.accessToken,this.auth=new Proxy({},{get:(g,v)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(v)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((l=p.auth)!==null&&l!==void 0?l:{},this.headers,p.global.fetch),this.fetch=rut(s,this._getAccessToken.bind(this),p.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},p.realtime)),this.rest=new idt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new Gdt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new Qct(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,s={},n={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,s,n)}channel(t,s={config:{}}){return this.realtime.channel(t,s)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t,s;if(this.accessToken)return await this.accessToken();const{data:n}=await this.auth.getSession();return(s=(t=n.session)===null||t===void 0?void 0:t.access_token)!==null&&s!==void 0?s:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:s,detectSessionInUrl:n,storage:a,userStorage:o,storageKey:l,flowType:i,lock:d,debug:m},p,g){const v={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new hht({url:this.authUrl.href,headers:Object.assign(Object.assign({},v),p),storageKey:l,autoRefreshToken:t,persistSession:s,detectSessionInUrl:n,storage:a,userStorage:o,flowType:i,lock:d,debug:m,fetch:g,hasCustomAuthorizationHeader:Object.keys(this.headers).some(_=>_.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new jdt(this.realtimeUrl.href,Object.assign(Object.assign({},t),{params:Object.assign({apikey:this.supabaseKey},t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((s,n)=>{this._handleTokenChanged(s,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(t,s,n){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==n?(this.changedAccessToken=n,this.realtime.setAuth(n)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),s=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const fht=(e,t,s)=>new mht(e,t,s);function pht(){if(typeof window<"u"||typeof process>"u")return!1;const e=process.version;if(e==null)return!1;const t=e.match(/^v(\d+)\./);return t?parseInt(t[1],10)<=18:!1}pht()&&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",xht="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",Y=fht(ght,xht,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),ARe=A.createContext(void 0),yht=({children:e})=>{const[t,s]=A.useState(null),[n,a]=A.useState(null),[o,l]=A.useState(!0),[i,d]=A.useState(!1),[m,p]=A.useState(!1),[g,v]=A.useState(null),[_,k]=A.useState([]),[w,S]=A.useState(null),T=Ks(),C=async B=>{try{console.log("Checking roles via RPC for user:",B);const[{data:$,error:q},{data:W,error:K}]=await Promise.all([Y.rpc("has_role",{_user_id:B,_role:"admin"}),Y.rpc("has_role",{_user_id:B,_role:"brokerage_manager"})]);if(q||K)console.error("Role RPC errors:",{isAdminError:q,isBrokerError:K}),d(!1),p(!1);else{const oe=!!$,se=!!W;console.log("RPC roles result:",{adminValue:oe,brokerValue:se}),d(oe),p(se)}const{data:re,error:ae}=await Y.from("profiles").select("brokerage_id").eq("id",B).single();if(v(!ae&&re?re.brokerage_id:null),W){console.log("Fetching managed brokerages for user:",B);const{data:oe,error:se}=await Y.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",B);if(console.log("Managed brokerage assignments result:",{assignments:oe,assignmentsError:se}),se||!oe){console.error("Error fetching managed brokerage assignments:",se),k([]);return}const pe=Array.from(new Set(oe.map(ge=>ge.brokerage_id).filter(Boolean)));if(pe.length===0){k([]);return}const{data:ie,error:de}=await Y.from("brokerages").select("id, name").in("id",pe);if(console.log("Managed brokerages details result:",{brokeragesData:ie,brokeragesError:de}),de||!ie){console.error("Error fetching managed brokerages details:",de),k([]);return}const ce=ie.map(ge=>({id:ge.id,name:ge.name})).sort((ge,Te)=>pe.indexOf(ge.id)-pe.indexOf(Te.id));console.log("Parsed managed brokerages:",ce),k(ce),ce.length>0&&!w&&S(ce[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),k([])}catch($){console.error("Unexpected error in checkRoles:",$),d(!1),p(!1),v(null),k([])}};A.useEffect(()=>{const{data:{subscription:B}}=Y.auth.onAuthStateChange(($,q)=>{console.log("Auth event:",$),a(q),s((q==null?void 0:q.user)??null),$==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{T("/profile?reset=true")},100)),q!=null&&q.user?setTimeout(()=>{C(q.user.id)},0):(d(!1),p(!1),v(null),k([]),S(null))});return Y.auth.getSession().then(({data:{session:$}})=>{a($),s(($==null?void 0:$.user)??null),$!=null&&$.user?C($.user.id).finally(()=>{l(!1)}):l(!1)}),()=>B.unsubscribe()},[]);const I=async(B,$)=>{const{error:q}=await Y.auth.signInWithPassword({email:B,password:$});if(q)throw we.error(q.message),q;we.success("Welcome back!"),T("/dashboard")},R=async(B,$,q)=>{const W=`${window.location.origin}/dashboard`,{error:K}=await Y.auth.signUp({email:B,password:$,options:{emailRedirectTo:W,data:{name:q}}});if(K)throw we.error(K.message),K;we.success("Account created! Welcome to LevelUp."),T("/dashboard")},D=async()=>{try{const{data:{session:B}}=await Y.auth.getSession();if(B){const{error:$}=await Y.auth.signOut();$?$.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",$.message):(console.error("Sign out error:",$),we.error($.message)):we.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");s(null),a(null),d(!1),p(!1),v(null),k([]),S(null),T("/auth")}catch(B){console.error("Unexpected sign out error:",B),T("/auth")}};return r.jsx(ARe.Provider,{value:{user:t,session:n,loading:o,signIn:I,signUp:R,signOut:D,isAdmin:i,isBrokerageManager:m,brokerageId:g,managedBrokerages:_,selectedBrokerageId:w,setSelectedBrokerageId:S},children:e})},Gr=()=>{const e=A.useContext(ARe);if(e===void 0)throw new Error("useAuth must be used within an AuthProvider");return e},ERe=A.createContext(void 0),ob="levelup_admin_session",uv="levelup_impersonation",vht=({children:e})=>{const[t,s]=A.useState(!1),[n,a]=A.useState(null),[o,l]=A.useState(!1);A.useEffect(()=>{const m=sessionStorage.getItem(uv);if(m)try{const p=JSON.parse(m);s(!0),a(p)}catch{sessionStorage.removeItem(uv)}},[]);const i=async m=>{l(!0);try{const{data:{session:p}}=await Y.auth.getSession();if(!p)return we.error("No active session found"),!1;const g={access_token:p.access_token,refresh_token:p.refresh_token};sessionStorage.setItem(ob,JSON.stringify(g));const v=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p.access_token}`},body:JSON.stringify({targetUserId:m})}),_=await v.json();if(!v.ok)throw new Error(_.error||"Failed to impersonate user");const k={id:_.targetUser.id,name:_.targetUser.name,email:_.targetUser.email};if(sessionStorage.setItem(uv,JSON.stringify(k)),_.method==="session"){const{error:w}=await Y.auth.setSession({access_token:_.access_token,refresh_token:_.refresh_token});if(w)throw console.error("Set session error:",w),sessionStorage.removeItem(ob),sessionStorage.removeItem(uv),new Error("Failed to establish impersonation session")}else{const w=_.type||"recovery",{error:S}=await Y.auth.verifyOtp({token_hash:_.token_hash,type:w});if(S)throw console.error("Verify OTP error:",S),sessionStorage.removeItem(ob),sessionStorage.removeItem(uv),new Error("Failed to establish impersonation session")}return s(!0),a(k),we.success(`Now viewing as ${k.name}`),window.location.href="/dashboard",!0}catch(p){return console.error("Impersonation error:",p),we.error(p.message||"Failed to impersonate user"),sessionStorage.removeItem(ob),sessionStorage.removeItem(uv),!1}finally{l(!1)}},d=async()=>{l(!0);try{const m=sessionStorage.getItem(ob);if(!m){await Y.auth.signOut(),window.location.href="/auth";return}const p=JSON.parse(m);await Y.auth.signOut();const{error:g}=await Y.auth.setSession({access_token:p.access_token,refresh_token:p.refresh_token});if(sessionStorage.removeItem(ob),sessionStorage.removeItem(uv),g){console.error("Failed to restore admin session:",g),we.error("Admin session expired, please sign in again"),window.location.href="/auth";return}s(!1),a(null),we.success("Returned to admin account"),window.location.href="/admin/members"}catch(m){console.error("Stop impersonation error:",m),we.error("Failed to restore admin session"),sessionStorage.removeItem(ob),sessionStorage.removeItem(uv),window.location.href="/auth"}finally{l(!1)}};return r.jsx(ERe.Provider,{value:{isImpersonating:t,impersonatedUser:n,startImpersonation:i,stopImpersonation:d,isLoading:o},children:e})},ove=()=>{const e=A.useContext(ERe);if(e===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return e},GI=_3("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"}}),X=A.forwardRef(({className:e,variant:t,size:s,asChild:n=!1,...a},o)=>{const l=n?S0e:"button";return r.jsx(l,{className:Vt(GI({variant:t,size:s,className:e})),ref:o,...a})});X.displayName="Button";const _ht=()=>{const{isImpersonating:e,impersonatedUser:t,stopImpersonation:s,isLoading:n}=ove();return!e||!t?null:r.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:r.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ch,{className:"h-5 w-5 flex-shrink-0"}),r.jsxs("span",{className:"font-medium text-sm md:text-base",children:[r.jsx("span",{className:"hidden sm:inline",children:"You are viewing as "}),r.jsx("strong",{children:t.name}),r.jsxs("span",{className:"hidden md:inline text-amber-800",children:[" (",t.email,")"]})]})]}),r.jsx(X,{size:"sm",variant:"secondary",onClick:s,disabled:n,className:"bg-amber-100 hover:bg-amber-200 text-amber-950 border-0",children:n?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsxs(r.Fragment,{children:[r.jsx(Xs,{className:"h-4 w-4 mr-1"}),r.jsx("span",{className:"hidden sm:inline",children:"Exit Impersonation"}),r.jsx("span",{className:"sm:hidden",children:"Exit"})]})})]})})},IRe=A.createContext(void 0),uA="levelup_acting_as",bht=({children:e})=>{const{user:t}=Gr(),[s,n]=A.useState(!1),[a,o]=A.useState([]),[l,i]=A.useState(null),[d,m]=A.useState({}),[p,g]=A.useState(!0);A.useEffect(()=>{if(!(t!=null&&t.id)){n(!1),o([]),i(null),m({}),g(!1);return}(async()=>{g(!0);try{const{data:S}=await Y.rpc("has_role",{_user_id:t.id,_role:"assistant"});if(!S){n(!1),o([]),i(null),m({}),g(!1);return}n(!0);const{data:T,error:C}=await Y.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",t.id);if(C||!T||T.length===0){o([]),g(!1);return}const I=T.map($=>$.agent_id),{data:R}=await Y.from("profiles").select("id, name, email, avatar_url").in("id",I),D=(R||[]).map($=>({id:$.id,name:$.name||$.email||"Unknown",email:$.email||"",avatar_url:$.avatar_url}));o(D);const B=sessionStorage.getItem(uA);if(B){const $=D.find(q=>q.id===B);if($){i($);const q=T.find(W=>W.agent_id===B);m((q==null?void 0:q.permissions)||{})}else if(D.length>0){i(D[0]);const q=T.find(W=>W.agent_id===D[0].id);m((q==null?void 0:q.permissions)||{}),sessionStorage.setItem(uA,D[0].id)}}else if(D.length>0){i(D[0]);const $=T.find(q=>q.agent_id===D[0].id);m(($==null?void 0:$.permissions)||{}),sessionStorage.setItem(uA,D[0].id)}}catch(S){console.error("Error loading assistant data:",S)}finally{g(!1)}})()},[t==null?void 0:t.id]);const v=w=>{i(w),w?(sessionStorage.setItem(uA,w.id),Y.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(t==null?void 0:t.id)||"").eq("agent_id",w.id).single().then(({data:S})=>{m((S==null?void 0:S.permissions)||{})})):(sessionStorage.removeItem(uA),m({}))},_=w=>s?d[w]===!0:!0,k=s&&l?l.id:(t==null?void 0:t.id)||null;return r.jsx(IRe.Provider,{value:{isAssistant:s,assignedAgents:a,actingAsAgent:l,setActingAsAgent:v,effectiveUserId:k,permissions:d,hasPermission:_,isLoading:p},children:e})},lve=()=>{const e=A.useContext(IRe);if(e===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return e},fl=()=>{const{effectiveUserId:e}=lve();return e};var PRe={exports:{}},LRe={};/** * @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 A5=A;function wht(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jht=typeof Object.is=="function"?Object.is:wht,kht=A5.useState,Nht=A5.useEffect,Sht=A5.useLayoutEffect,Cht=A5.useDebugValue;function Mht(e,t){var s=t(),n=kht({inst:{value:s,getSnapshot:t}}),a=n[0].inst,o=n[1];return Sht(function(){a.value=s,a.getSnapshot=t,gue(a)&&o({inst:a})},[e,s,t]),Nht(function(){return gue(a)&&o({inst:a}),e(function(){gue(a)&&o({inst:a})})},[e]),Cht(s),s}function gue(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!jht(e,s)}catch{return!0}}function Tht(e,t){return t()}var Aht=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Tht:Mht;LRe.useSyncExternalStore=A5.useSyncExternalStore!==void 0?A5.useSyncExternalStore:Aht;PRe.exports=LRe;var Eht=PRe.exports;function Iht(){return Eht.useSyncExternalStore(Pht,()=>!0,()=>!1)}function Pht(){return()=>{}}var cve="Avatar",[Lht]=Sc(cve),[Dht,DRe]=Lht(cve),ORe=A.forwardRef((e,t)=>{const{__scopeAvatar:s,...n}=e,[a,o]=A.useState("idle");return r.jsx(Dht,{scope:s,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:r.jsx(Hs.span,{...n,ref:t})})});ORe.displayName=cve;var RRe="AvatarImage",FRe=A.forwardRef((e,t)=>{const{__scopeAvatar:s,src:n,onLoadingStatusChange:a=()=>{},...o}=e,l=DRe(RRe,s),i=Oht(n,o),d=gc(m=>{a(m),l.onImageLoadingStatusChange(m)});return kc(()=>{i!=="idle"&&d(i)},[i,d]),i==="loaded"?r.jsx(Hs.img,{...o,ref:t,src:n}):null});FRe.displayName=RRe;var zRe="AvatarFallback",BRe=A.forwardRef((e,t)=>{const{__scopeAvatar:s,delayMs:n,...a}=e,o=DRe(zRe,s),[l,i]=A.useState(n===void 0);return A.useEffect(()=>{if(n!==void 0){const d=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(d)}},[n]),l&&o.imageLoadingStatus!=="loaded"?r.jsx(Hs.span,{...a,ref:t}):null});BRe.displayName=zRe;function UCe(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Oht(e,{referrerPolicy:t,crossOrigin:s}){const n=Iht(),a=A.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=A.useState(()=>UCe(o,e));return kc(()=>{i(UCe(o,e))},[o,e]),kc(()=>{const d=g=>()=>{i(g)};if(!o)return;const m=d("loaded"),p=d("error");return o.addEventListener("load",m),o.addEventListener("error",p),t&&(o.referrerPolicy=t),typeof s=="string"&&(o.crossOrigin=s),()=>{o.removeEventListener("load",m),o.removeEventListener("error",p)}},[o,s,t]),l}var $Re=ORe,URe=FRe,VRe=BRe;const cn=A.forwardRef(({className:e,...t},s)=>r.jsx($Re,{ref:s,className:Vt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",e),...t}));cn.displayName=$Re.displayName;const xa=A.forwardRef(({className:e,...t},s)=>r.jsx(URe,{ref:s,className:Vt("aspect-square h-full w-full",e),...t}));xa.displayName=URe.displayName;const dn=A.forwardRef(({className:e,...t},s)=>r.jsx(VRe,{ref:s,className:Vt("flex h-full w-full items-center justify-center rounded-full bg-muted",e),...t}));dn.displayName=VRe.displayName;const Rht=_3("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 _t({className:e,variant:t,...s}){return r.jsx("div",{className:Vt(Rht({variant:t}),e),...s})}var Fht=A.createContext(void 0);function vN(e){const t=A.useContext(Fht);return e||t||"ltr"}var xue=0;function aie(){A.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??VCe()),document.body.insertAdjacentElement("beforeend",e[1]??VCe()),xue++,()=>{xue===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),xue--}},[])}function VCe(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var yue="focusScope.autoFocusOnMount",vue="focusScope.autoFocusOnUnmount",qCe={bubbles:!1,cancelable:!0},zht="FocusScope",_6=A.forwardRef((e,t)=>{const{loop:s=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=e,[i,d]=A.useState(null),m=gc(a),p=gc(o),g=A.useRef(null),v=va(t,w=>d(w)),_=A.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;A.useEffect(()=>{if(n){let w=function(I){if(_.paused||!i)return;const R=I.target;i.contains(R)?g.current=R:pv(g.current,{select:!0})},S=function(I){if(_.paused||!i)return;const R=I.relatedTarget;R!==null&&(i.contains(R)||pv(g.current,{select:!0}))},T=function(I){if(document.activeElement===document.body)for(const D of I)D.removedNodes.length>0&&pv(i)};document.addEventListener("focusin",w),document.addEventListener("focusout",S);const C=new MutationObserver(T);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",S),C.disconnect()}}},[n,i,_.paused]),A.useEffect(()=>{if(i){WCe.add(_);const w=document.activeElement;if(!i.contains(w)){const T=new CustomEvent(yue,qCe);i.addEventListener(yue,m),i.dispatchEvent(T),T.defaultPrevented||(Bht(Hht(qRe(i)),{select:!0}),document.activeElement===w&&pv(i))}return()=>{i.removeEventListener(yue,m),setTimeout(()=>{const T=new CustomEvent(vue,qCe);i.addEventListener(vue,p),i.dispatchEvent(T),T.defaultPrevented||pv(w??document.body,{select:!0}),i.removeEventListener(vue,p),WCe.remove(_)},0)}}},[i,m,p,_]);const k=A.useCallback(w=>{if(!s&&!n||_.paused)return;const S=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,T=document.activeElement;if(S&&T){const C=w.currentTarget,[I,R]=$ht(C);I&&R?!w.shiftKey&&T===R?(w.preventDefault(),s&&pv(I,{select:!0})):w.shiftKey&&T===I&&(w.preventDefault(),s&&pv(R,{select:!0})):T===C&&w.preventDefault()}},[s,n,_.paused]);return r.jsx(Hs.div,{tabIndex:-1,...l,ref:v,onKeyDown:k})});_6.displayName=zht;function Bht(e,{select:t=!1}={}){const s=document.activeElement;for(const n of e)if(pv(n,{select:t}),document.activeElement!==s)return}function $ht(e){const t=qRe(e),s=HCe(t,e),n=HCe(t.reverse(),e);return[s,n]}function qRe(e){const t=[],s=document.createTreeWalker(e,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(;s.nextNode();)t.push(s.currentNode);return t}function HCe(e,t){for(const s of e)if(!Uht(s,{upTo:t}))return s}function Uht(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Vht(e){return e instanceof HTMLInputElement&&"select"in e}function pv(e,{select:t=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&Vht(e)&&t&&e.select()}}var WCe=qht();function qht(){let e=[];return{add(t){const s=e[0];t!==s&&(s==null||s.pause()),e=GCe(e,t),e.unshift(t)},remove(t){var s;e=GCe(e,t),(s=e[0])==null||s.resume()}}}function GCe(e,t){const s=[...e],n=s.indexOf(t);return n!==-1&&s.splice(n,1),s}function Hht(e){return e.filter(t=>t.tagName!=="A")}var _ue="rovingFocusGroup.onEntryFocus",Wht={bubbles:!1,cancelable:!0},b6="RovingFocusGroup",[ipe,HRe,Ght]=h6(b6),[Kht,E3]=Sc(b6,[Ght]),[Zht,Yht]=Kht(b6),WRe=A.forwardRef((e,t)=>r.jsx(ipe.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(ipe.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Xht,{...e,ref:t})})}));WRe.displayName=b6;var Xht=A.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:s,orientation:n,loop:a=!1,dir:o,currentTabStopId:l,defaultCurrentTabStopId:i,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:p=!1,...g}=e,v=A.useRef(null),_=va(t,v),k=vN(o),[w,S]=bh({prop:l,defaultProp:i??null,onChange:d,caller:b6}),[T,C]=A.useState(!1),I=gc(m),R=HRe(s),D=A.useRef(!1),[B,$]=A.useState(0);return A.useEffect(()=>{const q=v.current;if(q)return q.addEventListener(_ue,I),()=>q.removeEventListener(_ue,I)},[I]),r.jsx(Zht,{scope:s,orientation:n,dir:k,loop:a,currentTabStopId:w,onItemFocus:A.useCallback(q=>S(q),[S]),onItemShiftTab:A.useCallback(()=>C(!0),[]),onFocusableItemAdd:A.useCallback(()=>$(q=>q+1),[]),onFocusableItemRemove:A.useCallback(()=>$(q=>q-1),[]),children:r.jsx(Hs.div,{tabIndex:T||B===0?-1:0,"data-orientation":n,...g,ref:_,style:{outline:"none",...e.style},onMouseDown:bs(e.onMouseDown,()=>{D.current=!0}),onFocus:bs(e.onFocus,q=>{const W=!D.current;if(q.target===q.currentTarget&&W&&!T){const K=new CustomEvent(_ue,Wht);if(q.currentTarget.dispatchEvent(K),!K.defaultPrevented){const re=R().filter(ie=>ie.focusable),ae=re.find(ie=>ie.active),oe=re.find(ie=>ie.id===w),pe=[ae,oe,...re].filter(Boolean).map(ie=>ie.ref.current);ZRe(pe,p)}}D.current=!1}),onBlur:bs(e.onBlur,()=>C(!1))})})}),GRe="RovingFocusGroupItem",KRe=A.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:s,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=e,d=Md(),m=o||d,p=Yht(GRe,s),g=p.currentTabStopId===m,v=HRe(s),{onFocusableItemAdd:_,onFocusableItemRemove:k,currentTabStopId:w}=p;return A.useEffect(()=>{if(n)return _(),()=>k()},[n,_,k]),r.jsx(ipe.ItemSlot,{scope:s,id:m,focusable:n,active:a,children:r.jsx(Hs.span,{tabIndex:g?0:-1,"data-orientation":p.orientation,...i,ref:t,onMouseDown:bs(e.onMouseDown,S=>{n?p.onItemFocus(m):S.preventDefault()}),onFocus:bs(e.onFocus,()=>p.onItemFocus(m)),onKeyDown:bs(e.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){p.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const T=emt(S,p.orientation,p.dir);if(T!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let I=v().filter(R=>R.focusable).map(R=>R.ref.current);if(T==="last")I.reverse();else if(T==="prev"||T==="next"){T==="prev"&&I.reverse();const R=I.indexOf(S.currentTarget);I=p.loop?tmt(I,R+1):I.slice(R+1)}setTimeout(()=>ZRe(I))}}),children:typeof l=="function"?l({isCurrentTabStop:g,hasTabStop:w!=null}):l})})});KRe.displayName=GRe;var Qht={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Jht(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function emt(e,t,s){const n=Jht(e.key,s);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Qht[n]}function ZRe(e,t=!1){const s=document.activeElement;for(const n of e)if(n===s||(n.focus({preventScroll:t}),document.activeElement!==s))return}function tmt(e,t){return e.map((s,n)=>e[(t+n)%e.length])}var dve=WRe,uve=KRe,rmt=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},xC=new WeakMap,SO=new WeakMap,CO={},bue=0,YRe=function(e){return e&&(e.host||YRe(e.parentNode))},smt=function(e,t){return t.map(function(s){if(e.contains(s))return s;var n=YRe(s);return n&&e.contains(n)?n:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},nmt=function(e,t,s,n){var a=smt(t,Array.isArray(e)?e:[e]);CO[s]||(CO[s]=new WeakMap);var o=CO[s],l=[],i=new Set,d=new Set(a),m=function(g){!g||i.has(g)||(i.add(g),m(g.parentNode))};a.forEach(m);var p=function(g){!g||d.has(g)||Array.prototype.forEach.call(g.children,function(v){if(i.has(v))p(v);else try{var _=v.getAttribute(n),k=_!==null&&_!=="false",w=(xC.get(v)||0)+1,S=(o.get(v)||0)+1;xC.set(v,w),o.set(v,S),l.push(v),w===1&&k&&SO.set(v,!0),S===1&&v.setAttribute(s,"true"),k||v.setAttribute(n,"true")}catch(T){console.error("aria-hidden: cannot operate on ",v,T)}})};return p(t),i.clear(),bue++,function(){l.forEach(function(g){var v=xC.get(g)-1,_=o.get(g)-1;xC.set(g,v),o.set(g,_),v||(SO.has(g)||g.removeAttribute(n),SO.delete(g)),_||g.removeAttribute(s)}),bue--,bue||(xC=new WeakMap,xC=new WeakMap,SO=new WeakMap,CO={})}},iie=function(e,t,s){s===void 0&&(s="data-aria-hidden");var n=Array.from(Array.isArray(e)?e:[e]),a=rmt(e);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),nmt(n,a,s,"aria-hidden")):function(){return null}},rre="right-scroll-bar-position",sre="width-before-scroll-bar",amt="with-scroll-bars-hidden",imt="--removed-body-scroll-bar-size";function wue(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function omt(e,t){var s=A.useState(function(){return{value:e,callback:t,facade:{get current(){return s.value},set current(n){var a=s.value;a!==n&&(s.value=n,s.callback(n,a))}}}})[0];return s.callback=t,s.facade}var lmt=typeof window<"u"?A.useLayoutEffect:A.useEffect,KCe=new WeakMap;function cmt(e,t){var s=omt(null,function(n){return e.forEach(function(a){return wue(a,n)})});return lmt(function(){var n=KCe.get(s);if(n){var a=new Set(n),o=new Set(e),l=s.current;a.forEach(function(i){o.has(i)||wue(i,null)}),o.forEach(function(i){a.has(i)||wue(i,l)})}KCe.set(s,e)},[e]),s}function dmt(e){return e}function umt(e,t){t===void 0&&(t=dmt);var s=[],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 s.length?s[s.length-1]:e},useMedium:function(o){var l=t(o,n);return s.push(l),function(){s=s.filter(function(i){return i!==l})}},assignSyncMedium:function(o){for(n=!0;s.length;){var l=s;s=[],l.forEach(o)}s={push:function(i){return o(i)},filter:function(){return s}}},assignMedium:function(o){n=!0;var l=[];if(s.length){var i=s;s=[],i.forEach(o),l=s}var d=function(){var p=l;l=[],p.forEach(o)},m=function(){return Promise.resolve().then(d)};m(),s={push:function(p){l.push(p),m()},filter:function(p){return l=l.filter(p),s}}}};return a}function hmt(e){e===void 0&&(e={});var t=umt(null);return t.options=Sf({async:!0,ssr:!1},e),t}var XRe=function(e){var t=e.sideCar,s=t_(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=t.read();if(!n)throw new Error("Sidecar medium not found");return A.createElement(n,Sf({},s))};XRe.isSideCarExport=!0;function mmt(e,t){return e.useMedium(t),XRe}var QRe=hmt(),jue=function(){},oie=A.forwardRef(function(e,t){var s=A.useRef(null),n=A.useState({onScrollCapture:jue,onWheelCapture:jue,onTouchMoveCapture:jue}),a=n[0],o=n[1],l=e.forwardProps,i=e.children,d=e.className,m=e.removeScrollBar,p=e.enabled,g=e.shards,v=e.sideCar,_=e.noRelative,k=e.noIsolation,w=e.inert,S=e.allowPinchZoom,T=e.as,C=T===void 0?"div":T,I=e.gapMode,R=t_(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),D=v,B=cmt([s,t]),$=Sf(Sf({},R),a);return A.createElement(A.Fragment,null,p&&A.createElement(D,{sideCar:QRe,removeScrollBar:m,shards:g,noRelative:_,noIsolation:k,inert:w,setCallbacks:o,allowPinchZoom:!!S,lockRef:s,gapMode:I}),l?A.cloneElement(A.Children.only(i),Sf(Sf({},$),{ref:B})):A.createElement(C,Sf({},$,{className:d,ref:B}),i))});oie.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};oie.classNames={fullWidth:sre,zeroRight:rre};var fmt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pmt(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=fmt();return t&&e.setAttribute("nonce",t),e}function gmt(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function xmt(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ymt=function(){var e=0,t=null;return{add:function(s){e==0&&(t=pmt())&&(gmt(t,s),xmt(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},vmt=function(){var e=ymt();return function(t,s){A.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&s])}},JRe=function(){var e=vmt(),t=function(s){var n=s.styles,a=s.dynamic;return e(n,a),null};return t},_mt={left:0,top:0,right:0,gap:0},kue=function(e){return parseInt(e||"",10)||0},bmt=function(e){var t=window.getComputedStyle(document.body),s=t[e==="padding"?"paddingLeft":"marginLeft"],n=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[kue(s),kue(n),kue(a)]},wmt=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return _mt;var t=bmt(e),s=document.documentElement.clientWidth,n=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,n-s+t[2]-t[0])}},jmt=JRe(),G4="data-scroll-locked",kmt=function(e,t,s,n){var a=e.left,o=e.top,l=e.right,i=e.gap;return s===void 0&&(s="margin"),` .`.concat(amt,` { overflow: hidden `).concat(n,`; padding-right: `).concat(i,"px ").concat(n,`; } body[`).concat(G4,`] { overflow: hidden `).concat(n,`; overscroll-behavior: contain; `).concat([t&&"position: relative ".concat(n,";"),s==="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,`; `),s==="padding"&&"padding-right: ".concat(i,"px ").concat(n,";")].filter(Boolean).join(""),` } .`).concat(rre,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(sre,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(rre," .").concat(rre,` { right: 0 `).concat(n,`; } .`).concat(sre," .").concat(sre,` { margin-right: 0 `).concat(n,`; } body[`).concat(G4,`] { `).concat(imt,": ").concat(i,`px; } `)},ZCe=function(){var e=parseInt(document.body.getAttribute(G4)||"0",10);return isFinite(e)?e:0},Nmt=function(){A.useEffect(function(){return document.body.setAttribute(G4,(ZCe()+1).toString()),function(){var e=ZCe()-1;e<=0?document.body.removeAttribute(G4):document.body.setAttribute(G4,e.toString())}},[])},Smt=function(e){var t=e.noRelative,s=e.noImportant,n=e.gapMode,a=n===void 0?"margin":n;Nmt();var o=A.useMemo(function(){return wmt(a)},[a]);return A.createElement(jmt,{styles:kmt(o,!t,a,s?"":"!important")})},ope=!1;if(typeof window<"u")try{var MO=Object.defineProperty({},"passive",{get:function(){return ope=!0,!0}});window.addEventListener("test",MO,MO),window.removeEventListener("test",MO,MO)}catch{ope=!1}var yC=ope?{passive:!1}:!1,Cmt=function(e){return e.tagName==="TEXTAREA"},eFe=function(e,t){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[t]!=="hidden"&&!(s.overflowY===s.overflowX&&!Cmt(e)&&s[t]==="visible")},Mmt=function(e){return eFe(e,"overflowY")},Tmt=function(e){return eFe(e,"overflowX")},YCe=function(e,t){var s=t.ownerDocument,n=t;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=tFe(e,n);if(a){var o=rFe(e,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==s.body);return!1},Amt=function(e){var t=e.scrollTop,s=e.scrollHeight,n=e.clientHeight;return[t,s,n]},Emt=function(e){var t=e.scrollLeft,s=e.scrollWidth,n=e.clientWidth;return[t,s,n]},tFe=function(e,t){return e==="v"?Mmt(t):Tmt(t)},rFe=function(e,t){return e==="v"?Amt(t):Emt(t)},Imt=function(e,t){return e==="h"&&t==="rtl"?-1:1},Pmt=function(e,t,s,n,a){var o=Imt(e,window.getComputedStyle(t).direction),l=o*n,i=s.target,d=t.contains(i),m=!1,p=l>0,g=0,v=0;do{if(!i)break;var _=rFe(e,i),k=_[0],w=_[1],S=_[2],T=w-S-o*k;(k||T)&&tFe(e,i)&&(g+=T,v+=k);var C=i.parentNode;i=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!d&&i!==document.body||d&&(t.contains(i)||t===i));return(p&&Math.abs(g)<1||!p&&Math.abs(v)<1)&&(m=!0),m},TO=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},XCe=function(e){return[e.deltaX,e.deltaY]},QCe=function(e){return e&&"current"in e?e.current:e},Lmt=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Dmt=function(e){return` .block-interactivity-`.concat(e,` {pointer-events: none;} .allow-interactivity-`).concat(e,` {pointer-events: all;} `)},Omt=0,vC=[];function Rmt(e){var t=A.useRef([]),s=A.useRef([0,0]),n=A.useRef(),a=A.useState(Omt++)[0],o=A.useState(JRe)[0],l=A.useRef(e);A.useEffect(function(){l.current=e},[e]),A.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var w=Q0e([e.lockRef.current],(e.shards||[]).map(QCe),!0).filter(Boolean);return w.forEach(function(S){return S.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),w.forEach(function(S){return S.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var i=A.useCallback(function(w,S){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!l.current.allowPinchZoom;var T=TO(w),C=s.current,I="deltaX"in w?w.deltaX:C[0]-T[0],R="deltaY"in w?w.deltaY:C[1]-T[1],D,B=w.target,$=Math.abs(I)>Math.abs(R)?"h":"v";if("touches"in w&&$==="h"&&B.type==="range")return!1;var q=YCe($,B);if(!q)return!0;if(q?D=$:(D=$==="v"?"h":"v",q=YCe($,B)),!q)return!1;if(!n.current&&"changedTouches"in w&&(I||R)&&(n.current=D),!D)return!0;var W=n.current||D;return Pmt(W,S,w,W==="h"?I:R)},[]),d=A.useCallback(function(w){var S=w;if(!(!vC.length||vC[vC.length-1]!==o)){var T="deltaY"in S?XCe(S):TO(S),C=t.current.filter(function(D){return D.name===S.type&&(D.target===S.target||S.target===D.shadowParent)&&Lmt(D.delta,T)})[0];if(C&&C.should){S.cancelable&&S.preventDefault();return}if(!C){var I=(l.current.shards||[]).map(QCe).filter(Boolean).filter(function(D){return D.contains(S.target)}),R=I.length>0?i(S,I[0]):!l.current.noIsolation;R&&S.cancelable&&S.preventDefault()}}},[]),m=A.useCallback(function(w,S,T,C){var I={name:w,delta:S,target:T,should:C,shadowParent:Fmt(T)};t.current.push(I),setTimeout(function(){t.current=t.current.filter(function(R){return R!==I})},1)},[]),p=A.useCallback(function(w){s.current=TO(w),n.current=void 0},[]),g=A.useCallback(function(w){m(w.type,XCe(w),w.target,i(w,e.lockRef.current))},[]),v=A.useCallback(function(w){m(w.type,TO(w),w.target,i(w,e.lockRef.current))},[]);A.useEffect(function(){return vC.push(o),e.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:v}),document.addEventListener("wheel",d,yC),document.addEventListener("touchmove",d,yC),document.addEventListener("touchstart",p,yC),function(){vC=vC.filter(function(w){return w!==o}),document.removeEventListener("wheel",d,yC),document.removeEventListener("touchmove",d,yC),document.removeEventListener("touchstart",p,yC)}},[]);var _=e.removeScrollBar,k=e.inert;return A.createElement(A.Fragment,null,k?A.createElement(o,{styles:Dmt(a)}):null,_?A.createElement(Smt,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Fmt(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const zmt=mmt(QRe,Rmt);var w6=A.forwardRef(function(e,t){return A.createElement(oie,Sf({},e,{ref:t,sideCar:zmt}))});w6.classNames=oie.classNames;var lpe=["Enter"," "],Bmt=["ArrowDown","PageUp","Home"],sFe=["ArrowUp","PageDown","End"],$mt=[...Bmt,...sFe],Umt={ltr:[...lpe,"ArrowRight"],rtl:[...lpe,"ArrowLeft"]},Vmt={ltr:["ArrowLeft"],rtl:["ArrowRight"]},j6="Menu",[KI,qmt,Hmt]=h6(j6),[_N,nFe]=Sc(j6,[Hmt,Ix,E3]),lie=Ix(),aFe=E3(),[Wmt,bN]=_N(j6),[Gmt,k6]=_N(j6),iFe=e=>{const{__scopeMenu:t,open:s=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=e,i=lie(t),[d,m]=A.useState(null),p=A.useRef(!1),g=gc(o),v=vN(a);return A.useEffect(()=>{const _=()=>{p.current=!0,document.addEventListener("pointerdown",k,{capture:!0,once:!0}),document.addEventListener("pointermove",k,{capture:!0,once:!0})},k=()=>p.current=!1;return document.addEventListener("keydown",_,{capture:!0}),()=>{document.removeEventListener("keydown",_,{capture:!0}),document.removeEventListener("pointerdown",k,{capture:!0}),document.removeEventListener("pointermove",k,{capture:!0})}},[]),r.jsx(g6,{...i,children:r.jsx(Wmt,{scope:t,open:s,onOpenChange:g,content:d,onContentChange:m,children:r.jsx(Gmt,{scope:t,onClose:A.useCallback(()=>g(!1),[g]),isUsingKeyboardRef:p,dir:v,modal:l,children:n})})})};iFe.displayName=j6;var Kmt="MenuAnchor",hve=A.forwardRef((e,t)=>{const{__scopeMenu:s,...n}=e,a=lie(s);return r.jsx(k3,{...a,...n,ref:t})});hve.displayName=Kmt;var mve="MenuPortal",[Zmt,oFe]=_N(mve,{forceMount:void 0}),lFe=e=>{const{__scopeMenu:t,forceMount:s,children:n,container:a}=e,o=bN(mve,t);return r.jsx(Zmt,{scope:t,forceMount:s,children:r.jsx(Wc,{present:s||o.open,children:r.jsx(v3,{asChild:!0,container:a,children:n})})})};lFe.displayName=mve;var $f="MenuContent",[Ymt,fve]=_N($f),cFe=A.forwardRef((e,t)=>{const s=oFe($f,e.__scopeMenu),{forceMount:n=s.forceMount,...a}=e,o=bN($f,e.__scopeMenu),l=k6($f,e.__scopeMenu);return r.jsx(KI.Provider,{scope:e.__scopeMenu,children:r.jsx(Wc,{present:n||o.open,children:r.jsx(KI.Slot,{scope:e.__scopeMenu,children:l.modal?r.jsx(Xmt,{...a,ref:t}):r.jsx(Qmt,{...a,ref:t})})})})}),Xmt=A.forwardRef((e,t)=>{const s=bN($f,e.__scopeMenu),n=A.useRef(null),a=va(t,n);return A.useEffect(()=>{const o=n.current;if(o)return iie(o)},[]),r.jsx(pve,{...e,ref:a,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:bs(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),Qmt=A.forwardRef((e,t)=>{const s=bN($f,e.__scopeMenu);return r.jsx(pve,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),Jmt=$1("MenuContent.ScrollLock"),pve=A.forwardRef((e,t)=>{const{__scopeMenu:s,loop:n=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:l,disableOutsidePointerEvents:i,onEntryFocus:d,onEscapeKeyDown:m,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:v,onDismiss:_,disableOutsideScroll:k,...w}=e,S=bN($f,s),T=k6($f,s),C=lie(s),I=aFe(s),R=qmt(s),[D,B]=A.useState(null),$=A.useRef(null),q=va(t,$,S.onContentChange),W=A.useRef(0),K=A.useRef(""),re=A.useRef(0),ae=A.useRef(null),oe=A.useRef("right"),se=A.useRef(0),pe=k?w6:A.Fragment,ie=k?{as:Jmt,allowPinchZoom:!0}:void 0,de=ge=>{var Ue,Ve;const Te=K.current+ge,_e=R().filter(Ie=>!Ie.disabled),ve=document.activeElement,Me=(Ue=_e.find(Ie=>Ie.ref.current===ve))==null?void 0:Ue.textValue,Ze=_e.map(Ie=>Ie.textValue),Ae=uft(Ze,Te,Me),Le=(Ve=_e.find(Ie=>Ie.textValue===Ae))==null?void 0:Ve.ref.current;(function Ie(We){K.current=We,window.clearTimeout(W.current),We!==""&&(W.current=window.setTimeout(()=>Ie(""),1e3))})(Te),Le&&setTimeout(()=>Le.focus())};A.useEffect(()=>()=>window.clearTimeout(W.current),[]),aie();const ce=A.useCallback(ge=>{var _e,ve;return oe.current===((_e=ae.current)==null?void 0:_e.side)&&mft(ge,(ve=ae.current)==null?void 0:ve.area)},[]);return r.jsx(Ymt,{scope:s,searchRef:K,onItemEnter:A.useCallback(ge=>{ce(ge)&&ge.preventDefault()},[ce]),onItemLeave:A.useCallback(ge=>{var Te;ce(ge)||((Te=$.current)==null||Te.focus(),B(null))},[ce]),onTriggerLeave:A.useCallback(ge=>{ce(ge)&&ge.preventDefault()},[ce]),pointerGraceTimerRef:re,onPointerGraceIntentChange:A.useCallback(ge=>{ae.current=ge},[]),children:r.jsx(pe,{...ie,children:r.jsx(_6,{asChild:!0,trapped:a,onMountAutoFocus:bs(o,ge=>{var Te;ge.preventDefault(),(Te=$.current)==null||Te.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:r.jsx(J1,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:m,onPointerDownOutside:p,onFocusOutside:g,onInteractOutside:v,onDismiss:_,children:r.jsx(dve,{asChild:!0,...I,dir:T.dir,orientation:"vertical",loop:n,currentTabStopId:D,onCurrentTabStopIdChange:B,onEntryFocus:bs(d,ge=>{T.isUsingKeyboardRef.current||ge.preventDefault()}),preventScrollOnEntryFocus:!0,children:r.jsx(x6,{role:"menu","aria-orientation":"vertical","data-state":NFe(S.open),"data-radix-menu-content":"",dir:T.dir,...C,...w,ref:q,style:{outline:"none",...w.style},onKeyDown:bs(w.onKeyDown,ge=>{const _e=ge.target.closest("[data-radix-menu-content]")===ge.currentTarget,ve=ge.ctrlKey||ge.altKey||ge.metaKey,Me=ge.key.length===1;_e&&(ge.key==="Tab"&&ge.preventDefault(),!ve&&Me&&de(ge.key));const Ze=$.current;if(ge.target!==Ze||!$mt.includes(ge.key))return;ge.preventDefault();const Le=R().filter(Ue=>!Ue.disabled).map(Ue=>Ue.ref.current);sFe.includes(ge.key)&&Le.reverse(),cft(Le)}),onBlur:bs(e.onBlur,ge=>{ge.currentTarget.contains(ge.target)||(window.clearTimeout(W.current),K.current="")}),onPointerMove:bs(e.onPointerMove,ZI(ge=>{const Te=ge.target,_e=se.current!==ge.clientX;if(ge.currentTarget.contains(Te)&&_e){const ve=ge.clientX>se.current?"right":"left";oe.current=ve,se.current=ge.clientX}}))})})})})})})});cFe.displayName=$f;var eft="MenuGroup",gve=A.forwardRef((e,t)=>{const{__scopeMenu:s,...n}=e;return r.jsx(Hs.div,{role:"group",...n,ref:t})});gve.displayName=eft;var tft="MenuLabel",dFe=A.forwardRef((e,t)=>{const{__scopeMenu:s,...n}=e;return r.jsx(Hs.div,{...n,ref:t})});dFe.displayName=tft;var ise="MenuItem",JCe="menu.itemSelect",cie=A.forwardRef((e,t)=>{const{disabled:s=!1,onSelect:n,...a}=e,o=A.useRef(null),l=k6(ise,e.__scopeMenu),i=fve(ise,e.__scopeMenu),d=va(t,o),m=A.useRef(!1),p=()=>{const g=o.current;if(!s&&g){const v=new CustomEvent(JCe,{bubbles:!0,cancelable:!0});g.addEventListener(JCe,_=>n==null?void 0:n(_),{once:!0}),C0e(g,v),v.defaultPrevented?m.current=!1:l.onClose()}};return r.jsx(uFe,{...a,ref:d,disabled:s,onClick:bs(e.onClick,p),onPointerDown:g=>{var v;(v=e.onPointerDown)==null||v.call(e,g),m.current=!0},onPointerUp:bs(e.onPointerUp,g=>{var v;m.current||(v=g.currentTarget)==null||v.click()}),onKeyDown:bs(e.onKeyDown,g=>{const v=i.searchRef.current!=="";s||v&&g.key===" "||lpe.includes(g.key)&&(g.currentTarget.click(),g.preventDefault())})})});cie.displayName=ise;var uFe=A.forwardRef((e,t)=>{const{__scopeMenu:s,disabled:n=!1,textValue:a,...o}=e,l=fve(ise,s),i=aFe(s),d=A.useRef(null),m=va(t,d),[p,g]=A.useState(!1),[v,_]=A.useState("");return A.useEffect(()=>{const k=d.current;k&&_((k.textContent??"").trim())},[o.children]),r.jsx(KI.ItemSlot,{scope:s,disabled:n,textValue:a??v,children:r.jsx(uve,{asChild:!0,...i,focusable:!n,children:r.jsx(Hs.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:m,onPointerMove:bs(e.onPointerMove,ZI(k=>{n?l.onItemLeave(k):(l.onItemEnter(k),k.defaultPrevented||k.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:bs(e.onPointerLeave,ZI(k=>l.onItemLeave(k))),onFocus:bs(e.onFocus,()=>g(!0)),onBlur:bs(e.onBlur,()=>g(!1))})})})}),rft="MenuCheckboxItem",hFe=A.forwardRef((e,t)=>{const{checked:s=!1,onCheckedChange:n,...a}=e;return r.jsx(xFe,{scope:e.__scopeMenu,checked:s,children:r.jsx(cie,{role:"menuitemcheckbox","aria-checked":ose(s)?"mixed":s,...a,ref:t,"data-state":yve(s),onSelect:bs(a.onSelect,()=>n==null?void 0:n(ose(s)?!0:!s),{checkForDefaultPrevented:!1})})})});hFe.displayName=rft;var mFe="MenuRadioGroup",[sft,nft]=_N(mFe,{value:void 0,onValueChange:()=>{}}),fFe=A.forwardRef((e,t)=>{const{value:s,onValueChange:n,...a}=e,o=gc(n);return r.jsx(sft,{scope:e.__scopeMenu,value:s,onValueChange:o,children:r.jsx(gve,{...a,ref:t})})});fFe.displayName=mFe;var pFe="MenuRadioItem",gFe=A.forwardRef((e,t)=>{const{value:s,...n}=e,a=nft(pFe,e.__scopeMenu),o=s===a.value;return r.jsx(xFe,{scope:e.__scopeMenu,checked:o,children:r.jsx(cie,{role:"menuitemradio","aria-checked":o,...n,ref:t,"data-state":yve(o),onSelect:bs(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,s)},{checkForDefaultPrevented:!1})})})});gFe.displayName=pFe;var xve="MenuItemIndicator",[xFe,aft]=_N(xve,{checked:!1}),yFe=A.forwardRef((e,t)=>{const{__scopeMenu:s,forceMount:n,...a}=e,o=aft(xve,s);return r.jsx(Wc,{present:n||ose(o.checked)||o.checked===!0,children:r.jsx(Hs.span,{...a,ref:t,"data-state":yve(o.checked)})})});yFe.displayName=xve;var ift="MenuSeparator",vFe=A.forwardRef((e,t)=>{const{__scopeMenu:s,...n}=e;return r.jsx(Hs.div,{role:"separator","aria-orientation":"horizontal",...n,ref:t})});vFe.displayName=ift;var oft="MenuArrow",_Fe=A.forwardRef((e,t)=>{const{__scopeMenu:s,...n}=e,a=lie(s);return r.jsx(y6,{...a,...n,ref:t})});_Fe.displayName=oft;var lft="MenuSub",[Xmr,bFe]=_N(lft),VA="MenuSubTrigger",wFe=A.forwardRef((e,t)=>{const s=bN(VA,e.__scopeMenu),n=k6(VA,e.__scopeMenu),a=bFe(VA,e.__scopeMenu),o=fve(VA,e.__scopeMenu),l=A.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:d}=o,m={__scopeMenu:e.__scopeMenu},p=A.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return A.useEffect(()=>p,[p]),A.useEffect(()=>{const g=i.current;return()=>{window.clearTimeout(g),d(null)}},[i,d]),r.jsx(hve,{asChild:!0,...m,children:r.jsx(uFe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":a.contentId,"data-state":NFe(s.open),...e,ref:t0(t,a.onTriggerChange),onClick:g=>{var v;(v=e.onClick)==null||v.call(e,g),!(e.disabled||g.defaultPrevented)&&(g.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:bs(e.onPointerMove,ZI(g=>{o.onItemEnter(g),!g.defaultPrevented&&!e.disabled&&!s.open&&!l.current&&(o.onPointerGraceIntentChange(null),l.current=window.setTimeout(()=>{s.onOpenChange(!0),p()},100))})),onPointerLeave:bs(e.onPointerLeave,ZI(g=>{var _,k;p();const v=(_=s.content)==null?void 0:_.getBoundingClientRect();if(v){const w=(k=s.content)==null?void 0:k.dataset.side,S=w==="right",T=S?-5:5,C=v[S?"left":"right"],I=v[S?"right":"left"];o.onPointerGraceIntentChange({area:[{x:g.clientX+T,y:g.clientY},{x:C,y:v.top},{x:I,y:v.top},{x:I,y:v.bottom},{x:C,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:bs(e.onKeyDown,g=>{var _;const v=o.searchRef.current!=="";e.disabled||v&&g.key===" "||Umt[n.dir].includes(g.key)&&(s.onOpenChange(!0),(_=s.content)==null||_.focus(),g.preventDefault())})})})});wFe.displayName=VA;var jFe="MenuSubContent",kFe=A.forwardRef((e,t)=>{const s=oFe($f,e.__scopeMenu),{forceMount:n=s.forceMount,...a}=e,o=bN($f,e.__scopeMenu),l=k6($f,e.__scopeMenu),i=bFe(jFe,e.__scopeMenu),d=A.useRef(null),m=va(t,d);return r.jsx(KI.Provider,{scope:e.__scopeMenu,children:r.jsx(Wc,{present:n||o.open,children:r.jsx(KI.Slot,{scope:e.__scopeMenu,children:r.jsx(pve,{id:i.contentId,"aria-labelledby":i.triggerId,...a,ref:m,align:"start",side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{var g;l.isUsingKeyboardRef.current&&((g=d.current)==null||g.focus()),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:bs(e.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:bs(e.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:bs(e.onKeyDown,p=>{var _;const g=p.currentTarget.contains(p.target),v=Vmt[l.dir].includes(p.key);g&&v&&(o.onOpenChange(!1),(_=i.trigger)==null||_.focus(),p.preventDefault())})})})})})});kFe.displayName=jFe;function NFe(e){return e?"open":"closed"}function ose(e){return e==="indeterminate"}function yve(e){return ose(e)?"indeterminate":e?"checked":"unchecked"}function cft(e){const t=document.activeElement;for(const s of e)if(s===t||(s.focus(),document.activeElement!==t))return}function dft(e,t){return e.map((s,n)=>e[(t+n)%e.length])}function uft(e,t,s){const a=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,o=s?e.indexOf(s):-1;let l=dft(e,Math.max(o,0));a.length===1&&(l=l.filter(m=>m!==s));const d=l.find(m=>m.toLowerCase().startsWith(a.toLowerCase()));return d!==s?d:void 0}function hft(e,t){const{x:s,y:n}=e;let a=!1;for(let o=0,l=t.length-1;on!=v>n&&s<(g-m)*(n-p)/(v-p)+m&&(a=!a)}return a}function mft(e,t){if(!t)return!1;const s={x:e.clientX,y:e.clientY};return hft(s,t)}function ZI(e){return t=>t.pointerType==="mouse"?e(t):void 0}var fft=iFe,pft=hve,gft=lFe,xft=cFe,yft=gve,vft=dFe,_ft=cie,bft=hFe,wft=fFe,jft=gFe,kft=yFe,Nft=vFe,Sft=_Fe,Cft=wFe,Mft=kFe,die="DropdownMenu",[Tft]=Sc(die,[nFe]),Sh=nFe(),[Aft,SFe]=Tft(die),CFe=e=>{const{__scopeDropdownMenu:t,children:s,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=e,d=Sh(t),m=A.useRef(null),[p,g]=bh({prop:a,defaultProp:o??!1,onChange:l,caller:die});return r.jsx(Aft,{scope:t,triggerId:Md(),triggerRef:m,contentId:Md(),open:p,onOpenChange:g,onOpenToggle:A.useCallback(()=>g(v=>!v),[g]),modal:i,children:r.jsx(fft,{...d,open:p,onOpenChange:g,dir:n,modal:i,children:s})})};CFe.displayName=die;var MFe="DropdownMenuTrigger",TFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,disabled:n=!1,...a}=e,o=SFe(MFe,s),l=Sh(s);return r.jsx(pft,{asChild:!0,...l,children:r.jsx(Hs.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:t0(t,o.triggerRef),onPointerDown:bs(e.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:bs(e.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});TFe.displayName=MFe;var Eft="DropdownMenuPortal",AFe=e=>{const{__scopeDropdownMenu:t,...s}=e,n=Sh(t);return r.jsx(gft,{...n,...s})};AFe.displayName=Eft;var EFe="DropdownMenuContent",IFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=SFe(EFe,s),o=Sh(s),l=A.useRef(!1);return r.jsx(xft,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:t,onCloseAutoFocus:bs(e.onCloseAutoFocus,i=>{var d;l.current||(d=a.triggerRef.current)==null||d.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:bs(e.onInteractOutside,i=>{const d=i.detail.originalEvent,m=d.button===0&&d.ctrlKey===!0,p=d.button===2||m;(!a.modal||p)&&(l.current=!0)}),style:{...e.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)"}})});IFe.displayName=EFe;var Ift="DropdownMenuGroup",Pft=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(yft,{...a,...n,ref:t})});Pft.displayName=Ift;var Lft="DropdownMenuLabel",PFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(vft,{...a,...n,ref:t})});PFe.displayName=Lft;var Dft="DropdownMenuItem",LFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(_ft,{...a,...n,ref:t})});LFe.displayName=Dft;var Oft="DropdownMenuCheckboxItem",DFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(bft,{...a,...n,ref:t})});DFe.displayName=Oft;var Rft="DropdownMenuRadioGroup",Fft=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(wft,{...a,...n,ref:t})});Fft.displayName=Rft;var zft="DropdownMenuRadioItem",OFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(jft,{...a,...n,ref:t})});OFe.displayName=zft;var Bft="DropdownMenuItemIndicator",RFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(kft,{...a,...n,ref:t})});RFe.displayName=Bft;var $ft="DropdownMenuSeparator",FFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(Nft,{...a,...n,ref:t})});FFe.displayName=$ft;var Uft="DropdownMenuArrow",Vft=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(Sft,{...a,...n,ref:t})});Vft.displayName=Uft;var qft="DropdownMenuSubTrigger",zFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(Cft,{...a,...n,ref:t})});zFe.displayName=qft;var Hft="DropdownMenuSubContent",BFe=A.forwardRef((e,t)=>{const{__scopeDropdownMenu:s,...n}=e,a=Sh(s);return r.jsx(Mft,{...a,...n,ref:t,style:{...e.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)"}})});BFe.displayName=Hft;var Wft=CFe,Gft=TFe,Kft=AFe,$Fe=IFe,UFe=PFe,VFe=LFe,qFe=DFe,HFe=OFe,WFe=RFe,GFe=FFe,KFe=zFe,ZFe=BFe;const Bu=Wft,$u=Gft,Zft=A.forwardRef(({className:e,inset:t,children:s,...n},a)=>r.jsxs(KFe,{ref:a,className:Vt("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",t&&"pl-8",e),...n,children:[s,r.jsx(Zi,{className:"ml-auto h-4 w-4"})]}));Zft.displayName=KFe.displayName;const Yft=A.forwardRef(({className:e,...t},s)=>r.jsx(ZFe,{ref:s,className:Vt("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",e),...t}));Yft.displayName=ZFe.displayName;const vu=A.forwardRef(({className:e,sideOffset:t=4,...s},n)=>r.jsx(Kft,{children:r.jsx($Fe,{ref:n,sideOffset:t,className:Vt("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",e),...s})}));vu.displayName=$Fe.displayName;const Ba=A.forwardRef(({className:e,inset:t,...s},n)=>r.jsx(VFe,{ref:n,className:Vt("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",t&&"pl-8",e),...s}));Ba.displayName=VFe.displayName;const Xft=A.forwardRef(({className:e,children:t,checked:s,...n},a)=>r.jsxs(qFe,{ref:a,className:Vt("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",e),checked:s,...n,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(WFe,{children:r.jsx(mi,{className:"h-4 w-4"})})}),t]}));Xft.displayName=qFe.displayName;const Qft=A.forwardRef(({className:e,children:t,...s},n)=>r.jsxs(HFe,{ref:n,className:Vt("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",e),...s,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(WFe,{children:r.jsx(vh,{className:"h-2 w-2 fill-current"})})}),t]}));Qft.displayName=HFe.displayName;const cpe=A.forwardRef(({className:e,inset:t,...s},n)=>r.jsx(UFe,{ref:n,className:Vt("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...s}));cpe.displayName=UFe.displayName;const Yk=A.forwardRef(({className:e,...t},s)=>r.jsx(GFe,{ref:s,className:Vt("-mx-1 my-1 h-px bg-muted",e),...t}));Yk.displayName=GFe.displayName;const Jft=()=>{const{isAssistant:e,actingAsAgent:t,assignedAgents:s,setActingAsAgent:n}=lve();if(!(e&&!!t))return null;const o=l=>l.split(" ").map(i=>i[0]).join("").toUpperCase().slice(0,2);return r.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:r.jsxs("div",{className:"container mx-auto flex items-center justify-between gap-4 h-full",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ws,{className:"h-4 w-4 flex-shrink-0"}),r.jsx("span",{className:"font-medium text-sm",children:"Acting as"}),s.length>1?r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{variant:"secondary",size:"sm",className:"gap-2 bg-primary-foreground/20 hover:bg-primary-foreground/30 text-primary-foreground border-0",children:[r.jsxs(cn,{className:"h-5 w-5",children:[r.jsx(xa,{src:t.avatar_url||void 0}),r.jsx(dn,{className:"text-[10px] bg-primary-foreground/30",children:o(t.name)})]}),r.jsx("strong",{children:t.name}),r.jsx(ad,{className:"h-3 w-3"})]})}),r.jsx(vu,{align:"start",children:s.map(l=>r.jsxs(Ba,{onClick:()=>n(l),className:"gap-2",children:[r.jsxs(cn,{className:"h-6 w-6",children:[r.jsx(xa,{src:l.avatar_url||void 0}),r.jsx(dn,{className:"text-[10px]",children:o(l.name)})]}),r.jsx("span",{children:l.name}),l.id===t.id&&r.jsx(_t,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},l.id))})]}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(cn,{className:"h-5 w-5",children:[r.jsx(xa,{src:t.avatar_url||void 0}),r.jsx(dn,{className:"text-[10px] bg-primary-foreground/30",children:o(t.name)})]}),r.jsx("strong",{children:t.name})]})]}),r.jsx(_t,{variant:"secondary",className:"bg-primary-foreground/20 text-primary-foreground border-0 text-xs",children:"Assistant Mode"})]})})},Ss=({children:e,requireAdmin:t=!1,requireBrokerageManager:s=!1})=>{const{user:n,loading:a,isAdmin:o,isBrokerageManager:l}=Gr();return a?r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})}):n?t&&!o?r.jsx(sue,{to:"/dashboard",replace:!0}):s&&!l&&!o?r.jsx(sue,{to:"/dashboard",replace:!0}):r.jsx(r.Fragment,{children:e}):r.jsx(sue,{to:"/auth",replace:!0})};var vve={};(function e(t,s,n,a){var o=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),l=typeof Path2D=="function"&&typeof DOMMatrix=="function",i=function(){if(!t.OffscreenCanvas)return!1;try{var Te=new OffscreenCanvas(1,1),_e=Te.getContext("2d");_e.fillRect(0,0,1,1);var ve=Te.transferToImageBitmap();_e.createPattern(ve,"no-repeat")}catch{return!1}return!0}();function d(){}function m(Te){var _e=s.exports.Promise,ve=_e!==void 0?_e:t.Promise;return typeof ve=="function"?new ve(Te):(Te(d,d),null)}var p=function(Te,_e){return{transform:function(ve){if(Te)return ve;if(_e.has(ve))return _e.get(ve);var Me=new OffscreenCanvas(ve.width,ve.height),Ze=Me.getContext("2d");return Ze.drawImage(ve,0,0),_e.set(ve,Me),Me},clear:function(){_e.clear()}}}(i,new Map),g=function(){var Te=Math.floor(16.666666666666668),_e,ve,Me={},Ze=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(_e=function(Ae){var Le=Math.random();return Me[Le]=requestAnimationFrame(function Ue(Ve){Ze===Ve||Ze+Te-1{const{data:t,error:s}=await Y.from("celebration_queue").select("*").eq("user_id",e.id).is("seen_at",null).order("created_at",{ascending:!0});if(s)throw s;return t},enabled:!!(e!=null&&e.id),refetchOnWindowFocus:!0,staleTime:0})}function tpt(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("celebration_queue").update({seen_at:new Date().toISOString()}).eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["celebrations"]})}})}function rpt(){const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{error:n}=await Y.from("celebration_queue").insert({user_id:s.user_id,celebration_type:s.celebration_type,title:s.title,message:s.message||null,points_amount:s.points_amount||null,created_by:t==null?void 0:t.id});if(n)throw n},onSuccess:()=>{e.invalidateQueries({queryKey:["celebrations"]})}})}var uie="Dialog",[YFe,XFe]=Sc(uie),[spt,pg]=YFe(uie),QFe=e=>{const{__scopeDialog:t,children:s,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=e,i=A.useRef(null),d=A.useRef(null),[m,p]=bh({prop:n,defaultProp:a??!1,onChange:o,caller:uie});return r.jsx(spt,{scope:t,triggerRef:i,contentRef:d,contentId:Md(),titleId:Md(),descriptionId:Md(),open:m,onOpenChange:p,onOpenToggle:A.useCallback(()=>p(g=>!g),[p]),modal:l,children:s})};QFe.displayName=uie;var JFe="DialogTrigger",eze=A.forwardRef((e,t)=>{const{__scopeDialog:s,...n}=e,a=pg(JFe,s),o=va(t,a.triggerRef);return r.jsx(Hs.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":wve(a.open),...n,ref:o,onClick:bs(e.onClick,a.onOpenToggle)})});eze.displayName=JFe;var _ve="DialogPortal",[npt,tze]=YFe(_ve,{forceMount:void 0}),rze=e=>{const{__scopeDialog:t,forceMount:s,children:n,container:a}=e,o=pg(_ve,t);return r.jsx(npt,{scope:t,forceMount:s,children:A.Children.map(n,l=>r.jsx(Wc,{present:s||o.open,children:r.jsx(v3,{asChild:!0,container:a,children:l})}))})};rze.displayName=_ve;var lse="DialogOverlay",sze=A.forwardRef((e,t)=>{const s=tze(lse,e.__scopeDialog),{forceMount:n=s.forceMount,...a}=e,o=pg(lse,e.__scopeDialog);return o.modal?r.jsx(Wc,{present:n||o.open,children:r.jsx(ipt,{...a,ref:t})}):null});sze.displayName=lse;var apt=$1("DialogOverlay.RemoveScroll"),ipt=A.forwardRef((e,t)=>{const{__scopeDialog:s,...n}=e,a=pg(lse,s);return r.jsx(w6,{as:apt,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(Hs.div,{"data-state":wve(a.open),...n,ref:t,style:{pointerEvents:"auto",...n.style}})})}),Xk="DialogContent",nze=A.forwardRef((e,t)=>{const s=tze(Xk,e.__scopeDialog),{forceMount:n=s.forceMount,...a}=e,o=pg(Xk,e.__scopeDialog);return r.jsx(Wc,{present:n||o.open,children:o.modal?r.jsx(opt,{...a,ref:t}):r.jsx(lpt,{...a,ref:t})})});nze.displayName=Xk;var opt=A.forwardRef((e,t)=>{const s=pg(Xk,e.__scopeDialog),n=A.useRef(null),a=va(t,s.contentRef,n);return A.useEffect(()=>{const o=n.current;if(o)return iie(o)},[]),r.jsx(aze,{...e,ref:a,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:bs(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=s.triggerRef.current)==null||l.focus()}),onPointerDownOutside:bs(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:bs(e.onFocusOutside,o=>o.preventDefault())})}),lpt=A.forwardRef((e,t)=>{const s=pg(Xk,e.__scopeDialog),n=A.useRef(!1),a=A.useRef(!1);return r.jsx(aze,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=e.onCloseAutoFocus)==null||l.call(e,o),o.defaultPrevented||(n.current||(i=s.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,m;(d=e.onInteractOutside)==null||d.call(e,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((m=s.triggerRef.current)==null?void 0:m.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),aze=A.forwardRef((e,t)=>{const{__scopeDialog:s,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=e,i=pg(Xk,s),d=A.useRef(null),m=va(t,d);return aie(),r.jsxs(r.Fragment,{children:[r.jsx(_6,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(J1,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":wve(i.open),...l,ref:m,onDismiss:()=>i.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(dpt,{titleId:i.titleId}),r.jsx(hpt,{contentRef:d,descriptionId:i.descriptionId})]})]})}),bve="DialogTitle",ize=A.forwardRef((e,t)=>{const{__scopeDialog:s,...n}=e,a=pg(bve,s);return r.jsx(Hs.h2,{id:a.titleId,...n,ref:t})});ize.displayName=bve;var oze="DialogDescription",lze=A.forwardRef((e,t)=>{const{__scopeDialog:s,...n}=e,a=pg(oze,s);return r.jsx(Hs.p,{id:a.descriptionId,...n,ref:t})});lze.displayName=oze;var cze="DialogClose",dze=A.forwardRef((e,t)=>{const{__scopeDialog:s,...n}=e,a=pg(cze,s);return r.jsx(Hs.button,{type:"button",...n,ref:t,onClick:bs(e.onClick,()=>a.onOpenChange(!1))})});dze.displayName=cze;function wve(e){return e?"open":"closed"}var uze="DialogTitleWarning",[cpt,hze]=Vst(uze,{contentName:Xk,titleName:bve,docsSlug:"dialog"}),dpt=({titleId:e})=>{const t=hze(uze),s=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return A.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},upt="DialogDescriptionWarning",hpt=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hze(upt).contentName}}.`;return A.useEffect(()=>{var o;const a=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},hie=QFe,jve=eze,mie=rze,I3=sze,P3=nze,N6=ize,S6=lze,fie=dze;const Ir=hie,Qi=jve,mpt=mie,mze=A.forwardRef(({className:e,...t},s)=>r.jsx(I3,{ref:s,className:Vt("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",e),...t}));mze.displayName=I3.displayName;const Er=A.forwardRef(({className:e,children:t,...s},n)=>r.jsxs(mpt,{children:[r.jsx(mze,{}),r.jsxs(P3,{ref:n,className:Vt("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",e),...s,children:[t,r.jsxs(fie,{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:[r.jsx(Xs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Er.displayName=P3.displayName;const zr=({className:e,...t})=>r.jsx("div",{className:Vt("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zr.displayName="DialogHeader";const Rn=({className:e,...t})=>r.jsx("div",{className:Vt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Rn.displayName="DialogFooter";const Fr=A.forwardRef(({className:e,...t},s)=>r.jsx(N6,{ref:s,className:Vt("text-lg font-semibold leading-none tracking-tight",e),...t}));Fr.displayName=N6.displayName;const Zs=A.forwardRef(({className:e,...t},s)=>r.jsx(S6,{ref:s,className:Vt("text-sm text-muted-foreground",e),...t}));Zs.displayName=S6.displayName;const fpt={points_earned:go,listing_created:Vn,deal_closed:Sd,custom:Dn},t4e={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 ppt(){const{user:e}=Gr(),t=Rr(),{data:s}=ept(),n=tpt(),[a,o]=A.useState(null),[l,i]=A.useState(!1),d=A.useCallback(()=>{const _=Date.now()+3e3,k={startVelocity:30,spread:360,ticks:60,zIndex:9999},w=(T,C)=>Math.random()*(C-T)+T,S=setInterval(()=>{const T=_-Date.now();if(T<=0){clearInterval(S);return}const C=50*(T/3e3);e4e({...k,particleCount:C,origin:{x:w(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),e4e({...k,particleCount:C,origin:{x:w(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);A.useEffect(()=>{s&&s.length>0&&!a&&(o(s[0]),i(!0),setTimeout(d,100))},[s,a,d]);const m=async()=>{if(a){const v=a.id;i(!1),o(null),t.setQueryData(["celebrations","pending",e==null?void 0:e.id],_=>(_==null?void 0:_.filter(k=>k.id!==v))??[]),await n.mutateAsync(v)}};if(!a)return null;const p=fpt[a.celebration_type]||Dn,g=t4e[a.celebration_type]||t4e.custom;return r.jsx(Ir,{open:l,onOpenChange:v=>!v&&m(),children:r.jsxs(Er,{className:"sm:max-w-md text-center border-0 overflow-hidden",children:[r.jsx("div",{className:`absolute inset-0 bg-gradient-to-br ${g} opacity-10`}),r.jsxs("div",{className:"relative z-10 py-6",children:[r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("div",{className:`w-20 h-20 rounded-full bg-gradient-to-br ${g} flex items-center justify-center animate-bounce`,children:r.jsx(p,{className:"w-10 h-10 text-white"})})}),r.jsxs("div",{className:"flex justify-center gap-1 mb-4",children:[r.jsx(bn,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),r.jsx(bn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),r.jsx(bn,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-150"})]}),r.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&&r.jsxs("div",{className:"text-4xl font-bold text-primary mb-2",children:["+",a.points_amount," points!"]}),a.message&&r.jsx("p",{className:"text-muted-foreground mb-6",children:a.message}),r.jsx(X,{onClick:m,className:"w-full",size:"lg",children:"Awesome! 🙌"}),s&&s.length>1&&r.jsxs("p",{className:"text-sm text-muted-foreground mt-3",children:["+",s.length-1," more celebration",s.length>2?"s":""," waiting"]})]})]})})}const fze="/assets/levelup-logo-horizontal-DEFNc0ms.png",kve="/assets/levelup-logo-white-C2RAgAoG.png",gpt="/assets/listings-hero-BI9Ki9Dq.jpg",Ye=A.forwardRef(({className:e,type:t,...s},n)=>r.jsx("input",{type:t,className:Vt("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",e),ref:n,...s}));Ye.displayName="Input";var pze={exports:{}};(function(e,t){(function(s,n){e.exports=n()})(Ny,function(){var s,n,a;function o(i,d){if(!s)s=d;else if(!n)n=d;else{var m="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 = {}; ("+s+")(sharedChunk); ("+n+")(sharedChunk); self.onerror = null;",p={};s(p),a=d(p),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(a.workerUrl=window.URL.createObjectURL(new Blob([m],{type:"text/javascript"})))}}o(["exports"],function(i){var d=1e-6,m=typeof Float32Array<"u"?Float32Array:Array;function p(f,c){var h=c[0],y=c[1],b=c[2],M=c[3],E=h*M-b*y;return E?(f[0]=M*(E=1/E),f[1]=-y*E,f[2]=-b*E,f[3]=h*E,f):null}function g(){var f=new m(9);return m!=Float32Array&&(f[1]=0,f[2]=0,f[3]=0,f[5]=0,f[6]=0,f[7]=0),f[0]=1,f[4]=1,f[8]=1,f}function v(f,c){var h=c[0],y=c[1],b=c[2],M=c[3],E=c[4],L=c[5],z=c[6],V=c[7],Z=c[8];return f[0]=E*Z-L*V,f[1]=b*V-y*Z,f[2]=y*L-b*E,f[3]=L*z-M*Z,f[4]=h*Z-b*z,f[5]=b*M-h*L,f[6]=M*V-E*z,f[7]=y*z-h*V,f[8]=h*E-y*M,f}function _(f,c,h){var y=c[0],b=c[1],M=c[2],E=c[3],L=c[4],z=c[5],V=c[6],Z=c[7],Q=c[8],ee=h[0],ne=h[1],le=h[2],xe=h[3],Ce=h[4],Ne=h[5],Fe=h[6],Be=h[7],Je=h[8];return f[0]=ee*y+ne*E+le*V,f[1]=ee*b+ne*L+le*Z,f[2]=ee*M+ne*z+le*Q,f[3]=xe*y+Ce*E+Ne*V,f[4]=xe*b+Ce*L+Ne*Z,f[5]=xe*M+Ce*z+Ne*Q,f[6]=Fe*y+Be*E+Je*V,f[7]=Fe*b+Be*L+Je*Z,f[8]=Fe*M+Be*z+Je*Q,f}function k(){var f=new m(16);return m!=Float32Array&&(f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[11]=0,f[12]=0,f[13]=0,f[14]=0),f[0]=1,f[5]=1,f[10]=1,f[15]=1,f}function w(f){var c=new m(16);return c[0]=f[0],c[1]=f[1],c[2]=f[2],c[3]=f[3],c[4]=f[4],c[5]=f[5],c[6]=f[6],c[7]=f[7],c[8]=f[8],c[9]=f[9],c[10]=f[10],c[11]=f[11],c[12]=f[12],c[13]=f[13],c[14]=f[14],c[15]=f[15],c}function S(f){return f[0]=1,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=1,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=1,f[11]=0,f[12]=0,f[13]=0,f[14]=0,f[15]=1,f}function T(f,c){var h=c[0],y=c[1],b=c[2],M=c[3],E=c[4],L=c[5],z=c[6],V=c[7],Z=c[8],Q=c[9],ee=c[10],ne=c[11],le=c[12],xe=c[13],Ce=c[14],Ne=c[15],Fe=h*L-y*E,Be=h*z-b*E,Je=h*V-M*E,yt=y*z-b*L,mt=y*V-M*L,kt=b*V-M*z,It=Z*xe-Q*le,Rt=Z*Ce-ee*le,tr=Z*Ne-ne*le,$t=Q*Ce-ee*xe,or=Q*Ne-ne*xe,mr=ee*Ne-ne*Ce,fr=Fe*mr-Be*or+Je*$t+yt*tr-mt*Rt+kt*It;return fr?(f[0]=(L*mr-z*or+V*$t)*(fr=1/fr),f[1]=(b*or-y*mr-M*$t)*fr,f[2]=(xe*kt-Ce*mt+Ne*yt)*fr,f[3]=(ee*mt-Q*kt-ne*yt)*fr,f[4]=(z*tr-E*mr-V*Rt)*fr,f[5]=(h*mr-b*tr+M*Rt)*fr,f[6]=(Ce*Je-le*kt-Ne*Be)*fr,f[7]=(Z*kt-ee*Je+ne*Be)*fr,f[8]=(E*or-L*tr+V*It)*fr,f[9]=(y*tr-h*or-M*It)*fr,f[10]=(le*mt-xe*Je+Ne*Fe)*fr,f[11]=(Q*Je-Z*mt-ne*Fe)*fr,f[12]=(L*Rt-E*$t-z*It)*fr,f[13]=(h*$t-y*Rt+b*It)*fr,f[14]=(xe*Be-le*yt-Ce*Fe)*fr,f[15]=(Z*yt-Q*Be+ee*Fe)*fr,f):null}function C(f,c,h){var y=c[0],b=c[1],M=c[2],E=c[3],L=c[4],z=c[5],V=c[6],Z=c[7],Q=c[8],ee=c[9],ne=c[10],le=c[11],xe=c[12],Ce=c[13],Ne=c[14],Fe=c[15],Be=h[0],Je=h[1],yt=h[2],mt=h[3];return f[0]=Be*y+Je*L+yt*Q+mt*xe,f[1]=Be*b+Je*z+yt*ee+mt*Ce,f[2]=Be*M+Je*V+yt*ne+mt*Ne,f[3]=Be*E+Je*Z+yt*le+mt*Fe,f[4]=(Be=h[4])*y+(Je=h[5])*L+(yt=h[6])*Q+(mt=h[7])*xe,f[5]=Be*b+Je*z+yt*ee+mt*Ce,f[6]=Be*M+Je*V+yt*ne+mt*Ne,f[7]=Be*E+Je*Z+yt*le+mt*Fe,f[8]=(Be=h[8])*y+(Je=h[9])*L+(yt=h[10])*Q+(mt=h[11])*xe,f[9]=Be*b+Je*z+yt*ee+mt*Ce,f[10]=Be*M+Je*V+yt*ne+mt*Ne,f[11]=Be*E+Je*Z+yt*le+mt*Fe,f[12]=(Be=h[12])*y+(Je=h[13])*L+(yt=h[14])*Q+(mt=h[15])*xe,f[13]=Be*b+Je*z+yt*ee+mt*Ce,f[14]=Be*M+Je*V+yt*ne+mt*Ne,f[15]=Be*E+Je*Z+yt*le+mt*Fe,f}function I(f,c,h){var y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe=h[0],Ce=h[1],Ne=h[2];return c===f?(f[12]=c[0]*xe+c[4]*Ce+c[8]*Ne+c[12],f[13]=c[1]*xe+c[5]*Ce+c[9]*Ne+c[13],f[14]=c[2]*xe+c[6]*Ce+c[10]*Ne+c[14],f[15]=c[3]*xe+c[7]*Ce+c[11]*Ne+c[15]):(b=c[1],M=c[2],E=c[3],L=c[4],z=c[5],V=c[6],Z=c[7],Q=c[8],ee=c[9],ne=c[10],le=c[11],f[0]=y=c[0],f[1]=b,f[2]=M,f[3]=E,f[4]=L,f[5]=z,f[6]=V,f[7]=Z,f[8]=Q,f[9]=ee,f[10]=ne,f[11]=le,f[12]=y*xe+L*Ce+Q*Ne+c[12],f[13]=b*xe+z*Ce+ee*Ne+c[13],f[14]=M*xe+V*Ce+ne*Ne+c[14],f[15]=E*xe+Z*Ce+le*Ne+c[15]),f}function R(f,c,h){var y=h[0],b=h[1],M=h[2];return f[0]=c[0]*y,f[1]=c[1]*y,f[2]=c[2]*y,f[3]=c[3]*y,f[4]=c[4]*b,f[5]=c[5]*b,f[6]=c[6]*b,f[7]=c[7]*b,f[8]=c[8]*M,f[9]=c[9]*M,f[10]=c[10]*M,f[11]=c[11]*M,f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15],f}function D(f,c,h){var y=Math.sin(h),b=Math.cos(h),M=c[4],E=c[5],L=c[6],z=c[7],V=c[8],Z=c[9],Q=c[10],ee=c[11];return c!==f&&(f[0]=c[0],f[1]=c[1],f[2]=c[2],f[3]=c[3],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[4]=M*b+V*y,f[5]=E*b+Z*y,f[6]=L*b+Q*y,f[7]=z*b+ee*y,f[8]=V*b-M*y,f[9]=Z*b-E*y,f[10]=Q*b-L*y,f[11]=ee*b-z*y,f}function B(f,c,h){var y=Math.sin(h),b=Math.cos(h),M=c[0],E=c[1],L=c[2],z=c[3],V=c[8],Z=c[9],Q=c[10],ee=c[11];return c!==f&&(f[4]=c[4],f[5]=c[5],f[6]=c[6],f[7]=c[7],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[0]=M*b-V*y,f[1]=E*b-Z*y,f[2]=L*b-Q*y,f[3]=z*b-ee*y,f[8]=M*y+V*b,f[9]=E*y+Z*b,f[10]=L*y+Q*b,f[11]=z*y+ee*b,f}function $(f,c,h){var y=Math.sin(h),b=Math.cos(h),M=c[0],E=c[1],L=c[2],z=c[3],V=c[4],Z=c[5],Q=c[6],ee=c[7];return c!==f&&(f[8]=c[8],f[9]=c[9],f[10]=c[10],f[11]=c[11],f[12]=c[12],f[13]=c[13],f[14]=c[14],f[15]=c[15]),f[0]=M*b+V*y,f[1]=E*b+Z*y,f[2]=L*b+Q*y,f[3]=z*b+ee*y,f[4]=V*b-M*y,f[5]=Z*b-E*y,f[6]=Q*b-L*y,f[7]=ee*b-z*y,f}function q(f,c){return f[0]=c[0],f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=c[1],f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=c[2],f[11]=0,f[12]=0,f[13]=0,f[14]=0,f[15]=1,f}function W(f,c,h){var y,b,M,E=h[0],L=h[1],z=h[2],V=Math.sqrt(E*E+L*L+z*z);return V0&&(M=1/Math.sqrt(M)),f[0]=c[0]*M,f[1]=c[1]*M,f[2]=c[2]*M,f}function We(f,c){return f[0]*c[0]+f[1]*c[1]+f[2]*c[2]}function wt(f,c,h){var y=c[0],b=c[1],M=c[2],E=h[0],L=h[1],z=h[2];return f[0]=b*z-M*L,f[1]=M*E-y*z,f[2]=y*L-b*E,f}function Pe(f,c,h,y){var b=c[0],M=c[1],E=c[2];return f[0]=b+y*(h[0]-b),f[1]=M+y*(h[1]-M),f[2]=E+y*(h[2]-E),f}function st(f,c,h){var y=c[0],b=c[1],M=c[2],E=h[3]*y+h[7]*b+h[11]*M+h[15];return f[0]=(h[0]*y+h[4]*b+h[8]*M+h[12])/(E=E||1),f[1]=(h[1]*y+h[5]*b+h[9]*M+h[13])/E,f[2]=(h[2]*y+h[6]*b+h[10]*M+h[14])/E,f}function ue(f,c,h){var y=c[0],b=c[1],M=c[2];return f[0]=y*h[0]+b*h[3]+M*h[6],f[1]=y*h[1]+b*h[4]+M*h[7],f[2]=y*h[2]+b*h[5]+M*h[8],f}function $e(f,c,h){var y=h[0],b=h[1],M=h[2],E=h[3],L=c[0],z=c[1],V=c[2],Z=b*V-M*z,Q=M*L-y*V,ee=y*z-b*L;return f[0]=L+E*(Z+=Z)+b*(ee+=ee)-M*(Q+=Q),f[1]=z+E*Q+M*Z-y*ee,f[2]=V+E*ee+y*Q-b*Z,f}function tt(f){return f[0]=0,f[1]=0,f[2]=0,f}function rt(f,c){return f[0]===c[0]&&f[1]===c[1]&&f[2]===c[2]}var je=ge,it=Te,Se=pe;function et(){var f=new m(4);return m!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0,f[3]=0),f}function Qe(f,c,h){return f[0]=c[0]*h,f[1]=c[1]*h,f[2]=c[2]*h,f[3]=c[3]*h,f}function He(f,c){var h=c[0],y=c[1],b=c[2],M=c[3],E=h*h+y*y+b*b+M*M;return E>0&&(E=1/Math.sqrt(E)),f[0]=h*E,f[1]=y*E,f[2]=b*E,f[3]=M*E,f}function ot(f,c,h){var y=c[0],b=c[1],M=c[2],E=c[3];return f[0]=h[0]*y+h[4]*b+h[8]*M+h[12]*E,f[1]=h[1]*y+h[5]*b+h[9]*M+h[13]*E,f[2]=h[2]*y+h[6]*b+h[10]*M+h[14]*E,f[3]=h[3]*y+h[7]*b+h[11]*M+h[15]*E,f}function ut(){var f=new m(4);return m!=Float32Array&&(f[0]=0,f[1]=0,f[2]=0),f[3]=1,f}function ft(f){return f[0]=0,f[1]=0,f[2]=0,f[3]=1,f}function ct(f,c,h){h*=.5;var y=c[0],b=c[1],M=c[2],E=c[3],L=Math.sin(h),z=Math.cos(h);return f[0]=y*z+E*L,f[1]=b*z+M*L,f[2]=M*z-b*L,f[3]=E*z-y*L,f}function Tt(f,c,h){h*=.5;var y=c[0],b=c[1],M=c[2],E=c[3],L=Math.sin(h),z=Math.cos(h);return f[0]=y*z-M*L,f[1]=b*z+E*L,f[2]=M*z+y*L,f[3]=E*z-b*L,f}oe(),et();var Ot,rr,Lr,cr=He,Mr=(Ot=oe(),rr=ie(1,0,0),Lr=ie(0,1,0),function(f,c,h){var y=We(c,h);return y<-.999999?(wt(Ot,rr,c),Se(Ot)<1e-6&&wt(Ot,Lr,c),Ie(Ot,Ot),function(b,M,E){E*=.5;var L=Math.sin(E);b[0]=L*M[0],b[1]=L*M[1],b[2]=L*M[2],b[3]=Math.cos(E)}(f,Ot,Math.PI),f):y>.999999?(f[0]=0,f[1]=0,f[2]=0,f[3]=1,f):(wt(Ot,c,h),f[0]=Ot[0],f[1]=Ot[1],f[2]=Ot[2],f[3]=1+y,cr(f,f))});function As(){var f=new m(2);return m!=Float32Array&&(f[0]=0,f[1]=0),f}function Et(f,c){var h=new m(2);return h[0]=f,h[1]=c,h}function Pt(f,c,h){return f[0]=c,f[1]=h,f}function Sr(f,c,h){return f[0]=c[0]+h[0],f[1]=c[1]+h[1],f}function fs(f,c,h){return f[0]=c[0]-h[0],f[1]=c[1]-h[1],f}function Ws(f,c,h){return f[0]=c[0]*h,f[1]=c[1]*h,f}function tn(f){var c=f[0],h=f[1];return Math.sqrt(c*c+h*h)}function xi(f,c){var h=c[0],y=c[1],b=h*h+y*y;return b>0&&(b=1/Math.sqrt(b)),f[0]=c[0]*b,f[1]=c[1]*b,f}function La(f,c){return f[0]*c[0]+f[1]*c[1]}ut(),ut(),g();var un,ia,rn=fs;function Wn(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}As();var Yn=function(){if(ia)return un;function f(c,h,y,b){this.cx=3*c,this.bx=3*(y-c)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*h,this.by=3*(b-h)-this.cy,this.ay=1-this.cy-this.by,this.p1x=c,this.p1y=h,this.p2x=y,this.p2y=b}return ia=1,un=f,f.prototype={sampleCurveX:function(c){return((this.ax*c+this.bx)*c+this.cx)*c},sampleCurveY:function(c){return((this.ay*c+this.by)*c+this.cy)*c},sampleCurveDerivativeX:function(c){return(3*this.ax*c+2*this.bx)*c+this.cx},solveCurveX:function(c,h){if(h===void 0&&(h=1e-6),c<0)return 0;if(c>1)return 1;for(var y=c,b=0;b<8;b++){var M=this.sampleCurveX(y)-c;if(Math.abs(M)M?L=y:z=y,y=.5*(z-L)+L;return y},solve:function(c,h){return this.sampleCurveY(this.solveCurveX(c,h))}},un}(),Pi=Wn(Yn);function dr(f,c){this.x=f,this.y=c}function $a(f,c){if(Array.isArray(f)){if(!Array.isArray(c)||f.length!==c.length)return!1;for(let h=0;h=1)return 1;const c=f*f,h=c*f;return 4*(f<.5?h:3*(f-c)+h-.75)}function Tc(f,c,h,y){const b=new Pi(f,c,h,y);return function(M){return b.solve(M)}}const nt=Tc(.25,.1,.25,1);function ye(f,c,h){return Math.min(h,Math.max(c,f))}function De(f,c,h){return(h=ye((h-f)/(c-f),0,1))*h*(3-2*h)}function Xe(f,c,h){const y=h-c,b=((f-c)%y+y)%y+c;return b===c?h:b}function Ct(f,c,h){if(!f.length)return h(null,[]);let y=f.length;const b=new Array(f.length);let M=null;f.forEach((E,L)=>{c(E,(z,V)=>{z&&(M=z),b[L]=V,--y==0&&h(M,b)})})}let jt=1;function Dt(){return jt++}function Gt(f){return f<=1?1:Math.pow(2,Math.ceil(Math.log2(f)))}function Ft(f,c){f.forEach(h=>{c[h]&&(c[h]=c[h].bind(c))})}function Yt(f,c,h){const y={};for(const b in f)y[b]=c.call(this,f[b],b,f);return y}function yr(f,c,h){const y={};for(const b in f)c.call(this,f[b],b,f)&&(y[b]=f[b]);return y}function hr(f){return Array.isArray(f)?f.map(hr):typeof f=="object"&&f?Yt(f,hr):f}function ss(f,c){for(let h=0;h=0)return!0;return!1}const Is={};function ts(f){Is[f]||(typeof console<"u"&&console.warn(f),Is[f]=!0)}function yn(f,c,h){return(h.y-f.y)*(c.x-f.x)>(c.y-f.y)*(h.x-f.x)}function vn(f){let c=0;for(let h,y,b=0,M=f.length,E=M-1;b@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(h,y,b,M)=>{const E=b||M;return c[y]=!E||E.toLowerCase(),""}),c["max-age"]){const h=parseInt(c["max-age"],10);isNaN(h)?delete c["max-age"]:c["max-age"]=h}return c}let Eo=null;function Ma(f,c){return[f[4*c],f[4*c+1],f[4*c+2],f[4*c+3]]}function Do(f,c,h,y){for(;c>1;f[b]>1;f[b]<=y?c=b+1:h=b}return c}function da(f){return f>0?1/(1.001-f):1+f}function Ui(f){return f>0?1-1/(1.001-f):-f}function Ja(f,c,h){return(f-c.min)*(h.max-h.min)/(c.max-c.min)+h.min}const Gn={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(!Gn.API_URL)return null;try{const f=new URL(Gn.API_URL);return f.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":f.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",RASTERARRAYS_URL_PREFIX:"rasterarrays/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.4.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function Vi(f){return Gn.API_URL_REGEX.test(f)}function Cl(f){return Gn.API_SPRITE_REGEX.test(f)}let $l,hd,Ym,el,Jd,Ac;function Ch(){return $l==null&&($l=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),$l}const tl={now:()=>el!==void 0?el:performance.now(),setNow(f){el=f},restoreNow(){el=void 0},frame(f){const c=requestAnimationFrame(f);return{cancel:()=>cancelAnimationFrame(c)}},getImageData(f,c=0){const{width:h,height:y}=f;Jd||(Jd=document.createElement("canvas"));const b=Jd.getContext("2d",{willReadFrequently:!0});if(!b)throw new Error("failed to create canvas 2d context");return(h>Jd.width||y>Jd.height)&&(Jd.width=h,Jd.height=y),b.clearRect(-c,-c,h+2*c,y+2*c),b.drawImage(f,0,0,h,y),b.getImageData(-c,-c,h+2*c,y+2*c)},resolveURL:f=>(hd||(hd=document.createElement("a")),hd.href=f,hd.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Ym==null&&(Ym=window.matchMedia("(prefers-reduced-motion: reduce)")),Ym.matches)},hasCanvasFingerprintNoise(){if(Ac!==void 0)return Ac;if(!Ch())return Ac=!1,!1;const f=new OffscreenCanvas(85,1),c=f.getContext("2d",{willReadFrequently:!0});let h=0;for(let b=0;b0?`?${M}`:""}`}const w0="mapbox-tiles";let j0=500,k0=50;const lm=["language","worldview","jobid"];let Wu,md;function _u(){try{return caches}catch{}}function Ec(){const f=_u();f&&Wu==null&&(Wu=f.open(w0))}let fd=1/0;const Zo={supported:!1,testSupport:function(f){!eu&&cm&&(tp?Fx(f):Gu=f)}};let Gu,cm,eu=!1,tp=!1;const N0=typeof self<"u"?self:{};function Fx(f){const c=f.createTexture();f.bindTexture(f.TEXTURE_2D,c);try{if(f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,cm),f.isContextLost())return;Zo.supported=!0}catch{}f.deleteTexture(c),eu=!0}N0.document&&(cm=N0.document.createElement("img"),cm.onload=function(){Gu&&Fx(Gu),Gu=null,tp=!0},cm.onerror=function(){eu=!0,Gu=null},cm.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const rp={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(rp);class Ed extends Error{constructor(c,h,y){h===401&&Vi(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=h,this.url=y}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const S0=ra()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Xm=function(f,c){if(!(/^file:/.test(h=f.url)||/^file:/.test(S0())&&!/^\w+:/.test(h))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(y,b){const M=new AbortController,E=new Request(y.url,{method:y.method||"GET",body:y.body,credentials:y.credentials,headers:y.headers,referrer:S0(),referrerPolicy:y.referrerPolicy,signal:M.signal});let L=!1,z=!1;const V=(Z=E.url).indexOf("sku=")>0&&Vi(Z);var Z;y.type==="json"&&E.headers.set("Accept","application/json");const Q=(ne,le,xe)=>{if(z)return;if(ne&&ne.message!=="SecurityError"&&ts(ne.toString()),le&&xe)return ee(le);const Ce=Date.now();fetch(E).then(Ne=>{if(Ne.ok){const Fe=V?Ne.clone():null;return ee(Ne,Fe,Ce)}return b(new Ed(Ne.statusText,Ne.status,y.url))}).catch(Ne=>{Ne.name!=="AbortError"&&b(new Error(`${Ne.message} ${y.url}`))})},ee=(ne,le,xe)=>{(y.type==="arrayBuffer"?ne.arrayBuffer():y.type==="json"?ne.json():ne.text()).then(Ce=>{z||(le&&xe&&function(Ne,Fe,Be){if(Ec(),Wu==null)return;const Je=eo(Fe.headers.get("Cache-Control")||"");if(Je["no-store"])return;const yt={status:Fe.status,statusText:Fe.statusText,headers:new Headers};Fe.headers.forEach((It,Rt)=>yt.headers.set(Rt,It)),Je["max-age"]&&yt.headers.set("Expires",new Date(Be+1e3*Je["max-age"]).toUTCString());const mt=yt.headers.get("Expires");if(!mt||new Date(mt).getTime()-Be<42e4)return;let kt=_g(Ne.url,{persistentParams:lm});if(Fe.status===206){const It=Ne.headers.get("Range");if(!It)return;yt.status=200,kt=ep(kt,{range:It})}(function(It,Rt){if(md===void 0)try{new Response(new ReadableStream),md=!0}catch{md=!1}md?Rt(It.body):It.blob().then(Rt).catch(tr=>ts(tr.message))})(Fe,It=>{const Rt=new Response((tr=Fe.status)!==200&&tr!==404&&[101,103,204,205,304].includes(tr)?null:It,yt);var tr;Ec(),Wu!=null&&Wu.then($t=>$t.put(kt,Rt)).catch($t=>ts($t.message))})}(E,le,xe),L=!0,b(null,Ce,ne.headers))}).catch(Ce=>{z||b(new Error(Ce.message))})};return V?function(ne,le){if(Ec(),Wu==null)return le(null);Wu.then(xe=>{let Ce=_g(ne.url,{persistentParams:lm});const Ne=ne.headers.get("Range");Ne&&(Ce=ep(Ce,{range:Ne})),xe.match(Ce).then(Fe=>{const Be=function(Je){if(!Je)return!1;const yt=new Date(Je.headers.get("Expires")||0),mt=eo(Je.headers.get("Cache-Control")||"");return Number(yt)>Date.now()&&!mt["no-cache"]}(Fe);xe.delete(Ce).catch(le),Be&&xe.put(Ce,Fe.clone()).catch(le),le(null,Fe,Be)}).catch(le)}).catch(le)}(E,Q):Q(null,null),{cancel:()=>{z=!0,L||M.abort()}}}(f,c);if(ra(self)&&self.worker.actor)return self.worker.actor.send("getResource",f,c,void 0,!0)}var h;return function(y,b){const M=new XMLHttpRequest;M.open(y.method||"GET",y.url,!0),y.type==="arrayBuffer"&&(M.responseType="arraybuffer");for(const E in y.headers)M.setRequestHeader(E,y.headers[E]);return y.type==="json"&&(M.responseType="text",M.setRequestHeader("Accept","application/json")),M.withCredentials=y.credentials==="include",M.onerror=()=>{b(new Error(M.statusText))},M.onload=()=>{if((M.status>=200&&M.status<300||M.status===0)&&M.response!==null){let E=M.response;if(y.type==="json")try{E=JSON.parse(M.response)}catch(z){return b(z)}const L=new Headers;M.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(z=>{const V=z.split(": "),Z=V.shift(),Q=V.join(": ");L.append(Z,Q)}),b(null,E,L)}else b(new Ed(M.statusText,M.status,y.url))},M.send(y.body),{cancel:()=>M.abort()}}(f,c)},Ku=function(f,c){return Xm(Object.assign(f,{type:"arrayBuffer"}),c)};function oM(f){const c=document.createElement("a");return c.href=f,c.protocol===location.protocol&&c.host===location.host}const AN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let zx,oa;zx=[],oa=0;const C0=function(f,c){if(Zo.supported&&(f.headers||(f.headers={}),f.headers.accept="image/webp,*/*"),oa>=Gn.MAX_PARALLEL_IMAGE_REQUESTS){const M={requestParameters:f,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return zx.push(M),M}oa++;let h=!1;const y=()=>{if(!h)for(h=!0,oa--;zx.length&&oa{y(),M?c(M):E&&(self.createImageBitmap?function(z,V){const Z=new Blob([new Uint8Array(z)],{type:"image/png"});createImageBitmap(Z).then(Q=>{V(null,Q)}).catch(Q=>{V(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.`))})}(E,(z,V)=>c(z,V,L)):function(z,V){const Z=new Image;Z.onload=()=>{V(null,Z),URL.revokeObjectURL(Z.src),Z.onload=null,requestAnimationFrame(()=>{Z.src=AN})},Z.onerror=()=>V(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"});Z.src=z.byteLength?URL.createObjectURL(Q):AN}(E,(z,V)=>c(z,V,L)))});return{cancel:()=>{b.cancel(),y()}}};var x_,EN,IN,Qm={exports:{}},bg={exports:{}},Bx={exports:{}},St=function(){if(IN)return Qm.exports;IN=1;var f=(x_||(x_=1,bg.exports=function(h,y){var b,M,E,L,z,V,Z,Q;for(M=h.length-(b=3&h.length),E=y,z=3432918353,V=461845907,Q=0;Q>>16)*z&65535)<<16)&4294967295)<<15|Z>>>17))*V+(((Z>>>16)*V&65535)<<16)&4294967295)<<13|E>>>19))+((5*(E>>>16)&65535)<<16)&4294967295))+((58964+(L>>>16)&65535)<<16);switch(Z=0,b){case 3:Z^=(255&h.charCodeAt(Q+2))<<16;case 2:Z^=(255&h.charCodeAt(Q+1))<<8;case 1:E^=Z=(65535&(Z=(Z=(65535&(Z^=255&h.charCodeAt(Q)))*z+(((Z>>>16)*z&65535)<<16)&4294967295)<<15|Z>>>17))*V+(((Z>>>16)*V&65535)<<16)&4294967295}return E^=h.length,E=2246822507*(65535&(E^=E>>>16))+((2246822507*(E>>>16)&65535)<<16)&4294967295,E=3266489909*(65535&(E^=E>>>13))+((3266489909*(E>>>16)&65535)<<16)&4294967295,(E^=E>>>16)>>>0}),bg.exports),c=(EN||(EN=1,Bx.exports=function(h,y){for(var b,M=h.length,E=y^M,L=0;M>=4;)b=1540483477*(65535&(b=255&h.charCodeAt(L)|(255&h.charCodeAt(++L))<<8|(255&h.charCodeAt(++L))<<16|(255&h.charCodeAt(++L))<<24))+((1540483477*(b>>>16)&65535)<<16),E=1540483477*(65535&E)+((1540483477*(E>>>16)&65535)<<16)^(b=1540483477*(65535&(b^=b>>>24))+((1540483477*(b>>>16)&65535)<<16)),M-=4,++L;switch(M){case 3:E^=(255&h.charCodeAt(L+2))<<16;case 2:E^=(255&h.charCodeAt(L+1))<<8;case 1:E=1540483477*(65535&(E^=255&h.charCodeAt(L)))+((1540483477*(E>>>16)&65535)<<16)}return E=1540483477*(65535&(E^=E>>>13))+((1540483477*(E>>>16)&65535)<<16),(E^=E>>>15)>>>0}),Bx.exports);return Qm.exports=f,Qm.exports.murmur3=f,Qm.exports.murmur2=c,Qm.exports}(),vr=Wn(St);class Hr{constructor(c,...h){Object.assign(this,h[0]||{}),this.type=c}}class pn extends Hr{constructor(c,h={}){super("error",Object.assign({error:c},h))}}function gn(f,c,h){h[f]&&h[f].indexOf(c)!==-1||(h[f]=h[f]||[],h[f].push(c))}function ua(f,c,h){if(h&&h[f]){const y=h[f].indexOf(c);y!==-1&&h[f].splice(y,1)}}class Kn{on(c,h){return this._listeners=this._listeners||{},gn(c,h,this._listeners),this}off(c,h){return ua(c,h,this._listeners),ua(c,h,this._oneTimeListeners),this}once(c,h){return h?(this._oneTimeListeners=this._oneTimeListeners||{},gn(c,h,this._oneTimeListeners),this):new Promise(y=>{this.once(c,y)})}fire(c,h){const y=typeof c=="string"?new Hr(c,h):c,b=y.type;if(this.listens(b)){y.target=this;const M=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const z of M)z.call(this,y);const E=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const z of E)ua(b,z,this._oneTimeListeners),z.call(this,y);const L=this._eventedParent;if(L){const z=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(y,z),L.fire(y)}}else y instanceof pn&&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,h){return this._eventedParent=c,this._eventedParentData=h,this}}class Ta{constructor(c){typeof c=="string"?this.name=c:(this.name=c.name,this.iconsetId=c.iconsetId)}static from(c){return new Ta(c)}static toString(c){return c.iconsetId?`${c.name}${c.iconsetId}`:c.name}static parse(c){const[h,y]=c.split("");return new Ta({name:h,iconsetId:y})}static isEqual(c,h){return c.name===h.name&&c.iconsetId===h.iconsetId}toString(){return Ta.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var dm,bu={},Ul=function(){if(dm)return bu;dm=1;var f={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function c(M){return(M=Math.round(M))<0?0:M>255?255:M}function h(M){return c(M[M.length-1]==="%"?parseFloat(M)/100*255:parseInt(M))}function y(M){return(E=M[M.length-1]==="%"?parseFloat(M)/100:parseFloat(M))<0?0:E>1?1:E;var E}function b(M,E,L){return L<0?L+=1:L>1&&(L-=1),6*L<1?M+(E-M)*L*6:2*L<1?E:3*L<2?M+(E-M)*(2/3-L)*6:M}try{bu.parseCSSColor=function(M){var E,L=M.replace(/ /g,"").toLowerCase();if(L in f)return f[L].slice();if(L[0]==="#")return L.length===4?(E=parseInt(L.substr(1),16))>=0&&E<=4095?[(3840&E)>>4|(3840&E)>>8,240&E|(240&E)>>4,15&E|(15&E)<<4,1]:null:L.length===7&&(E=parseInt(L.substr(1),16))>=0&&E<=16777215?[(16711680&E)>>16,(65280&E)>>8,255&E,1]:null;var z=L.indexOf("("),V=L.indexOf(")");if(z!==-1&&V+1===L.length){var Z=L.substr(0,z),Q=L.substr(z+1,V-(z+1)).split(","),ee=1;switch(Z){case"rgba":if(Q.length!==4)return null;ee=y(Q.pop());case"rgb":return Q.length!==3?null:[h(Q[0]),h(Q[1]),h(Q[2]),ee];case"hsla":if(Q.length!==4)return null;ee=y(Q.pop());case"hsl":if(Q.length!==3)return null;var ne=(parseFloat(Q[0])%360+360)%360/360,le=y(Q[1]),xe=y(Q[2]),Ce=xe<=.5?xe*(le+1):xe+le-xe*le,Ne=2*xe-Ce;return[c(255*b(Ne,Ce,ne+1/3)),c(255*b(Ne,Ce,ne)),c(255*b(Ne,Ce,ne-1/3)),ee];default:return null}}return null}}catch{}return bu}();class Aa{constructor(c,h,y,b=1){this.r=c,this.g=h,this.b=y,this.a=b}static parse(c){if(!c)return;if(c instanceof Aa)return c;if(typeof c!="string")return;const h=Ul.parseCSSColor(c);return h?new Aa(h[0]/255,h[1]/255,h[2]/255,h[3]):void 0}toString(){const[c,h,y,b]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*c)},${Math.round(255*h)},${Math.round(255*y)},${b})`}toNonPremultipliedRenderColor(c){const{r:h,g:y,b,a:M}=this;return new tL(c,h,y,b,M)}toPremultipliedRenderColor(c){const{r:h,g:y,b,a:M}=this;return new rL(c,h*M,y*M,b*M,M)}clone(){return new Aa(this.r,this.g,this.b,this.a)}}class PN{constructor(c,h,y,b,M,E=!1){if(this.premultiplied=!1,this.premultiplied=E,c){const L=c.image.height,z=L*L;this.premultiplied?(h=M===0?0:h/M*(L-1),y=M===0?0:y/M*(L-1),b=M===0?0:b/M*(L-1)):(h*=L-1,y*=L-1,b*=L-1);const V=Math.floor(h),Z=Math.floor(y),Q=Math.floor(b),ee=Math.ceil(h),ne=Math.ceil(y),le=Math.ceil(b),xe=h-V,Ce=y-Z,Ne=b-Q,Fe=c.image.data,Be=4*(V+Z*z+Q*L),Je=4*(V+Z*z+le*L),yt=4*(V+ne*z+Q*L),mt=4*(V+ne*z+le*L),kt=4*(ee+Z*z+Q*L),It=4*(ee+Z*z+le*L),Rt=4*(ee+ne*z+Q*L),tr=4*(ee+ne*z+le*L);if(Be<0||tr>=Fe.length)throw new Error("out of range");this.r=Gs(Gs(Gs(Fe[Be],Fe[Je],Ne),Gs(Fe[yt],Fe[mt],Ne),Ce),Gs(Gs(Fe[kt],Fe[It],Ne),Gs(Fe[Rt],Fe[tr],Ne),Ce),xe)/255*(this.premultiplied?M:1),this.g=Gs(Gs(Gs(Fe[Be+1],Fe[Je+1],Ne),Gs(Fe[yt+1],Fe[mt+1],Ne),Ce),Gs(Gs(Fe[kt+1],Fe[It+1],Ne),Gs(Fe[Rt+1],Fe[tr+1],Ne),Ce),xe)/255*(this.premultiplied?M:1),this.b=Gs(Gs(Gs(Fe[Be+2],Fe[Je+2],Ne),Gs(Fe[yt+2],Fe[mt+2],Ne),Ce),Gs(Gs(Fe[kt+2],Fe[It+2],Ne),Gs(Fe[Rt+2],Fe[tr+2],Ne),Ce),xe)/255*(this.premultiplied?M:1),this.a=M}else this.r=h,this.g=y,this.b=b,this.a=M}toArray(){const{r:c,g:h,b:y,a:b}=this;return[255*c,255*h,255*y,b]}toHslaArray(){let{r:c,g:h,b:y,a:b}=this;if(this.premultiplied){if(b===0)return[0,0,0,0];const le=1/b;c*=le,h*=le,y*=le}const M=Math.min(Math.max(c,0),1),E=Math.min(Math.max(h,0),1),L=Math.min(Math.max(y,0),1),z=Math.min(M,E,L),V=Math.max(M,E,L),Z=V-z,Q=.5*(z+V);if(Z===0)return[0,0,100*Q,b];const ee=Q>.5?Z/(2-V-z):Z/(V+z);let ne;switch(V){case M:ne=60*((E-L)/Z+(EGs(y,c[b],h))}Aa.black=new Aa(0,0,0,1),Aa.white=new Aa(1,1,1,1),Aa.transparent=new Aa(0,0,0,0),Aa.red=new Aa(1,0,0,1),Aa.blue=new Aa(0,0,1,1);var y_=Object.freeze({__proto__:null,array:lM,color:function(f,c,h){return new Aa(Gs(f.r,c.r,h),Gs(f.g,c.g,h),Gs(f.b,c.b,h),Gs(f.a,c.a,h))},number:Gs});class Mh extends Error{constructor(c,h){super(h),this.message=h,this.key=c}}class M0{constructor(c,h=[]){this.parent=c,this.bindings={};for(const[y,b]of h)this.bindings[y]=b}concat(c){return new M0(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 um={kind:"null"},Ts={kind:"number"},ha={kind:"string"},Ya={kind:"boolean"},tu={kind:"color"},Jm={kind:"object"},Ua={kind:"value"},LN={kind:"collator"},v_={kind:"formatted"},__={kind:"resolvedImage"};function Gc(f,c){return{kind:"array",itemType:f,N:c}}function Ho(f){if(f.kind==="array"){const c=Ho(f.itemType);return typeof f.N=="number"?`array<${c}, ${f.N}>`:f.itemType.kind==="value"?"array":`array<${c}>`}return f.kind}const kle=[um,Ts,ha,Ya,tu,v_,Jm,Gc(Ua),__];function wg(f,c){if(c.kind==="error")return null;if(f.kind==="array"){if(c.kind==="array"&&(c.N===0&&c.itemType.kind==="value"||!wg(f.itemType,c.itemType))&&(typeof f.N!="number"||f.N===c.N))return null}else{if(f.kind===c.kind)return null;if(f.kind==="value"){for(const h of kle)if(!wg(h,c))return null}}return`Expected ${Ho(f)} but found ${Ho(c)} instead.`}function cM(f,c){return c.some(h=>h.kind===f.kind)}function b_(f,c){return c.some(h=>h==="null"?f===null:h==="array"?Array.isArray(f):h==="object"?f&&!Array.isArray(f)&&typeof f=="object":h===typeof f)}function DN(f,c){return f.kind==="array"&&c.kind==="array"?f.N===c.N&&DN(f.itemType,c.itemType):f.kind===c.kind}class dM{constructor(c,h,y){this.sensitivity=c?h?"variant":"case":h?"accent":"base",this.locale=y,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(c,h){return this.collator.compare(c,h)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ON{constructor(c,h,y,b,M){this.text=c.normalize?c.normalize():c,this.image=h,this.scale=y,this.fontStack=b,this.textColor=M}}class Id{constructor(c){this.sections=c}static fromString(c){return new Id([new ON(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 Id?c:Id.fromString(c)}toString(){return this.sections.length===0?"":this.sections.map(c=>c.text).join("")}serialize(){const c=["format"];for(const h of this.sections){if(h.image){const b=h.image.getPrimary().id.toString();c.push(["image",b]);continue}c.push(h.text);const y={};h.fontStack&&(y["text-font"]=["literal",h.fontStack.split(",")]),h.scale&&(y["font-scale"]=h.scale),h.textColor&&(y["text-color"]=["rgba"].concat(h.textColor.toNonPremultipliedRenderColor(null).toArray())),c.push(y)}return c}}class sp{constructor(c,h={}){this.id=Ta.from(c),this.params=h.params,this.sx=h.sx||1,this.sy=h.sy||1}toString(){return JSON.stringify(this)}static parse(c){let h,y,b,M;try{({id:h,params:y,sx:b,sy:M}=JSON.parse(c)||{})}catch{return null}return h?new sp(h,{params:y,sx:b,sy:M}):null}scaleSelf(c,h=c){return this.sx*=c,this.sy*=h,this}}class Pd{constructor(c,h,y,b,M=!1){this.primaryId=Ta.from(c),this.primaryOptions=h,y&&(this.secondaryId=Ta.from(y)),this.secondaryOptions=b,this.available=M}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new sp(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new sp(this.secondaryId,this.secondaryOptions):null}static from(c){return typeof c=="string"?Pd.build({name:c}):c}static build(c,h,y,b){return!c||typeof c=="object"&&!("name"in c)?null:new Pd(c,y,h,b)}}function $x(f,c,h,y){return typeof f=="number"&&f>=0&&f<=255&&typeof c=="number"&&c>=0&&c<=255&&typeof h=="number"&&h>=0&&h<=255?y===void 0||typeof y=="number"&&y>=0&&y<=1?null:`Invalid rgba value [${[f,c,h,y].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof y=="number"?[f,c,h,y]:[f,c,h]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function T0(f){if(f===null||typeof f=="string"||typeof f=="boolean"||typeof f=="number"||f instanceof Aa||f instanceof dM||f instanceof Id||f instanceof Pd)return!0;if(Array.isArray(f)){for(const c of f)if(!T0(c))return!1;return!0}if(typeof f=="object"){for(const c in f)if(!T0(f[c]))return!1;return!0}return!1}function Ml(f){if(f===null)return um;if(typeof f=="string")return ha;if(typeof f=="boolean")return Ya;if(typeof f=="number")return Ts;if(f instanceof Aa)return tu;if(f instanceof dM)return LN;if(f instanceof Id)return v_;if(f instanceof Pd)return __;if(Array.isArray(f)){const c=f.length;let h;for(const y of f){const b=Ml(y);if(h){if(h===b)continue;h=Ua;break}h=b}return Gc(h||Ua,c)}return Jm}function Th(f){const c=typeof f;return f===null?"":c==="string"||c==="number"||c==="boolean"?String(f):f instanceof Id||f instanceof Pd||f instanceof Aa?f.toString():JSON.stringify(f)}class np{constructor(c,h){this.type=c,this.value=h}static parse(c,h){if(c.length!==2)return h.error(`'literal' expression requires exactly one argument, but found ${c.length-1} instead.`);if(!T0(c[1]))return h.error("invalid value");const y=c[1];let b=Ml(y);const M=h.expectedType;return b.kind!=="array"||b.N!==0||!M||M.kind!=="array"||typeof M.N=="number"&&M.N!==0||(b=M),new np(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 Aa?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Id?this.value.serialize():this.value}}class gl{constructor(c){this.name="ExpressionEvaluationError",this.message=c}toJSON(){return this.message}}const uM={string:ha,number:Ts,boolean:Ya,object:Jm};class hm{constructor(c,h){this.type=c,this.args=h}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");let y,b=1;const M=c[0];if(M==="array"){let L,z;if(c.length>2){const V=c[1];if(typeof V!="string"||!(V in uM)||V==="object")return h.error('The item type argument of "array" must be one of string, number, boolean',1);L=uM[V],b++}else L=Ua;if(c.length>3){if(c[2]!==null&&(typeof c[2]!="number"||c[2]<0||c[2]!==Math.floor(c[2])))return h.error('The length argument to "array" must be a positive integer literal',2);z=c[2],b++}y=Gc(L,z)}else y=uM[M];const E=[];for(;bc.outputDefined())}serialize(){const c=this.type,h=[c.kind];if(c.kind==="array"){const y=c.itemType;if(y.kind==="string"||y.kind==="number"||y.kind==="boolean"){h.push(y.kind);const b=c.N;(typeof b=="number"||this.args.length>1)&&h.push(b)}}return h.concat(this.args.map(y=>y.serialize()))}}class ef{constructor(c){this.type=v_,this.sections=c}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");const y=c[1];if(!Array.isArray(y)&&typeof y=="object")return h.error("First argument must be an image or text section.");const b=[];let M=!1;for(let E=1;E<=c.length-1;++E){const L=c[E];if(M&&typeof L=="object"&&!Array.isArray(L)){M=!1;let z=null;if(L["font-scale"]&&(z=h.parseObjectValue(L["font-scale"],E,"font-scale",Ts),!z))return null;let V=null;if(L["text-font"]&&(V=h.parseObjectValue(L["text-font"],E,"text-font",Gc(ha)),!V))return null;let Z=null;if(L["text-color"]&&(Z=h.parseObjectValue(L["text-color"],E,"text-color",tu),!Z))return null;const Q=b[b.length-1];Q.scale=z,Q.font=V,Q.textColor=Z}else{const z=h.parse(c[E],E,Ua);if(!z)return null;const V=z.type.kind;if(V!=="string"&&V!=="value"&&V!=="null"&&V!=="resolvedImage")return h.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");M=!0,b.push({content:z,scale:null,font:null,textColor:null})}}return new ef(b)}evaluate(c){return new Id(this.sections.map(h=>{const y=h.content.evaluate(c);return DN(Ml(y),__)?new ON("",y,null,null,null):new ON(Th(y),null,h.scale?h.scale.evaluate(c):null,h.font?h.font.evaluate(c).join(","):null,h.textColor?h.textColor.evaluate(c):null)}))}eachChild(c){for(const h of this.sections)c(h.content),h.scale&&c(h.scale),h.font&&c(h.font),h.textColor&&c(h.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const h of this.sections){c.push(h.content.serialize());const y={};h.scale&&(y["font-scale"]=h.scale.serialize()),h.font&&(y["text-font"]=h.font.serialize()),h.textColor&&(y["text-color"]=h.textColor.serialize()),c.push(y)}return c}}class wn{constructor(c,h,y,b){this._imageWarnHistory={},this.type=__,this.namePrimary=c,this.nameSecondary=h,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,h){if(c.length<2)return h.error("Expected two or more arguments.");let y=1;const b=[];function M(){if(yTa.isEqual(E,M)),b.available){const E=b.getSecondary()?b.getSecondary().id:null;E&&(b.available=c.availableImages.some(L=>Ta.isEqual(L,E)))}}return b}eachChild(c){if(c(this.namePrimary),this.paramsPrimary)for(const h in this.paramsPrimary)this.paramsPrimary[h]&&c(this.paramsPrimary[h]);if(this.nameSecondary&&(c(this.nameSecondary),this.paramsSecondary))for(const h in this.paramsSecondary)this.paramsSecondary[h]&&c(this.paramsSecondary[h])}outputDefined(){return!1}serializeOptions(c,h){const y={};if(h&&(y.iconset={id:h}),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 h=this.serializeOptions(this.paramsPrimary,this.iconsetIdPrimary);h&&c.push(h)}if(this.nameSecondary&&(c.push(this.nameSecondary.serialize()),this.paramsSecondary||this.iconsetIdSecondary)){const h=this.serializeOptions(this.paramsSecondary,this.iconsetIdSecondary);h&&c.push(h)}return c}}function ks(f){return Js(f)?"string":A0(f)?"number":FN(f)?"boolean":Array.isArray(f)?"array":f===null?"null":RN(f)?"object":typeof f}function RN(f){return f!=null&&!Array.isArray(f)&&typeof f!="function"&&!(f instanceof String||f instanceof Number||f instanceof Boolean)&&typeof f=="object"}function Js(f){return typeof f=="string"||f instanceof String}function A0(f){return typeof f=="number"||f instanceof Number}function FN(f){return typeof f=="boolean"||f instanceof Boolean}const Ys={"to-boolean":Ya,"to-color":tu,"to-number":Ts,"to-string":ha};class tf{constructor(c,h){this.type=c,this.args=h}static parse(c,h){if(c.length<2)return h.error("Expected at least one argument.");const y=c[0],b=[];let M=um;if(y==="to-array"){if(!Array.isArray(c[1]))return null;const E=c[1].length;if(h.expectedType){if(h.expectedType.kind!=="array")return h.error(`Expected ${h.expectedType.kind} but found array.`);M=Gc(h.expectedType.itemType,E)}else{if(!(E>0&&T0(c[1][0])))return null;M=Gc(Ml(c[1][0]),E)}for(let L=0;L4?`Invalid rbga value ${JSON.stringify(h)}: expected an array containing either three or four numeric values.`:$x(h[0],h[1],h[2],h[3]),!y))return new Aa(h[0]/255,h[1]/255,h[2]/255,h[3])}throw new gl(y||`Could not parse color from value '${typeof h=="string"?h:String(JSON.stringify(h))}'`)}if(this.type.kind==="number"){let h=null;for(const y of this.args){if(h=y.evaluate(c),h===null)return 0;const b=Number(h);if(!isNaN(b))return b}throw new gl(`Could not convert ${JSON.stringify(h)} to number.`)}return this.type.kind==="formatted"?Id.fromString(Th(this.args[0].evaluate(c))):this.type.kind==="resolvedImage"?Pd.build(Th(this.args[0].evaluate(c))):this.type.kind==="array"?this.args.map(h=>h.evaluate(c)):Th(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 ef([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new wn(this.args[0]).serialize();const c=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(h=>{c.push(h.serialize())}),c}}const hM=["Unknown","Point","LineString","Polygon"];class zN{constructor(c,h,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=h,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"?hM[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,h=this.featureDistanceData.scale,{x:y,y:b}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(y*h-c[0])+this.featureDistanceData.bearing[1]*(b*h-c[1])}return 0}parseColor(c){let h=this._parseColorCache[c];return h||(h=this._parseColorCache[c]=Aa.parse(c)),h}getConfig(c){return this.options?this.options.get(c):null}}class Ld{constructor(c,h,y,b,M){this.name=c,this.type=h,this._evaluate=y,this.args=b,this._overloadIndex=M}evaluate(c){if(!this._evaluate){const h=Ld.definitions[this.name];this._evaluate=Array.isArray(h)?h[2]:h.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,h){const y=c[0],b=Ld.definitions[y];if(!b)return h.error(`Unknown expression "${y}". If you wanted a literal array, use ["literal", [...]].`,0);const M=Array.isArray(b)?b[0]:b.type,E=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,L=[];let z=null,V=-1;for(const[Z,Q]of E){if(Array.isArray(Z)&&Z.length!==c.length-1)continue;L.push(Z),V++,z=new XN(h.registry,h.path,null,h.scope,void 0,h._scope,h.options,h.iconImageUseTheme);const ee=[];let ne=!1;for(let le=1;leee)).map(BN).join(" | "),Q=[];for(let ee=1;eeh;){if(y-h>600){const z=y-h+1,V=c-h+1,Z=Math.log(z),Q=.5*Math.exp(2*Z/3),ee=.5*Math.sqrt(Z*Q*(z-Q)/z)*(V-z/2<0?-1:1);$N(f,c,Math.max(h,Math.floor(c-V*Q/z+ee)),Math.min(y,Math.floor(c+(z-V)*Q/z+ee)),b)}const M=f[c];let E=h,L=y;for(mm(f,h,c),b(f[y],M)>0&&mm(f,h,y);E0;)L--}b(f[h],M)===0?mm(f,h,L):(L++,mm(f,L,y)),L<=c&&(h=L+1),c<=L&&(y=L-1)}}function mm(f,c,h){const y=f[c];f[c]=f[h],f[h]=y}function mM(f,c){return fc?1:0}function jg(f){let c=0;for(let h,y,b=0,M=f.length,E=M-1;b=c[2]||f[1]<=c[1]||f[3]>=c[3])}function Nle(f,c,h){const y=f[0]-c[0],b=f[1]-c[1],M=f[0]-h[0],E=f[1]-h[1];return y*E-M*b==0&&y*M<=0&&b*E<=0}function E0(f,c,h=!1){let y=!1;for(let L=0,z=c.length;L(b=f)[1]!=(E=le)[1]>b[1]&&b[0]<(E[0]-M[0])*(b[1]-M[1])/(E[1]-M[1])+M[0]&&(y=!y)}}var b,M,E;return y}function j_(f,c,h,y){const b=y[0]-h[0],M=y[1]-h[1],E=(f[0]-h[0])*M-b*(f[1]-h[1]),L=(c[0]-h[0])*M-b*(c[1]-h[1]);return E>0&&L<0||E<0&&L>0}function k_(f,c,h,y){return(b=[y[0]-h[0],y[1]-h[1]])[0]*(M=[c[0]-f[0],c[1]-f[1]])[1]-b[1]*M[0]!=0&&!(!j_(f,c,h,y)||!j_(h,y,f,c));var b,M}function ap(f){const c=new dr(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h=new dr(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const y of f[0])c.x>y.x&&(c.x=y.x),c.y>y.y&&(c.y=y.y),h.xh[2]){const b=.5*y;let M=f[0]-h[0]>b?-y:h[0]-f[0]>b?y:0;M===0&&(M=f[0]-h[2]>b?-y:h[2]-f[0]>b?y:0),f[0]+=M}Ah(c,f)}function iL(f,c,h,y){const b=Math.pow(2,y.z)*kg,M=[y.x*kg,y.y*kg],E=[];if(!f)return E;for(const L of f)for(const z of L){const V=[z.x+M[0],z.y+M[1]];aL(V,c,h,b),E.push(V)}return E}function UN(f,c,h,y){const b=Math.pow(2,y.z)*kg,M=[y.x*kg,y.y*kg],E=[];if(!f)return E;for(const z of f){const V=[];for(const Z of z){const Q=[Z.x+M[0],Z.y+M[1]];Ah(c,Q),V.push(Q)}E.push(V)}if(c[2]-c[0]<=b/2){(L=c)[0]=L[1]=1/0,L[2]=L[3]=-1/0;for(const z of E)for(const V of z)aL(V,c,h,b)}var L;return E}class Sg{constructor(c,h){this.type=Ya,this.geojson=c,this.geometries=h}static parse(c,h){if(c.length!==2)return h.error(`'within' expression requires exactly one argument, but found ${c.length-1} instead.`);if(T0(c[1])){const y=c[1];if(y.type==="FeatureCollection")for(let b=0;bh)return VN(M,E,(h-(y-L))/L)}return c[c.length-1]}pointToSegmentDistance(c,h,y){let[b,M]=h,E=Zu(y[0]-b)*this.kx,L=(y[1]-M)*this.ky;if(E!==0||L!==0){const z=(Zu(c[0]-b)*this.kx*E+(c[1]-M)*this.ky*L)/(E*E+L*L);z>1?(b=y[0],M=y[1]):z>0&&(b+=E/this.kx*z,M+=L/this.ky*z)}return E=Zu(c[0]-b)*this.kx,L=(c[1]-M)*this.ky,Math.sqrt(E*E+L*L)}pointOnLine(c,h){let y=1/0,b=c[0][0],M=c[0][1],E=0,L=0;for(let z=0;z1?(V=c[z+1][0],Z=c[z+1][1]):ne>0&&(V+=Q/this.kx*ne,Z+=ee/this.ky*ne)),Q=Zu(h[0]-V)*this.kx,ee=(h[1]-Z)*this.ky;const le=Q*Q+ee*ee;leM.index||b.index===M.index&&b.t>M.t){const V=b;b=M,M=V}const E=[b.point],L=b.index+1,z=M.index;!gM(y[L],E[0])&&L<=z&&E.push(y[L]);for(let V=L+1;V<=z;V++)E.push(y[V]);return gM(y[z],M.point)||E.push(M.point),E}lineSliceAlong(c,h,y){let b=0;const M=[];for(let E=0;Ec&&M.length===0&&M.push(VN(L,z,(c-(b-V))/V)),b>=h)return M.push(VN(L,z,(h-(b-V))/V)),M;b>c&&M.push(z)}return M}bufferPoint(c,h){const y=h/this.ky,b=h/this.kx;return[c[0]-b,c[1]-y,c[0]+b,c[1]+y]}bufferBBox(c,h){const y=h/this.ky,b=h/this.kx;return[c[0]-b,c[1]-y,c[2]+b,c[3]+y]}insideBBox(c,h){return Zu(c[0]-h[0])>=0&&Zu(c[0]-h[2])<=0&&c[1]>=h[1]&&c[1]<=h[3]}}function gM(f,c){return f[0]===c[0]&&f[1]===c[1]}function VN(f,c,h){const y=Zu(c[0]-f[0]);return[f[0]+y*h,f[1]+(c[1]-f[1])*h]}function Zu(f){for(;f<-180;)f+=360;for(;f>180;)f-=360;return f}class qN{constructor(c=[],h=(y,b)=>yb?1:0){if(this.data=c,this.length=this.data.length,this.compare=h,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],h=this.data.pop();return--this.length>0&&(this.data[0]=h,this._down(0)),c}peek(){return this.data[0]}_up(c){const{data:h,compare:y}=this,b=h[c];for(;c>0;){const M=c-1>>1,E=h[M];if(y(b,E)>=0)break;h[c]=E,c=M}h[c]=b}_down(c){const{data:h,compare:y}=this,b=this.length>>1,M=h[c];for(;c=0)break;h[c]=h[E],c=E}h[c]=M}}var Br=8192;function xM(f,c){return c.dist-f.dist}const HN=100,WN=50;function yM(f){const c=[1/0,1/0,-1/0,-1/0];if(c.length!==f.length)return!1;for(let h=0;h=f[0]&&f[1]f[1])return[null,null];const h=S_(f);if(c){if(h===2)return[f,null];const y=Math.floor(h/2);return[[f[0],f[0]+y],[f[0]+y,f[1]]]}{if(h===1)return[f,null];const y=Math.floor(h/2)-1;return[[f[0],f[0]+y],[f[0]+y+1,f[1]]]}}function Ux(f,c){const h=[1/0,1/0,-1/0,-1/0];if(!rf(c,f.length))return h;for(let y=c[0];y<=c[1];++y)Ah(h,f[y]);return h}function Vx(f){const c=[1/0,1/0,-1/0,-1/0];for(let h=0;hc[2]&&(y=f[0]-c[2]),f[1]>c[3]&&(b=f[1]-c[3]),f[3]=y)return y;if(w_(b,M)){if(bM(f,c))return 0}else if(bM(c,f))return 0;let E=y;for(const L of f)for(let z=0,V=L.length,Z=V-1;z=M)continue;const Z=V.range1;if(S_(Z)<=L){if(!rf(Z,f.length))return NaN;if(c){const Q=Ele(f,Z,h,y);if((M=Math.min(M,Q))===0)return M}else for(let Q=Z[0];Q<=Z[1];++Q){const ee=Ale(f[Q],h,y);if((M=Math.min(M,ee))===0)return M}}else{const Q=vM(Z,c);if(Q[0]!==null){const ee=Cg(Ux(f,Q[0]),z,y);ee=E)continue;const Q=Z.range1,ee=Z.range2;if(S_(Q)<=z&&S_(ee)<=V){if(!rf(Q,f.length)||!rf(ee,h.length))return NaN;if(c&&y?E=Math.min(E,fa(f,Q,h,ee,b)):c||y?c&&!y?E=Math.min(E,_M(h,ee,f,Q,b)):!c&&y&&(E=Math.min(E,_M(f,Q,h,ee,b))):E=Math.min(E,Tle(f,Q,h,ee,b)),E===0)return E}else{const ne=vM(Q,c),le=vM(ee,y);qi(L,E,b,f,h,ne[0],le[0]),qi(L,E,b,f,h,ne[0],le[1]),qi(L,E,b,f,h,ne[1],le[0]),qi(L,E,b,f,h,ne[1],le[1])}}return E}function wM(f,c,h,y,b=1/0){let M=b;const E=Ux(f,[0,f.length-1]);for(const L of h)if(!(M!==1/0&&Cg(E,Ux(L,[0,L.length-1]),y)>=M)&&(M=Math.min(M,dL(f,c,L,!0,y,M)),M===0))return M;return M}function ZN(f,c,h,y,b=1/0){let M=b;const E=Ux(f,[0,f.length-1]);for(const L of h){if(M!==1/0&&Cg(E,Vx(L),y)>=M)continue;const z=Ple(f,c,L,y,M);if(isNaN(z))return z;if((M=Math.min(M,z))===0)return M}return M}function jM(f){return f==="Point"||f==="MultiPoint"||f==="LineString"||f==="MultiLineString"||f==="Polygon"||f==="MultiPolygon"}class qx{constructor(c,h){this.type=Ts,this.geojson=c,this.geometries=h}static parse(c,h){if(c.length!==2)return h.error(`'distance' expression requires either one argument, but found ' ${c.length-1} instead.`);if(T0(c[1])){const y=c[1];if(y.type==="FeatureCollection"){for(let b=0;b{c&&!L0(h)&&(c=!1)}),c}function C_(f){if(f instanceof Ld&&f.name==="feature-state")return!1;let c=!0;return f.eachChild(h=>{c&&!C_(h)&&(c=!1)}),c}function D0(f,c){if(f instanceof Ld&&c.indexOf(f.name)>=0)return!1;let h=!0;return f.eachChild(y=>{h&&!D0(y,c)&&(h=!1)}),h}function uL(f,c,h){return[f,c,h].filter(Boolean).join("")}function kM(f,c){switch(f){case"string":return Th(c);case"number":return+c;case"boolean":return!!c;case"color":return Aa.parse(c);case"formatted":return Id.fromString(Th(c));case"resolvedImage":return Pd.build(Th(c))}return c}function hL(f,c,h,y){return y!==void 0&&(f=y*Math.round(f/y)),c!==void 0&&fh&&(f=h),f}class O0{constructor(c,h,y,b=!1){this.type=c,this.key=h,this.scope=y,this.featureConstant=b}static parse(c,h){let y=h.expectedType;if(y==null&&(y=Ua),c.length<2||c.length>3)return h.error("Invalid number of arguments for 'config' expression.");const b=h.parse(c[1],1);if(!(b instanceof np))return h.error("Key name of 'config' expression must be a string literal.");let M,E=!0;const L=Th(b.value);if(c.length>=3){const z=h.parse(c[2],2);if(!(z instanceof np))return h.error("Scope of 'config' expression must be a string literal.");M=Th(z.value)}if(h.options){const z=uL(L,M,h._scope),V=h.options.get(z);V&&(E=L0(V.value||V.default))}return new O0(y,L,M,E)}evaluate(c){const h=uL(this.key,this.scope,c.scope),y=c.getConfig(h);if(!y)return null;const{type:b,value:M,values:E,minValue:L,maxValue:z,stepValue:V}=y,Z=y.default.evaluate(c);let Q=Z;if(M){const ee=c.scope;c.scope=(ee||"").split("").slice(1).join(""),Q=M.evaluate(c),c.scope=ee}return b&&(Q=kM(b,Q)),Q===void 0||L===void 0&&z===void 0&&V===void 0||(typeof Q=="number"?Q=hL(Q,L,z,V):Array.isArray(Q)&&(Q=Q.map(ee=>typeof ee=="number"?hL(ee,L,z,V):ee))),M!==void 0&&Q!==void 0&&E&&!E.includes(Q)&&(Q=Z,b&&(Q=kM(b,Q))),(b&&b!==this.type||Q!==void 0&&!DN(Ml(Q),this.type))&&(Q=kM(this.type.kind,Q)),Q}eachChild(){}outputDefined(){return!1}serialize(){const c=["config",this.key];return this.scope&&c.concat(this.scope),c}}class YN{constructor(c,h){this.type=h.type,this.name=c,this.boundExpression=h}static parse(c,h){if(c.length!==2||typeof c[1]!="string")return h.error("'var' expression requires exactly one string literal argument.");const y=c[1];return h.scope.has(y)?new YN(y,h.scope.get(y)):h.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 XN{constructor(c,h=[],y,b=new M0,M=[],E,L,z){this.registry=c,this.path=h,this.key=h.map(V=>typeof V=="string"?`['${V}']`:`[${V}]`).join(""),this.scope=b,this.errors=M,this.expectedType=y,this._scope=E,this.options=L,this.iconImageUseTheme=z}parse(c,h,y,b,M={}){return h||y?this.concat(h,null,y,b)._parse(c,M):this._parse(c,M)}parseObjectValue(c,h,y,b,M,E={}){return this.concat(h,y,b,M)._parse(c,E)}_parse(c,h){function y(b,M,E){return E==="assert"?new hm(M,[b]):E==="coerce"?new tf(M,[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 M=b.parse(c,this);if(!M)return null;if(this.expectedType){const E=this.expectedType,L=M.type;if(E.kind!=="string"&&E.kind!=="number"&&E.kind!=="boolean"&&E.kind!=="object"&&E.kind!=="array"||L.kind!=="value")if(E.kind!=="color"&&E.kind!=="formatted"&&E.kind!=="resolvedImage"||L.kind!=="value"&&L.kind!=="string"){if(this.checkSubtype(E,L))return null}else M=y(M,E,h.typeAnnotation||"coerce");else M=y(M,E,h.typeAnnotation||"assert")}if(!(M instanceof np)&&M.type.kind!=="resolvedImage"&&NM(M)){const E=new zN(this._scope,this.options,this.iconImageUseTheme);try{M=new np(M.type,M.evaluate(E))}catch(L){return this.error(L.message),null}}return M}return tf.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,h,y,b){let M=typeof c=="number"?this.path.concat(c):this.path;M=typeof h=="string"?M.concat(h):M;const E=b?this.scope.concat(b):this.scope;return new XN(this.registry,M,y||null,E,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(c,...h){const y=`${this.key}${h.map(b=>`[${b}]`).join("")}`;this.errors.push(new Mh(y,c))}checkSubtype(c,h){const y=wg(c,h);return y&&this.error(y),y}}function NM(f){if(f instanceof YN)return NM(f.boundExpression);if(f instanceof Ld&&f.name==="error"||f instanceof Vl||f instanceof Sg||f instanceof qx||f instanceof O0)return!1;const c=f instanceof tf||f instanceof hm;let h=!0;return f.eachChild(y=>{h=c?h&&NM(y):h&&y instanceof np}),!!h&&L0(f)&&D0(f,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function QN(f,c){const h=f.length-1;let y,b,M=0,E=h,L=0;for(;M<=E;)if(L=Math.floor((M+E)/2),y=f[L],b=f[L+1],y<=c){if(L===h||cc))throw new gl("Input is not a number.");E=L-1}return 0}class M_{constructor(c,h,y){this.type=c,this.input=h,this.labels=[],this.outputs=[];for(const[b,M]of y)this.labels.push(b),this.outputs.push(M)}static parse(c,h){if(c.length-1<4)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if((c.length-1)%2!=0)return h.error("Expected an even number of arguments.");const y=h.parse(c[1],1,Ts);if(!y)return null;const b=[];let M=null;h.expectedType&&h.expectedType.kind!=="value"&&(M=h.expectedType);for(let E=1;E=L)return h.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',V);const Q=h.parse(z,Z,M);if(!Q)return null;M=M||Q.type,b.push([L,Q])}return new M_(M,y,b)}evaluate(c){const h=this.labels,y=this.outputs;if(h.length===1)return y[0].evaluate(c);const b=this.input.evaluate(c);if(b<=h[0])return y[0].evaluate(c);const M=h.length;return b>=h[M-1]?y[M-1].evaluate(c):y[QN(h,b)].evaluate(c)}eachChild(c){c(this.input);for(const h of this.outputs)c(h)}outputDefined(){return this.outputs.every(c=>c.outputDefined())}serialize(){const c=["step",this.input.serialize()];for(let h=0;h0&&c.push(this.labels[h]),c.push(this.outputs[h].serialize());return c}}const mL=.95047,fL=1.08883,pL=4/29,R0=6/29,gL=3*R0*R0,Lle=R0*R0*R0,Dle=Math.PI/180,Ole=180/Math.PI;function SM(f){return f>Lle?Math.pow(f,1/3):f/gL+pL}function CM(f){return f>R0?f*f*f:gL*(f-pL)}function MM(f){return 255*(f<=.0031308?12.92*f:1.055*Math.pow(f,1/2.4)-.055)}function TM(f){return(f/=255)<=.04045?f/12.92:Math.pow((f+.055)/1.055,2.4)}function xL(f){const c=TM(f.r),h=TM(f.g),y=TM(f.b),b=SM((.4124564*c+.3575761*h+.1804375*y)/mL),M=SM((.2126729*c+.7151522*h+.072175*y)/1);return{l:116*M-16,a:500*(b-M),b:200*(M-SM((.0193339*c+.119192*h+.9503041*y)/fL)),alpha:f.a}}function JN(f){let c=(f.l+16)/116,h=isNaN(f.a)?c:c+f.a/500,y=isNaN(f.b)?c:c-f.b/200;return c=1*CM(c),h=mL*CM(h),y=fL*CM(y),new Aa(MM(3.2404542*h-1.5371385*c-.4985314*y),MM(-.969266*h+1.8760108*c+.041556*y),MM(.0556434*h-.2040259*c+1.0572252*y),f.alpha)}function eS(f,c,h){const y=c-f;return f+h*(y>180||y<-180?y-360*Math.round(y/360):y)}const F0={forward:xL,reverse:JN,interpolate:function(f,c,h){return{l:Gs(f.l,c.l,h),a:Gs(f.a,c.a,h),b:Gs(f.b,c.b,h),alpha:Gs(f.alpha,c.alpha,h)}}},T_={forward:function(f){const{l:c,a:h,b:y}=xL(f),b=Math.atan2(y,h)*Ole;return{h:b<0?b+360:b,c:Math.sqrt(h*h+y*y),l:c,alpha:f.a}},reverse:function(f){const c=f.h*Dle,h=f.c;return JN({l:f.l,a:Math.cos(c)*h,b:Math.sin(c)*h,alpha:f.alpha})},interpolate:function(f,c,h){return{h:eS(f.h,c.h,h),c:Gs(f.c,c.c,h),l:Gs(f.l,c.l,h),alpha:Gs(f.alpha,c.alpha,h)}}};var yL=Object.freeze({__proto__:null,hcl:T_,lab:F0});class Yu{constructor(c,h,y,b,M){this.type=c,this.operator=h,this.interpolation=y,this.input=b,this.labels=[],this.outputs=[];for(const[E,L]of M)this.labels.push(E),this.outputs.push(L)}static interpolationFactor(c,h,y,b){let M=0;if(c.name==="exponential")M=tS(h,c.base,y,b);else if(c.name==="linear")M=tS(h,1,y,b);else if(c.name==="cubic-bezier"){const E=c.controlPoints;M=new Pi(E[0],E[1],E[2],E[3]).solve(tS(h,1,y,b))}return M}static parse(c,h){let[y,b,M,...E]=c;if(!Array.isArray(b)||b.length===0)return h.error("Expected an interpolation type expression.",1);if(b[0]==="linear")b={name:"linear"};else if(b[0]==="exponential"){const V=b[1];if(typeof V!="number")return h.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:V}}else{if(b[0]!=="cubic-bezier")return h.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const V=b.slice(1);if(V.length!==4||V.some(Z=>typeof Z!="number"||Z<0||Z>1))return h.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:V}}}if(c.length-1<4)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length-1>3&&(c.length-1)%2!=0)return h.error("Expected an even number of arguments.");if(M=h.parse(M,2,Ts),!M)return null;const L=[];let z=null;y==="interpolate-hcl"||y==="interpolate-lab"?z=tu:h.expectedType&&h.expectedType.kind!=="value"&&(z=h.expectedType);for(let V=0;V=Z)return h.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ee);const le=h.parse(Q,ne,z);if(!le)return null;z=z||le.type,L.push([Z,le])}return z.kind==="number"||z.kind==="color"||z.kind==="array"&&z.itemType.kind==="number"&&typeof z.N=="number"?new Yu(z,y,b,M,L):h.error(`Type ${Ho(z)} is not interpolatable.`)}evaluate(c){const h=this.labels,y=this.outputs;if(h.length===1)return y[0].evaluate(c);const b=this.input.evaluate(c);if(b<=h[0])return y[0].evaluate(c);const M=h.length;if(b>=h[M-1])return y[M-1].evaluate(c);const E=QN(h,b),L=Yu.interpolationFactor(this.interpolation,b,h[E],h[E+1]),z=y[E].evaluate(c),V=y[E+1].evaluate(c);return this.operator==="interpolate"?y_[this.type.kind.toLowerCase()](z,V,L):this.operator==="interpolate-hcl"?T_.reverse(T_.interpolate(T_.forward(z),T_.forward(V),L)):F0.reverse(F0.interpolate(F0.forward(z),F0.forward(V),L))}eachChild(c){c(this.input);for(const h of this.outputs)c(h)}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 h=[this.operator,c,this.input.serialize()];for(let y=0;ywg(b,L.type));return new A_(E?Ua:y,M)}evaluate(c){let h,y=null,b=0;for(const M of this.args){if(b++,y=M.evaluate(c),y&&y instanceof Pd&&!y.available&&(h||(h=y),y=null,b===this.args.length))return h;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(h=>{c.push(h.serialize())}),c}}class ip{constructor(c,h){this.type=h.type,this.bindings=[].concat(c),this.result=h}evaluate(c){return this.result.evaluate(c)}eachChild(c){for(const h of this.bindings)c(h[1]);c(this.result)}static parse(c,h){if(c.length<4)return h.error(`Expected at least 3 arguments, but found ${c.length-1} instead.`);const y=[];for(let M=1;M=y.length)throw new gl("Array index out of bounds: index exceeds array size");if(h!==Math.floor(h))throw new gl("Array index must be an integer. Use at-interpolated for fractional indices");return y[h]}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class sS{constructor(c,h,y){this.type=c,this.index=h,this.input=y}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const y=h.parse(c[1],1,Ts),b=h.parse(c[2],2,Gc(h.expectedType||Ua));return y&&b?new sS(b.type.itemType,y,b):null}evaluate(c){const h=this.index.evaluate(c),y=this.input.evaluate(c);if(h<0)throw new gl(`Array index out of bounds: ${h} < 0.`);if(h>y.length-1)throw new gl(`Array index out of bounds: ${h} > ${y.length-1}.`);if(h===Math.floor(h))return y[h];const b=Math.floor(h),M=Math.ceil(h),E=y[b],L=y[M];if(typeof E!="number"||typeof L!="number")throw new gl(`Cannot interpolate between non-number values at index ${h}.`);const z=h-b;return E*(1-z)+L*z}eachChild(c){c(this.index),c(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class AM{constructor(c,h){this.type=Ya,this.needle=c,this.haystack=h}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const y=h.parse(c[1],1,Ua),b=h.parse(c[2],2,Ua);return y&&b?cM(y.type,[Ya,ha,Ts,um,Ua])?new AM(y,b):h.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ho(y.type)} instead`):null}evaluate(c){const h=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(y==null)return!1;if(!b_(h,["boolean","string","number","null"]))throw new gl(`Expected first argument to be of type boolean, string, number or null, but found ${Ho(Ml(h))} instead.`);if(!b_(y,["string","array"]))throw new gl(`Expected second argument to be of type array or string, but found ${Ho(Ml(y))} instead.`);return y.indexOf(h)>=0}eachChild(c){c(this.needle),c(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class z0{constructor(c,h,y){this.type=Ts,this.needle=c,this.haystack=h,this.fromIndex=y}static parse(c,h){if(c.length<=2||c.length>=5)return h.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`);const y=h.parse(c[1],1,Ua),b=h.parse(c[2],2,Ua);if(!y||!b)return null;if(!cM(y.type,[Ya,ha,Ts,um,Ua]))return h.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ho(y.type)} instead`);if(c.length===4){const M=h.parse(c[3],3,Ts);return M?new z0(y,b,M):null}return new z0(y,b)}evaluate(c){const h=this.needle.evaluate(c),y=this.haystack.evaluate(c);if(!b_(h,["boolean","string","number","null"]))throw new gl(`Expected first argument to be of type boolean, string, number or null, but found ${Ho(Ml(h))} instead.`);if(!b_(y,["string","array"]))throw new gl(`Expected second argument to be of type array or string, but found ${Ho(Ml(y))} instead.`);if(this.fromIndex){const b=this.fromIndex.evaluate(c);return y.indexOf(h,b)}return y.indexOf(h)}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 E_{constructor(c,h,y,b,M,E){this.inputType=c,this.type=h,this.input=y,this.cases=b,this.outputs=M,this.otherwise=E}static parse(c,h){if(c.length<5)return h.error(`Expected at least 4 arguments, but found only ${c.length-1}.`);if(c.length%2!=1)return h.error("Expected an even number of arguments.");let y,b;h.expectedType&&h.expectedType.kind!=="value"&&(b=h.expectedType);const M={},E=[];for(let V=2;VNumber.MAX_SAFE_INTEGER)return ee.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof le=="number"&&Math.floor(le)!==le)return ee.error("Numeric branch labels must be integer values.");if(y){if(ee.checkSubtype(y,Ml(le)))return null}else y=Ml(le);if(M[String(le)]!==void 0)return ee.error("Branch labels must be unique.");M[String(le)]=E.length}const ne=h.parse(Q,V,b);if(!ne)return null;b=b||ne.type,E.push(ne)}const L=h.parse(c[1],1,Ua);if(!L)return null;const z=h.parse(c[c.length-1],c.length-1,b);return z?L.type.kind!=="value"&&h.concat(1).checkSubtype(y,L.type)?null:new E_(y,b,L,M,E,z):null}evaluate(c){const h=this.input.evaluate(c);return(DN(Ml(h),this.inputType)&&this.outputs[this.cases[h]]||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()],h=Object.keys(this.cases).sort(),y=[],b={};for(const E of h){const L=b[this.cases[E]];L===void 0?(b[this.cases[E]]=y.length,y.push([this.cases[E],[E]])):y[L][1].push(E)}const M=E=>this.inputType.kind==="number"?Number(E):E;for(const[E,L]of y)c.push(L.length===1?M(L[0]):L.map(M)),c.push(this.outputs[E].serialize());return c.push(this.otherwise.serialize()),c}}class I_{constructor(c,h,y){this.type=c,this.branches=h,this.otherwise=y}static parse(c,h){if(c.length<4)return h.error(`Expected at least 3 arguments, but found only ${c.length-1}.`);if(c.length%2!=0)return h.error("Expected an odd number of arguments.");let y;h.expectedType&&h.expectedType.kind!=="value"&&(y=h.expectedType);const b=[];for(let E=1;Eh.outputDefined())&&this.otherwise.outputDefined()}serialize(){const c=["case"];return this.eachChild(h=>{c.push(h.serialize())}),c}}class nS{constructor(c,h,y,b){this.type=c,this.input=h,this.beginIndex=y,this.endIndex=b}static parse(c,h){if(c.length<=2||c.length>=5)return h.error(`Expected 3 or 4 arguments, but found ${c.length-1} instead.`);const y=h.parse(c[1],1,Ua),b=h.parse(c[2],2,Ts);if(!y||!b)return null;if(!cM(y.type,[Gc(Ua),ha,Ua]))return h.error(`Expected first argument to be of type array or string, but found ${Ho(y.type)} instead`);if(c.length===4){const M=h.parse(c[3],3,Ts);return M?new nS(y.type,y,b,M):null}return new nS(y.type,y,b)}evaluate(c){const h=this.input.evaluate(c),y=this.beginIndex.evaluate(c);if(!b_(h,["string","array"]))throw new gl(`Expected first argument to be of type array or string, but found ${Ho(Ml(h))} instead.`);if(this.endIndex){const b=this.endIndex.evaluate(c);return h.slice(y,b)}return h.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 EM{constructor(c,h){this.type=Gc(ha),this.str=c,this.delimiter=h}static parse(c,h){if(c.length!==3)return h.error(`Expected 2 arguments, but found ${c.length-1} instead.`);const y=h.parse(c[1],1,ha),b=h.parse(c[2],2,ha);return y&&b?new EM(y,b):void 0}evaluate(c){const h=this.str.evaluate(c),y=this.delimiter.evaluate(c);return h.split(y)}eachChild(c){c(this.str),c(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function IM(f,c){return f==="=="||f==="!="?c.kind==="boolean"||c.kind==="string"||c.kind==="number"||c.kind==="null"||c.kind==="value":c.kind==="string"||c.kind==="number"||c.kind==="value"}function PM(f,c,h,y){return y.compare(c,h)===0}function B0(f,c,h){const y=f!=="=="&&f!=="!=";return class gze{constructor(M,E,L){this.type=Ya,this.lhs=M,this.rhs=E,this.collator=L,this.hasUntypedArgument=M.type.kind==="value"||E.type.kind==="value"}static parse(M,E){if(M.length!==3&&M.length!==4)return E.error("Expected two or three arguments.");const L=M[0];let z=E.parse(M[1],1,Ua);if(!z)return null;if(!IM(L,z.type))return E.concat(1).error(`"${L}" comparisons are not supported for type '${Ho(z.type)}'.`);let V=E.parse(M[2],2,Ua);if(!V)return null;if(!IM(L,V.type))return E.concat(2).error(`"${L}" comparisons are not supported for type '${Ho(V.type)}'.`);if(z.type.kind!==V.type.kind&&z.type.kind!=="value"&&V.type.kind!=="value")return E.error(`Cannot compare types '${Ho(z.type)}' and '${Ho(V.type)}'.`);y&&(z.type.kind==="value"&&V.type.kind!=="value"?z=new hm(V.type,[z]):z.type.kind!=="value"&&V.type.kind==="value"&&(V=new hm(z.type,[V])));let Z=null;if(M.length===4){if(z.type.kind!=="string"&&V.type.kind!=="string"&&z.type.kind!=="value"&&V.type.kind!=="value")return E.error("Cannot use collator to compare non-string types.");if(Z=E.parse(M[3],3,LN),!Z)return null}return new gze(z,V,Z)}evaluate(M){const E=this.lhs.evaluate(M),L=this.rhs.evaluate(M);if(y&&this.hasUntypedArgument){const z=Ml(E),V=Ml(L);if(z.kind!==V.kind||z.kind!=="string"&&z.kind!=="number")throw new gl(`Expected arguments for "${f}" to be (string, string) or (number, number), but found (${z.kind}, ${V.kind}) instead.`)}if(this.collator&&!y&&this.hasUntypedArgument){const z=Ml(E),V=Ml(L);if(z.kind!=="string"||V.kind!=="string")return c(M,E,L)}return this.collator?h(M,E,L,this.collator.evaluate(M)):c(M,E,L)}eachChild(M){M(this.lhs),M(this.rhs),this.collator&&M(this.collator)}outputDefined(){return!0}serialize(){const M=[f];return this.eachChild(E=>{M.push(E.serialize())}),M}}}const Rle=B0("==",function(f,c,h){return c===h},PM),Fle=B0("!=",function(f,c,h){return c!==h},function(f,c,h,y){return!PM(0,c,h,y)}),vL=B0("<",function(f,c,h){return c",function(f,c,h){return c>h},function(f,c,h,y){return y.compare(c,h)>0}),aS=B0("<=",function(f,c,h){return c<=h},function(f,c,h,y){return y.compare(c,h)<=0}),zle=B0(">=",function(f,c,h){return c>=h},function(f,c,h,y){return y.compare(c,h)>=0});class iS{constructor(c,h,y,b,M,E){this.type=ha,this.number=c,this.locale=h,this.currency=y,this.unit=b,this.minFractionDigits=M,this.maxFractionDigits=E}static parse(c,h){if(c.length!==3)return h.error("Expected two arguments.");const y=h.parse(c[1],1,Ts);if(!y)return null;const b=c[2];if(typeof b!="object"||Array.isArray(b))return h.error("NumberFormat options argument must be an object.");let M=null;if(b.locale&&(M=h.parseObjectValue(b.locale,2,"locale",ha),!M))return null;let E=null;if(b.currency&&(E=h.parseObjectValue(b.currency,2,"currency",ha),!E))return null;let L=null;if(b.unit&&(L=h.parseObjectValue(b.unit,2,"unit",ha),!L))return null;let z=null;if(b["min-fraction-digits"]&&(z=h.parseObjectValue(b["min-fraction-digits"],2,"min-fraction-digits",Ts),!z))return null;let V=null;return b["max-fraction-digits"]&&(V=h.parseObjectValue(b["max-fraction-digits"],2,"max-fraction-digits",Ts),!V)?null:new iS(y,M,E,L,z,V)}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 LM{constructor(c){this.type=Ts,this.input=c}static parse(c,h){if(c.length!==2)return h.error(`Expected 1 argument, but found ${c.length-1} instead.`);const y=h.parse(c[1],1);return y?y.type.kind!=="array"&&y.type.kind!=="string"&&y.type.kind!=="value"?h.error(`Expected argument of type string or array, but found ${Ho(y.type)} instead.`):new LM(y):null}evaluate(c){const h=this.input.evaluate(c);if(typeof h=="string"||Array.isArray(h))return h.length;throw new gl(`Expected value to be of type string or array, but found ${Ho(Ml(h))} instead.`)}eachChild(c){c(this.input)}outputDefined(){return!1}serialize(){const c=["length"];return this.eachChild(h=>{c.push(h.serialize())}),c}}function bL(f){return function(){f=1831565813+(f|=0)|0;let c=Math.imul(f^f>>>15,1|f);return c=c+Math.imul(c^c>>>7,61|c)^c,((c^c>>>14)>>>0)/4294967296}}const $0={"==":Rle,"!=":Fle,">":_L,"<":vL,">=":zle,"<=":aS,array:hm,at:rS,"at-interpolated":sS,boolean:hm,case:I_,coalesce:A_,collator:Vl,format:ef,image:wn,in:AM,"index-of":z0,interpolate:Yu,"interpolate-hcl":Yu,"interpolate-lab":Yu,length:LM,let:ip,literal:np,match:E_,number:hm,"number-format":iS,object:hm,slice:nS,step:M_,string:hm,"to-boolean":tf,"to-color":tf,"to-number":tf,"to-string":tf,var:YN,within:Sg,distance:qx,config:O0,split:EM};function DM(f,[c,h,y,b]){c=c.evaluate(f),h=h.evaluate(f),y=y.evaluate(f);const M=b?b.evaluate(f):1,E=$x(c,h,y,M);if(E)throw new gl(E);return new Aa(c/255,h/255,y/255,M)}function OM(f,[c,h,y,b]){c=c.evaluate(f),h=h.evaluate(f),y=y.evaluate(f);const M=b?b.evaluate(f):1,E=function(V,Z,Q,ee){return typeof V=="number"&&V>=0&&V<=360?typeof Z=="number"&&Z>=0&&Z<=100&&typeof Q=="number"&&Q>=0&&Q<=100?ee===void 0||typeof ee=="number"&&ee>=0&&ee<=1?null:`Invalid hsla value [${[V,Z,Q,ee].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ee=="number"?[V,Z,Q,ee]:[V,Z,Q]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ee=="number"?[V,Z,Q,ee]:[V,Z,Q]).join(", ")}]: 'h' must be between 0 and 360.`}(c,h,y,M);if(E)throw new gl(E);const L=`hsla(${c}, ${h}%, ${y}%, ${M})`,z=Aa.parse(L);if(!z)throw new gl(`Failed to parse HSLA color: ${L}`);return z}function wL(f,c){return f in c}function RM(f,c){const h=c[f];return h===void 0?null:h}function Tg(f){return{type:f}}function Hx(f){if(f instanceof O0)return new Set([f.key]);let c=new Set;return f.eachChild(h=>{c=new Set([...c,...Hx(h)])}),c}function oS(f){if(f instanceof Ld&&f.name==="is-active-floor")return!0;let c=!1;return f.eachChild(h=>{!c&&oS(h)&&(c=!0)}),c}function jL(f){return{result:"success",value:f}}function Ag(f){return{result:"error",value:f}}function FM(f,c){return!!f&&!!f.parameters&&f.parameters.indexOf(c)>-1}function P_(f){return f["property-type"]==="data-driven"}function kL(f){return FM(f.expression,"measure-light")}function NL(f){return FM(f.expression,"zoom")}function lS(f){return!!f.expression&&f.expression.interpolated}function cS(f){return typeof f=="object"&&f!==null&&!Array.isArray(f)}function SL(f){return f}function CL(f,c){const h=c.type==="color",y=f.stops&&typeof f.stops[0][0]=="object",b=y||!(y||f.property!==void 0),M=f.type||(lS(c)?"exponential":"interval");if(h&&((f=Object.assign({},f)).stops&&(f.stops=f.stops.map(V=>[V[0],Aa.parse(V[1])])),f.default=Aa.parse(f.default?f.default:c.default)),f.colorSpace&&f.colorSpace!=="rgb"&&!yL[f.colorSpace])throw new Error(`Unknown color space: ${f.colorSpace}`);let E,L,z;if(M==="exponential")E=ML;else if(M==="interval")E=$le;else if(M==="categorical"){E=Ble,L=Object.create(null);for(const V of f.stops)L[V[0]]=V[1];z=typeof f.stops[0][0]}else{if(M!=="identity")throw new Error(`Unknown function type "${M}"`);E=TL}if(y){const V={},Z=[];for(let ne=0;nene[0]),evaluate:({zoom:ne},le)=>ML({stops:Q,base:f.base},c,ne).evaluate(ne,le)}}if(b){const V=M==="exponential"?{name:"exponential",base:f.base!==void 0?f.base:1}:null;return{kind:"camera",interpolationType:V,interpolationFactor:Yu.interpolationFactor.bind(void 0,V),zoomStops:f.stops.map(Z=>Z[0]),evaluate:({zoom:Z})=>E(f,c,Z,L,z)}}return{kind:"source",evaluate(V,Z){const Q=Z&&Z.properties?Z.properties[f.property]:void 0;return Q===void 0?sf(f.default,c.default):E(f,c,Q,L,z)}}}function sf(f,c,h){return f!==void 0?f:c!==void 0?c:h!==void 0?h:void 0}function Ble(f,c,h,y,b){return sf(typeof h===b?y[h]:void 0,f.default,c.default)}function $le(f,c,h){if(!A0(h))return sf(f.default,c.default);const y=f.stops.length;if(y===1||h<=f.stops[0][0])return f.stops[0][1];if(h>=f.stops[y-1][0])return f.stops[y-1][1];const b=QN(f.stops.map(M=>M[0]),h);return f.stops[b][1]}function ML(f,c,h){const y=f.base!==void 0?f.base:1;if(!A0(h))return sf(f.default,c.default);const b=f.stops.length;if(b===1||h<=f.stops[0][0])return f.stops[0][1];if(h>=f.stops[b-1][0])return f.stops[b-1][1];const M=QN(f.stops.map(Z=>Z[0]),h),E=function(Z,Q,ee,ne){const le=ne-ee,xe=Z-ee;return le===0?0:Q===1?xe/le:(Math.pow(Q,xe)-1)/(Math.pow(Q,le)-1)}(h,y,f.stops[M][0],f.stops[M+1][0]),L=f.stops[M][1],z=f.stops[M+1][1];let V=y_[c.type]||SL;if(f.colorSpace&&f.colorSpace!=="rgb"){const Z=yL[f.colorSpace];V=(Q,ee)=>Z.reverse(Z.interpolate(Z.forward(Q),Z.forward(ee),E))}return typeof L.evaluate=="function"?{evaluate(...Z){const Q=L.evaluate.apply(void 0,Z),ee=z.evaluate.apply(void 0,Z);if(Q!==void 0&&ee!==void 0)return V(Q,ee,E)}}:V(L,z,E)}function TL(f,c,h){return c.type==="color"?h=Aa.parse(h):c.type==="formatted"?h=Id.fromString(h.toString()):c.type==="resolvedImage"?h=Pd.build(h.toString()):ks(h)===c.type||c.type==="enum"&&c.values[h]||(h=void 0),sf(h,f.default,c.default)}Ld.register($0,{error:[{kind:"error"},[ha],(f,[c])=>{throw new gl(c.evaluate(f))}],typeof:[ha,[Ua],(f,[c])=>Ho(Ml(c.evaluate(f)))],"to-rgba":[Gc(Ts,4),[tu],(f,[c])=>c.evaluate(f).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Gc(Ts,4),[tu],(f,[c])=>c.evaluate(f).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[tu,[Ts,Ts,Ts],DM],rgba:[tu,[Ts,Ts,Ts,Ts],DM],hsl:[tu,[Ts,Ts,Ts],OM],hsla:[tu,[Ts,Ts,Ts,Ts],OM],has:{type:Ya,overloads:[[[ha],(f,[c])=>wL(c.evaluate(f),f.properties())],[[ha,Jm],(f,[c,h])=>wL(c.evaluate(f),h.evaluate(f))]]},get:{type:Ua,overloads:[[[ha],(f,[c])=>RM(c.evaluate(f),f.properties())],[[ha,Jm],(f,[c,h])=>RM(c.evaluate(f),h.evaluate(f))]]},"feature-state":[Ua,[ha],(f,[c])=>RM(c.evaluate(f),f.featureState||{})],properties:[Jm,[],f=>f.properties()],"geometry-type":[ha,[],f=>f.geometryType()],worldview:[ha,[],f=>f.globals.worldview||""],"is-active-floor":[Ya,Tg(ha),(f,c)=>{if(!(f.globals.activeFloors&&f.globals.activeFloors.size>0))return!1;const h=f.globals.activeFloors;return c.some(y=>{const b=y.evaluate(f);return h.has(b)})}],id:[Ua,[],f=>f.id()],zoom:[Ts,[],f=>f.globals.zoom],pitch:[Ts,[],f=>f.globals.pitch||0],"distance-from-center":[Ts,[],f=>f.distanceFromCenter()],"measure-light":[Ts,[ha],(f,[c])=>f.measureLight(c.evaluate(f))],"heatmap-density":[Ts,[],f=>f.globals.heatmapDensity||0],"line-progress":[Ts,[],f=>f.globals.lineProgress||0],"raster-value":[Ts,[],f=>f.globals.rasterValue||0],"raster-particle-speed":[Ts,[],f=>f.globals.rasterParticleSpeed||0],"sky-radial-progress":[Ts,[],f=>f.globals.skyRadialProgress||0],accumulated:[Ua,[],f=>f.globals.accumulated===void 0?null:f.globals.accumulated],"+":[Ts,Tg(Ts),(f,c)=>{let h=0;for(const y of c)h+=y.evaluate(f);return h}],"*":[Ts,Tg(Ts),(f,c)=>{let h=1;for(const y of c)h*=y.evaluate(f);return h}],"-":{type:Ts,overloads:[[[Ts,Ts],(f,[c,h])=>c.evaluate(f)-h.evaluate(f)],[[Ts],(f,[c])=>-c.evaluate(f)]]},"/":[Ts,[Ts,Ts],(f,[c,h])=>c.evaluate(f)/h.evaluate(f)],"%":[Ts,[Ts,Ts],(f,[c,h])=>c.evaluate(f)%h.evaluate(f)],ln2:[Ts,[],()=>Math.LN2],pi:[Ts,[],()=>Math.PI],e:[Ts,[],()=>Math.E],"^":[Ts,[Ts,Ts],(f,[c,h])=>Math.pow(c.evaluate(f),h.evaluate(f))],sqrt:[Ts,[Ts],(f,[c])=>Math.sqrt(c.evaluate(f))],log10:[Ts,[Ts],(f,[c])=>Math.log(c.evaluate(f))/Math.LN10],ln:[Ts,[Ts],(f,[c])=>Math.log(c.evaluate(f))],log2:[Ts,[Ts],(f,[c])=>Math.log2(c.evaluate(f))],sin:[Ts,[Ts],(f,[c])=>Math.sin(c.evaluate(f))],cos:[Ts,[Ts],(f,[c])=>Math.cos(c.evaluate(f))],tan:[Ts,[Ts],(f,[c])=>Math.tan(c.evaluate(f))],asin:[Ts,[Ts],(f,[c])=>Math.asin(c.evaluate(f))],acos:[Ts,[Ts],(f,[c])=>Math.acos(c.evaluate(f))],atan:[Ts,[Ts],(f,[c])=>Math.atan(c.evaluate(f))],min:[Ts,Tg(Ts),(f,c)=>Math.min(...c.map(h=>h.evaluate(f)))],max:[Ts,Tg(Ts),(f,c)=>Math.max(...c.map(h=>h.evaluate(f)))],abs:[Ts,[Ts],(f,[c])=>Math.abs(c.evaluate(f))],round:[Ts,[Ts],(f,[c])=>{const h=c.evaluate(f);return h<0?-Math.round(-h):Math.round(h)}],floor:[Ts,[Ts],(f,[c])=>Math.floor(c.evaluate(f))],ceil:[Ts,[Ts],(f,[c])=>Math.ceil(c.evaluate(f))],"filter-==":[Ya,[ha,Ua],(f,[c,h])=>f.properties()[c.value]===h.value],"filter-id-==":[Ya,[Ua],(f,[c])=>f.id()===c.value],"filter-type-==":[Ya,[ha],(f,[c])=>f.geometryType()===c.value],"filter-<":[Ya,[ha,Ua],(f,[c,h])=>{const y=f.properties()[c.value],b=h.value;return typeof y==typeof b&&y{const h=f.id(),y=c.value;return typeof h==typeof y&&h":[Ya,[ha,Ua],(f,[c,h])=>{const y=f.properties()[c.value],b=h.value;return typeof y==typeof b&&y>b}],"filter-id->":[Ya,[Ua],(f,[c])=>{const h=f.id(),y=c.value;return typeof h==typeof y&&h>y}],"filter-<=":[Ya,[ha,Ua],(f,[c,h])=>{const y=f.properties()[c.value],b=h.value;return typeof y==typeof b&&y<=b}],"filter-id-<=":[Ya,[Ua],(f,[c])=>{const h=f.id(),y=c.value;return typeof h==typeof y&&h<=y}],"filter->=":[Ya,[ha,Ua],(f,[c,h])=>{const y=f.properties()[c.value],b=h.value;return typeof y==typeof b&&y>=b}],"filter-id->=":[Ya,[Ua],(f,[c])=>{const h=f.id(),y=c.value;return typeof h==typeof y&&h>=y}],"filter-has":[Ya,[Ua],(f,[c])=>c.value in f.properties()],"filter-has-id":[Ya,[],f=>f.id()!==null&&f.id()!==void 0],"filter-type-in":[Ya,[Gc(ha)],(f,[c])=>c.value.indexOf(f.geometryType())>=0],"filter-id-in":[Ya,[Gc(Ua)],(f,[c])=>c.value.indexOf(f.id())>=0],"filter-in-small":[Ya,[ha,Gc(Ua)],(f,[c,h])=>h.value.indexOf(f.properties()[c.value])>=0],"filter-in-large":[Ya,[ha,Gc(Ua)],(f,[c,h])=>function(y,b,M,E){for(;M<=E;){const L=M+E>>1;if(b[L]===y)return!0;b[L]>y?E=L-1:M=L+1}return!1}(f.properties()[c.value],h.value,0,h.value.length-1)],all:{type:Ya,overloads:[[[Ya,Ya],(f,[c,h])=>c.evaluate(f)&&h.evaluate(f)],[Tg(Ya),(f,c)=>{for(const h of c)if(!h.evaluate(f))return!1;return!0}]]},any:{type:Ya,overloads:[[[Ya,Ya],(f,[c,h])=>c.evaluate(f)||h.evaluate(f)],[Tg(Ya),(f,c)=>{for(const h of c)if(h.evaluate(f))return!0;return!1}]]},"!":[Ya,[Ya],(f,[c])=>!c.evaluate(f)],"is-supported-script":[Ya,[ha],(f,[c])=>{const h=f.globals&&f.globals.isSupportedScript;return!h||h(c.evaluate(f))}],upcase:[ha,[ha],(f,[c])=>c.evaluate(f).toUpperCase()],downcase:[ha,[ha],(f,[c])=>c.evaluate(f).toLowerCase()],concat:[ha,Tg(Ua),(f,c)=>c.map(h=>Th(h.evaluate(f))).join("")],"resolved-locale":[ha,[LN],(f,[c])=>c.evaluate(f).resolvedLocale()],random:[Ts,[Ts,Ts,Ua],(f,c)=>{const[h,y,b]=c.map(E=>E.evaluate(f));if(h>y||h===y)return h;let M;if(typeof b=="string")M=function(E){let L=0;if(E.length===0)return L;for(let z=0;zJSON.stringify(Q)).join(", ")}, but found ${JSON.stringify(Z)} instead.`);return Z}catch(Z){const Q=Z;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 L_(f){return Array.isArray(f)&&f.length>0&&typeof f[0]=="string"&&f[0]in $0}function Eg(f,c,h,y,b){const M=new XN($0,[],c?function(L){const z={color:tu,string:ha,number:Ts,enum:ha,boolean:Ya,formatted:v_,resolvedImage:__};return L.type==="array"?Gc(z[L.value]||Ua,L.length):z[L.type]}(c):void 0,void 0,void 0,h,y,b),E=M.parse(f,void 0,void 0,void 0,c&&c.type==="string"?{typeAnnotation:"coerce"}:void 0);return E?jL(new dS(E,c,h,y,b)):Ag(M.errors)}class U0{constructor(c,h,y,b){this.kind=c,this._styleExpression=h,this.isLightConstant=y,this.isLineProgressConstant=b,this.isStateDependent=c!=="constant"&&!C_(h.expression),this.configDependencies=Hx(h.expression),this.isIndoorDependent=oS(h.expression)}evaluateWithoutErrorHandling(c,h,y,b,M,E){return this._styleExpression.evaluateWithoutErrorHandling(c,h,y,b,M,E)}evaluate(c,h,y,b,M,E,L){return this._styleExpression.evaluate(c,h,y,b,M,E,void 0,void 0,L)}}class Wx{constructor(c,h,y,b,M,E){this.kind=c,this.zoomStops=y,this._styleExpression=h,this.isStateDependent=c!=="camera"&&!C_(h.expression),this.isIndoorDependent=oS(h.expression),this.isLightConstant=M,this.isLineProgressConstant=E,this.configDependencies=Hx(h.expression),this.interpolationType=b}evaluateWithoutErrorHandling(c,h,y,b,M,E){return this._styleExpression.evaluateWithoutErrorHandling(c,h,y,b,M,E)}evaluate(c,h,y,b,M,E){return this._styleExpression.evaluate(c,h,y,b,M,E)}interpolationFactor(c,h,y){return this.interpolationType?Yu.interpolationFactor(this.interpolationType,c,h,y):0}}function zM(f,c,h,y,b){if((f=Eg(f,c,h,y,b)).result==="error")return f;const M=f.value.expression,E=L0(M);if(!E&&!P_(c))return Ag([new Mh("","data expressions not supported")]);const L=D0(M,["zoom","pitch","distance-from-center"]);if(!L&&!NL(c))return Ag([new Mh("","zoom expressions not supported")]);const z=D0(M,["measure-light"]);if(!z&&!kL(c))return Ag([new Mh("","measure-light expression not supported")]);const V=D0(M,["line-progress"]);if(!V&&!function(ee){return FM(ee.expression,"line-progress")}(c))return Ag([new Mh("","line-progress expression not supported")]);const Z=c.expression&&c.expression.relaxZoomRestriction,Q=fm(M);return Q||L||Z?Q instanceof Mh?Ag([Q]):Q instanceof Yu&&!lS(c)?Ag([new Mh("",'"interpolate" expressions cannot be used with this property')]):jL(Q?new Wx(E&&V?"camera":"composite",f.value,Q.labels,Q instanceof Yu?Q.interpolation:void 0,z,V):new U0(E&&V?"constant":"source",f.value,z,V)):Ag([new Mh("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class uS{constructor(c,h){this._parameters=c,this._specification=h,Object.assign(this,CL(this._parameters,this._specification))}static deserialize(c){return new uS(c._parameters,c._specification)}static serialize(c){return{_parameters:c._parameters,_specification:c._specification}}}function fm(f){let c=null;if(f instanceof ip)c=fm(f.result);else if(f instanceof A_){for(const h of f.args)if(c=fm(h),c)break}else(f instanceof M_||f instanceof Yu)&&f.input instanceof Ld&&f.input.name==="zoom"&&(c=f);return c instanceof Mh||f.eachChild(h=>{const y=fm(h);y instanceof Mh?c=y:c&&y&&c!==y&&(c=new Mh("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),c}var BM,AL,EL=function(){if(AL)return BM;AL=1,BM=c;var f=3;function c(h,y,b){var M=this.cells=[];if(h instanceof ArrayBuffer){this.arrayBuffer=h;var E=new Int32Array(this.arrayBuffer);h=E[0],this.d=(y=E[1])+2*(b=E[2]);for(var L=0;L=ee[xe+0]&&M>=ee[xe+1])?(z[le]=!0,L.push(Q[le])):z[le]=!1}}},c.prototype._forEachCell=function(h,y,b,M,E,L,z,V){for(var Z=this._convertToCellCoord(h),Q=this._convertToCellCoord(y),ee=this._convertToCellCoord(b),ne=this._convertToCellCoord(M),le=Z;le<=ee;le++)for(var xe=Q;xe<=ne;xe++){var Ce=this.d*xe+le;if((!V||V(this._convertFromCellCoord(le),this._convertFromCellCoord(xe),this._convertFromCellCoord(le+1),this._convertFromCellCoord(xe+1)))&&E.call(this,h,y,b,M,Ce,L,z,V))return}},c.prototype._convertFromCellCoord=function(h){return(h-this.padding)/this.scale},c.prototype._convertToCellCoord=function(h){return Math.max(0,Math.min(this.d-1,Math.floor(h*this.scale)+this.padding))},c.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var h=this.cells,y=f+this.cells.length+1+1,b=0,M=0;M=0||(b[M]=op(f[M],c)));f instanceof Error&&(b.message=f.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 f)}function Ig(f){if(f==null||typeof f=="boolean"||typeof f=="number"||typeof f=="string"||f instanceof Boolean||f instanceof Number||f instanceof String||f instanceof Date||f instanceof RegExp||D_(f)||f instanceof ImageBitmap||ArrayBuffer.isView(f)||f instanceof ImageData)return f;if(Array.isArray(f))return f.map(Ig);if(typeof f=="object"){const c=f.$name||"Object";if(c==="Map"){const b=f.entries||[],M=new Map;for(let E=0;Ef>=128&&f<=255,Arabic:f=>f>=1536&&f<=1791,"Arabic Supplement":f=>f>=1872&&f<=1919,"Arabic Extended-A":f=>f>=2208&&f<=2303,"Hangul Jamo":f=>f>=4352&&f<=4607,"Unified Canadian Aboriginal Syllabics":f=>f>=5120&&f<=5759,Khmer:f=>f>=6016&&f<=6143,"Unified Canadian Aboriginal Syllabics Extended":f=>f>=6320&&f<=6399,"General Punctuation":f=>f>=8192&&f<=8303,"Letterlike Symbols":f=>f>=8448&&f<=8527,"Number Forms":f=>f>=8528&&f<=8591,"Miscellaneous Technical":f=>f>=8960&&f<=9215,"Control Pictures":f=>f>=9216&&f<=9279,"Optical Character Recognition":f=>f>=9280&&f<=9311,"Enclosed Alphanumerics":f=>f>=9312&&f<=9471,"Geometric Shapes":f=>f>=9632&&f<=9727,"Miscellaneous Symbols":f=>f>=9728&&f<=9983,"Miscellaneous Symbols and Arrows":f=>f>=11008&&f<=11263,"CJK Radicals Supplement":f=>f>=11904&&f<=12031,"Kangxi Radicals":f=>f>=12032&&f<=12255,"Ideographic Description Characters":f=>f>=12272&&f<=12287,"CJK Symbols and Punctuation":f=>f>=12288&&f<=12351,Hiragana:f=>f>=12352&&f<=12447,Katakana:f=>f>=12448&&f<=12543,Bopomofo:f=>f>=12544&&f<=12591,"Hangul Compatibility Jamo":f=>f>=12592&&f<=12687,Kanbun:f=>f>=12688&&f<=12703,"Bopomofo Extended":f=>f>=12704&&f<=12735,"CJK Strokes":f=>f>=12736&&f<=12783,"Katakana Phonetic Extensions":f=>f>=12784&&f<=12799,"Enclosed CJK Letters and Months":f=>f>=12800&&f<=13055,"CJK Compatibility":f=>f>=13056&&f<=13311,"CJK Unified Ideographs Extension A":f=>f>=13312&&f<=19903,"Yijing Hexagram Symbols":f=>f>=19904&&f<=19967,"CJK Unified Ideographs":f=>f>=19968&&f<=40959,"Yi Syllables":f=>f>=40960&&f<=42127,"Yi Radicals":f=>f>=42128&&f<=42191,"Hangul Jamo Extended-A":f=>f>=43360&&f<=43391,"Hangul Syllables":f=>f>=44032&&f<=55215,"Hangul Jamo Extended-B":f=>f>=55216&&f<=55295,"Private Use Area":f=>f>=57344&&f<=63743,"CJK Compatibility Ideographs":f=>f>=63744&&f<=64255,"Arabic Presentation Forms-A":f=>f>=64336&&f<=65023,"Vertical Forms":f=>f>=65040&&f<=65055,"CJK Compatibility Forms":f=>f>=65072&&f<=65103,"Small Form Variants":f=>f>=65104&&f<=65135,"Arabic Presentation Forms-B":f=>f>=65136&&f<=65279,"Halfwidth and Fullwidth Forms":f=>f>=65280&&f<=65519,Osage:f=>f>=66736&&f<=66815,"CJK Unified Ideographs Extension B":f=>f>=131072&&f<=173791};function O_(f){for(const c of f)if(hS(c.charCodeAt(0)))return!0;return!1}function $M(f){for(const c of f)if(!IL(c.charCodeAt(0)))return!1;return!0}function IL(f){return!(Rs.Arabic(f)||Rs["Arabic Supplement"](f)||Rs["Arabic Extended-A"](f)||Rs["Arabic Presentation Forms-A"](f)||Rs["Arabic Presentation Forms-B"](f))}function hS(f){return!(f!==746&&f!==747&&(f<4352||!(Rs["Bopomofo Extended"](f)||Rs.Bopomofo(f)||Rs["CJK Compatibility Forms"](f)&&!(f>=65097&&f<=65103)||Rs["CJK Compatibility Ideographs"](f)||Rs["CJK Compatibility"](f)||Rs["CJK Radicals Supplement"](f)||Rs["CJK Strokes"](f)||!(!Rs["CJK Symbols and Punctuation"](f)||f>=12296&&f<=12305||f>=12308&&f<=12319||f===12336)||Rs["CJK Unified Ideographs Extension A"](f)||Rs["CJK Unified Ideographs"](f)||Rs["Enclosed CJK Letters and Months"](f)||Rs["Hangul Compatibility Jamo"](f)||Rs["Hangul Jamo Extended-A"](f)||Rs["Hangul Jamo Extended-B"](f)||Rs["Hangul Jamo"](f)||Rs["Hangul Syllables"](f)||Rs.Hiragana(f)||Rs["Ideographic Description Characters"](f)||Rs.Kanbun(f)||Rs["Kangxi Radicals"](f)||Rs["Katakana Phonetic Extensions"](f)||Rs.Katakana(f)&&f!==12540||!(!Rs["Halfwidth and Fullwidth Forms"](f)||f===65288||f===65289||f===65293||f>=65306&&f<=65310||f===65339||f===65341||f===65343||f>=65371&&f<=65503||f===65507||f>=65512&&f<=65519)||!(!Rs["Small Form Variants"](f)||f>=65112&&f<=65118||f>=65123&&f<=65126)||Rs["Unified Canadian Aboriginal Syllabics"](f)||Rs["Unified Canadian Aboriginal Syllabics Extended"](f)||Rs["Vertical Forms"](f)||Rs["Yijing Hexagram Symbols"](f)||Rs["Yi Syllables"](f)||Rs["Yi Radicals"](f))))}function mS(f){return!(hS(f)||function(c){return!!(Rs["Latin-1 Supplement"](c)&&(c===167||c===169||c===174||c===177||c===188||c===189||c===190||c===215||c===247)||Rs["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)||Rs["Letterlike Symbols"](c)||Rs["Number Forms"](c)||Rs["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)||Rs["Control Pictures"](c)&&c!==9251||Rs["Optical Character Recognition"](c)||Rs["Enclosed Alphanumerics"](c)||Rs["Geometric Shapes"](c)||Rs["Miscellaneous Symbols"](c)&&!(c>=9754&&c<=9759)||Rs["Miscellaneous Symbols and Arrows"](c)&&(c>=11026&&c<=11055||c>=11088&&c<=11097||c>=11192&&c<=11243)||Rs["CJK Symbols and Punctuation"](c)||Rs.Katakana(c)||Rs["Private Use Area"](c)||Rs["CJK Compatibility Forms"](c)||Rs["Small Form Variants"](c)||Rs["Halfwidth and Fullwidth Forms"](c)||c===8734||c===8756||c===8757||c>=9984&&c<=10087||c>=10102&&c<=10131||c===65532||c===65533)}(f))}function fS(f){return Rs.Arabic(f)||Rs["Arabic Supplement"](f)||Rs["Arabic Extended-A"](f)||Rs["Arabic Presentation Forms-A"](f)||Rs["Arabic Presentation Forms-B"](f)}function UM(f){return f>=1424&&f<=2303||Rs["Arabic Presentation Forms-A"](f)||Rs["Arabic Presentation Forms-B"](f)}function lp(f,c){return!(!c&&UM(f)||f>=2304&&f<=3583||f>=3840&&f<=4255||Rs.Khmer(f))}function Ule(f){for(const c of f)if(UM(c.charCodeAt(0)))return!0;return!1}const wu={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let VM=null,Dd=wu.unavailable,cp=null;const R_=function(f){f&&typeof f=="string"&&f.indexOf("NetworkError")>-1&&(Dd=wu.error),VM&&VM(f)};function pS(){gS.fire(new Hr("pluginStateChange",{pluginStatus:Dd,pluginURL:cp}))}const gS=new Kn,F_=function(){return Dd},PL=function(){if(Dd!==wu.deferred||!cp)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Dd=wu.loading,pS(),cp&&Ku({url:cp},f=>{f?R_(f):(Dd=wu.loaded,pS())})},dp={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Dd===wu.loaded||dp.applyArabicShaping!=null,isLoading:()=>Dd===wu.loading,setState(f){Dd=f.pluginStatus,cp=f.pluginURL},isParsing:()=>Dd===wu.parsing,isParsed:()=>Dd===wu.parsed,getPluginURL:()=>cp};class bi{constructor(c,h){this.zoom=c,h?(this.now=h.now,this.fadeDuration=h.fadeDuration,this.transition=h.transition,this.pitch=h.pitch,this.brightness=h.brightness,this.worldview=h.worldview,this.activeFloors=h.activeFloors):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(c){return function(h,y){for(const b of h)if(!lp(b.charCodeAt(0),y))return!1;return!0}(c,dp.isLoaded())}}class xS{constructor(c,h,y,b,M){this.property=c,this.value=h,this.expression=function(E,L,z,V,Z){if(cS(E))return new uS(E,L);if(L_(E)||Array.isArray(E)&&E.length>0){const Q=zM(E,L,z,V,Z);if(Q.result==="error")throw new Error(Q.value.map(ee=>`${ee.key}: ${ee.message}`).join(", "));return Q.value}{let Q=E;return typeof E=="string"&&L.type==="color"&&(Q=Aa.parse(E)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>Q}}}(h===void 0?c.specification.default:h,c.specification,y,b,M)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(c,h,y,b){return this.property.possiblyEvaluate(this,c,h,y,b)}}class qM{constructor(c,h,y,b){this.property=c,this.value=new xS(c,void 0,h,y,b)}transitioned(c,h){return new DL(this.property,this.value,h,Object.assign({},c.transition,this.transition),c.now)}untransitioned(){return new DL(this.property,this.value,null,{},0)}}class LL{constructor(c,h,y,b){this._properties=c,this._values=Object.create(c.defaultTransitionablePropertyValues),this._scope=h,this._options=y,this._iconImageUseTheme=b,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(c){return hr(this._values[c].value.value)}setValue(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new qM(this._values[c].property,this._scope,this._options,this._iconImageUseTheme)),this._values[c].value=new xS(this._values[c].property,h===null?void 0:hr(h),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,h){h&&(this._options=h);const y=this._properties.properties;if(c)for(const b in c){const M=c[b];if(b.endsWith("-transition")){const E=b.slice(0,-11);y[E]&&this.setTransition(E,M)}else y.hasOwnProperty(b)&&this.setValue(b,M)}}getTransition(c){return hr(this._values[c].transition)}setTransition(c,h){this._values.hasOwnProperty(c)||(this._values[c]=new qM(this._values[c].property)),this._values[c].transition=hr(h)||void 0}serialize(){const c={};for(const h of Object.keys(this._values)){const y=this.getValue(h);y!==void 0&&(c[h]=y);const b=this.getTransition(h);b!==void 0&&(c[`${h}-transition`]=b)}return c}transitioned(c,h){const y=new OL(this._properties);for(const b of Object.keys(this._values))y._values[b]=this._values[b].transitioned(c,h._values[b]);return y}untransitioned(){const c=new OL(this._properties);for(const h of Object.keys(this._values))c._values[h]=this._values[h].untransitioned();return c}isIndoorDependent(){return this._isIndoorDependent}}class DL{constructor(c,h,y,b,M){const E=b.delay||0,L=b.duration||0;M=M||0,this.property=c,this.value=h,this.begin=M+E,this.end=this.begin+L,c.specification.transition&&(b.delay||b.duration)&&(this.prior=y)}possiblyEvaluate(c,h,y){const b=c.now||0,M=this.value.possiblyEvaluate(c,h,y),E=this.prior;if(E){if(b>this.end)return this.prior=null,M;if(this.value.isDataDriven())return this.prior=null,M;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 FL(f){return f instanceof Number||f instanceof String||f instanceof Boolean?f.valueOf():f}function yS(f){if(Array.isArray(f))return f.map(yS);if(f instanceof Object&&!(f instanceof Number||f instanceof String||f instanceof Boolean)){const c={};for(const h in f)c[h]=yS(f[h]);return c}return FL(f)}function nf(f){if(f===!0||f===!1)return!0;if(!Array.isArray(f)||f.length===0)return!1;switch(f[0]){case"has":return f.length>=2&&f[1]!=="$id"&&f[1]!=="$type";case"in":return f.length>=3&&(typeof f[1]!="string"||Array.isArray(f[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return f.length!==3||Array.isArray(f[1])||Array.isArray(f[2]);case"any":case"all":for(const c of f.slice(1))if(!nf(c)&&typeof c!="boolean")return!1;return!0;default:return!0}}function vS(f,c="",h=null,y="fill"){if(f==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};nf(f)||(f=_S(f));const b=f;let M=!0;try{M=function(Z){if(!q0(Z))return Z;let Q=yS(Z);return zL(Q),Q=Xx(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 E=null,L=null;if(y!=="background"&&y!=="sky"&&y!=="slot"){L=qt[`filter_${y}`];const Z=Eg(M,L,c,h);if(Z.result==="error")throw new Error(Z.value.map(Q=>`${Q.key}: ${Q.message}`).join(", "));E=(Q,ee,ne)=>Z.value.evaluate(Q,ee,{},ne)}let z=null,V=null;if(M!==b){const Z=Eg(b,L,c,h);if(Z.result==="error")throw new Error(Z.value.map(Q=>`${Q.key}: ${Q.message}`).join(", "));z=(Q,ee,ne,le,xe)=>Z.value.evaluate(Q,ee,{},ne,void 0,void 0,le,xe),V=!L0(Z.value.expression)}return{filter:E,dynamicFilter:z||void 0,needGeometry:BL(M),needFeature:!!V}}function Xx(f){if(!Array.isArray(f))return f;const c=function(h){if(Vle.has(h[0])){for(let y=1;yXx(h))}function zL(f){let c=!1;const h=[];if(f[0]==="case"){for(let y=1;y",">=","<","<=","to-boolean"]);function qle(f,c){return fc?1:0}function BL(f){if(!Array.isArray(f))return!1;if(f[0]==="within"||f[0]==="distance")return!0;for(let c=1;c"||c==="<="||c===">="?bS(f[1],f[2],c):c==="any"?(h=f.slice(1),["any"].concat(h.map(_S))):c==="all"?["all"].concat(f.slice(1).map(_S)):c==="none"?["all"].concat(f.slice(1).map(_S).map(z_)):c==="in"?wS(f[1],f.slice(2)):c==="!in"?z_(wS(f[1],f.slice(2))):c==="has"?jS(f[1]):c!=="!has"||z_(jS(f[1]));var h}function bS(f,c,h){switch(f){case"$type":return[`filter-type-${h}`,c];case"$id":return[`filter-id-${h}`,c];default:return[`filter-${h}`,f,c]}}function wS(f,c){if(c.length===0)return!1;switch(f){case"$type":return["filter-type-in",["literal",c]];case"$id":return["filter-id-in",["literal",c]];default:return c.length>200&&!c.some(h=>typeof h!=typeof c[0])?["filter-in-large",f,["literal",c.sort(qle)]]:["filter-in-small",f,["literal",c]]}}function jS(f){switch(f){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",f]}}function z_(f){return["!",f]}const Qx="";function pm(f,c){return c?`${f}${Qx}${c}`:f}let $L;const UL=()=>$L||($L=new mo({"icon-size":new Wr(qt.layout_symbol["icon-size"]),"icon-image":new Wr(qt.layout_symbol["icon-image"]),"icon-rotate":new Wr(qt.layout_symbol["icon-rotate"]),"icon-offset":new Wr(qt.layout_symbol["icon-offset"]),"text-size":new Wr(qt.layout_symbol["text-size"]),"text-rotate":new Wr(qt.layout_symbol["text-rotate"]),"text-offset":new Wr(qt.layout_symbol["text-offset"])}));class VL{constructor(c,h,y,b,M,E){const L=Eg(c,qt.appearance.condition);if(L.result==="success"&&(this.condition=L.value),this.name=h,y){this.properties=new Zx(UL()),this.unevaluatedLayout=new RL(UL(),b,M,E);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,h,y){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(c,void 0,h,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"),h=this.hasProperty("icon-size"),y=this.hasProperty("icon-offset"),b=this.hasProperty("icon-rotate");return c||h||y||b}hasTextProperties(){const c=this.hasProperty("text-size"),h=this.hasProperty("text-offset"),y=this.hasProperty("text-rotate");return c||h||y}hasProperty(c){return this.getUnevaluatedProperty(c).value!==void 0}}const qL="-transition",af=new Set(["fill","line","background","hillshade","raster"]);class Od extends Kn{constructor(c,h,y,b,M,E){if(super(),this.id=c.id,this.fqid=pm(this.id,y),this.type=c.type,this.scope=y,this.lut=b,this.options=M,this.iconImageUseTheme=E,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 L=Eg(this.filter,qt[`filter_${c.type}`]);L.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...L.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||L.value.isIndoorDependent)}if(c.slot&&(this.slot=c.slot),c.appearances&&this.setAppearances(c.appearances),h.layout&&(this._unevaluatedLayout=new RL(h.layout,this.scope,M,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),h.paint){this._transitionablePaint=new LL(h.paint,this.scope,M);for(const L in c.paint)this.setPaintProperty(L,c.paint[L]);for(const L in c.layout)this.setLayoutProperty(L,c.layout[L]);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 Zx(h.paint)}}}onAdd(c){}onRemove(c){}isDraped(c){return!this.is3D(!0)&&af.has(this.type)}getLayoutProperty(c){return c==="visibility"?this.visibility:this._unevaluatedLayout.getValue(c)}setLayoutProperty(c,h){if(this.type==="custom"&&c==="visibility")return void(this.visibility=h);const y=this._unevaluatedLayout;y._properties.properties[c]&&(y.setValue(c,h),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(h=>{this.appearances.push(new VL(h.condition,h.name,h.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(qL)?this._transitionablePaint.getTransition(c.slice(0,-11)):this._transitionablePaint.getValue(c)}isPaintProperty(c){return!!this._transitionablePaint._properties.properties[c]}setPaintProperty(c,h){const y=this._transitionablePaint,b=y._properties.properties;if(c.endsWith(qL)){const Q=c.slice(0,-11);return b[Q]&&y.setTransition(Q,h||void 0),!1}if(!b[c])return!1;const M=y._values[c],E=M.value.isDataDriven(),L=M.value;y.setValue(c,h),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,V=z.isDataDriven(),Z=c.endsWith("pattern")||c==="line-dasharray";return V||E||Z||this._handleOverridablePaintPropertyUpdate(c,L,z)}_handleSpecialPaintPropertyUpdate(c){}getProgramIds(){return null}getDefaultProgramParams(c,h,y){return null}_handleOverridablePaintPropertyUpdate(c,h,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,h){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(c,void 0,h,this.iconImageUseTheme)),this.paint=this._transitioningPaint.possiblyEvaluate(c,void 0,h)}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(h=>h.serialize())),yr(c,(h,y)=>!(h===void 0||y==="layout"&&!Object.keys(h).length||y==="paint"&&!Object.keys(h).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 h=this.paint.get(c);if(h instanceof Kx&&P_(h.property.specification)&&(h.value.kind==="source"||h.value.kind==="composite")&&h.value.isStateDependent)return!0}for(const c of this.appearances)if(!C_(c.condition.expression))return!0;return!1}compileFilter(c){this._filterCompiled||(this._featureFilter=vS(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,h,y){return{}}queryRadius(c){}queryIntersectsFeature(c,h,y,b,M,E,L,z,V){}}const HL={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class B_{constructor(c,h){this._structArray=c,this._pos1=h*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const Hle=new ArrayBuffer(0);class Li{constructor(){this._reallocCount=0,this.capacity=0,this.length=0}static serialize(c,h){return c._trim(),h&&c.arrayBuffer&&h.add(c.arrayBuffer),{length:c.length,arrayBuffer:c.arrayBuffer}}static deserialize(c){const h=Object.create(this.prototype);return h.arrayBuffer=c.arrayBuffer,h.length=c.length,c.arrayBuffer?h.capacity=c.arrayBuffer.byteLength/h.bytesPerElement:(h.capacity=0,h.arrayBuffer=Hle),h._refreshViews(),h}_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 h=this.uint8;this._refreshViews(),h&&this.uint8.set(h)}}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 Xn(f,c=1){let h=0,y=0;return{members:f.map(b=>{const M=HL[b.type].BYTES_PER_ELEMENT,E=h=WL(h,Math.max(c,M)),L=b.components||1;return y=Math.max(y,M),h+=M*L,{name:b.name,type:b.type,components:L,offset:E}}),size:WL(h,Math.max(y,c)),alignment:c}}function WL(f,c){return Math.ceil(f/c)*c}class Pg extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h){const y=this.length;return this.resize(y+1),this.emplace(y,c,h)}emplace(c,h,y){const b=2*c;return this.int16[b+0]=h,this.int16[b+1]=y,c}}Pg.prototype.bytesPerElement=4,ms(Pg,"StructArrayLayout2i4");class H0 extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,h,y)}emplace(c,h,y,b){const M=3*c;return this.int16[M+0]=h,this.int16[M+1]=y,this.int16[M+2]=b,c}}H0.prototype.bytesPerElement=6,ms(H0,"StructArrayLayout3i6");class W0 extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,y,b){const M=this.length;return this.resize(M+1),this.emplace(M,c,h,y,b)}emplace(c,h,y,b,M){const E=4*c;return this.int16[E+0]=h,this.int16[E+1]=y,this.int16[E+2]=b,this.int16[E+3]=M,c}}W0.prototype.bytesPerElement=8,ms(W0,"StructArrayLayout4i8");class up extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.float32[1*c+0]=h,c}}up.prototype.bytesPerElement=4,ms(up,"StructArrayLayout1f4");class HM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,h,y)}emplace(c,h,y,b){const M=4*c,E=2*c;return this.int16[M+0]=h,this.int16[M+1]=y,this.float32[E+1]=b,c}}HM.prototype.bytesPerElement=8,ms(HM,"StructArrayLayout2i1f8");class WM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,h,y)}emplace(c,h,y,b){const M=4*c;return this.int16[M+0]=h,this.int16[M+1]=y,this.int16[M+2]=b,c}}WM.prototype.bytesPerElement=8,ms(WM,"StructArrayLayout3i8");class GM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M){const E=this.length;return this.resize(E+1),this.emplace(E,c,h,y,b,M)}emplace(c,h,y,b,M,E){const L=5*c;return this.int16[L+0]=h,this.int16[L+1]=y,this.int16[L+2]=b,this.int16[L+3]=M,this.int16[L+4]=E,c}}GM.prototype.bytesPerElement=10,ms(GM,"StructArrayLayout5i10");class kS extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L){const z=this.length;return this.resize(z+1),this.emplace(z,c,h,y,b,M,E,L)}emplace(c,h,y,b,M,E,L,z){const V=6*c,Z=12*c,Q=3*c;return this.int16[V+0]=h,this.int16[V+1]=y,this.uint8[Z+4]=b,this.uint8[Z+5]=M,this.uint8[Z+6]=E,this.uint8[Z+7]=L,this.float32[Q+2]=z,c}}kS.prototype.bytesPerElement=12,ms(kS,"StructArrayLayout2i4ub1f12");class Xu extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,h,y)}emplace(c,h,y,b){const M=3*c;return this.float32[M+0]=h,this.float32[M+1]=y,this.float32[M+2]=b,c}}Xu.prototype.bytesPerElement=12,ms(Xu,"StructArrayLayout3f12");class ru extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M){const E=this.length;return this.resize(E+1),this.emplace(E,c,h,y,b,M)}emplace(c,h,y,b,M,E){const L=6*c,z=3*c;return this.uint16[L+0]=h,this.uint16[L+1]=y,this.uint16[L+2]=b,this.uint16[L+3]=M,this.float32[z+2]=E,c}}ru.prototype.bytesPerElement=12,ms(ru,"StructArrayLayout4ui1f12");class Jx extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,y,b){const M=this.length;return this.resize(M+1),this.emplace(M,c,h,y,b)}emplace(c,h,y,b,M){const E=4*c;return this.uint16[E+0]=h,this.uint16[E+1]=y,this.uint16[E+2]=b,this.uint16[E+3]=M,c}}Jx.prototype.bytesPerElement=8,ms(Jx,"StructArrayLayout4ui8");class NS extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E){const L=this.length;return this.resize(L+1),this.emplace(L,c,h,y,b,M,E)}emplace(c,h,y,b,M,E,L){const z=6*c;return this.int16[z+0]=h,this.int16[z+1]=y,this.int16[z+2]=b,this.int16[z+3]=M,this.int16[z+4]=E,this.int16[z+5]=L,c}}NS.prototype.bytesPerElement=12,ms(NS,"StructArrayLayout6i12");class KM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L,z,V,Z,Q,ee){const ne=this.length;return this.resize(ne+1),this.emplace(ne,c,h,y,b,M,E,L,z,V,Z,Q,ee)}emplace(c,h,y,b,M,E,L,z,V,Z,Q,ee,ne){const le=12*c;return this.int16[le+0]=h,this.int16[le+1]=y,this.int16[le+2]=b,this.int16[le+3]=M,this.uint16[le+4]=E,this.uint16[le+5]=L,this.uint16[le+6]=z,this.uint16[le+7]=V,this.int16[le+8]=Z,this.int16[le+9]=Q,this.int16[le+10]=ee,this.int16[le+11]=ne,c}}KM.prototype.bytesPerElement=24,ms(KM,"StructArrayLayout4i4ui4i24");class ZM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E){const L=this.length;return this.resize(L+1),this.emplace(L,c,h,y,b,M,E)}emplace(c,h,y,b,M,E,L){const z=10*c,V=5*c;return this.int16[z+0]=h,this.int16[z+1]=y,this.int16[z+2]=b,this.float32[V+2]=M,this.float32[V+3]=E,this.float32[V+4]=L,c}}ZM.prototype.bytesPerElement=20,ms(ZM,"StructArrayLayout3i3f20");class Lg extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b){const M=this.length;return this.resize(M+1),this.emplace(M,c,h,y,b)}emplace(c,h,y,b,M){const E=4*c;return this.float32[E+0]=h,this.float32[E+1]=y,this.float32[E+2]=b,this.float32[E+3]=M,c}}Lg.prototype.bytesPerElement=16,ms(Lg,"StructArrayLayout4f16");class SS extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint32[1*c+0]=h,c}}SS.prototype.bytesPerElement=4,ms(SS,"StructArrayLayout1ul4");class Qu extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h){const y=this.length;return this.resize(y+1),this.emplace(y,c,h)}emplace(c,h,y){const b=2*c;return this.uint16[b+0]=h,this.uint16[b+1]=y,c}}Qu.prototype.bytesPerElement=4,ms(Qu,"StructArrayLayout2ui4");class CS extends Li{_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,h,y,b,M,E,L,z,V,Z,Q,ee,ne){const le=this.length;return this.resize(le+1),this.emplace(le,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne)}emplace(c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le){const xe=20*c,Ce=10*c;return this.int16[xe+0]=h,this.int16[xe+1]=y,this.int16[xe+2]=b,this.int16[xe+3]=M,this.int16[xe+4]=E,this.float32[Ce+3]=L,this.float32[Ce+4]=z,this.float32[Ce+5]=V,this.float32[Ce+6]=Z,this.int16[xe+14]=Q,this.uint32[Ce+8]=ee,this.uint16[xe+18]=ne,this.uint16[xe+19]=le,c}}CS.prototype.bytesPerElement=40,ms(CS,"StructArrayLayout5i4f1i1ul2ui40");class MS extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L){const z=this.length;return this.resize(z+1),this.emplace(z,c,h,y,b,M,E,L)}emplace(c,h,y,b,M,E,L,z){const V=8*c;return this.int16[V+0]=h,this.int16[V+1]=y,this.int16[V+2]=b,this.int16[V+4]=M,this.int16[V+5]=E,this.int16[V+6]=L,this.int16[V+7]=z,c}}MS.prototype.bytesPerElement=16,ms(MS,"StructArrayLayout3i2i2i16");class TS extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M){const E=this.length;return this.resize(E+1),this.emplace(E,c,h,y,b,M)}emplace(c,h,y,b,M,E){const L=4*c,z=8*c;return this.float32[L+0]=h,this.float32[L+1]=y,this.float32[L+2]=b,this.int16[z+6]=M,this.int16[z+7]=E,c}}TS.prototype.bytesPerElement=16,ms(TS,"StructArrayLayout2f1f2i16");class YM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E){const L=this.length;return this.resize(L+1),this.emplace(L,c,h,y,b,M,E)}emplace(c,h,y,b,M,E,L){const z=20*c,V=5*c;return this.uint8[z+0]=h,this.uint8[z+1]=y,this.float32[V+1]=b,this.float32[V+2]=M,this.float32[V+3]=E,this.float32[V+4]=L,c}}YM.prototype.bytesPerElement=20,ms(YM,"StructArrayLayout2ub4f20");class rl extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,y){const b=this.length;return this.resize(b+1),this.emplace(b,c,h,y)}emplace(c,h,y,b){const M=3*c;return this.uint16[M+0]=h,this.uint16[M+1]=y,this.uint16[M+2]=b,c}}rl.prototype.bytesPerElement=6,ms(rl,"StructArrayLayout3ui6");class G0 extends Li{_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,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe,Be,Je,yt){const mt=this.length;return this.resize(mt+1),this.emplace(mt,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe,Be,Je,yt)}emplace(c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe,Be,Je,yt,mt){const kt=30*c,It=15*c,Rt=60*c;return this.int16[kt+0]=h,this.int16[kt+1]=y,this.int16[kt+2]=b,this.float32[It+2]=M,this.float32[It+3]=E,this.uint16[kt+8]=L,this.uint16[kt+9]=z,this.uint32[It+5]=V,this.uint32[It+6]=Z,this.uint32[It+7]=Q,this.uint16[kt+16]=ee,this.uint16[kt+17]=ne,this.uint16[kt+18]=le,this.float32[It+10]=xe,this.float32[It+11]=Ce,this.uint8[Rt+48]=Ne,this.uint8[Rt+49]=Fe,this.uint8[Rt+50]=Be,this.uint32[It+13]=Je,this.int16[kt+28]=yt,this.uint8[Rt+58]=mt,c}}G0.prototype.bytesPerElement=60,ms(G0,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class XM extends Li{_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,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe,Be,Je,yt,mt,kt,It,Rt,tr,$t,or,mr,fr,wr,kr,xr){const _r=this.length;return this.resize(_r+1),this.emplace(_r,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe,Be,Je,yt,mt,kt,It,Rt,tr,$t,or,mr,fr,wr,kr,xr)}emplace(c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe,Be,Je,yt,mt,kt,It,Rt,tr,$t,or,mr,fr,wr,kr,xr,_r){const ir=20*c,sr=40*c,br=80*c;return this.float32[ir+0]=h,this.float32[ir+1]=y,this.int16[sr+4]=b,this.int16[sr+5]=M,this.int16[sr+6]=E,this.int16[sr+7]=L,this.int16[sr+8]=z,this.int16[sr+9]=V,this.int16[sr+10]=Z,this.int16[sr+11]=Q,this.int16[sr+12]=ee,this.uint16[sr+13]=ne,this.uint16[sr+14]=le,this.uint16[sr+15]=xe,this.uint16[sr+16]=Ce,this.uint16[sr+17]=Ne,this.uint16[sr+18]=Fe,this.uint16[sr+19]=Be,this.uint16[sr+20]=Je,this.uint16[sr+21]=yt,this.uint16[sr+22]=mt,this.uint16[sr+23]=kt,this.uint16[sr+24]=It,this.uint16[sr+25]=Rt,this.uint16[sr+26]=tr,this.uint16[sr+27]=$t,this.uint32[ir+14]=or,this.float32[ir+15]=mr,this.float32[ir+16]=fr,this.float32[ir+17]=wr,this.float32[ir+18]=kr,this.uint8[br+76]=xr,this.uint16[sr+39]=_r,c}}XM.prototype.bytesPerElement=80,ms(XM,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class QM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E){const L=this.length;return this.resize(L+1),this.emplace(L,c,h,y,b,M,E)}emplace(c,h,y,b,M,E,L){const z=6*c;return this.float32[z+0]=h,this.float32[z+1]=y,this.float32[z+2]=b,this.float32[z+3]=M,this.float32[z+4]=E,this.float32[z+5]=L,c}}QM.prototype.bytesPerElement=24,ms(QM,"StructArrayLayout6f24");class ey extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M){const E=this.length;return this.resize(E+1),this.emplace(E,c,h,y,b,M)}emplace(c,h,y,b,M,E){const L=5*c;return this.float32[L+0]=h,this.float32[L+1]=y,this.float32[L+2]=b,this.float32[L+3]=M,this.float32[L+4]=E,c}}ey.prototype.bytesPerElement=20,ms(ey,"StructArrayLayout5f20");class JM extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L){const z=this.length;return this.resize(z+1),this.emplace(z,c,h,y,b,M,E,L)}emplace(c,h,y,b,M,E,L,z){const V=7*c;return this.float32[V+0]=h,this.float32[V+1]=y,this.float32[V+2]=b,this.float32[V+3]=M,this.float32[V+4]=E,this.float32[V+5]=L,this.float32[V+6]=z,c}}JM.prototype.bytesPerElement=28,ms(JM,"StructArrayLayout7f28");class eT extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L,z,V,Z,Q){const ee=this.length;return this.resize(ee+1),this.emplace(ee,c,h,y,b,M,E,L,z,V,Z,Q)}emplace(c,h,y,b,M,E,L,z,V,Z,Q,ee){const ne=11*c;return this.float32[ne+0]=h,this.float32[ne+1]=y,this.float32[ne+2]=b,this.float32[ne+3]=M,this.float32[ne+4]=E,this.float32[ne+5]=L,this.float32[ne+6]=z,this.float32[ne+7]=V,this.float32[ne+8]=Z,this.float32[ne+9]=Q,this.float32[ne+10]=ee,c}}eT.prototype.bytesPerElement=44,ms(eT,"StructArrayLayout11f44");class K0 extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L,z,V){const Z=this.length;return this.resize(Z+1),this.emplace(Z,c,h,y,b,M,E,L,z,V)}emplace(c,h,y,b,M,E,L,z,V,Z){const Q=9*c;return this.float32[Q+0]=h,this.float32[Q+1]=y,this.float32[Q+2]=b,this.float32[Q+3]=M,this.float32[Q+4]=E,this.float32[Q+5]=L,this.float32[Q+6]=z,this.float32[Q+7]=V,this.float32[Q+8]=Z,c}}K0.prototype.bytesPerElement=36,ms(K0,"StructArrayLayout9f36");class of extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h){const y=this.length;return this.resize(y+1),this.emplace(y,c,h)}emplace(c,h,y){const b=2*c;return this.float32[b+0]=h,this.float32[b+1]=y,c}}of.prototype.bytesPerElement=8,ms(of,"StructArrayLayout2f8");class su extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c,h,y,b){const M=this.length;return this.resize(M+1),this.emplace(M,c,h,y,b)}emplace(c,h,y,b,M){const E=6*c;return this.uint32[3*c+0]=h,this.uint16[E+2]=y,this.uint16[E+3]=b,this.uint16[E+4]=M,c}}su.prototype.bytesPerElement=12,ms(su,"StructArrayLayout1ul3ui12");class Dg extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint16[1*c+0]=h,c}}Dg.prototype.bytesPerElement=2,ms(Dg,"StructArrayLayout1ui2");class tT extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce){const Ne=this.length;return this.resize(Ne+1),this.emplace(Ne,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce)}emplace(c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne){const Fe=16*c;return this.float32[Fe+0]=h,this.float32[Fe+1]=y,this.float32[Fe+2]=b,this.float32[Fe+3]=M,this.float32[Fe+4]=E,this.float32[Fe+5]=L,this.float32[Fe+6]=z,this.float32[Fe+7]=V,this.float32[Fe+8]=Z,this.float32[Fe+9]=Q,this.float32[Fe+10]=ee,this.float32[Fe+11]=ne,this.float32[Fe+12]=le,this.float32[Fe+13]=xe,this.float32[Fe+14]=Ce,this.float32[Fe+15]=Ne,c}}tT.prototype.bytesPerElement=64,ms(tT,"StructArrayLayout16f64");class AS extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(c,h,y,b,M,E,L){const z=this.length;return this.resize(z+1),this.emplace(z,c,h,y,b,M,E,L)}emplace(c,h,y,b,M,E,L,z){const V=10*c,Z=5*c;return this.uint16[V+0]=h,this.uint16[V+1]=y,this.uint16[V+2]=b,this.uint16[V+3]=M,this.float32[Z+2]=E,this.float32[Z+3]=L,this.float32[Z+4]=z,c}}AS.prototype.bytesPerElement=20,ms(AS,"StructArrayLayout4ui3f20");class rT extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.int16[1*c+0]=h,c}}rT.prototype.bytesPerElement=2,ms(rT,"StructArrayLayout1i2");class ES extends Li{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(c){const h=this.length;return this.resize(h+1),this.emplace(h,c)}emplace(c,h){return this.uint8[1*c+0]=h,c}}ES.prototype.bytesPerElement=1,ms(ES,"StructArrayLayout1ub1");class IS extends B_{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]}}IS.prototype.size=40;class GL extends CS{get(c){return new IS(this,c)}}ms(GL,"CollisionBoxArray");class PS extends B_{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}}PS.prototype.size=60;class KL extends G0{get(c){return new PS(this,c)}}ms(KL,"PlacedSymbolArray");class ZL extends B_{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]}}ZL.prototype.size=80;class sT extends XM{get(c){return new ZL(this,c)}}ms(sT,"SymbolInstanceArray");class LS extends up{getoffsetX(c){return this.float32[1*c+0]}}ms(LS,"GlyphOffsetArray");class YL extends Pg{getx(c){return this.int16[2*c+0]}gety(c){return this.int16[2*c+1]}}ms(YL,"SymbolLineVertexArray");class nT extends B_{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]}}nT.prototype.size=12;class aT extends su{get(c){return new nT(this,c)}}ms(aT,"FeatureIndexArray");class XL extends Qu{geta_centroid_pos0(c){return this.uint16[2*c+0]}geta_centroid_pos1(c){return this.uint16[2*c+1]}}ms(XL,"FillExtrusionCentroidArray");class DS extends B_{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]}}DS.prototype.size=6;class $_ extends H0{get(c){return new DS(this,c)}}ms($_,"FillExtrusionWallArray");const QL=Xn([{name:"a_pos",components:2,type:"Int16"}],4),Wle=Xn([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),JL=Xn([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class to{constructor(c=[]){this.segments=c}_prepareSegment(c,h,y,b){let M=this.segments[this.segments.length-1];return c>to.MAX_VERTEX_ARRAY_LENGTH&&ts(`Max vertices per segment is ${to.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${c}`),(!M||M.vertexLength+c>to.MAX_VERTEX_ARRAY_LENGTH||M.sortKey!==b)&&(M={vertexOffset:h,primitiveOffset:y,vertexLength:0,primitiveLength:0},b!==void 0&&(M.sortKey=b),this.segments.push(M)),M}prepareSegment(c,h,y,b){return this._prepareSegment(c,h.length,y.length,b)}get(){return this.segments}destroy(){for(const c of this.segments)for(const h in c.vaos)c.vaos[h].destroy()}static simpleSegment(c,h,y,b){return new to([{vertexOffset:c,primitiveOffset:h,vertexLength:y,primitiveLength:b,vaos:{},sortKey:0}])}}function OS(f,c){return 256*(f=ye(Math.floor(f),0,255))+ye(Math.floor(c),0,255)}to.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,ms(to,"SegmentVector");const Gle=Xn([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Kle=Xn([{name:"a_pattern_b",components:4,type:"Uint16"}]),Zle=Xn([{name:"a_dash",components:4,type:"Uint16"}]);class U_{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(c,h,y,b){this.ids.push(iT(c)),this.positions.push(h,y,b)}eachPosition(c,h){const y=iT(c);let b=0,M=this.ids.length-1;for(;b>1;this.ids[E]>=y?M=E:b=E+1}for(;this.ids[b]===y;)h(this.positions[3*b],this.positions[3*b+1],this.positions[3*b+2]),b++}static serialize(c,h){const y=new Float64Array(c.ids),b=new Uint32Array(c.positions);return oT(y,b,0,y.length-1),h&&(h.add(y.buffer),h.add(b.buffer)),{ids:y,positions:b}}static deserialize(c){const h=new U_;let y;h.ids=c.ids,h.positions=c.positions;for(const b of h.ids)b!==y&&h.uniqueIds.push(b),y=b;return h.indexed=!0,h}}function iT(f){const c=+f;return Number.isSafeInteger(c)?c:vr(String(f))}function oT(f,c,h,y){for(;h>1];let M=h-1,E=y+1;for(;;){do M++;while(f[M]b);if(M>=E)break;RS(f,M,E),RS(c,3*M,3*E),RS(c,3*M+1,3*E+1),RS(c,3*M+2,3*E+2)}E-h`u_${M}`),this.type=y,this.context=b}setUniform(c,h,y,b,M){const E=b.constantOr(this.value);h.set(c,M,E instanceof Aa?E.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):E)}getBinding(c,h){return this.type==="color"?new q_(c):new sl(c)}}class Z0{constructor(c,h){this.uniformNames=h.map(y=>`u_${y}`),this.pattern=null,this.patternTransition=null,this.pixelRatio=1}setConstantPatternPositions(c,h){this.pixelRatio=c.pixelRatio||1,this.pattern=c.tl.concat(c.br),this.patternTransition=h?h.tl.concat(h.br):this.pattern}setUniform(c,h,y,b,M){let E=null;M!=="u_pattern"&&M!=="u_dash"||(E=this.pattern),M==="u_pattern_b"&&(E=this.patternTransition),M==="u_pixel_ratio"&&(E=this.pixelRatio),E&&h.set(c,M,E)}getBinding(c,h){return h==="u_pattern"||h==="u_pattern_b"||h==="u_dash"?new zS(c):new sl(c)}}class mp{constructor(c,h,y,b){this.expression=c,this.type=y,this.maxValue=0,this.paintVertexAttributes=h.map(M=>({name:`a_${M}`,type:"Float32",components:y==="color"?2:1,offset:0})),this.paintVertexArray=new b}populatePaintArray(c,h,y,b,M,E,L,z){const V=this.paintVertexArray.length,Z=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new bi(0,{brightness:E,worldview:z}),h,{},M,b,L):this.expression.kind==="constant"&&this.expression.value,Q=W_(this.lutExpression,h,{},b,M,E,L,z);this.paintVertexArray.resize(c),this._setPaintValue(V,c,Z,Q?null:this.context.lut)}updatePaintArray(c,h,y,b,M,E,L,z){const V=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:L,worldview:z},y,b,void 0,M):this.expression.kind==="constant"&&this.expression.value,Z=W_(this.lutExpression,y,b,M,void 0,L,void 0,z);this._setPaintValue(c,h,V,Z?null:this.context.lut)}_setPaintValue(c,h,y,b){if(this.type==="color"){const M=lT(y.toPremultipliedRenderColor(b));for(let E=c;E`u_${L}_t`),this.type=y,this.useIntegerZoom=b,this.context=M,this.maxValue=0,this.paintVertexAttributes=h.map(L=>({name:`a_${L}`,type:"Float32",components:y==="color"?4:2,offset:0})),this.paintVertexArray=new E}populatePaintArray(c,h,y,b,M,E,L,z){const V=this.expression.evaluate(new bi(this.context.zoom,{brightness:E,worldview:z}),h,{},M,b,L),Z=this.expression.evaluate(new bi(this.context.zoom+1,{brightness:E,worldview:z}),h,{},M,b,L),Q=W_(this.lutExpression,h,{},b,M,E,L,z),ee=this.paintVertexArray.length;this.paintVertexArray.resize(c),this._setPaintValue(ee,c,V,Z,Q?null:this.context.lut)}updatePaintArray(c,h,y,b,M,E,L,z){const V=this.expression.evaluate({zoom:this.context.zoom,brightness:L,worldview:z},y,b,void 0,M),Z=this.expression.evaluate({zoom:this.context.zoom+1,brightness:L,worldview:z},y,b,void 0,M),Q=W_(this.lutExpression,y,b,M,void 0,L,void 0,z);this._setPaintValue(c,h,V,Z,Q?null:this.context.lut)}_setPaintValue(c,h,y,b,M){if(this.type==="color"){const E=lT(y.toPremultipliedRenderColor(M)),L=lT(y.toPremultipliedRenderColor(M));for(let z=c;z!0){this.binders={},this._buffers=[],this.context=h;const b=[];for(const M in c.paint._values){const E=c.paint.get(M);if(M.endsWith("-use-theme")||!y(M)||!(E instanceof Kx&&P_(E.property.specification)))continue;const L=Jle(M,c.type),z=E.value,V=E.property.specification.type,Z=!!E.property.useIntegerZoom,Q=M==="line-dasharray"||M.endsWith("pattern"),ee=c.paint.get(`${M}-use-theme`),ne=M==="line-dasharray"&&c.layout.get("line-cap").value.kind!=="constant"||ee&&ee.value.kind!=="constant";if(z.kind!=="constant"||ne)if(z.kind==="source"||ne||Q){const le=cT(M,V,"source");this.binders[M]=Q?new pp(z,L,V,le,c.id):new mp(z,L,V,le),b.push(`/a_${M}`)}else{const le=cT(M,V,"composite");this.binders[M]=new fp(z,L,V,Z,h,le),b.push(`/z_${M}`)}else this.binders[M]=Q?new Z0(z.value,L):new G_(z.value,L,V,h),b.push(`/u_${M}`);ee&&(this.binders[M].lutExpression=ee.value)}this.cacheKey=b.sort().join("")}getMaxValue(c){const h=this.binders[c];return h instanceof mp||h instanceof fp?h.maxValue:0}populatePaintArrays(c,h,y,b,M,E,L,z){for(const V in this.binders){const Z=this.binders[V];Z.context=this.context,(Z instanceof mp||Z instanceof fp||Z instanceof pp)&&Z.populatePaintArray(c,h,y,b,M,E,L,z)}}setConstantPatternPositions(c,h){for(const y in this.binders){const b=this.binders[y];b instanceof Z0&&b.setConstantPatternPositions(c,h)}}getPatternTransitionVertexBuffer(c){const h=this.binders[c];return h instanceof pp?h.paintTransitionVertexBuffer:null}updatePaintArrays(c,h,y,b,M,E,L,z,V,Z){let Q=!1;const ee=Object.keys(c),ne=ee.length!==0&&!z,le=ne?ee:h.uniqueIds;this.context.lut=M.lut;for(const xe in this.binders){const Ce=this.binders[xe];if(Ce.context=this.context,(Ce instanceof mp||Ce instanceof fp||Ce instanceof pp)&&Ce.expression&&Ce.expression.kind&&Ce.expression.kind!=="constant"&&(Ce.expression.isStateDependent===!0||Ce.expression.isLightConstant===!1)){const Ne=M.paint.get(xe);Ce.expression=Ne.value;for(const Fe of le){const Be=c[Fe.toString()];h.eachPosition(Fe,(Je,yt,mt)=>{const kt=b.feature(Je);Ce.updatePaintArray(yt,mt,kt,Be,E,L,V,Z)})}if(!ne)for(const Fe of y.uniqueIds){const Be=c[Fe.toString()];y.eachPosition(Fe,(Je,yt,mt)=>{const kt=b.feature(Je);Ce.updatePaintArray(yt,mt,kt,Be,E,L,V,Z)})}Q=!0}}return Q}defines(){const c=[];for(const h in this.binders){const y=this.binders[h];(y instanceof G_||y instanceof Z0)&&c.push(...y.uniformNames.map(b=>`#define HAS_UNIFORM_${b}`))}return c}getPaintVertexBuffers(){return this._buffers}getUniforms(c){const h=[];for(const y in this.binders){const b=this.binders[y];if(b instanceof G_||b instanceof Z0||b instanceof fp)for(const M of b.uniformNames)h.push({name:M,property:y,binding:b.getBinding(c,M)})}return h}setUniforms(c,h,y,b,M){for(const{name:E,property:L,binding:z}of y)this.binders[L].setUniform(c,z,M,b.get(L),E)}updatePaintBuffers(){this._buffers=[];for(const c in this.binders){const h=this.binders[c];(h instanceof mp||h instanceof fp||h instanceof pp)&&h.paintVertexBuffer&&this._buffers.push(h.paintVertexBuffer),h instanceof pp&&h.paintTransitionVertexBuffer&&this._buffers.push(h.paintTransitionVertexBuffer)}}upload(c){for(const h in this.binders){const y=this.binders[h];(y instanceof mp||y instanceof fp||y instanceof pp)&&y.upload(c)}this.updatePaintBuffers()}destroy(){for(const c in this.binders){const h=this.binders[c];(h instanceof mp||h instanceof fp||h instanceof pp)&&h.destroy()}}}class gm{constructor(c,h,y=()=>!0){this.programConfigurations={};for(const b of c)this.programConfigurations[b.id]=new Og(b,h,y);this.needsUpload=!1,this._featureMap=new U_,this._featureMapWithoutIds=new U_,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(c,h,y,b,M,E,L,z,V){for(const Z in this.programConfigurations)this.programConfigurations[Z].populatePaintArrays(c,h,b,M,E,L,z,V);h.id!==void 0?this._featureMap.add(h.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,h,y,b,M,E,L,z){for(const V of y)this.needsUpload=this.programConfigurations[V.id].updatePaintArrays(c,this._featureMap,this._featureMapWithoutIds,h,V,b,M,E,L||0,z)||this.needsUpload}get(c){return this.programConfigurations[c]}upload(c){if(this.needsUpload){for(const h in this.programConfigurations)this.programConfigurations[h].upload(c);this.needsUpload=!1}}destroy(){for(const c in this.programConfigurations)this.programConfigurations[c].destroy()}}const Qle={"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 Jle(f,c){return Qle[f]||[f.replace(`${c}-`,"").replace(/-/g,"_")]}const ece={"line-pattern":{source:ru,composite:ru},"fill-pattern":{source:ru,composite:ru},"fill-extrusion-pattern":{source:ru,composite:ru},"line-dasharray":{source:Jx,composite:Jx}},tce={color:{source:of,composite:Lg},number:{source:up,composite:of}};function cT(f,c,h){const y=ece[f];return y&&y[h]||tce[c][h]}ms(G_,"ConstantBinder"),ms(Z0,"PatternConstantBinder"),ms(mp,"SourceExpressionBinder"),ms(pp,"PatternCompositeBinder"),ms(fp,"CompositeExpressionBinder"),ms(Og,"ProgramConfiguration",{omit:["_buffers"]}),ms(gm,"ProgramConfigurationSet");const Kc=Br/Math.PI/2,Ih=5,US=6,rce=16383,Y0=64,dT=[Y0,32,16],Ph=-Kc,Lh=Kc;function ty(f,c,h,y=Kc){return h=Qs(h),[f*Math.sin(h)*y,-c*y,f*Math.cos(h)*y]}function X0(f,c,h){return ty(Math.cos(Qs(f)),Math.sin(Qs(f)),c,h)}const j=63710088e-1,u=2*Math.PI*j;class x{constructor(c,h){if(isNaN(c)||isNaN(h))throw new Error(`Invalid LngLat object: (${c}, ${h})`);if(this.lng=+c,this.lat=+h,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new x(Xe(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(c){const h=Math.PI/180,y=this.lat*h,b=c.lat*h,M=Math.sin(y)*Math.sin(b)+Math.cos(y)*Math.cos(b)*Math.cos((c.lng-this.lng)*h);return j*Math.acos(Math.min(M,1))}toBounds(c=0){const h=360*c/40075017,y=h/Math.cos(Math.PI/180*this.lat);return new N({lng:this.lng-y,lat:this.lat-h},{lng:this.lng+y,lat:this.lat+h})}toEcef(c){return X0(this.lat,this.lng,Kc+c*Kc/j)}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 N{constructor(c,h){c&&(h?this.setSouthWest(c).setNorthEast(h):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 h=this._sw,y=this._ne;let b,M;if(c instanceof x)b=c,M=c;else{if(!(c instanceof N))return Array.isArray(c)?c.length===4||c.every(Array.isArray)?this.extend(N.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,M=c._ne,!b||!M)return this}return h||y?(h.lng=Math.min(b.lng,h.lng),h.lat=Math.min(b.lat,h.lat),y.lng=Math.max(M.lng,y.lng),y.lat=Math.max(M.lat,y.lat)):(this._sw=new x(b.lng,b.lat),this._ne=new x(M.lng,M.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:h,lat:y}=x.convert(c);let b=this._sw.lng<=h&&h<=this._ne.lng;return this._sw.lng>this._ne.lng&&(b=this._sw.lng>=h&&h>=this._ne.lng),this._sw.lat<=y&&y<=this._ne.lat&&b}static convert(c){if(c)return c instanceof N?c:new N(c)}}const P=0,O=25.5;function F(f){return u*Math.cos(f*Math.PI/180)}function U(f){return(180+f)/360}function G(f){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+f*Math.PI/360)))/360}function J(f,c){return f/F(c)}function te(f){return 360*f-180}function me(f){return 360/Math.PI*Math.atan(Math.exp((180-360*f)*Math.PI/180))-90}function he(f,c){return f*F(me(c))}const fe=85.051129;function ke(f){return Math.cos(Qs(ye(f,-fe,fe)))}function be(f,c){const h=ye(c,P,O),y=Math.pow(2,h);return ke(f)*u/(512*y)}function Re(f){return 1/Math.cos(f*Math.PI/180)}function Oe(f,c=0){const h=Math.exp(Math.PI*(1-(f.y+c/Br)/(1<=z?(at(f,c,h,V,Z,M,Q,L,z),at(f,V,Z,y,b,Q,E,L,z)):f.push(E)}function Ke(f,c,h){let y=f[0],b=y.x,M=y.y;c(y);const E=[y];for(let L=1;Lf.x+1||yf.y+1)&&ts("Geometry exceeds allowed extent, reduce your vector tile buffer size"),f}function At(f,c,h){const y=f.loadGeometry(),b=f.extent,M=Br/b;if(c&&h&&h.projection.isReprojectedInTileSpace){const E=1<{const ne=te((c.x+ee.x/b)/E),le=me((c.y+ee.y/b)/E),xe=Z.project(ne,le);ee.x=(xe.x*L-z)*b,ee.y=(xe.y*L-V)*b};for(let ee=0;ee=b||le.y<0||le.y>=b||(Q(le),ne.push(le));y[ee]=ne}}for(const E of y)for(const L of E)ht(L,M);return y}function Bt(f,c){return{type:f.type,id:f.id,properties:f.properties,geometry:c?At(f):[]}}class zt{constructor(c,h,y,b,M){this.properties={},this.extent=y,this.type=0,this.id=void 0,this._pbf=c,this._geometry=-1,this._keys=b,this._values=M,c.readFields(Jt,this,h)}loadGeometry(){const c=this._pbf;c.pos=this._geometry;const h=c.readVarint()+c.pos,y=[];let b,M=1,E=0,L=0,z=0;for(;c.pos>3}if(E--,M===1||M===2)L+=c.readSVarint(),z+=c.readSVarint(),M===1&&(b&&y.push(b),b=[]),b&&b.push(new dr(L,z));else{if(M!==7)throw new Error(`unknown command ${M}`);b&&b.push(b[0].clone())}}return b&&y.push(b),y}bbox(){const c=this._pbf;c.pos=this._geometry;const h=c.readVarint()+c.pos;let y=1,b=0,M=0,E=0,L=1/0,z=-1/0,V=1/0,Z=-1/0;for(;c.pos>3}if(b--,y===1||y===2)M+=c.readSVarint(),E+=c.readSVarint(),Mz&&(z=M),EZ&&(Z=E);else if(y!==7)throw new Error(`unknown command ${y}`)}return[L,V,z,Z]}toGeoJSON(c,h,y){const b=this.extent*Math.pow(2,y),M=this.extent*c,E=this.extent*h,L=this.loadGeometry();function z(ee){return[360*(ee.x+M)/b-180,360/Math.PI*Math.atan(Math.exp((1-2*(ee.y+E)/b)*Math.PI))-90]}function V(ee){return ee.map(z)}let Z;if(this.type===1){const ee=[];for(const le of L)ee.push(le[0]);const ne=V(ee);Z=ee.length===1?{type:"Point",coordinates:ne[0]}:{type:"MultiPoint",coordinates:ne}}else if(this.type===2){const ee=L.map(V);Z=ee.length===1?{type:"LineString",coordinates:ee[0]}:{type:"MultiLineString",coordinates:ee}}else{if(this.type!==3)throw new Error("unknown feature type");{const ee=function(le){const xe=le.length;if(xe<=1)return[le];const Ce=[];let Ne,Fe;for(let Be=0;Be=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[c];const h=this._pbf.readVarint()+this._pbf.pos;return new zt(this._pbf,h,this.extent,this._keys,this._values)}}function Cr(f,c,h){f===15?c.version=h.readVarint():f===1?c.name=h.readString():f===5?c.extent=h.readVarint():f===2?c._features.push(h.pos):f===3?c._keys.push(h.readString()):f===4&&c._values.push(function(y){let b=null;const M=y.readVarint()+y.pos;for(;y.pos>3;b=E===1?y.readString():E===2?y.readFloat():E===3?y.readDouble():E===4?y.readVarint64():E===5?y.readVarint():E===6?y.readSVarint():E===7?y.readBoolean():null}if(b==null)throw new Error("unknown feature value");return b}(h))}class Kt{constructor(c,h){this.layers=c.readFields(Lt,{},h)}}function Lt(f,c,h){if(f===3){const y=new ur(h,h.readVarint()+h.pos);y.length&&(c[y.name]=y)}}const nr="3d_elevation_id",Xt="level";class gr{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,h){return this._valid&&c(h(this._geometry)),this}require(c,h,y){return this.get(c,!0,h,y)}optional(c,h,y){return this.get(c,!1,h,y)}success(){return this._valid}get(c,h,y,b){const M=this.feature.properties.hasOwnProperty(c)?+this.feature.properties[c]:void 0;return this._valid&&M!==void 0&&!Number.isNaN(M)?y(b?b(M):M):h&&(this._valid=!1),this}}class qr{constructor(c,h){this.featureFunc=c,this.vertexFunc=h}parseFeature(c,h,y){return this.featureFunc(c,h,y)}parseVertex(c,h,y){return this.vertexFunc(c,h,y)}}const rs=new qr((f,c,h)=>f.reset(c).require(nr,y=>{h.id=y}).optional("fixed_height_relative",y=>{h.constantHeight=y},Tr.decodeRelativeHeight).geometry(y=>{h.bounds=y},ap).success(),(f,c,h)=>f.reset(c).require(nr,y=>{h.id=y}).require("elevation_idx",y=>{h.idx=y}).require("extent",y=>{h.extent=y}).require("height_relative",y=>{h.height=y},Tr.decodeRelativeHeight).geometry(y=>{h.position=y},Tr.getPoint).success()),Or=new qr((f,c,h)=>f.reset(c).require(nr,y=>{h.id=y}).optional("fixed_height",y=>{h.constantHeight=y},Tr.decodeMetricHeight).geometry(y=>{h.bounds=y},ap).success(),(f,c,h)=>f.reset(c).require(nr,y=>{h.id=y}).require("elevation_idx",y=>{h.idx=y}).require("extent",y=>{h.extent=y}).require("height",y=>{h.height=y},Tr.decodeMetricHeight).geometry(y=>{h.position=y},Tr.getPoint).success());class Tr{static getPoint(c){return Et(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"?Or:void 0:rs}static parse(c){const h=[],y=[],b=c.length,M=new gr;for(let E=0;E=0);if(M===0)return 0;M!==c.length&&(h=!1)}return h?2:1}function mn(f,c){for(const h of f.projections){const y=ns(c,f.points[0],h.axis);if(h.projection[1]y[1])return 0}return 1}function sa(f,c){let h=0;const y=[0,0,0,0];for(let E=0;E=0&&h++;var b,M;return h}class Ea{constructor(c,h){this.points=c||new Array(8).fill([0,0,0]),this.planes=h||new Array(6).fill([0,0,0,0]),this.bounds=js.fromPoints(this.points),this.projections=[],this.frustumEdges=[je([],this.points[2],this.points[3]),je([],this.points[0],this.points[3]),je([],this.points[4],this.points[0]),je([],this.points[5],this.points[1]),je([],this.points[6],this.points[2]),je([],this.points[7],this.points[3])];for(const y of this.frustumEdges){const b=[0,-y[2],y[1]],M=[y[2],0,-y[0]];this.projections.push({axis:b,projection:ns(this.points,this.points[0],b)}),this.projections.push({axis:M,projection:ns(this.points,this.points[0],M)})}}static fromInvProjectionMatrix(c,h,y,b){const M=Math.pow(2,y),E=[[-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(V=>{const Z=ot([],V,c),Q=1/Z[3]/h*M;return(ee=Z)[0]=(ne=Z)[0]*(le=[Q,Q,b?1/Z[3]:Q,Q])[0],ee[1]=ne[1]*le[1],ee[2]=ne[2]*le[2],ee[3]=ne[3]*le[3],ee;var ee,ne,le}),L=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(V=>{const Z=Ie([],wt([],je([],E[V[0]],E[V[1]]),je([],E[V[2]],E[V[1]]))),Q=-We(Z,E[V[1]]);return Z.concat(Q)}),z=[];for(let V=0;VV[1]||V[0]>z[1])return 0}return 1}containsPoint(c){for(const h of this.planes){const y=h[3];if(We([h[0],h[1],h[2]],c)+y<0)return!1}return!0}}class js{static fromPoints(c){const h=[1/0,1/0,1/0],y=[-1/0,-1/0,-1/0];for(const b of c)_e(h,h,b),ve(y,y,b);return new js(h,y)}static fromTileIdAndHeight(c,h,y){const b=1<c.max[h]||c.min[h]>this.max[h])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 h=0;h<3;h++)this.min[h]=Math.min(this.min[h],c.min[h]),this.max[h]=Math.max(this.max[h],c.max[h])}encapsulatePoint(c){for(let h=0;h<3;h++)this.min[h]=Math.min(this.min[h],c[h]),this.max[h]=Math.max(this.max[h],c[h])}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])]}}ms(js,"Aabb");class ja{constructor(c,h){this.feature=c,this.metersToTile=h,this.index=0}get(){const c=this.feature.vertices[this.index],h=this.feature.vertexProps[this.index].dir,y=h[1],b=-h[0],M=(c.extent+1)*this.metersToTile;return[new dr(Math.trunc(c.position[0]+y*M),Math.trunc(c.position[1]+b*M)),new dr(Math.trunc(c.position[0]-y*M),Math.trunc(c.position[1]-b*M))]}next(){this.index++}valid(){return this.index{return L.a0?Me(z,z,1/V):de(z,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(c){if(this.edges.length===0)return;let h=0,y=Number.POSITIVE_INFINITY,b=0;const[M,E,L,z,V,Z,Q]=this._tmpVec2;Pt(Q,c.x,c.y);const ee=new vs(Q,null);for(let ne=0;ne0?La(z,L)/Je:0,mt=ye(yt,0,1),kt=Math.abs((yt-mt)*this.edgeProps[ne].len);fs(V,Q,Ce),Pt(Z,xe[1],-xe[0]);const It=kt+Math.abs(La(V,Z));It=0;--E){const L=this.edges[E].a,z=this.edges[E].b,{position:V,height:Z,extent:Q}=this.vertices[L],{position:ee,height:ne,extent:le}=this.vertices[z],xe=this.vertexProps[L].dir,Ce=this.vertexProps[z].dir;if(de(h,V[0]/c,V[1]/c,Z),de(y,ee[0]/c,ee[1]/c,ne),de(b,xe[1],-xe[0],0),Me(b,b,Q),de(M,Ce[1],-Ce[0],0),Me(M,M,le),this.distSqLines(ie(h[0]+.5*b[0],h[1]+.5*b[1],h[2]+.5*b[2]),ie(y[0]-.5*M[0],y[1]-.5*M[1],y[2]-.5*M[2]),ie(h[0]-.5*b[0],h[1]-.5*b[1],h[2]-.5*b[2]),ie(y[0]+.5*M[0],y[1]+.5*M[1],y[2]+.5*M[2]))<=.0025000000000000005)continue;const Ne=this.vertices.length,Fe=Sr(As(),V,ee);this.vertices.push({position:Ws(Fe,Fe,.5),height:.5*(Z+ne),extent:.5*(Q+le)});const Be=Sr(As(),xe,Ce);this.vertexProps.push({dir:xi(Be,Be)}),this.edges.splice(E,1),this.edgeProps.splice(E,1),this.edges.push({a:L,b:Ne}),this.edges.push({a:Ne,b:z});const Je=fs(As(),this.vertices[Ne].position,V),yt=tn(Je),mt={vec:Je,dir:Ws(As(),Je,1/yt),len:yt};this.edgeProps.push(mt),this.edgeProps.push(mt)}}distSqLines(c,h,y,b){const M=ge(oe(),h,c),E=ge(oe(),b,y),L=ge(oe(),c,y),z=We(M,M),V=We(M,E),Z=We(M,L),Q=We(E,E),ee=We(E,L),ne=z*Q-V*V;if(ne===0)return Le(Pe(M,y,b,We(L,E)/We(E,E)),c);const le=(z*ee-V*Z)/ne;return Le(Pe(M,c,h,(V*ee-Z*Q)/ne),Pe(E,y,b,le))}}class Oa{static parseFrom(c,h){const y=Tr.parse(c);if(!y)return[];let{vertices:b,features:M}=y;const E=1/Oe(h);M.sort((Z,Q)=>Z.id-Q.id),b.sort((Z,Q)=>Z.id-Q.id||Z.idx-Q.idx),b=b.filter((Z,Q,ee)=>Q===ee.findIndex(ne=>ne.id===Z.id&&ne.idx===Z.idx));const L=new Array;let z=0;const V=b.length;for(const Z of M){if(Z.constantHeight){L.push(new an(Z.id,Z.bounds,Z.constantHeight));continue}for(;z!==V&&b[z].idb.id===y)}}class Xa{constructor(c,h){this.zScale=1,this.xOffset=0,this.yOffset=0,c.equals(h)||(this.zScale=Math.pow(2,h.z-c.z),this.xOffset=(c.x*this.zScale-h.x)*Br,this.yOffset=(c.y*this.zScale-h.y)*Br)}constantElevation(c,h){if(c.constantHeight!=null)return this.computeBiasedHeight(c.constantHeight,h)}pointElevation(c,h,y){const b=this.constantElevation(h,y);return b??(c.x=c.x*this.zScale+this.xOffset,c.y=c.y*this.zScale+this.yOffset,this.computeBiasedHeight(h.pointElevation(c),y))}computeBiasedHeight(c,h){return h<=0?c:c+h*De(0,h,c>=0?c:Math.abs(.5*c))}}ms(an,"ElevationFeature");class qa{constructor(c){this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.projection=c.projection,this.layoutVertexArray=new Pg,this.indexArray=new rl,this.segments=new to,this.programConfigurations=new gm(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,this.elevationMode!=="none"&&(this.elevatedLayoutVertexArray=new up),this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,y,b){}populate(c,h,y,b){const M=this.layers[0],E=[];let L=null;M.type==="circle"&&(L=M.layout.get("circle-sort-key"));for(const{feature:V,id:Z,index:Q,sourceLayerIndex:ee}of c){const ne=this.layers[0]._featureFilter.needGeometry,le=Bt(V,ne);if(!this.layers[0]._featureFilter.filter(new bi(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),le,y))continue;const xe=L?L.evaluate(le,{},y):void 0,Ce={id:Z,properties:V.properties,type:V.type,sourceLayerIndex:ee,index:Q,geometry:ne?le.geometry:At(V,y,b),patterns:{},sortKey:xe};E.push(Ce)}L&&E.sort((V,Z)=>V.sortKey-Z.sortKey);let z=null;b.projection.name==="globe"&&(this.globeExtVertexArray=new NS,z=b.projection);for(const V of E){const{geometry:Z,index:Q,sourceLayerIndex:ee}=V,ne=c[Q].feature;this.addFeature(V,Z,Q,h.availableImages,y,z,h.brightness,h.elevationFeatures),h.featureIndex.insert(ne,Z,Q,ee,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(c,h,y,b,M,E,L){this.programConfigurations.updatePaintArrays(c,h,M,y,b,E,L,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,QL.members),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,JL.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=c.createVertexBuffer(this.elevatedLayoutVertexArray,Wle.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,h,y,b,M,E,L,z){let V;this.elevationMode!=="none"&&(V=Oa.getElevationFeature(c,z));for(const Z of h)for(const Q of Z){const ee=Q.x,ne=Q.y;if(ee<0||ee>=Br||ne<0||ne>=Br)continue;if(E){const Ce=E.projectTilePoint(ee,ne,M),Ne=E.upVector(M,ee,ne);this.addGlobeExtVertex(Ce,Ne),this.addGlobeExtVertex(Ce,Ne),this.addGlobeExtVertex(Ce,Ne),this.addGlobeExtVertex(Ce,Ne)}const le=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,c.sortKey),xe=le.vertexLength;if(this.addCircleVertex(ee,ne,-1,-1),this.addCircleVertex(ee,ne,1,-1),this.addCircleVertex(ee,ne,1,1),this.addCircleVertex(ee,ne,-1,1),this.elevationMode!=="none"){const Ce=V?V.pointElevation(new dr(ee,ne)):0;this.hasElevation=this.hasElevation||Ce!==0;for(let Ne=0;Ne<4;Ne++)this.elevatedLayoutVertexArray.emplaceBack(Ce)}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,M,L,void 0,this.worldview)}addCircleVertex(c,h,y,b){this.layoutVertexArray.emplaceBack(2*c+(y+1)/2,2*h+(b+1)/2)}addGlobeExtVertex(c,h){this.globeExtVertexArray.emplaceBack(c.x,c.y,c.z,h[0]*16384,h[1]*16384,h[2]*16384)}}function wa(f,c){for(let h=0;h1){if(Di(f,c))return!0;for(let y=0;y1?h:h.sub(c)._mult(b)._add(c))}function ro(f,c){let h,y,b,M=!1;for(let E=0;Ec.y!=b.y>c.y&&c.x<(b.x-y.x)*(c.y-y.y)/(b.y-y.y)+y.x&&(M=!M)}return M}function oi(f,c){let h=!1;for(let y=0,b=f.length-1;yc.y!=E.y>c.y&&c.x<(E.x-M.x)*(c.y-M.y)/(E.y-M.y)+M.x&&(h=!h)}return h}function Rd(f,c,h,y,b){for(const E of f)if(c<=E.x&&h<=E.y&&y>=E.x&&b>=E.y)return!0;const M=[new dr(c,h),new dr(c,b),new dr(y,b),new dr(y,h)];if(f.length>2){for(const E of M)if(oi(f,E))return!0}for(let E=0;Eb.x&&c.x>b.x||f.yb.y&&c.y>b.y)return!1;const M=yn(f,c,h[0]);return M!==yn(f,c,h[1])||M!==yn(f,c,h[2])||M!==yn(f,c,h[3])}function nl(f,c,h,y,b,M){let E=c.y-f.y,L=f.x-c.x;if(M=M||0){const z=E*E+L*L;if(z===0)return!0;const V=Math.sqrt(z);E/=V,L/=V}return!((h.x-f.x)*E+(h.y-f.y)*L-M<0||(y.x-f.x)*E+(y.y-f.y)*L-M<0||(b.x-f.x)*E+(b.y-f.y)*L-M<0)}function Zc(f,c,h,y,b,M,E){return!(nl(f,c,y,b,M,E)||nl(c,h,y,b,M,E)||nl(h,f,y,b,M,E)||nl(y,b,f,c,h,E)||nl(b,M,f,c,h,E)||nl(M,y,f,c,h,E))}function Yc(f,c,h){const y=c.paint.get(f).value;return y.kind==="constant"?y.value:h.programConfigurations.get(c.id).getMaxValue(f)}function nc(f){return Math.sqrt(f[0]*f[0]+f[1]*f[1])}function Ju(f,c,h,y,b){if(!c[0]&&!c[1])return f;const M=dr.convert(c)._mult(b);h==="viewport"&&M._rotate(-y);const E=[];for(let L=0;L>h&&c.y===this.y>>h}url(c,h){const y=function(M,E,L){var z=So(256*M,256*(E=Math.pow(2,L)-E-1),L),V=So(256*(M+1),256*(E+1),L);return z[0]+","+z[1]+","+V[0]+","+V[1]}(this.x,this.y,this.z),b=function(M,E,L){let z,V="";for(let Z=M;Z>0;Z--)z=1<this.canonical.z?new oo(c,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new oo(c,this.wrap,c,this.canonical.x>>h,this.canonical.y>>h)}calculateScaledKey(c,h=!0){if(this.overscaledZ===c&&h)return this.key;if(c>this.canonical.z)return so(this.wrap*+h,c,this.canonical.z,this.canonical.x,this.canonical.y);{const y=this.canonical.z-c;return so(this.wrap*+h,c,c,this.canonical.x>>y,this.canonical.y>>y)}}isChildOf(c){if(c.wrap!==this.wrap)return!1;const h=this.canonical.z-c.canonical.z;return c.overscaledZ===0||c.overscaledZ>h&&c.canonical.y===this.canonical.y>>h}children(c){if(this.overscaledZ>=c)return[new oo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const h=this.canonical.z+1,y=2*this.canonical.x,b=2*this.canonical.y;return[new oo(h,this.wrap,h,y,b),new oo(h,this.wrap,h,y+1,b),new oo(h,this.wrap,h,y,b+1),new oo(h,this.wrap,h,y+1,b+1)]}isLessThan(c){return this.wrapc.wrap)&&(this.overscaledZc.overscaledZ)&&(this.canonical.xc.canonical.x)&&this.canonical.y{let c=f.canonical.x-1,h=f.wrap;return c<0&&(c=(1<{let c=f.canonical.x+1,h=f.wrap;return c===1<new oo(f.overscaledZ,f.wrap,f.canonical.z,f.canonical.x,(f.canonical.y===0?1<new oo(f.overscaledZ,f.wrap,f.canonical.z,f.canonical.x,f.canonical.y===(1<1?null:function(y,b,M,E){const L=Math.sin(M);return y*(Math.sin((1-E)*M)/L)+b*(Math.sin(E*M)/L)}(f.a[c],f.b[c],f.angle,ye(h,0,1))+f.center[c]}function ym(f){if(f.z<=1)return gp[f.z+2*f.y+f.x];const c=sce(eD(f));return js.fromPoints(c)}function yp(f,c,h){return Me(f,f,1-h),Ze(f,f,c,h)}function vwe(f,c,h){for(const y of f)st(y,y,c),Me(y,y,h)}function _we(f,c,h,y){const b=c/f.worldSize,M=f.globeMatrix;if(h.z<=1){const Rt=ym(h).getCorners();return vwe(Rt,M,b),js.fromPoints(Rt)}const E=eD(h,y),L=sce(E,Kc+cf(f._tileCoverLift));vwe(L,M,b);const z=Number.MAX_VALUE,V=[-z,-z,-z],Z=[z,z,z];if(E.contains(f.center)){for(const $t of L)_e(Z,Z,$t),ve(V,V,$t);V[2]=0;const Rt=f.point,tr=[Rt.x*b,Rt.y*b,0];return _e(Z,Z,tr),ve(V,V,tr),new js(Z,V)}if(f._tileCoverLift>0){for(const Rt of L)_e(Z,Z,Rt),ve(V,V,Rt);return new js(Z,V)}const Q=[M[12]*b,M[13]*b,M[14]*b],ee=E.getCenter(),ne=ye(f.center.lat,-fe,fe),le=ye(ee.lat,-fe,fe),xe=U(f.center.lng),Ce=G(ne);let Ne=xe-U(ee.lng);const Fe=Ce-G(le);Ne>.5?Ne-=1:Ne<-.5&&(Ne+=1);let Be=0;Math.abs(Ne)>Math.abs(Fe)?Be=Ne>=0?1:3:(Be=Fe>=0?0:2,Ze(Q,Q,[M[4]*b,M[5]*b,M[6]*b],-Math.sin(Qs(Fe>=0?E.getSouth():E.getNorth()))*Kc));const Je=L[Be],yt=L[(Be+1)%4],mt=new Rg(Je,yt,Q),kt=[xp(mt,0)||Je[0],xp(mt,1)||Je[1],xp(mt,2)||Je[2]],It=ev(f.zoom);if(It>0){const Rt=function({x:$t,y:or,z:mr},fr,wr,kr,xr){const _r=1/(1<.5?Ar=-1:Ns<-.5&&(Ar=1),ir=((ir+Ar)*fr-(kr*=fr))*wr+kr,sr=((sr+Ar)*fr-kr)*wr+kr,br=(br*fr-(xr*=fr))*wr+xr,Vr=(Vr*fr-xr)*wr+xr,[[ir,Vr,0],[sr,Vr,0],[sr,br,0],[ir,br,0]]}(h,c,f._pixelsPerMercatorPixel,xe,Ce);for(let $t=0;$tMath.PI/2*1.01}const Nwe=Qs(85),NXe=Math.cos(Nwe),SXe=Math.sin(Nwe),CXe=k(),Swe=f=>{const c=[];return f.paint.get("circle-pitch-alignment")==="map"&&c.push("PITCH_WITH_MAP"),f.paint.get("circle-pitch-scale")==="map"&&c.push("SCALE_WITH_MAP"),c};function Cwe(f,c,h,y,b,M,E,L,z){if(M&&f.queryGeometry.isAboveHorizon)return!1;M&&(z*=f.pixelToTileUnitsFactor);const V=f.tileID.canonical,Z=h.projection.upVectorScale(V,h.center.lat,h.worldSize).metersToTile;for(const Q of c)for(const ee of Q){const ne=ee.add(L),le=b&&h.elevation?h.elevation.exaggeration()*b.getElevationAt(ne.x,ne.y,!0):0,xe=h.projection.projectTilePoint(ne.x,ne.y,V);if(le>0){const Be=h.projection.upVector(V,ne.x,ne.y);xe.x+=Be[0]*Z*le,xe.y+=Be[1]*Z*le,xe.z+=Be[2]*Z*le}const Ce=M?ne:MXe(xe.x,xe.y,xe.z,y),Ne=M?f.tilespaceRays.map(Be=>AXe(Be,le)):f.queryGeometry.screenGeometry,Fe=ot([],[xe.x,xe.y,xe.z,1],y);if(!E&&M?z*=Fe[3]/h.cameraToCenterDistance:E&&!M&&(z*=h.cameraToCenterDistance/Fe[3]),M){const Be=me((ee.y/Br+V.y)/(1<f.width||b.height>f.height||h.x>f.width-b.width||h.y>f.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=f.data,V=c.data,Z=M===4&&L;for(let Q=0;Q{c[f.evaluationKey]=z;const V=f.expression.evaluate(c),Z=V?V.toNonPremultipliedRenderColor(null):null;Z&&(b.data[E+L+0]=Math.floor(255*Z.r),b.data[E+L+1]=Math.floor(255*Z.g),b.data[E+L+2]=Math.floor(255*Z.b),b.data[E+L+3]=Math.floor(255*Z.a))};if(f.clips)for(let E=0,L=0;E80*h){L=f[0],z=f[1];let Z=L,Q=z;for(let ee=h;eeZ&&(Z=ne),le>Q&&(Q=le)}V=Math.max(Z-L,Q-z),V=V!==0?32767/V:0}return mT(M,E,h,L,z,V,0),E}function Rwe(f,c,h,y,b){let M;if(b===function(E,L,z,V){let Z=0;for(let Q=L,ee=z-V;Q0)for(let E=c;E=c;E-=y)M=$we(E/y|0,f[E],f[E+1],M);return M&&qS(M,M.next)&&(gT(M),M=M.next),M}function Y_(f,c){if(!f)return f;c||(c=f);let h,y=f;do if(h=!1,y.steiner||!qS(y,y.next)&&ql(y.prev,y,y.next)!==0)y=y.next;else{if(gT(y),y=c=y.prev,y===y.next)break;h=!0}while(h||y!==c);return c}function mT(f,c,h,y,b,M,E){if(!f)return;!E&&M&&function(z,V,Z,Q){let ee=z;do ee.z===0&&(ee.z=lce(ee.x,ee.y,V,Z,Q)),ee.prevZ=ee.prev,ee.nextZ=ee.next,ee=ee.next;while(ee!==z);ee.prevZ.nextZ=null,ee.prevZ=null,function(ne){let le,xe=1;do{let Ce,Ne=ne;ne=null;let Fe=null;for(le=0;Ne;){le++;let Be=Ne,Je=0;for(let mt=0;mt0||yt>0&&Be;)Je!==0&&(yt===0||!Be||Ne.z<=Be.z)?(Ce=Ne,Ne=Ne.nextZ,Je--):(Ce=Be,Be=Be.nextZ,yt--),Fe?Fe.nextZ=Ce:ne=Ce,Ce.prevZ=Fe,Fe=Ce;Ne=Be}Fe.nextZ=null,xe*=2}while(le>1)}(ee)}(f,y,b,M);let L=f;for(;f.prev!==f.next;){const z=f.prev,V=f.next;if(M?OXe(f,y,b,M):DXe(f))c.push(z.i,f.i,V.i),gT(f),f=V.next,L=V.next;else if((f=V)===L){E?E===1?mT(f=RXe(Y_(f),c),c,h,y,b,M,2):E===2&&FXe(f,c,h,y,b,M):mT(Y_(f),c,h,y,b,M,1);break}}}function DXe(f){const c=f.prev,h=f,y=f.next;if(ql(c,h,y)>=0)return!1;const b=c.x,M=h.x,E=y.x,L=c.y,z=h.y,V=y.y,Z=Math.min(b,M,E),Q=Math.min(L,z,V),ee=Math.max(b,M,E),ne=Math.max(L,z,V);let le=y.next;for(;le!==c;){if(le.x>=Z&&le.x<=ee&&le.y>=Q&&le.y<=ne&&fT(b,L,M,z,E,V,le.x,le.y)&&ql(le.prev,le,le.next)>=0)return!1;le=le.next}return!0}function OXe(f,c,h,y){const b=f.prev,M=f,E=f.next;if(ql(b,M,E)>=0)return!1;const L=b.x,z=M.x,V=E.x,Z=b.y,Q=M.y,ee=E.y,ne=Math.min(L,z,V),le=Math.min(Z,Q,ee),xe=Math.max(L,z,V),Ce=Math.max(Z,Q,ee),Ne=lce(ne,le,c,h,y),Fe=lce(xe,Ce,c,h,y);let Be=f.prevZ,Je=f.nextZ;for(;Be&&Be.z>=Ne&&Je&&Je.z<=Fe;){if(Be.x>=ne&&Be.x<=xe&&Be.y>=le&&Be.y<=Ce&&Be!==b&&Be!==E&&fT(L,Z,z,Q,V,ee,Be.x,Be.y)&&ql(Be.prev,Be,Be.next)>=0||(Be=Be.prevZ,Je.x>=ne&&Je.x<=xe&&Je.y>=le&&Je.y<=Ce&&Je!==b&&Je!==E&&fT(L,Z,z,Q,V,ee,Je.x,Je.y)&&ql(Je.prev,Je,Je.next)>=0))return!1;Je=Je.nextZ}for(;Be&&Be.z>=Ne;){if(Be.x>=ne&&Be.x<=xe&&Be.y>=le&&Be.y<=Ce&&Be!==b&&Be!==E&&fT(L,Z,z,Q,V,ee,Be.x,Be.y)&&ql(Be.prev,Be,Be.next)>=0)return!1;Be=Be.prevZ}for(;Je&&Je.z<=Fe;){if(Je.x>=ne&&Je.x<=xe&&Je.y>=le&&Je.y<=Ce&&Je!==b&&Je!==E&&fT(L,Z,z,Q,V,ee,Je.x,Je.y)&&ql(Je.prev,Je,Je.next)>=0)return!1;Je=Je.nextZ}return!0}function RXe(f,c){let h=f;do{const y=h.prev,b=h.next.next;!qS(y,b)&&zwe(y,h,h.next,b)&&pT(y,b)&&pT(b,y)&&(c.push(y.i,h.i,b.i),gT(h),gT(h.next),h=f=b),h=h.next}while(h!==f);return Y_(h)}function FXe(f,c,h,y,b,M){let E=f;do{let L=E.next.next;for(;L!==E.prev;){if(E.i!==L.i&&VXe(E,L)){let z=Bwe(E,L);return E=Y_(E,E.next),z=Y_(z,z.next),mT(E,c,h,y,b,M,0),void mT(z,c,h,y,b,M,0)}L=L.next}E=E.next}while(E!==f)}function zXe(f,c){let h=f.x-c.x;return h===0&&(h=f.y-c.y,h===0)&&(h=(f.next.y-f.y)/(f.next.x-f.x)-(c.next.y-c.y)/(c.next.x-c.x)),h}function BXe(f,c){const h=function(b,M){let E=M;const L=b.x,z=b.y;let V,Z=-1/0;if(qS(b,E))return E;do{if(qS(b,E.next))return E.next;if(z<=E.y&&z>=E.next.y&&E.next.y!==E.y){const xe=E.x+(z-E.y)*(E.next.x-E.x)/(E.next.y-E.y);if(xe<=L&&xe>Z&&(Z=xe,V=E.x=E.x&&E.x>=ee&&L!==E.x&&Fwe(zV.x||E.x===V.x&&$Xe(V,E)))&&(V=E,le=xe)}E=E.next}while(E!==Q);return V}(f,c);if(!h)return c;const y=Bwe(h,f);return Y_(y,y.next),Y_(h,h.next)}function $Xe(f,c){return ql(f.prev,f,c.prev)<0&&ql(c.next,f,f.next)<0}function lce(f,c,h,y,b){return(f=1431655765&((f=858993459&((f=252645135&((f=16711935&((f=(f-h)*b|0)|f<<8))|f<<4))|f<<2))|f<<1))|(c=1431655765&((c=858993459&((c=252645135&((c=16711935&((c=(c-y)*b|0)|c<<8))|c<<4))|c<<2))|c<<1))<<1}function UXe(f){let c=f,h=f;do(c.x=(f-E)*(M-L)&&(f-E)*(y-L)>=(h-E)*(c-L)&&(h-E)*(M-L)>=(b-E)*(y-L)}function fT(f,c,h,y,b,M,E,L){return!(f===E&&c===L)&&Fwe(f,c,h,y,b,M,E,L)}function VXe(f,c){return f.next.i!==c.i&&f.prev.i!==c.i&&!function(h,y){let b=h;do{if(b.i!==h.i&&b.next.i!==h.i&&b.i!==y.i&&b.next.i!==y.i&&zwe(b,b.next,h,y))return!0;b=b.next}while(b!==h);return!1}(f,c)&&(pT(f,c)&&pT(c,f)&&function(h,y){let b=h,M=!1;const E=(h.x+y.x)/2,L=(h.y+y.y)/2;do b.y>L!=b.next.y>L&&b.next.y!==b.y&&E<(b.next.x-b.x)*(L-b.y)/(b.next.y-b.y)+b.x&&(M=!M),b=b.next;while(b!==h);return M}(f,c)&&(ql(f.prev,f,c.prev)||ql(f,c.prev,c))||qS(f,c)&&ql(f.prev,f,f.next)>0&&ql(c.prev,c,c.next)>0)}function ql(f,c,h){return(c.y-f.y)*(h.x-c.x)-(c.x-f.x)*(h.y-c.y)}function qS(f,c){return f.x===c.x&&f.y===c.y}function zwe(f,c,h,y){const b=nD(ql(f,c,h)),M=nD(ql(f,c,y)),E=nD(ql(h,y,f)),L=nD(ql(h,y,c));return b!==M&&E!==L||!(b!==0||!sD(f,h,c))||!(M!==0||!sD(f,y,c))||!(E!==0||!sD(h,f,y))||!(L!==0||!sD(h,c,y))}function sD(f,c,h){return c.x<=Math.max(f.x,h.x)&&c.x>=Math.min(f.x,h.x)&&c.y<=Math.max(f.y,h.y)&&c.y>=Math.min(f.y,h.y)}function nD(f){return f>0?1:f<0?-1:0}function pT(f,c){return ql(f.prev,f,f.next)<0?ql(f,c,f.next)>=0&&ql(f,f.prev,c)>=0:ql(f,c,f.prev)<0||ql(f,f.next,c)<0}function Bwe(f,c){const h=cce(f.i,f.x,f.y),y=cce(c.i,c.x,c.y),b=f.next,M=c.prev;return f.next=c,c.prev=f,h.next=b,b.prev=h,y.next=h,h.prev=y,M.next=y,y.prev=M,y}function $we(f,c,h,y){const b=cce(f,c,h);return y?(b.next=y.next,b.prev=y,y.next.prev=b,y.next=b):(b.prev=b,b.next=b),b}function gT(f){f.next.prev=f.prev,f.prev.next=f.next,f.prevZ&&(f.prevZ.nextZ=f.nextZ),f.nextZ&&(f.nextZ.prevZ=f.prevZ)}function cce(f,c,h){return{i:f,x:c,y:h,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function xT(f,c){const h=f.length;if(h<=1)return[f];const y=[];let b,M;for(let E=0;E1)for(let E=0;E=Br&&h>=Br}static evaluate(c){if(c.length===0)return new ry;let h=[];for(const z of c)h.push(...z.portals);if(h.length===0)return new ry;for(const z of h){const V=z.va,Z=z.vb;(ry.isOnBorder(V.x,Z.x)||ry.isOnBorder(V.y,Z.y))&&(z.type="border")}const y=h.filter(z=>z.type!=="unevaluated"),b=h.filter(z=>z.type==="unevaluated");if(b.length===0)return new ry;b.sort((z,V)=>z.hash===V.hash?z.isTunnel===V.isTunnel?0:z.isTunnel?-1:1:z.hashz.hashM!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new gm(h,{zoom:y,lut:b},M=>M!=="fill-bridge-guard-rail-color")}addVertices(c,h){const y=this.unevalVertices.length;for(let b=0;b=M.min.x&&Q.x<=M.max.x&&Q.y>=M.min.y&&Q.y<=M.max.y||ee.x>=M.min.x&&ee.x<=M.max.x&&ee.y>=M.min.y&&ee.y<=M.max.y||Ic(Q,ee,L))||this.isOnBorder(Q.x,ee.x)||this.isOnBorder(Q.y,ee.y))continue;const ne=eh.computeEdgeHash(this.unevalVertices[V],this.unevalVertices[Z]);let le,xe=this.vertexHashLookup.get(eh.computePosHash(Q));xe!=null?le=xe.next:(xe=this.vertexHashLookup.get(eh.computePosHash(ee)),le=xe!=null?xe.prev:ne),this.unevalEdges.push({polygonIdx:c,a:V,b:Z,hash:ne,portalHash:le,isTunnel:b,type:"unevaluated",featureInfo:E})}}addPortalCandidates(c,h,y,b,M){if(h.length===0)return;this.portalPolygons.add(c,{geometry:h,zLevel:M});const E=h[0];this.vertexHashLookup.clear();let L=eh.computeEdgeHash(E[E.length-2],E[E.length-1]);for(let z=0;z({vertexOffset:0,primitiveOffset:this.indexArray.length}),y=ee=>{ee.primitiveLength=this.indexArray.length-ee.primitiveOffset},b=new HXe(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(c.portals,this.unevalEdges);const M=h(),E=h(),L=h(),z=(ee,ne)=>{ee.sort((xe,Ce)=>xe.type===ne&&Ce.type!==ne?-1:xe.type!==ne&&Ce.type===ne?1:0);const le=ee.findIndex(xe=>xe.type!==ne);return le>=0?le:ee.length};let V=0;this.unevalEdges.length>0&&(V=z(this.unevalEdges,"none"),this.constructBridgeStructures(b,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:V},this.tileToMeters)),y(L);const Z=h(),Q=h();if(this.unevalEdges.length>0){const ee=this.unevalEdges.splice(V),ne=z(ee,"tunnel")+V;this.unevalEdges.push(...ee),this.constructTunnelStructures(b,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:V},{min:V,max:ne})}y(Z),b.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),y(Q),b.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),y(E),b.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),y(M),this.maskSegments=to.simpleSegment(0,Q.primitiveOffset,0,Q.primitiveLength),this.depthSegments=to.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength),this.renderableBridgeSegments=to.simpleSegment(0,L.primitiveOffset,0,L.primitiveLength),this.renderableTunnelSegments=to.simpleSegment(0,Z.primitiveOffset,0,Z.primitiveLength),this.shadowCasterSegments=to.simpleSegment(0,M.primitiveOffset,0,M.primitiveLength)}update(c,h,y,b,M,E,L,z){this.bridgeProgramConfigurations.updatePaintArrays(c,h,M,y,b,E,L,z),this.tunnelProgramConfigurations.updatePaintArrays(c,h,M,y,b,E,L,z)}upload(c){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=c.createVertexBuffer(this.vertexPositions,PXe.members),this.vertexBufferNormal=c.createVertexBuffer(this.vertexNormals,LXe.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,h,y,b,M){const E=(L,z)=>{for(let V=0;Vde(wr,h[kr].x,h[kr].y,y[kr]*z),Q=oe(),ee=oe(),ne=oe(),le=oe(),xe=oe(),Ce=(wr,kr)=>{const xr=L.get(eh.computePosHash(h[kr])),_r=xr.from,ir=xr.to;if(!_r||!ir)return;Z(Q,_r),Z(ee,kr),Z(ne,ir),tt(le),rt(Q,ee)||(je(xe,ee,Q),Ie(le,xe)),rt(ne,ee)||(je(xe,ne,ee),ce(le,le,Ie(xe,xe)));const sr=Se(le);return sr>0?Me(wr,le,1/sr):void 0};let Ne=Number.POSITIVE_INFINITY;this.sortSubarray(b,M.min,M.max,(wr,kr)=>wr.featureInfo.featureIndex-kr.featureInfo.featureIndex);const Fe=oe(),Be=oe(),Je=oe(),yt=oe(),mt=oe(),kt=oe(),It=oe(),Rt=oe(),tr=oe(),$t=[oe(),oe(),oe(),oe()],or=[oe(),oe(),oe(),oe()],mr=[{coord:new dr(0,0),height:0},{coord:new dr(0,0),height:0}],fr=(wr,kr)=>wr>kr;for(let wr=M.min;wrNe.featureInfo.featureIndex-Fe.featureInfo.featureIndex;this.sortSubarray(b,M.min,M.max,z),this.sortSubarray(b,E.min,E.max,z);const V=Ne=>Ie(Ne,Ne),Z=[{coord:new dr(0,0),height:0},{coord:new dr(0,0),height:0}],Q=(Ne,Fe)=>NeL.hash===z.hash?z.polygonIdx-L.polygonIdx:z.hash>L.hash?1:-1);let y=0,b=0,M=0,E=h[y].polygonIdx;do b++,(b===h.length||h[y].hash!==h[b].hash)&&((b-y==1||h[b-1].polygonIdx!==E)&&(MV.portalHashZ.hash?L++:Z.hash>V.portalHash?z++:(V.type=Z.type,L++)}}}isOnBorder(c,h){return c<=0&&h<=0||c>=Br&&h>=Br}addFeatureSection(c,h,y,b){return c!==h&&(h=c,y.push({featureIndex:c,vertexStart:b.getVertexCount()}),b.clearVertexLookup()),h}sortSubarray(c,h,y,b){const M=c.slice(h,y);M.sort(b),c.splice(h,M.length,...M)}static computeEdgeHash(c,h){return(c.y===h.y&&c.x>h.x||c.y>h.y)&&([c,h]=[h,c]),BigInt(eh.computePosHash(c))<<32n|BigInt(eh.computePosHash(h))}static computePosHash(c){return((65535&c.x)<<16|65535&c.y)>>>0}}var qwe,Hwe={exports:{}},Wwe=(qwe||(qwe=1,function(f){function c(pt,vt){return pt>vt?1:pt0){var Ms=jr+Math.floor(Yr/2),Es={key:vt[Ms],data:lr[Ms],parent:pt};return Es.left=b(Es,vt,lr,jr,Ms),Es.right=b(Es,vt,lr,Ms+1,Zr),Es}return null}function M(pt,vt,lr,jr,Zr){if(!(lr>=jr)){for(var Yr=pt[lr+jr>>1],Ms=lr-1,Es=jr+1;;){do Ms++;while(Zr(pt[Ms],Yr)<0);do Es--;while(Zr(pt[Es],Yr)>0);if(Ms>=Es)break;var xn=pt[Ms];pt[Ms]=pt[Es],pt[Es]=xn,xn=vt[Ms],vt[Ms]=vt[Es],vt[Es]=xn}M(pt,vt,lr,Es,Zr),M(pt,vt,Es+1,jr,Zr)}}h.prototype.rotateLeft=function(pt){var vt=pt.right;vt&&(pt.right=vt.left,vt.left&&(vt.left.parent=pt),vt.parent=pt.parent),pt.parent?pt===pt.parent.left?pt.parent.left=vt:pt.parent.right=vt:this._root=vt,vt&&(vt.left=pt),pt.parent=vt},h.prototype.rotateRight=function(pt){var vt=pt.left;vt&&(pt.left=vt.right,vt.right&&(vt.right.parent=pt),vt.parent=pt.parent),pt.parent?pt===pt.parent.left?pt.parent.left=vt:pt.parent.right=vt:this._root=vt,vt&&(vt.right=pt),pt.parent=vt},h.prototype._splay=function(pt){for(;pt.parent;){var vt=pt.parent;vt.parent?vt.left===pt&&vt.parent.left===vt?(this.rotateRight(vt.parent),this.rotateRight(vt)):vt.right===pt&&vt.parent.right===vt?(this.rotateLeft(vt.parent),this.rotateLeft(vt)):vt.left===pt&&vt.parent.right===vt?(this.rotateRight(vt),this.rotateLeft(vt)):(this.rotateLeft(vt),this.rotateRight(vt)):vt.left===pt?this.rotateRight(vt):this.rotateLeft(vt)}},h.prototype.splay=function(pt){for(var vt,lr,jr,Zr,Yr;pt.parent;)(lr=(vt=pt.parent).parent)&&lr.parent?((jr=lr.parent).left===lr?jr.left=pt:jr.right=pt,pt.parent=jr):(pt.parent=null,this._root=pt),Zr=pt.left,Yr=pt.right,pt===vt.left?(lr&&(lr.left===vt?(vt.right?(lr.left=vt.right,lr.left.parent=lr):lr.left=null,vt.right=lr,lr.parent=vt):(Zr?(lr.right=Zr,Zr.parent=lr):lr.right=null,pt.left=lr,lr.parent=pt)),Yr?(vt.left=Yr,Yr.parent=vt):vt.left=null,pt.right=vt,vt.parent=pt):(lr&&(lr.right===vt?(vt.left?(lr.right=vt.left,lr.right.parent=lr):lr.right=null,vt.left=lr,lr.parent=vt):(Yr?(lr.left=Yr,Yr.parent=lr):lr.left=null,pt.right=lr,lr.parent=pt)),Zr?(vt.right=Zr,Zr.parent=vt):vt.right=null,pt.left=vt,vt.parent=pt)},h.prototype.replace=function(pt,vt){pt.parent?pt===pt.parent.left?pt.parent.left=vt:pt.parent.right=vt:this._root=vt,vt&&(vt.parent=pt.parent)},h.prototype.minNode=function(pt){if(pt===void 0&&(pt=this._root),pt)for(;pt.left;)pt=pt.left;return pt},h.prototype.maxNode=function(pt){if(pt===void 0&&(pt=this._root),pt)for(;pt.right;)pt=pt.right;return pt},h.prototype.insert=function(pt,vt){var lr=this._root,jr=null,Zr=this._compare;if(this._noDuplicates)for(;lr;){if(jr=lr,Zr(lr.key,pt)===0)return;lr=Zr(lr.key,pt)<0?lr.right:lr.left}else for(;lr;)jr=lr,lr=Zr(lr.key,pt)<0?lr.right:lr.left;return lr={key:pt,data:vt,left:null,right:null,parent:jr},jr?Zr(jr.key,lr.key)<0?jr.right=lr:jr.left=lr:this._root=lr,this.splay(lr),this._size++,lr},h.prototype.find=function(pt){for(var vt=this._root,lr=this._compare;vt;){var jr=lr(vt.key,pt);if(jr<0)vt=vt.right;else{if(!(jr>0))return vt;vt=vt.left}}return null},h.prototype.contains=function(pt){for(var vt=this._root,lr=this._compare;vt;){var jr=lr(pt,vt.key);if(jr===0)return!0;vt=jr<0?vt.left:vt.right}return!1},h.prototype.remove=function(pt){var vt=this.find(pt);if(!vt)return!1;if(this.splay(vt),vt.left)if(vt.right){var lr=this.minNode(vt.right);lr.parent!==vt&&(this.replace(lr,lr.right),lr.right=vt.right,lr.right.parent=lr),this.replace(vt,lr),lr.left=vt.left,lr.left.parent=lr}else this.replace(vt,vt.left);else this.replace(vt,vt.right);return this._size--,!0},h.prototype.removeNode=function(pt){if(!pt)return!1;if(this.splay(pt),pt.left)if(pt.right){var vt=this.minNode(pt.right);vt.parent!==pt&&(this.replace(vt,vt.right),vt.right=pt.right,vt.right.parent=vt),this.replace(pt,vt),vt.left=pt.left,vt.left.parent=vt}else this.replace(pt,pt.left);else this.replace(pt,pt.right);return this._size--,!0},h.prototype.erase=function(pt){var vt=this.find(pt);if(vt){this.splay(vt);var lr=vt.left,jr=vt.right,Zr=null;lr&&(lr.parent=null,Zr=this.maxNode(lr),this.splay(Zr),this._root=Zr),jr&&(lr?Zr.right=jr:this._root=jr,jr.parent=Zr),this._size--}},h.prototype.pop=function(){var pt=this._root,vt=null;if(pt){for(;pt.left;)pt=pt.left;vt={key:pt.key,data:pt.data},this.remove(pt.key)}return vt},h.prototype.next=function(pt){var vt=pt;if(vt)if(vt.right)for(vt=vt.right;vt&&vt.left;)vt=vt.left;else for(vt=pt.parent;vt&&vt.right===pt;)pt=vt,vt=vt.parent;return vt},h.prototype.prev=function(pt){var vt=pt;if(vt)if(vt.left)for(vt=vt.left;vt&&vt.right;)vt=vt.right;else for(vt=pt.parent;vt&&vt.left===pt;)pt=vt,vt=vt.parent;return vt},h.prototype.forEach=function(pt){for(var vt=this._root,lr=[],jr=!1,Zr=0;!jr;)vt?(lr.push(vt),vt=vt.left):lr.length>0?(pt(vt=lr.pop(),Zr++),vt=vt.right):jr=!0;return this},h.prototype.range=function(pt,vt,lr,jr){for(var Zr=[],Yr=this._compare,Ms=this._root;Zr.length!==0||Ms;)if(Ms)Zr.push(Ms),Ms=Ms.left;else{if(Yr((Ms=Zr.pop()).key,vt)>0)break;if(Yr(Ms.key,pt)>=0&&lr.call(jr,Ms))return this;Ms=Ms.right}return this},h.prototype.keys=function(){for(var pt=this._root,vt=[],lr=[],jr=!1;!jr;)pt?(vt.push(pt),pt=pt.left):vt.length>0?(pt=vt.pop(),lr.push(pt.key),pt=pt.right):jr=!0;return lr},h.prototype.values=function(){for(var pt=this._root,vt=[],lr=[],jr=!1;!jr;)pt?(vt.push(pt),pt=pt.left):vt.length>0?(pt=vt.pop(),lr.push(pt.data),pt=pt.right):jr=!0;return lr},h.prototype.at=function(pt){for(var vt=this._root,lr=[],jr=!1,Zr=0;!jr;)if(vt)lr.push(vt),vt=vt.left;else if(lr.length>0){if(vt=lr.pop(),Zr===pt)return vt;Zr++,vt=vt.right}else jr=!0;return null},h.prototype.load=function(pt,vt,lr){if(pt===void 0&&(pt=[]),vt===void 0&&(vt=[]),lr===void 0&&(lr=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var jr=pt.length;return lr&&M(pt,vt,0,jr-1,this._compare),this._root=b(null,pt,vt,0,jr),this._size=jr,this},h.prototype.min=function(){var pt=this.minNode(this._root);return pt?pt.key:null},h.prototype.max=function(){var pt=this.maxNode(this._root);return pt?pt.key:null},h.prototype.isEmpty=function(){return this._root===null},y.size.get=function(){return this._size},h.createTree=function(pt,vt,lr,jr,Zr){return new h(lr,Zr).load(pt,vt,jr)},Object.defineProperties(h.prototype,y);var E=0,L=1,z=2,V=3,Z=0,Q=1,ee=2,ne=3;function le(pt,vt,lr){vt===null?(pt.inOut=!1,pt.otherInOut=!0):(pt.isSubject===vt.isSubject?(pt.inOut=!vt.inOut,pt.otherInOut=vt.otherInOut):(pt.inOut=!vt.otherInOut,pt.otherInOut=vt.isVertical()?!vt.inOut:vt.inOut),vt&&(pt.prevInResult=!xe(vt,lr)||vt.isVertical()?vt.prevInResult:vt));var jr=xe(pt,lr);pt.resultTransition=jr?function(Zr,Yr){var Ms,Es=!Zr.inOut,xn=!Zr.otherInOut;switch(Yr){case Z:Ms=Es&&xn;break;case Q:Ms=Es||xn;break;case ne:Ms=Es^xn;break;case ee:Ms=Zr.isSubject?Es&&!xn:xn&&!Es}return Ms?1:-1}(pt,lr):0}function xe(pt,vt){switch(pt.type){case E:switch(vt){case Z:return!pt.otherInOut;case Q:return pt.otherInOut;case ee:return pt.isSubject&&pt.otherInOut||!pt.isSubject&&!pt.otherInOut;case ne:return!0}break;case z:return vt===Z||vt===Q;case V:return vt===ee;case L:return!1}return!1}var Ce=function(pt,vt,lr,jr,Zr){this.left=vt,this.point=pt,this.otherEvent=lr,this.isSubject=jr,this.type=Zr||E,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},Ne={inResult:{configurable:!0}};function Fe(pt,vt){return pt[0]===vt[0]&&pt[1]===vt[1]}Ce.prototype.isBelow=function(pt){var vt=this.point,lr=this.otherEvent.point;return this.left?(vt[0]-pt[0])*(lr[1]-pt[1])-(lr[0]-pt[0])*(vt[1]-pt[1])>0:(lr[0]-pt[0])*(vt[1]-pt[1])-(vt[0]-pt[0])*(lr[1]-pt[1])>0},Ce.prototype.isAbove=function(pt){return!this.isBelow(pt)},Ce.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},Ne.inResult.get=function(){return this.resultTransition!==0},Ce.prototype.clone=function(){var pt=new Ce(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(Ce.prototype,Ne);var Be=11102230246251565e-32,Je=134217729,yt=(3+8*Be)*Be;function mt(pt,vt,lr,jr,Zr){var Yr,Ms,Es,xn,Sn=vt[0],En=jr[0],Qn=0,Bs=0;En>Sn==En>-Sn?(Yr=Sn,Sn=vt[++Qn]):(Yr=En,En=jr[++Bs]);var en=0;if(QnSn==En>-Sn?(Es=Yr-((Ms=Sn+Yr)-Sn),Sn=vt[++Qn]):(Es=Yr-((Ms=En+Yr)-En),En=jr[++Bs]),Yr=Ms,Es!==0&&(Zr[en++]=Es);QnSn==En>-Sn?(Es=Yr-((Ms=Yr+Sn)-(xn=Ms-Yr))+(Sn-xn),Sn=vt[++Qn]):(Es=Yr-((Ms=Yr+En)-(xn=Ms-Yr))+(En-xn),En=jr[++Bs]),Yr=Ms,Es!==0&&(Zr[en++]=Es);for(;Qn0!=Qn>0)return Bs;var en=Math.abs(En+Qn);return Math.abs(Bs)>=It*en?Bs:-function(_a,ka,Na,Ha,ci,ti,Ia){var Fa,Cn,la,Hi,Fs,Jn,ni,pi,wi,Co,yi,zs,no,Wa,Oi,al,Al,Wo,Go=_a-ci,yl=Na-ci,au=ka-ti,vi=Ha-ti;$t[0]=(Oi=(pi=Go-(ni=(Jn=Je*Go)-(Jn-Go)))*(Co=vi-(wi=(Jn=Je*vi)-(Jn-vi)))-((Wa=Go*vi)-ni*wi-pi*wi-ni*Co))-((yi=Oi-(Al=(pi=au-(ni=(Jn=Je*au)-(Jn-au)))*(Co=yl-(wi=(Jn=Je*yl)-(Jn-yl)))-((al=au*yl)-ni*wi-pi*wi-ni*Co)))+(Fs=Oi-yi))+(Fs-Al),$t[1]=(no=Wa-((zs=Wa+yi)-(Fs=zs-Wa))+(yi-Fs))-((yi=no-al)+(Fs=no-yi))+(Fs-al),$t[2]=zs-((Wo=zs+yi)-(Fs=Wo-zs))+(yi-Fs),$t[3]=Wo;var wo=function(Bg,Pc){for(var Fd=Pc[0],rh=1;rh<4;rh++)Fd+=Pc[rh];return Fd}(0,$t),Mo=Rt*Ia;if(wo>=Mo||-wo>=Mo||(Fa=_a-(Go+(Fs=_a-Go))+(Fs-ci),la=Na-(yl+(Fs=Na-yl))+(Fs-ci),Cn=ka-(au+(Fs=ka-au))+(Fs-ti),Hi=Ha-(vi+(Fs=Ha-vi))+(Fs-ti),Fa===0&&Cn===0&&la===0&&Hi===0)||(Mo=tr*Ia+yt*Math.abs(wo),(wo+=Go*Hi+vi*Fa-(au*la+yl*Cn))>=Mo||-wo>=Mo))return wo;wr[0]=(Oi=(pi=Fa-(ni=(Jn=Je*Fa)-(Jn-Fa)))*(Co=vi-(wi=(Jn=Je*vi)-(Jn-vi)))-((Wa=Fa*vi)-ni*wi-pi*wi-ni*Co))-((yi=Oi-(Al=(pi=Cn-(ni=(Jn=Je*Cn)-(Jn-Cn)))*(Co=yl-(wi=(Jn=Je*yl)-(Jn-yl)))-((al=Cn*yl)-ni*wi-pi*wi-ni*Co)))+(Fs=Oi-yi))+(Fs-Al),wr[1]=(no=Wa-((zs=Wa+yi)-(Fs=zs-Wa))+(yi-Fs))-((yi=no-al)+(Fs=no-yi))+(Fs-al),wr[2]=zs-((Wo=zs+yi)-(Fs=Wo-zs))+(yi-Fs),wr[3]=Wo;var ju=mt(4,$t,4,wr,or);wr[0]=(Oi=(pi=Go-(ni=(Jn=Je*Go)-(Jn-Go)))*(Co=Hi-(wi=(Jn=Je*Hi)-(Jn-Hi)))-((Wa=Go*Hi)-ni*wi-pi*wi-ni*Co))-((yi=Oi-(Al=(pi=au-(ni=(Jn=Je*au)-(Jn-au)))*(Co=la-(wi=(Jn=Je*la)-(Jn-la)))-((al=au*la)-ni*wi-pi*wi-ni*Co)))+(Fs=Oi-yi))+(Fs-Al),wr[1]=(no=Wa-((zs=Wa+yi)-(Fs=zs-Wa))+(yi-Fs))-((yi=no-al)+(Fs=no-yi))+(Fs-al),wr[2]=zs-((Wo=zs+yi)-(Fs=Wo-zs))+(yi-Fs),wr[3]=Wo;var il=mt(ju,or,4,wr,mr);wr[0]=(Oi=(pi=Fa-(ni=(Jn=Je*Fa)-(Jn-Fa)))*(Co=Hi-(wi=(Jn=Je*Hi)-(Jn-Hi)))-((Wa=Fa*Hi)-ni*wi-pi*wi-ni*Co))-((yi=Oi-(Al=(pi=Cn-(ni=(Jn=Je*Cn)-(Jn-Cn)))*(Co=la-(wi=(Jn=Je*la)-(Jn-la)))-((al=Cn*la)-ni*wi-pi*wi-ni*Co)))+(Fs=Oi-yi))+(Fs-Al),wr[1]=(no=Wa-((zs=Wa+yi)-(Fs=zs-Wa))+(yi-Fs))-((yi=no-al)+(Fs=no-yi))+(Fs-al),wr[2]=zs-((Wo=zs+yi)-(Fs=Wo-zs))+(yi-Fs),wr[3]=Wo;var uf=mt(il,mr,4,wr,fr);return fr[uf-1]}(Zr,Yr,Ms,Es,xn,Sn,en)}(pt[0],pt[1],vt[0],vt[1],lr[0],lr[1]);return jr>0?-1:jr<0?1:0}function xr(pt,vt){var lr=pt.point,jr=vt.point;return lr[0]>jr[0]?1:lr[0]jr[1]?1:-1:function(Zr,Yr,Ms,Es){return Zr.left!==Yr.left?Zr.left?1:-1:kr(Ms,Zr.otherEvent.point,Yr.otherEvent.point)!==0?Zr.isBelow(Yr.otherEvent.point)?-1:1:!Zr.isSubject&&Yr.isSubject?1:-1}(pt,vt,lr)}function _r(pt,vt,lr){var jr=new Ce(vt,!1,pt,pt.isSubject),Zr=new Ce(vt,!0,pt.otherEvent,pt.isSubject);return Fe(pt.point,pt.otherEvent.point)&&console.warn("what is that, a collapsed segment?",pt),jr.contourId=Zr.contourId=pt.contourId,xr(Zr,pt.otherEvent)>0&&(pt.otherEvent.left=!0,Zr.left=!1),pt.otherEvent.otherEvent=Zr,pt.otherEvent=jr,lr.push(Zr),lr.push(jr),lr}function ir(pt,vt){return pt[0]*vt[1]-pt[1]*vt[0]}function sr(pt,vt){return pt[0]*vt[0]+pt[1]*vt[1]}function br(pt,vt,lr){var jr=function(xn,Sn,En,Qn,Bs){var en=[Sn[0]-xn[0],Sn[1]-xn[1]],_a=[Qn[0]-En[0],Qn[1]-En[1]];function ka(Jn,ni,pi){return[Jn[0]+ni*pi[0],Jn[1]+ni*pi[1]]}var Na=[En[0]-xn[0],En[1]-xn[1]],Ha=ir(en,_a),ci=Ha*Ha,ti=sr(en,en);if(ci>0){var Ia=ir(Na,_a)/Ha;if(Ia<0||Ia>1)return null;var Fa=ir(Na,en)/Ha;return Fa<0||Fa>1?null:Ia===0||Ia===1?[ka(xn,Ia,en)]:Fa===0||Fa===1?[ka(En,Fa,_a)]:[ka(xn,Ia,en)]}if((ci=(Ha=ir(Na,en))*Ha)>0)return null;var Cn=sr(en,Na)/ti,la=Cn+sr(en,_a)/ti,Hi=Math.min(Cn,la),Fs=Math.max(Cn,la);return Hi<=1&&Fs>=0?Hi===1?[ka(xn,Hi>0?Hi:0,en)]:Fs===0?[ka(xn,Fs<1?Fs:1,en)]:[ka(xn,Hi>0?Hi:0,en),ka(xn,Fs<1?Fs:1,en)]:null}(pt.point,pt.otherEvent.point,vt.point,vt.otherEvent.point),Zr=jr?jr.length:0;if(Zr===0||Zr===1&&(Fe(pt.point,vt.point)||Fe(pt.otherEvent.point,vt.otherEvent.point))||Zr===2&&pt.isSubject===vt.isSubject)return 0;if(Zr===1)return Fe(pt.point,jr[0])||Fe(pt.otherEvent.point,jr[0])||_r(pt,jr[0],lr),Fe(vt.point,jr[0])||Fe(vt.otherEvent.point,jr[0])||_r(vt,jr[0],lr),1;var Yr=[],Ms=!1,Es=!1;return Fe(pt.point,vt.point)?Ms=!0:xr(pt,vt)===1?Yr.push(vt,pt):Yr.push(pt,vt),Fe(pt.otherEvent.point,vt.otherEvent.point)?Es=!0:xr(pt.otherEvent,vt.otherEvent)===1?Yr.push(vt.otherEvent,pt.otherEvent):Yr.push(pt.otherEvent,vt.otherEvent),Ms&&Es||Ms?(vt.type=L,pt.type=vt.inOut===pt.inOut?z:V,Ms&&!Es&&_r(Yr[1].otherEvent,Yr[0].point,lr),2):Es?(_r(Yr[0],Yr[1].point,lr),3):Yr[0]!==Yr[3].otherEvent?(_r(Yr[0],Yr[1].point,lr),_r(Yr[1],Yr[2].point,lr),3):(_r(Yr[0],Yr[1].point,lr),_r(Yr[3].otherEvent,Yr[2].point,lr),3)}function Vr(pt,vt){if(pt===vt)return 0;if(kr(pt.point,pt.otherEvent.point,vt.point)!==0||kr(pt.point,pt.otherEvent.point,vt.otherEvent.point)!==0)return Fe(pt.point,vt.point)?pt.isBelow(vt.otherEvent.point)?-1:1:pt.point[0]===vt.point[0]?pt.point[1]vt.contourId?1:-1:xr(pt,vt)===1?1:-1}var Ar=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Ns(pt,vt,lr,jr){var Zr,Yr=pt+1,Ms=vt[pt].point,Es=vt.length;for(Yrjr;)Yr--;return Yr}Ar.prototype.isExterior=function(){return this.holeOf==null};var Jr=xs,as=xs;function xs(pt,vt){if(!(this instanceof xs))return new xs(pt,vt);if(this.data=pt||[],this.length=this.data.length,this.compare=vt||In,this.length>0)for(var lr=(this.length>>1)-1;lr>=0;lr--)this._down(lr)}function In(pt,vt){return ptvt?1:0}xs.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 vt=this.data,lr=this.compare,jr=vt[pt];pt>0;){var Zr=pt-1>>1,Yr=vt[Zr];if(lr(jr,Yr)>=0)break;vt[pt]=Yr,pt=Zr}vt[pt]=jr},_down:function(pt){for(var vt=this.data,lr=this.compare,jr=this.length>>1,Zr=vt[pt];pt=0)break;vt[pt]=Es,pt=Yr}vt[pt]=Zr}},Jr.default=as;var Pr=Math.max,ys=Math.min,sn=0;function na(pt,vt,lr,jr,Zr,Yr){var Ms,Es,xn,Sn,En,Qn;for(Ms=0,Es=pt.length-1;Ms0?Qn.left=!0:En.left=!0;var Bs=xn[0],en=xn[1];Zr[0]=ys(Zr[0],Bs),Zr[1]=ys(Zr[1],en),Zr[2]=Pr(Zr[2],Bs),Zr[3]=Pr(Zr[3],en),jr.push(En),jr.push(Qn)}}var ca=[];function _n(pt,vt,lr){typeof pt[0][0][0]=="number"&&(pt=[pt]),typeof vt[0][0][0]=="number"&&(vt=[vt]);var jr=function(en,_a,ka){var Na=null;return en.length*_a.length==0&&(ka===Z?Na=ca:ka===ee?Na=en:ka!==Q&&ka!==ne||(Na=en.length===0?_a:en)),Na}(pt,vt,lr);if(jr)return jr===ca?null:jr;var Zr=[1/0,1/0,-1/0,-1/0],Yr=[1/0,1/0,-1/0,-1/0],Ms=function(en,_a,ka,Na,Ha){var ci,ti,Ia,Fa,Cn,la,Hi=new Jr(null,xr);for(Ia=0,Fa=en.length;IaNa[2]||Na[0]>ka[2]||ka[1]>Na[3]||Na[1]>ka[3])&&(Ha===Z?ci=ca:Ha===ee?ci=en:Ha!==Q&&Ha!==ne||(ci=en.concat(_a))),ci}(pt,vt,Zr,Yr,lr))return jr===ca?null:jr;for(var Es=function(en){var _a,ka,Na=function(Ia){var Fa,Cn,la,Hi,Fs=[];for(Cn=0,la=Ia.length;Cn0){var yi=Jn[Co];if(yi.holeOf!=null){var zs=yi.holeOf;Jn[zs].holeIds.push(ni),pi.holeOf=zs,pi.depth=Jn[Co].depth}else Jn[Co].holeIds.push(ni),pi.holeOf=Co,pi.depth=Jn[Co].depth+1}else pi.holeOf=null,pi.depth=Jn[Co].depth}else pi.holeOf=null,pi.depth=0;return pi}(Na[_a],ci,Ia),Cn=function(Fs){Ha[Fs]=!0,Fs=Na.length)&&Na[la];);ci.push(Fa)}};for(_a=0,ka=Na.length;_aHi||ci===ee&&Fs.point[0]>Na[2])break;if(Fs.left){Ia=ti=Cn.insert(Fs),ti=ti!==(Fa=Cn.minNode())?Cn.prev(ti):null,Ia=Cn.next(Ia);var Jn=ti?ti.key:null;if(le(Fs,Jn,ci),Ia&&br(Fs,Ia.key,en)===2&&(le(Fs,Jn,ci),le(Ia.key,Fs,ci)),ti&&br(ti.key,Fs,en)===2){var ni=ti;le(Jn,(ni=ni!==Fa?Cn.prev(ni):null)?ni.key:null,ci),le(Fs,Jn,ci)}}else Ia=ti=Cn.find(Fs=Fs.otherEvent),ti&&Ia&&(ti=ti!==Fa?Cn.prev(ti):null,Ia=Cn.next(Ia),Cn.remove(Fs),Ia&&ti&&br(ti.key,Ia.key,en))}return la}(Ms,0,0,Zr,Yr,lr)),xn=[],Sn=0;Sn * @license MIT * @preserve */function aD(f,c,h,y){const b=[],M=y===0?(E,L,z,V,Z,Q)=>{E.push(new dr(Q,z+(Q-L)/(V-L)*(Z-z)))}:(E,L,z,V,Z,Q)=>{E.push(new dr(L+(Q-z)/(Z-z)*(V-L),Q))};for(const E of f){const L=[];for(const z of E){if(z.length<=2)continue;const V=[];for(let ee=0;eec&&M(V,ne,le,xe,Ce,c):Ne>h?Fe=c&&M(V,ne,le,xe,Ce,c),Fe>h&&Ne<=h&&M(V,ne,le,xe,Ce,h)}let Z=z[z.length-1];const Q=y===0?Z.x:Z.y;Q>=c&&Q<=h&&V.push(Z),V.length&&(Z=V[V.length-1],V[0].x===Z.x&&V[0].y===Z.y||V.push(V[0]),L.push(V))}L.length&&b.push(L)}return b}function WXe(f,c){const h=hce(f),y=hce([c]),b=Wwe.intersection(h,y);return b==null?[]:Gwe(b)}function GXe(f,c){let y=hce(f,65536);const b=[];for(;c.valid();c.next()){const[M,E]=c.get(),L=M.x*65536,z=M.y*65536,V=E.x*65536,Z=E.y*65536,Q=V-L,ee=Z-z,ne=Math.hypot(Q,ee);if(ne===0)continue;const le=Math.trunc(ee/ne*3),xe=-Math.trunc(Q/ne*3);b.push([[[L,z],[V,Z],[V+le,Z+xe],[L+le,z+xe],[L,z]]])}return b.length>0&&(y=Wwe.diff(y,b)),Gwe(y,1/65536)}function hce(f,c=1){return[f.map(h=>h.map(y=>[y.x*c,y.y*c]))]}function Gwe(f,c=1){return f.map(h=>h.map((y,b)=>{const M=y.map(E=>new dr(E[0]*c,E[1]*c).round());return b>0&&M.reverse(),M}))}class mce{constructor(c,h){this.layoutVertexArray=new Pg,this.indexArray=new rl,this.lineIndexArray=new Qu,this.triangleSegments=new to,this.lineSegments=new to,this.programConfigurations=new gm(c.layers,{zoom:c.zoom,lut:c.lut}),this.uploaded=!1,h&&(this.elevatedLayoutVertexArray=new up)}update(c,h,y,b,M,E,L,z){this.programConfigurations.updatePaintArrays(c,h,M,y,b,E,L,z)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(c){this.uploaded||(this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,EXe.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,IXe.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,h,y,b,M,E,L){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,h,y,b,M,E,void 0,L)}}class fce{constructor(c){this.zoom=c.zoom,this.pixelRatio=c.pixelRatio,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.patternFeatures=[],this.lut=c.lut,this.bufferData=new mce(c,!1),this.elevationBufferData=new mce(c,!0),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.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,h){}updateAppearances(c,h,y,b){}populate(c,h,y,b){this.hasPattern=dce("fill",this.layers,this.pixelRatio,h);const M=this.layers[0].layout.get("fill-sort-key"),E=[];for(const{feature:L,id:z,index:V,sourceLayerIndex:Z}of c){const Q=this.layers[0]._featureFilter.needGeometry,ee=Bt(L,Q);if(!this.layers[0]._featureFilter.filter(new bi(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),ee,y))continue;const ne=M?M.evaluate(ee,{},y,h.availableImages):void 0,le={id:z,properties:L.properties,type:L.type,sourceLayerIndex:Z,index:V,geometry:Q?ee.geometry:At(L,y,b),patterns:{},sortKey:ne};E.push(le)}M&&E.sort((L,z)=>L.sortKey-z.sortKey);for(const L of E){const{geometry:z,index:V,sourceLayerIndex:Z}=L;if(this.hasPattern){const Q=uce("fill",this.layers,L,this.zoom,this.pixelRatio,h);this.patternFeatures.push(Q)}else this.addFeature(L,z,V,y,{},h.availableImages,h.brightness,h.elevationFeatures);h.featureIndex.insert(c[V].feature,z,V,Z,this.index)}}update(c,h,y,b,M,E,L){this.bufferData.update(c,h,y,b,M,E,L,this.worldview),this.elevationBufferData.update(c,h,y,b,M,E,L,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(c,h,y,b,M,E,L,this.worldview)}addFeatures(c,h,y,b,M,E){for(const L of this.patternFeatures)this.addFeature(L,L.geometry,L.index,h,y,b,E,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,h,y,b,M,E=[],L,z){const V=xT(h,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(c,V,b,y,z):this.addGeometry(V,this.bufferData),this.bufferData.populatePaintArrays(c,y,M,E,b,L,this.worldview),this.elevationBufferData.populatePaintArrays(c,y,M,E,b,L,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(c,h,y,b,M){this.elevatedStructures&&(this.elevatedStructures.construct(c),this.elevatedStructures.populatePaintArrays(h,y,b,M,this.worldview))}addElevatedRoadFeature(c,h,y,b,M){const E=new Array,L=Oa.getElevationFeature(c,M);if(!L)return void this.addGeometry(h,this.bufferData);{const V=this.clipPolygonsToTile(h,1);V.length>0&&E.push({polygons:V,elevationFeature:L,elevationTileID:y})}const z={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(c,{},y),featureIndex:b};for(const V of E)if(V.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new eh(V.elevationTileID,this.layers,this.zoom,this.lut));const Q=V.elevationFeature.isTunnel();let ee=0;c.properties.hasOwnProperty(Xt)&&(ee=+c.properties[Xt]);for(const ne of V.polygons)this.elevatedStructures.addPortalCandidates(V.elevationFeature.id,ne,Q,V.elevationFeature,ee)}V.elevationFeature.constantHeight==null&&(V.polygons=this.prepareElevatedPolygons(V.polygons,V.elevationFeature,V.elevationTileID));const Z=new Xa(y,V.elevationTileID);this.addElevatedGeometry(V.polygons,Z,V.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,b,z)}}addElevatedGeometry(c,h,y,b,M,E){const L={elevation:y,elevationSampler:h,bias:b,index:M,featureInfo:E},[z,V]=this.addGeometry(c,this.elevationBufferData,L);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:z,max:V}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,z),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,V))}addGeometry(c,h,y){let b=Number.POSITIVE_INFINITY,M=Number.NEGATIVE_INFINITY,E=null;y&&(E=y.elevationSampler.constantElevation(y.elevation,y.bias),E!=null&&(b=E,M=E));const L=(z,V,Z)=>{if(y!=null)if(V.push(z),E!=null)h.elevatedLayoutVertexArray.emplaceBack(E),Z.push(E);else{const Q=y.elevationSampler.pointElevation(z,y.elevation,y.bias);h.elevatedLayoutVertexArray.emplaceBack(Q),Z.push(Q),b=Math.min(b,Q),M=Math.max(M,Q)}};for(const z of c){let V=0;for(const Be of z)V+=Be.length;const Z=h.triangleSegments.prepareSegment(V,h.layoutVertexArray,h.indexArray),Q=Z.vertexLength,ee=[],ne=[],le=[],xe=[],Ce=[],Ne=h.layoutVertexArray.length;for(const Be of z){if(Be.length===0)continue;Be!==z[0]&&ne.push(ee.length/2);const Je=h.lineSegments.prepareSegment(Be.length,h.layoutVertexArray,h.lineIndexArray),yt=Je.vertexLength;y&&Ce.push(h.layoutVertexArray.length-Ne),L(Be[0],le,xe),h.layoutVertexArray.emplaceBack(Be[0].x,Be[0].y),h.lineIndexArray.emplaceBack(yt+Be.length-1,yt),ee.push(Be[0].x),ee.push(Be[0].y);for(let mt=1;mt0&&y&&this.elevationMode==="hd-road-base"){const Be=y.elevation.isTunnel(),Je=y.elevation.safeArea,yt=this.elevatedStructures.addVertices(le,xe);this.elevatedStructures.addTriangles(Fe,yt,Be);const mt=Ce.length;if(mt>0){for(let kt=0;kt=y&&ne.max.x<=M&&ne.min.y>=b&&ne.max.y<=E?z:V).push(ee)}if(z.length===c.length)return c;const Z=[new dr(y,b),new dr(M,b),new dr(M,E),new dr(y,E),new dr(y,b)],Q=z;for(const ee of V)Q.push(...WXe(ee,Z));return Q}}let Kwe,Zwe,Ywe,Xwe;ms(fce,"FillBucket",{omit:["layers","patternFeatures"]}),ms(mce,"FillBufferData"),ms(eh,"ElevatedStructures");class iD{constructor(c,h,y,b){if(this.triangleCount=h.length/3,this.min=new dr(0,0),this.max=new dr(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[M,E]=[c[0].clone(),c[0].clone()];for(let Q=1;QQ.cellIdx-ee.cellIdx||Q.triIdx-ee.triIdx);let Z=0;for(;Zthis.max.x||this.min.x>c.x||c.y>this.max.y||this.min.y>c.y)return;const y=Fg(c.x-this.min.x,this.xScale,this.cellsX),b=Fg(c.y-this.min.y,this.yScale,this.cellsY),M=this.cells[b*this.cellsX+y];if(M){this._lazyInitLookup();for(let E=0;Ethis.max.x||this.min.x>h.x||c.y>this.max.y||this.min.y>h.y)return;this._lazyInitLookup();const b=Fg(c.x-this.min.x,this.xScale,this.cellsX),M=Fg(h.x-this.min.x,this.xScale,this.cellsX),E=Fg(c.y-this.min.y,this.yScale,this.cellsY),L=Fg(h.y-this.min.y,this.yScale,this.cellsY);for(let z=E;z<=L;z++)for(let V=b;V<=M;V++){const Z=this.cells[z*this.cellsX+V];if(Z)for(let Q=0;Qh.fqid),this.index=c.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.footprints=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){for(const y of this.footprints)h.push({footprint:y,id:c})}updateAppearances(c,h,y,b){}populate(c,h,y,b){const M=[];for(const{feature:E,id:L,index:z,sourceLayerIndex:V}of c){const Z=this.layers[0]._featureFilter.needGeometry,Q=Bt(E,Z);if(!this.layers[0]._featureFilter.filter(new bi(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Q,y))continue;const ee={id:L,properties:E.properties,type:E.type,sourceLayerIndex:V,index:z,geometry:Z?Q.geometry:At(E,y,b),patterns:{}};M.push(ee)}for(const E of M){const{geometry:L,index:z,sourceLayerIndex:V}=E;this.addFeature(E,L,z,y,{},h.availableImages,h.brightness),h.featureIndex.insert(c[z].feature,L,z,V,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(c){}update(c,h,y,b,M,E,L){}destroy(){}addFeature(c,h,y,b,M,E=[],L){for(const z of xT(h,2)){const V=[],Z=[],Q=[],ee=new dr(1/0,1/0),ne=new dr(-1/0,-1/0);for(const Ce of z)if(Ce.length!==0){Ce!==z[0]&&Q.push(Z.length/2);for(let Ne=0;NeE===b)===void 0}(y,f.clipScope)}function oD(f,c){return f.x-c.x||f.y-c.y}function t2e(f,c){return oD(f.min,c.min)===0&&oD(f.max,c.max)===0}function pce(f,c){return!(f.min.x>c.max.x||f.max.xc.max.y||f.max.ynew dr((z.x+M.x*Br)*L-E.x*Br,(z.y+M.y*Br)*L-E.y*Br))}return gce(h,b,f.indices,0,f.indices.length,0,0)}function n2e(f,c,h,y){const b=Math.pow(2,y.z-h.z);return new dr((f+h.x*Br)*b-y.x*Br,(c+h.y*Br)*b-y.y*Br)}function a2e(f,c){const h=[];c.grid.queryPoint(f,h);const y=c.indices,b=c.vertices;for(let M=0;M0&&(y.length>1&&h.push(y),y=[])}return y.length>1&&h.push(y),h}const yce=zt.types,sQe=["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"],nQe=["fill-extrusion-flood-light-ground-radius"],aQe=Math.pow(2,13),iQe=Math.pow(2,15)-1,o2e=new dr(0,1),sy=2147483648,l2e=7,c2e=450;function vT(f,c,h,y,b,M,E,L){f.emplaceBack((c<<1)+E,(h<<1)+M,(Math.floor(y*aQe)<<1)+b,Math.round(L))}function _T(f,c,h){f.emplaceBack(c.x*Br,c.y*Br,h?1:0)}function cD(f,c,h,y,b,M){f.emplaceBack(c.x,c.y,(h.x<<1)+y,(h.y<<1)+b,M)}function bT(f,c,h){f.emplaceBack(c.x,c.y,c.z,h[0]*16384,h[1]*16384,h[2]*16384)}class d2e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class u2e{constructor(){this.centroidXY=new dr(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 dr(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new dr(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new dr(this.max.x-this.min.x,this.max.y-this.min.y)}}class h2e{constructor(){this.acc=new dr(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(c,h){c.min.x===Number.MAX_VALUE&&(c.min.x=c.max.x=h.x,c.min.y=c.max.y=h.y)}appendEdge(c,h,y){this.accCount++,this.acc._add(h);let b=!!this.borders;h.xc.max.x&&(c.max.x=h.x,b=!0),h.yc.max.y&&(c.max.y=h.y,b=!0),((h.x===0||h.x===Br)&&h.x===y.x)!=((h.y===0||h.y===Br)&&h.y===y.y)&&this.processBorderOverlap(h,y),b&&this.checkBorderIntersection(h,y)}checkBorderIntersection(c,h){h.x<0!=c.x<0&&this.addBorderIntersection(0,Gs(h.y,c.y,(0-h.x)/(c.x-h.x))),h.x>Br!=c.x>Br&&this.addBorderIntersection(1,Gs(h.y,c.y,(Br-h.x)/(c.x-h.x))),h.y<0!=c.y<0&&this.addBorderIntersection(2,Gs(h.x,c.x,(0-h.y)/(c.y-h.y))),h.y>Br!=c.y>Br&&this.addBorderIntersection(3,Gs(h.x,c.x,(Br-h.y)/(c.y-h.y)))}addBorderIntersection(c,h){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];hy[1]&&(y[1]=h)}processBorderOverlap(c,h){if(c.x===h.x){if(c.y===h.y)return;const y=c.x===0?0:1;this.addBorderIntersection(y,h.y),this.addBorderIntersection(y,c.y)}else{const y=c.y===0?2:3;this.addBorderIntersection(y,h.x),this.addBorderIntersection(y,c.x)}}centroid(){return this.accCount===0?new dr(0,0):new dr(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,h)=>c+ +(h[0]!==Number.MAX_VALUE),0):0}}function m2e(f,c){const h=f.add(c)._unit(),y=ye(f.x*h.x+f.y*h.y,-1,1);var b,M,E;return b=Math.acos(y),Math.min(4,Math.max(-4,Math.tan(b)))/4*iQe*((M=f).x*(E=c).y-M.y*E.x<0?-1:1)}const oQe=[f=>f.x<0,f=>f.x>Br,f=>f.y<0,f=>f.y>Br];function lQe(f,c,h,y){const b=[4];if(y===0)return b;h._mult(y);const M=f.sub(h),E=c.sub(h),L=[f,c,M,E];for(let z=0;z<4;z++)for(const V of L)if(oQe[z](V)){b.push(z);break}return b}class vce{constructor(c){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new GM,this.indexArray=new rl,this.programConfigurations=new gm(c.layers,{zoom:c.zoom,lut:c.lut},h=>nQe.includes(h)),this._segments=new to,this.hiddenByLandmarkVertexArray=new ES,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new to}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(c,h,y,b=!1){const M=c.length;if(M>2){let E=Math.max(0,this._segments.get().length-1);const L=this._segments._prepareSegment(4*M,this.vertexArray.length,2*this._segmentToGroundQuads[E].length);let z;E!==this._segments.get().length-1&&(E++,this._segmentToGroundQuads[E]=[],this._segmentToRegionTriCounts[E]=[0,0,0,0,0]);{const V=c[0],Z=c[1];z=m2e(V.sub(c[M-1])._perp()._unit(),Z.sub(V)._perp()._unit())}for(let V=0;Vb.region-M.region);for(let y=0;yz+V,0);let L=0;for(let z=0;z<=4;z++){const V=E[z];if(V!==0){let Z=this.regionSegments[z];Z||(Z=this.regionSegments[z]=new to);const Q={vertexOffset:M.vertexOffset,primitiveOffset:M.primitiveOffset+L,vertexLength:M.vertexLength,primitiveLength:V};Z.get().push(Q)}L+=V}for(let z=0;z0?this.hiddenByLandmarkVertexBuffer=c.createVertexBuffer(this.hiddenByLandmarkVertexArray,JXe.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 h=this.regionSegments[c];h&&h.destroy()}}}}class dD{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(h=>h.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 rl,this.footprintVertices=new Pg,this.footprintSegments=[],this.layoutVertexArray=new W0,this.centroidVertexArray=new XL,this.wallVertexArray=new $_,this.indexArray=new rl,this.programConfigurations=new gm(c.layers,{zoom:c.zoom,lut:c.lut},h=>sQe.includes(h)),this.segments=new to,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.groundEffect=new vce(c),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,y,b){}populate(c,h,y,b){this.features=[],this.hasPattern=dce("fill-extrusion",this.layers,this.pixelRatio,h),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=Oe(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:M,id:E,index:L,sourceLayerIndex:z}of c){const V=this.layers[0]._featureFilter.needGeometry,Z=Bt(M,V);if(!this.layers[0]._featureFilter.filter(new bi(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Z,y))continue;const Q={id:E,sourceLayerIndex:z,index:L,geometry:V?Z.geometry:At(M,y,b),properties:M.properties,type:M.type,patterns:{}},ee=this.layoutVertexArray.length,ne=yce[Q.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:M.id,feature:uce("fill-extrusion",this.layers,Q,this.zoom,this.pixelRatio,h)});else if(this.wallMode)for(const le of Q.geometry)for(const xe of i2e(le,ne))this.addFeature(M.id,Q,[xe],L,y,{},h.availableImages,b,h.brightness);else this.addFeature(M.id,Q,Q.geometry,L,y,{},h.availableImages,b,h.brightness);h.featureIndex.insert(M,Q.geometry,L,z,this.index,ee)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(c,h,y,b,M,E){for(const{featureId:L,feature:z}of this.features){const V=yce[z.type]==="Polygon",{geometry:Z}=z;if(this.wallMode)for(const Q of Z)for(const ee of i2e(Q,V))this.addFeature(L,z,[ee],z.index,h,y,b,M,E);else this.addFeature(L,z,Z,z.index,h,y,b,M,E)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(c,h,y,b,M,E,L){this.programConfigurations.updatePaintArrays(c,h,M,y,b,E,L,this.worldview),this.groundEffect.update(c,h,M,y,b,E,L,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,tQe),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.wallVertexBuffer=c.createVertexBuffer(this.wallVertexArray,QXe.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,XXe.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,h,y,b,M,E,L,z,V){const Z=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(h,{})/this.tileToMeter,Q=[new dr(0,0),new dr(Br,Br)],ee=z.projection,ne=ee.name==="globe",le=this.wallMode||yce[h.type]==="Polygon",xe=new h2e;xe.centroidDataIndex=this.centroidData.length;const Ce=new u2e;Ce.buildingId=c,h.properties&&h.properties.hasOwnProperty("building_id")&&(Ce.buildingId=h.properties.building_id);const Ne=this.layers[0].paint.get("fill-extrusion-base").evaluate(h,{},M)<=0,Fe=this.layers[0].paint.get("fill-extrusion-height").evaluate(h,{},M);let Be;if(Ce.height=Fe,Ce.vertexArrayOffset=this.layoutVertexArray.length,Ce.groundVertexArrayOffset=this.groundEffect.vertexArray.length,ne&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new NS),this.wallMode){if(ne)return void ts("Non zero fill-extrusion-line-width is not yet supported on globe.");if(y.length!==1)return;Be=function($t){const or=$t[0].x===$t[$t.length-1].x&&$t[0].y===$t[$t.length-1].y;(function(as){let xs=0;const In=as.length;for(let Pr=0;Pr=0})($t)||($t=$t.reverse());const fr={geometry:[],joinNormals:[],indices:[]},wr=[],kr=[],xr=[];let _r=$t.length;for(;_r>=2&&$t[_r-1].equals($t[_r-2]);)_r--;if(_r<(or?3:2))return fr;let ir,sr,br,Vr,Ar,Ns=0;for(;Ns<_r-1&&$t[Ns].equals($t[Ns+1]);)Ns++;or&&(ir=$t[_r-2],Ar=$t[Ns].sub(ir)._unit()._perp());for(let as=Ns;as<_r;as++){if(br=as===_r-1?or?$t[Ns+1]:void 0:$t[as+1],br&&$t[as].equals(br))continue;Ar&&(Vr=Ar),ir&&(sr=ir),ir=$t[as],Ar=br?br.sub(ir)._unit()._perp():Vr,Vr=Vr||Ar;let xs=Vr.add(Ar);xs.x===0&&xs.y===0||xs._unit();const In=xs.x*Ar.x+xs.y*Ar.y,Pr=In!==0?1/In:1/0,ys=Vr.x*Ar.y-Vr.y*Ar.x>0;let sn="miter";const na=2;sn==="miter"&&Pr>na&&(sn="bevel"),sn==="bevel"&&(Pr>100&&(sn="flipbevel"),Pr{const lr=new dr(_n.x,_n.y),jr=new dr(_n.x,_n.y);lr.x+=ei.x*vt,lr.y+=ei.y*vt,jr.x-=ei.x*Math.max(pt,1),jr.y-=ei.y*Math.max(pt,1),xr.push(ei),wr.push(lr),kr.push(jr)};if(sn==="miter")xs._mult(Pr),ca(ir,xs,0,0);else if(sn==="flipbevel")xs=Ar.mult(-1),ca(ir,xs,0,0),ca(ir,xs.mult(-1),0,0);else{const _n=-Math.sqrt(Pr*Pr-1),ei=ys?_n:0,pt=ys?0:_n;sr&&ca(ir,Vr,ei,pt),br&&ca(ir,Ar,ei,pt)}}fr.geometry=[...wr,...kr.reverse(),wr[0]],fr.joinNormals=[...xr,...xr.reverse(),xr[xr.length-1]];const Jr=fr.geometry.length-1;for(let as=0;as$t<(or.length-1)/2||$t===or.length-1,yt=this.wallMode?[y]:xT(y,500);for(let $t=yt.length-1;$t>=0;$t--){const or=yt[$t];(or.length===0||(mt=or[0]).every(mr=>mr.x<=0)||mt.every(mr=>mr.x>=Br)||mt.every(mr=>mr.y<=0)||mt.every(mr=>mr.y>=Br))&&yt.splice($t,1)}var mt;let kt;if(ne)kt=_2e(yt,Q,M);else{kt=[];for(const $t of yt)kt.push({polygon:$t,bounds:Q})}const It=le?this.edgeRadius:0,Rt=It>0&&this.zoom<17,tr=($t,or)=>{if($t.length===0)return!1;const mr=$t[$t.length-1];return or.x===mr.x&&or.y===mr.y};for(const{polygon:$t,bounds:or}of kt){let mr=0,fr=0;for(const _r of $t)le&&!_r[0].equals(_r[_r.length-1])&&_r.push(_r[0]),fr+=le?_r.length-1:_r.length;const wr=this.segments.prepareSegment((le?5:4)*fr,this.layoutVertexArray,this.indexArray);Ce.footprintSegIdx<0&&(Ce.footprintSegIdx=this.footprintSegments.length),Ce.polygonSegIdx<0&&(Ce.polygonSegIdx=this.polygonSegments.length);const kr={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},xr=new d2e;if(xr.vertexOffset=this.footprintVertices.length,xr.indexOffset=3*this.footprintIndices.length,xr.ringIndices=[],le){const _r=[],ir=[];mr=wr.vertexLength;for(let br=0;br<$t.length;br++){const Vr=$t[br];Vr.length&&br!==0&&ir.push(_r.length/2);const Ar=[];let Ns,Jr;Ns=Vr[1].sub(Vr[0])._perp()._unit(),xr.ringIndices.push(Vr.length-1);for(let as=1;as4&&x2e(ir[ir.length-2],ir[0],ir[1]),br=It?cQe(ir[ir.length-2],ir[0],ir[1],It):0;const Vr=[];let Ar,Ns,Jr;Ns=ir[1].sub(ir[0])._perp()._unit();let as=!0;for(let xs=1,In=0;xs0?1:0,ei=Pr.dist(ys);if(In+ei>32768&&(In=0),It){Jr=sn.sub(ys)._perp()._unit();let jr=p2e(Pr,ys,sn,f2e(Ns,Jr),It);isNaN(jr)&&(jr=0);const Zr=ys.sub(Pr)._unit();Pr=Pr.add(Zr.mult(br))._round(),ys=ys.add(Zr.mult(-jr))._round(),br=jr,Ns=Jr,Ne&&this.zoom>=17&&(tr(Vr,Pr)||Vr.push(Pr),tr(Vr,ys)||Vr.push(ys))}const pt=wr.vertexLength,vt=ir.length>4&&x2e(Pr,ys,sn);let lr=y2e(In,sr,as);if(vT(this.layoutVertexArray,Pr.x,Pr.y,ca,_n,0,0,lr),vT(this.layoutVertexArray,Pr.x,Pr.y,ca,_n,0,1,lr),this.wallMode){const jr=Je(xs-1,ir),Zr=Be.joinNormals[xs-1];_T(this.wallVertexArray,Zr,jr),_T(this.wallVertexArray,Zr,jr)}if(In+=ei,lr=y2e(In,vt,!as),sr=vt,vT(this.layoutVertexArray,ys.x,ys.y,ca,_n,0,0,lr),vT(this.layoutVertexArray,ys.x,ys.y,ca,_n,0,1,lr),this.wallMode){const jr=Je(xs,ir),Zr=Be.joinNormals[xs];_T(this.wallVertexArray,Zr,jr),_T(this.wallVertexArray,Zr,jr)}if(wr.vertexLength+=4,this.indexArray.emplaceBack(pt+0,pt+1,pt+2),this.indexArray.emplaceBack(pt+1,pt+3,pt+2),wr.primitiveLength+=2,It){const jr=mr+(xs===1?ir.length-2:xs-2),Zr=xs===1?mr:jr+1;if(this.indexArray.emplaceBack(pt+1,jr,pt+3),this.indexArray.emplaceBack(jr,Zr,pt+3),wr.primitiveLength+=2,Ar===void 0&&(Ar=pt),!_ce(sn,ir[xs],or)){const Yr=xs===ir.length-1?Ar:wr.vertexLength;this.indexArray.emplaceBack(pt+2,pt+3,Yr),this.indexArray.emplaceBack(pt+3,Yr+1,Yr),this.indexArray.emplaceBack(pt+3,Zr,Yr+1),wr.primitiveLength+=3}as=!as}if(ne){const jr=this.layoutVertexExtArray,Zr=ee.projectTilePoint(Pr.x,Pr.y,M),Yr=ee.projectTilePoint(ys.x,ys.y,M),Ms=ee.upVector(M,Pr.x,Pr.y),Es=ee.upVector(M,ys.x,ys.y);bT(jr,Zr,Ms),bT(jr,Zr,Ms),bT(jr,Yr,Es),bT(jr,Yr,Es)}}le&&(mr+=ir.length-1),Ne&&It&&this.zoom>=17&&(Vr.length!==0&&tr(Vr,Vr[0])&&Vr.pop(),this.groundEffect.addData(Vr,or,Z,It>0))}this.footprintSegments.push(xr),kr.triangleCount=this.indexArray.length-kr.triangleArrayOffset,this.polygonSegments.push(kr),++Ce.footprintSegLen,++Ce.polygonSegLen}if(Ce.vertexCount=this.layoutVertexArray.length-Ce.vertexArrayOffset,Ce.groundVertexCount=this.groundEffect.vertexArray.length-Ce.groundVertexArrayOffset,Ce.vertexCount!==0){if(Ce.centroidXY=xe.borders?o2e:this.encodeCentroid(xe,Ce),this.centroidData.push(Ce),xe.borders){this.featuresOnBorder.push(xe);const $t=this.featuresOnBorder.length-1;for(let or=0;orthis.featuresOnBorder[h].borders[c][0]-this.featuresOnBorder[y].borders[c][0])}splitToSubtiles(){const c=[];for(let L=0;LBr),Z=2*V+(+(z.min.x+z.max.x>Br)^V);for(let Q=0;QL.triangleSegmentIdx===z.triangleSegmentIdx?L.subtile-z.subtile:L.triangleSegmentIdx-z.triangleSegmentIdx);let y=0,b=0,M=0;for(const L of c){if(L.triangleSegmentIdx!==y)break;M++}const E=c.length;for(;b!==c.length;){y=c[b].triangleSegmentIdx;let L=0,z=b,V=b;for(let Z=z;Z0&&this.triangleSubSegments.push({segment:ne,min:Q,max:ee}),z=V;for(let le=z;le[xe[0]*(1-Ne[0])+Ce[0]*Ne[0],xe[1]*(1-Ne[1])+Ce[1]*Ne[1]],ne=[],le=[];for(const xe of this.triangleSubSegments){ne[0]=xe.min.x/Br,ne[1]=xe.min.y/Br,le[0]=xe.max.x/Br,le[1]=xe.max.y/Br;const Ce=ee(Z,Q,ne),Ne=ee(Z,Q,le);if(new js([Ce[0],Ce[1],M],[Ne[0],Ne[1],E]).intersectsPrecise(y)===0){V&&(b.segments.push(V),V=void 0);continue}const Fe=xe.segment;V&&V.vertexOffset!==Fe.vertexOffset&&(b.segments.push(V),V=void 0),V?(V.vertexLength+=Fe.vertexLength,V.primitiveLength+=Fe.primitiveLength):V={vertexOffset:Fe.vertexOffset,primitiveLength:Fe.primitiveLength,vertexLength:Fe.vertexLength,primitiveOffset:Fe.primitiveOffset,sortKey:void 0,vaos:{}}}return V&&b.segments.push(V),b}encodeCentroid(c,h){const y=c.centroid(),b=h.span(),M=Math.min(7,Math.round(b.x*this.tileToMeter/10)),E=Math.min(7,Math.round(b.y*this.tileToMeter/10));return new dr(ye(y.x,1,Br-1)<<3|M,ye(y.y,1,Br-1)<<3|E)}encodeBorderCentroid(c){if(!c.borders)return new dr(0,0);const h=c.borders,y=Number.MAX_VALUE;if(h[0][0]!==y||h[1][0]!==y){const b=h[0][0]!==y?0:1;return new dr(6|(h[0][0]!==y?0:65528),(h[b][0]+h[b][1])/2<<3|6)}{const b=h[2][0]!==y?2:3;return new dr((h[b][0]+h[b][1])/2<<3|6,6|(h[2][0]!==y?0:65528))}}showCentroid(c){const h=this.centroidData[c.centroidDataIndex];h.flags&=2147483647,h.centroidXY.x=0,h.centroidXY.y=0,this.writeCentroidToBuffer(h)}writeCentroidToBuffer(c){this.groundEffect.updateHiddenByLandmark(c);const h=c.vertexArrayOffset,y=c.vertexCount+c.vertexArrayOffset,b=c.flags&sy?o2e:c.centroidXY,M=this.centroidVertexArray.geta_centroid_pos0(h);if(this.centroidVertexArray.geta_centroid_pos1(h)!==b.y||M!==b.x){for(let E=h;Ez.max.x||z.min.x>E.max.x||E.min.y>z.max.y||z.min.y>E.max.y||E.footprint.buildingIds.has(z.buildingId)&&(z.flags|=sy);else for(const z of this.centroidData)if(!(z.flags&sy||E.min.x>z.max.x||z.min.x>E.max.x||E.min.y>z.max.y||z.min.y>E.max.y))for(let V=0;Vh!=ne>h&&c<(this.footprintVertices.int16[2*(Z+E.vertexOffset)+0]-Q)*(h-ee)/(ne-ee)+Q&&(b=!b)}L=z}}return b}getHeightAtTileCoord(c,h){let y=Number.NEGATIVE_INFINITY,b=!0;const M=4*(c+Br)*Br+(h+Br);if(this.partLookup.hasOwnProperty(M)){const E=this.partLookup[M];return E?{height:E.height,hidden:!!(E.flags&sy)}:void 0}for(const E of this.centroidData)c>E.max.x||E.min.x>c||h>E.max.y||E.min.y>h||E.height<=y||this.footprintContainsPoint(c,h,E)&&(y=E.height,this.partLookup[M]=E,b=!!(E.flags&sy));if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:b};this.partLookup[M]=void 0}}function f2e(f,c){const h=f.add(c)._unit();return f.x*h.x+f.y*h.y}function cQe(f,c,h,y){const b=c.sub(f)._perp()._unit(),M=h.sub(c)._perp()._unit();return p2e(f,c,h,f2e(b,M),y)}function p2e(f,c,h,y,b){const M=Math.sqrt(1-y*y);return Math.min(f.dist(c)/3,c.dist(h)/3,b*M/y)}function _ce(f,c,h){return f.xh[1].x&&c.x>h[1].x||f.yh[1].y&&c.y>h[1].y}function g2e(f,c){return f.xc[1].x||f.yc[1].y}function x2e(f,c,h){if(f.x<0||f.x>=Br||c.x<0||c.x>=Br||h.x<0||h.x>=Br)return!1;const y=h.sub(c),b=y.perp(),M=f.sub(c);return(y.x*M.x+y.y*M.y)/Math.sqrt((y.x*y.x+y.y*y.y)*(M.x*M.x+M.y*M.y))>-.866&&b.x*M.x+b.y*M.y<0}function y2e(f,c,h){const y=c?2|f:-3&f;return h?1|y:-2&y}function v2e(){const f=Math.PI/32,c=Math.tan(f),h=j;return h*Math.sqrt(1+2*c*c)-h}function _2e(f,c,h){const y=1<{for(const It of mt)le.push({polygon:It,bounds:kt})},Ce=Math.ceil(Math.log2(Z)),Ne=Math.ceil(Math.log2(Q)),Fe=Ce-Ne,Be=[];for(let mt=0;mt0?0:1);for(let mt=0;mtkt+1?yt.push({polygons:fr,bounds:kr,depth:kt+1}):xe(fr,kr)}if(wr.length){const kr=[new dr(It===0?mr:Rt.x,It===1?mr:Rt.y),tr];Be.length>kt+1?yt.push({polygons:wr,bounds:kr,depth:kt+1}):xe(wr,kr)}}return le}(f,c,Math.ceil((M-b)/11.25),Math.ceil((E-L)/11.25),1,(z,V,Z)=>{if(z===0)return .5*(V+Z);{const Q=me((h.y+V/Br)/y);return(G(.5*(me((h.y+Z/Br)/y)+Q))*y-h.y)*Br}})}function dQe(f,c,h,y,b,M){const E=Math.pow(2,y.z-b.z);for(let L=0;L=z[E]&&(L=c,z=f),L[E]b&&k2e(L,z,E,b),L[E]M&&k2e(z,L,E,M)}}function uD(f,c,h,y,b,M){const E=[];for(let L=0;L=y&&le.x>=y||(ne.x>=y?ne=new dr(y,ne.y+(y-ne.x)/(le.x-ne.x)*(le.y-ne.y))._round():le.x>=y&&(le=new dr(y,ne.y+(y-ne.x)/(le.x-ne.x)*(le.y-ne.y))._round()),ne.y>=b&&le.y>=b||(ne.y>=b?ne=new dr(ne.x+(b-ne.y)/(le.y-ne.y)*(le.x-ne.x),b)._round():le.y>=b&&(le=new dr(ne.x+(b-ne.y)/(le.y-ne.y)*(le.x-ne.x),b)._round()),V&&ne.equals(V[V.length-1])||(V=[ne],E.push(V),M&&M.push({progress:{min:Ce+S2e(Ne,Fe,ne)*xe,max:1},parentIndex:L,prevPoint:Ne,nextPoint:Fe})),V.push(le),M&&(M[M.length-1].progress.max=Ce+S2e(Ne,Fe,le)*xe,M[M.length-1].nextPoint=Fe)))))}if(M&&Q>0)for(let ee=Z;eeV.t-Z.t);let E=0,L=0,z=[];for(y.push(z);E!==f.length;){if(L===M.length){for(;E!==f.length;)z.length!==0&&z[z.length-1].equals(f[E])||z.push(f[E]),E++;break}M[L].t<=E?(z.length!==0&&z[z.length-1].equals(M[L].point)||z.push(M[L].point),Math.trunc(M[L].t),L++):(z.length!==0&&z[z.length-1].equals(f[E])||z.push(f[E]),E++)}}function S2e(f,c,h){return f.x!==c.x?(h.x-f.x)/(c.x-f.x):f.y!==c.y?(h.y-f.y)/(c.y-f.y):0}function wT(f,c){return f.x*c.x+f.y*c.y}function C2e(f,c){if(f.length===1){let h=0;const y=c[h++];let b;for(;!b||y.equals(b);)if(b=c[h++],!b)return 1/0;for(;h{mr[0]=fr,mr[1]=wr,mr[2]=kr,mr[3]=1},or=v2e();ne>0&&(ne+=or),le+=or;for(const mr of ee){const fr=[],wr=[];for(const kr of mr){const xr=kr.x+xe.x,_r=kr.y+xe.y,ir=Q.projection.projectTilePoint(xr,_r,yt),sr=Q.projection.upVector(yt,kr.x,kr.y);let br=ne,Vr=le;if(Ne){const Ar=A2e(xr,_r,ne,le,Ne,Fe,Be,Je);br+=Ar.base,Vr+=Ar.top}ne!==0?$t(Rt,ir.x+sr[0]*It*br,ir.y+sr[1]*It*br,ir.z+sr[2]*It*br):$t(Rt,ir.x,ir.y,ir.z),$t(tr,ir.x+sr[0]*It*Vr,ir.y+sr[1]*It*Vr,ir.z+sr[2]*It*Vr),st(Rt,Rt,Ce),st(tr,tr,Ce),fr.push(new X_(Rt[0],Rt[1],Rt[2])),wr.push(new X_(tr[0],tr[1],tr[2]))}mt.push(fr),kt.push(wr)}return[mt,kt]}(f,c,h,y,b,M,E,L,z,V,Z):E?function(Q,ee,ne,le,xe,Ce,Ne,Fe,Be){const Je=[],yt=[],mt=[0,0,0,1];for(const kt of Q){const It=[],Rt=[];for(const tr of kt){const $t=tr.x+le.x,or=tr.y+le.y,mr=A2e($t,or,ee,ne,Ce,Ne,Fe,Be);mt[0]=$t,mt[1]=or,mt[2]=mr.base,mt[3]=1,ot(mt,mt,xe),mt[3]=Math.max(mt[3],1e-5);const fr=new X_(mt[0]/mt[3],mt[1]/mt[3],mt[2]/mt[3]);mt[0]=$t,mt[1]=or,mt[2]=mr.top,mt[3]=1,ot(mt,mt,xe),mt[3]=Math.max(mt[3],1e-5);const wr=new X_(mt[0]/mt[3],mt[1]/mt[3],mt[2]/mt[3]);It.push(fr),Rt.push(wr)}Je.push(It),yt.push(Rt)}return[Je,yt]}(c,h,y,b,M,E,L,z,V):function(Q,ee,ne,le,xe){const Ce=[],Ne=[],Fe=xe[8]*ee,Be=xe[9]*ee,Je=xe[10]*ee,yt=xe[11]*ee,mt=xe[8]*ne,kt=xe[9]*ne,It=xe[10]*ne,Rt=xe[11]*ne;for(const tr of Q){const $t=[],or=[];for(const mr of tr){const fr=mr.x+le.x,wr=mr.y+le.y,kr=xe[0]*fr+xe[4]*wr+xe[12],xr=xe[1]*fr+xe[5]*wr+xe[13],_r=xe[2]*fr+xe[6]*wr+xe[14],ir=xe[3]*fr+xe[7]*wr+xe[15],sr=kr+Fe,br=xr+Be,Vr=_r+Je,Ar=Math.max(ir+yt,1e-5),Ns=kr+mt,Jr=xr+kt,as=_r+It,xs=Math.max(ir+Rt,1e-5);$t.push(new X_(sr/Ar,br/Ar,Vr/Ar)),or.push(new X_(Ns/xs,Jr/xs,as/xs))}Ce.push($t),Ne.push(or)}return[Ce,Ne]}(c,h,y,b,M)}function A2e(f,c,h,y,b,M,E,L){const z=E*b.getElevationAt(f,c,!0,!0),V=M[0]!==0,Z=V?M[1]===0?E*(M[0]/l2e-c2e):E*function(Q,ee,ne){const le=Math.floor(ee[0]/8),xe=Math.floor(ee[1]/8),Ce=10*(ee[0]-8*le),Ne=10*(ee[1]-8*xe),Fe=Q.getElevationAt(le,xe,!0,!0),Be=Q.getMeterToDEM(ne),Je=Math.floor(.5*(Ce*Be-1)),yt=Math.floor(.5*(Ne*Be-1)),mt=Q.tileCoordToPixel(le,xe),kt=2*Je+1,It=2*yt+1,Rt=function(wr,kr,xr,_r,ir){return[wr.getElevationAtPixel(kr,xr,!0),wr.getElevationAtPixel(kr+ir,xr,!0),wr.getElevationAtPixel(kr,xr+ir,!0),wr.getElevationAtPixel(kr+_r,xr+ir,!0)]}(Q,mt.x-Je,mt.y-yt,kt,It),tr=Math.abs(Rt[0]-Rt[1]),$t=Math.abs(Rt[2]-Rt[3]),or=Math.abs(Rt[0]-Rt[2])+Math.abs(Rt[1]-Rt[3]),mr=Math.min(.25,.5*Be*(tr+$t)/kt),fr=Math.min(.25,.5*Be*or/It);return Fe+Math.max(mr*Ce,fr*Ne)}(b,M,L):z;return{base:z+(h===0?-1:h),top:V?Math.max(Z+y,z+h+2):z+y}}class hQe{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 mQe{constructor(){this.tasks={},this.taskQueue=[],Ft(["process"],this),this.invoker=new hQe(this.process),this.nextId=0}add(c,h){const y=this.nextId++,b=function({type:M,isSymbolTile:E,zoom:L}){return L=L||0,M==="message"?0:M!=="maybePrepare"||E?M!=="parseTile"||E?M==="parseTile"&&E?300-L:M==="maybePrepare"&&E?400-L:500:200-L:100-L}(h);if(b===0){try{c()}finally{}return null}return this.tasks[y]={fn:c,metadata:h,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 h=this.tasks[c];if(delete this.tasks[c],this.taskQueue.length&&this.invoker.trigger(),!h)return;h.fn()}finally{}}pick(){let c=null,h=1/0;for(let b=0;b{y&&delete this.callbacks[L],this.target.postMessage({id:L,type:"",targetMapId:b,sourceMapId:this.mapId})}}}receive(c){const h=c.data;if(!h)return;const y=h.id;if(y&&(!h.targetMapId||this.mapId===h.targetMapId))if(h.type===""){const b=this.cancelCallbacks[y];delete this.cancelCallbacks[y],b&&b.cancel()}else if(h.mustQueue||ra(self)){const b=this.callbacks[y],M=this.scheduler.add(()=>this.processTask(y,h),b&&b.metadata||{type:"message"});M&&(this.cancelCallbacks[y]=M)}else this.processTask(y,h)}processTask(c,h){if(delete this.cancelCallbacks[c],h.type===""){const y=this.callbacks[c];delete this.callbacks[c],y&&(h.error?y(Ig(h.error)):y(null,Ig(h.data)))}else{const y=new Set,b=h.hasCallback?(E,L)=>{this.target.postMessage({id:c,type:"",sourceMapId:this.mapId,error:E?op(E):null,data:op(L,y)},y)}:()=>{},M=Ig(h.data);if(this.parent[h.type])this.parent[h.type](h.sourceMapId,M,b);else if(this.parent.getWorkerSource){const E=h.type.split("."),{source:L,scope:z}=M;this.parent.getWorkerSource(h.sourceMapId,E[0],L,z)[E[1]](M,b)}else b(new Error(`Could not find function ${h.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var jT={workerUrl:"",workerClass:null,workerParams:void 0};const bce="mapboxgl_preloaded_worker_pool";class Q_{constructor(c){this.active={},this.name=c}acquire(c,h=Q_.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{h.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[bce]}numActive(){return Object.keys(this.active).length}}Q_.workerCount=2;class HS{constructor(c,h,y="Worker",b=Q_.workerCount){this.workerPool=c,this.actors=[],this.currentActor=0,this.id=Dt();const M=this.workerPool.acquire(this.id,b);for(let E=0;E{this.ready=!0})}broadcast(c,h,y){Ct(this.actors,(b,M)=>{b.send(c,h,M)},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 kT,wce;function hD(){return kT||(kT=new Q_),kT}HS.Actor=E2e;const jce=4096;class fQe{constructor(c){this.module=c,this.memoryStack=this.module.malloc(jce),this.memoryStackNextFree=this.memoryStack}createIntArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>jce?-1:(new Int32Array(this.module.heap32.buffer,h,c.length).set(c),h)}createFloatArray(c){const h=this.memoryStackNextFree;return this.memoryStackNextFree+=c.length*Float32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>jce?-1:(new Float32Array(this.module.heapF32.buffer,h,c.length).set(c),h)}readStringBuffer(c){let h="";for(;this.module.heapU8[c]!==0;)h+=String.fromCharCode(this.module.heapU8[c]),++c;return h}setStyle(c){const h=c.normalScale;this.module.setStyle(h[0],h[1],h[2],c.tileToMeters)}setAOOptions(c,h){this.module.setAOOptions(c?1:0,h)}setMetricOptions(c,h){this.module.setMetricOptions(c?1:0,h)}setStructuralOptions(c){this.module.setStructuralOptions(c?1:0)}setFacadeOptions(c,h){this.module.setFacadeOptions(c,h?1:0)}setFauxFacadeOptions(c,h,y){this.module.setFauxFacadeOptions(c?1:0,h?1:0,y)}setFacadeClassifierOptions(c){this.module.setFacadeClassifierOptions(c)}generateMesh(c,h){this.memoryStackNextFree=this.memoryStack;for(const L of c){const z=this.createIntArray(L.ringIndices),V=this.createFloatArray(L.coordinates);if(z===-1||V===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(L.id,L.sourceId,L.minHeight,L.height,L.roofType,V,z,L.ringIndices.length-1)}for(const L of h){let z;z=L.entrances?JSON.parse(L.entrances):[];const V=this.createFloatArray(z),Z=this.createFloatArray(L.coordinates);if(V===-1||Z===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(L.sourceId,L.crossPerc,L.distanceToRoad,V,z.length,Z,L.coordinates.length)}if(!this.module.generateMesh()){const L=this.module.getLastError();return this.readStringBuffer(L)}const y=this.module.getMeshCount(),b=new Array(y);for(let L=0;Lb.arrayBuffer()).then(b=>{c.buffers[h]=b})}function z2e(f,c){const h=f.json.bufferViews[c];return new Uint8Array(f.buffers[h.buffer],h.byteOffset||0,h.byteLength)}function _Qe(f,c,h,y){if(f.uri){const b=F2e(f.uri,y);return fetch(b).then(M=>M.blob()).then(M=>createImageBitmap(M)).then(M=>{c.images[h]=M})}if(f.bufferView!==void 0){const b=z2e(c,f.bufferView),M=new Blob([b],{type:f.mimeType});return createImageBitmap(M).then(E=>{c.images[h]=E})}}function B2e(f,c=0,h){const y={json:null,images:[],buffers:[]};if(new Uint32Array(f,c,1)[0]===O2e){const Z=new Uint32Array(f,c);let Q=2;const ee=(Z[Q++]>>2)-3,ne=Z[Q++]>>2;if(Q++,y.json=JSON.parse(R2e.decode(Z.subarray(Q,Q+ne))),Q+=ne,Q{const Z=[],Q=L&&L.includes(Sce),ee=L&&L.includes(pD);if(Q&&Z.push(function(){if(!vp)return NT??(NT=function(ne){let le,xe=null;function Ce(){le=new Uint8Array(xe.buffer)}function Ne(){throw new Error("Unexpected Draco error.")}const Fe={a:{a:Ne,d:function(Be,Je,yt){return le.copyWithin(Be,Je,Je+yt)},c:function(Be){const Je=le.length,yt=Math.max(Be>>>0,Math.ceil(1.2*Je)),mt=Math.ceil((yt-Je)/65536);try{return xe.grow(mt),Ce(),!0}catch{return!1}},b:Ne}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(ne,Fe):ne.then(Be=>Be.arrayBuffer()).then(Be=>WebAssembly.instantiate(Be,Fe))).then(Be=>{const{Rb:Je,Qb:yt,P:mt,T:kt,X:It,Ja:Rt,La:tr,Qa:$t,Va:or,Wa:mr,eb:fr,jb:wr,f:kr,e:xr,yb:_r,zb:ir,Ab:sr,Bb:br,Db:Vr,Gb:Ar}=Be.instance.exports;xe=xr;const Ns=(()=>{let Jr=0,as=0,xs=0,In=0;return Pr=>{xs&&(Je(In),Je(Jr),as+=xs,xs=Jr=0),Jr||(as+=128,Jr=yt(as));const ys=Pr.length+7&-8;let sn=Jr;ys>=as&&(xs=ys,sn=In=yt(ys));for(let na=0;na{vp=ne,NT=void 0}))}()),ee&&Z.push(function(){if(Nce)return;const ne=function(le){let xe;const Ce=WebAssembly.instantiateStreaming(le,{}).then(Be=>{xe=Be.instance,xe.exports.__wasm_call_ctors()}),Ne={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Fe={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Ce,supported:!0,decodeGltfBuffer(Be,Je,yt,mt,kt,It){(function(Rt,tr,$t,or,mr,fr,wr){const kr=Rt.exports.sbrk,xr=or+3&-4,_r=kr(xr*mr),ir=kr(fr.length),sr=new Uint8Array(Rt.exports.memory.buffer);sr.set(fr,ir);const br=tr(_r,or,mr,ir,fr.length);if(br===0&&wr&&wr(_r,xr,mr),$t.set(sr.subarray(_r,_r+or*mr)),kr(_r-kr(0)),br!==0)throw new Error(`Malformed buffer data: ${br}`)})(xe,xe.exports[Fe[kt]],Be,Je,yt,mt,xe.exports[Ne[It]])}}}(fetch(L2e()));return ne.ready.then(()=>{Nce=ne})}()),M)for(let ne=0;ne{if(Q&&E)for(const{primitives:ne}of E)for(const le of ne)xQe(le,y);if(ee&&E&&z)for(const ne of z)yQe(ne,y);return y})})}function $2e(f){return fetch(f).then(c=>c.arrayBuffer()).then(c=>B2e(c,0,f))}function Cce(f){switch(f){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function Mce(f){switch(f){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Tce{constructor(c,h,y,b){this.context=c,this.format=y,this.useMipmap=b&&b.useMipmap,this.texture=c.gl.createTexture(),this.update(h,{premultiply:b&&b.premultiply})}update(c,h){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:M}=this,{gl:E}=M,{x:L,y:z}=h&&h.position?h.position:{x:0,y:0},V=L+y,Z=z+b;!this.size||this.size[0]===V&&this.size[1]===Z||(E.bindTexture(E.TEXTURE_2D,null),E.deleteTexture(this.texture),this.texture=E.createTexture(),this.size=null),E.bindTexture(E.TEXTURE_2D,this.texture),M.pixelStoreUnpackFlipY.set(!1),M.pixelStoreUnpack.set(1),M.pixelStoreUnpackPremultiplyAlpha.set(this.format===E.RGBA8&&(!h||h.premultiply!==!1));const Q=c instanceof HTMLImageElement||c instanceof HTMLCanvasElement||c instanceof HTMLVideoElement||c instanceof ImageData||ImageBitmap&&c instanceof ImageBitmap;if(!this.size&&V>0&&Z>0){const ee=this.useMipmap?Math.floor(Math.log2(Math.max(V,Z)))+1:1;E.texStorage2D(E.TEXTURE_2D,ee,this.format,V,Z),this.size=[V,Z]}this.size&&(Q?E.texSubImage2D(E.TEXTURE_2D,0,L,z,Cce(this.format),Mce(this.format),c):"data"in c&&c.data&&E.texSubImage2D(E.TEXTURE_2D,0,L,z,y,b,Cce(this.format),Mce(this.format),c.data)),this.useMipmap&&E.generateMipmap(E.TEXTURE_2D)}bind(c,h,y=!1){const{context:b}=this,{gl:M}=b;M.bindTexture(M.TEXTURE_2D,this.texture),c!==this.minFilter&&(M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MAG_FILTER,c),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_MIN_FILTER,this.useMipmap&&!y?c===M.NEAREST?M.NEAREST_MIPMAP_NEAREST:M.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),h!==this.wrapS&&(M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_S,h),M.texParameteri(M.TEXTURE_2D,M.TEXTURE_WRAP_T,h),this.wrapS=h)}bindExtraParam(c,h,y,b,M){const{context:E}=this,{gl:L}=E;L.bindTexture(L.TEXTURE_2D,this.texture),h!==this.magFilter&&(L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MAG_FILTER,h),this.magFilter=h),c!==this.minFilter&&(L.texParameteri(L.TEXTURE_2D,L.TEXTURE_MIN_FILTER,this.useMipmap?c===L.NEAREST?L.NEAREST_MIPMAP_NEAREST:L.LINEAR_MIPMAP_LINEAR:c),this.minFilter=c),y!==this.wrapS&&(L.texParameteri(L.TEXTURE_2D,L.TEXTURE_WRAP_S,y),this.wrapS=y),b!==this.wrapT&&(L.texParameteri(L.TEXTURE_2D,L.TEXTURE_WRAP_T,b),this.wrapT=b),M!==this.compareMode&&(M?(L.texParameteri(L.TEXTURE_2D,L.TEXTURE_COMPARE_MODE,L.COMPARE_REF_TO_TEXTURE),L.texParameteri(L.TEXTURE_2D,L.TEXTURE_COMPARE_FUNC,M)):L.texParameteri(L.TEXTURE_2D,L.TEXTURE_COMPARE_MODE,L.NONE),this.compareMode=M)}destroy(){const{gl:c}=this.context;c.deleteTexture(this.texture),this.texture=null}}class CT{constructor(c,h){this.context=c,this.texture=h}bind(c,h){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),h!==this.wrapS&&(b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,h),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,h),this.wrapS=h)}}const bQe=Xn([{name:"a_pos_3f",components:3,type:"Float32"}]),wQe=Xn([{name:"a_color_3f",components:3,type:"Float32"}]),jQe=Xn([{name:"a_color_4f",components:4,type:"Float32"}]),kQe=Xn([{name:"a_uv_2f",components:2,type:"Float32"}]),NQe=Xn([{name:"a_normal_3f",components:3,type:"Float32"}]),SQe=Xn([{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"}]),CQe=Xn([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function U2e(f,c){const h=gD(f.projection,f.zoom,f.width,f.height),y=function(M,E,L,z,V){const Z=new x(L.lng-180*rv,L.lat),Q=new x(L.lng+180*rv,L.lat),ee=M.project(Z.lng,Z.lat),ne=M.project(Q.lng,Q.lat),le=-Math.atan2(ne.y-ee.y,ne.x-ee.x),xe=Ge.fromLngLat(L);xe.y=ye(xe.y,-1+rv,1-rv);const Ce=xe.toLngLat(),Ne=M.project(Ce.lng,Ce.lat),Fe=Ge.fromLngLat(Ce);Fe.x+=rv;const Be=Fe.toLngLat(),Je=M.project(Be.lng,Be.lat),yt=q2e(Je.x-Ne.x,Je.y-Ne.y,le),mt=Ge.fromLngLat(Ce);mt.y+=rv;const kt=mt.toLngLat(),It=M.project(kt.lng,kt.lat),Rt=q2e(It.x-Ne.x,It.y-Ne.y,le),tr=Math.abs(yt.x)/Math.abs(Rt.y),$t=S([]);$($t,$t,-le*(1-(V?0:z)));const or=S([]);return R(or,or,[1,1-(1-tr)*z,1]),or[4]=-Rt.x/Rt.y*z,$(or,or,le),C(or,$t,or),or}(f.projection,0,f.center,h,c),b=V2e(f);return R(y,y,[b,b,1]),y}function V2e(f){const c=f.projection,h=gD(f.projection,f.zoom,f.width,f.height),y=Ace(c,f.center),b=Ace(c,x.convert(c.center));return Math.pow(2,y*h+(1-h)*b)}function gD(f,c,h,y,b=1/0){const M=f.range;if(!M)return 0;const E=Math.min(b,Math.max(h,y)),L=Math.log2(E/1024);return De(M[0]+L,M[1]+L,c)}const rv=1/4e4;function Ace(f,c){const h=ye(c.lat,-fe,fe),y=new x(c.lng-180*rv,h),b=new x(c.lng+180*rv,h),M=f.project(y.lng,h),E=f.project(b.lng,h),L=Ge.fromLngLat(y),z=Ge.fromLngLat(b),V=E.x-M.x,Z=E.y-M.y,Q=z.x-L.x,ee=z.y-L.y,ne=Math.sqrt((Q*Q+ee*ee)/(V*V+Z*Z));return Math.log2(ne)}function q2e(f,c,h){const y=Math.cos(h),b=Math.sin(h);return{x:f*y-c*b,y:f*b+c*y}}function H2e(f,c,h){S(f),$(f,f,Qs(c[2])),D(f,f,Qs(c[0])),B(f,f,Qs(c[1])),R(f,f,h),C(f,f,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function xD(f,c,h,y,b,M,E,L){const z=[h[0]-c[0],h[1]-c[1],0],V=[y[0]-c[0],y[1]-c[1],0];if(pe(z)<1e-12||pe(V)<1e-12)return ft(f);const Z=wt([],z,V);Ie(Z,Z),ge(V,y,c),z[2]=(M-b)*L,V[2]=(E-b)*L;const Q=z;return wt(Q,z,V),Ie(Q,Q),Mr(f,Z,Q)}function yD(f,c,h=!1){const y=ev(c.zoom),b=function(M,E,L){const z=E.worldSize,V=[M[12],M[13],M[14]],Z=me(V[1]/z),Q=te(V[0]/z),ee=S([]),ne=J(1,Z)*z,le=J(1,0)*z*be(Z,E.zoom),xe=1/ace(z);let Ce=le*xe;if(L){const Je=gD(E.projection,E.zoom,E.width,E.height,1024);Ce=xe*E.projection.pixelSpaceConversion(E.center.lat,z,Je)}const Ne=X0(Z,Q);ce(Ne,Ne,Me([],Ie([],Ne),ne*Ce*V[2]));const Fe=function(Je){const yt=[Je[0],Je[1],Je[2]];let mt=[0,1,0];const kt=wt([],mt,yt);return wt(mt,yt,kt),Ue(mt)===0&&(mt=[0,1,0],wt(kt,yt,mt)),Ie(kt,kt),Ie(mt,mt),Ie(yt,yt),[kt[0],kt[1],kt[2],0,mt[0],mt[1],mt[2],0,yt[0],yt[1],yt[2],0,Je[0],Je[1],Je[2],1]}(Ne);R(ee,ee,[Ce,Ce,Ce*ne]),I(ee,ee,[-V[0],-V[1],-V[2]]);const Be=C([],E.globeMatrix,Fe);return C(Be,Be,ee),C(Be,Be,M),Be}(f,c,h);if(y>0){const M=function(E,L){const z=L.worldSize,V=J(1,0)*z*be(L.center.lat,L.zoom)/ace(z),Z=J(1,L.center.lat)*z,Q=S([]);B(Q,Q,Qs(L.center.lng)),D(Q,Q,Qs(L.center.lat)),I(Q,Q,[0,0,Kc]),R(Q,Q,[V,V,V*Z]);const ee=L.point;return I(Q,Q,[-ee.x,-ee.y,0]),C(Q,Q,E),C(Q,L.globeMatrix,Q)}(f,c);return function(E,L,z){const V=(le,xe,Ce)=>{const Ne=pe(le),Fe=pe(xe),Be=yp(le,xe,Ce);return Me(Be,Be,1/pe(Be)*Gs(Ne,Fe,Ce))},Z=V([E[0],E[1],E[2]],[L[0],L[1],L[2]],z),Q=V([E[4],E[5],E[6]],[L[4],L[5],L[6]],z),ee=V([E[8],E[9],E[10]],[L[8],L[9],L[10]],z),ne=yp([E[12],E[13],E[14]],[L[12],L[13],L[14]],z);return[Z[0],Z[1],Z[2],0,Q[0],Q[1],Q[2],0,ee[0],ee[1],ee[2],0,ne[0],ne[1],ne[2],1]}(b,M,y)}return b}function Ece(f,c,h,y){const b=js.projectAabbCorners(y,h);let M=Number.MAX_VALUE;for(let L=0;L0||Ce===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])&&(Z=ne)}Q=Z}while(Q!==V);return z.length>0&&z.push(z[0]),z}(b);if(wa(f,E))return M}const J_=64,ZS={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function vD(f,c,h,y,b,M,E,L,z,V=!1){const Z=h.zoom,Q=h.project(y),ee=be(y.lat,Z),ne=1/ee;S(f),I(f,f,[Q.x+E[0]*ne,Q.y+E[1]*ne,E[2]]);let le=1,xe=1;const Ce=h.worldSize;if(V){if(h.projection.name==="mercator"){let Je=0;h.elevation&&(Je=h.elevation.getAtPointOrZero(new Ge(Q.x/Ce,Q.y/Ce),0));const yt=ot([],[Q.x,Q.y,Je,1],h.projMatrix)[3]/h.cameraToCenterDistance;le=yt,xe=yt*be(h.center.lat,Z)}else if(h.projection.name==="globe"){const Je=yD(f,h),yt=[0,0,0,1];ot(yt,yt,C([],h.projMatrix,Je));const mt=yt[3]/h.cameraToCenterDistance,kt=ev(Z),It=h.projection.pixelsPerMeter(y.lat,Ce)*be(y.lat,Z),Rt=h.projection.pixelsPerMeter(h.center.lat,Ce)*be(h.center.lat,Z);le=mt/Gs(It,ke(h.center.lat),kt),xe=mt*ee/It,le*=Rt,xe*=Rt}}else le=ne;R(f,f,[le,le,xe]);const Ne=[...f],Fe=c.orientation,Be=[];if(H2e(Be,[Fe[0]+(b?b[0]:0),Fe[1]+(b?b[1]:0),Fe[2]+(b?b[2]:0)],M),C(f,Ne,Be),L&&h.elevation){let Je=0;const yt=[];if(z&&h.elevation){Je=function(kt,It,Rt,tr,$t){const or=It.elevation;if(!or)return 0;const mr=js.projectAabbCorners(Rt,tr),fr=J(1,$t.lat)*It.worldSize,wr=function(as,xs){const In=[0,0,1],Pr=[{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 ys of Pr){const sn=as[ys.corners[0]],na=as[ys.corners[1]],ca=as[ys.corners[2]],_n=[na[0]-sn[0],na[1]-sn[1],xs*(na[2]-sn[2])],ei=wt(_n,_n,[ca[0]-sn[0],ca[1]-sn[1],xs*(ca[2]-sn[2])]);Ie(ei,ei),ys.dotProductWithUp=We(ei,In)}return Pr.sort((ys,sn)=>ys.dotProductWithUp-sn.dotProductWithUp),Pr[0].corners}(mr,fr),kr=mr[wr[0]],xr=mr[wr[1]],_r=mr[wr[2]],ir=mr[wr[3]],sr=or.getAtPointOrZero(new Ge(kr[0]/It.worldSize,kr[1]/It.worldSize),0),br=or.getAtPointOrZero(new Ge(xr[0]/It.worldSize,xr[1]/It.worldSize),0),Vr=or.getAtPointOrZero(new Ge(_r[0]/It.worldSize,_r[1]/It.worldSize),0),Ar=or.getAtPointOrZero(new Ge(ir[0]/It.worldSize,ir[1]/It.worldSize),0),Ns=(sr+Ar)/2,Jr=(br+Vr)/2;return Ns>Jr?br=c.gl.NEAREST_MIPMAP_NEAREST}),f.uploaded=!0,f.image=null)}function MQe(f,c,h){f.indexBuffer=c.createIndexBuffer(f.indexArray,!1,!0),f.vertexBuffer=c.createVertexBuffer(f.vertexArray,bQe.members,!1,!0),f.normalArray&&(f.normalBuffer=c.createVertexBuffer(f.normalArray,NQe.members,!1,!0)),f.texcoordArray&&(f.texcoordBuffer=c.createVertexBuffer(f.texcoordArray,kQe.members,!1,!0)),f.colorArray&&(f.colorBuffer=c.createVertexBuffer(f.colorArray,(f.colorArray.bytesPerElement===12?wQe:jQe).members,!1,!0)),f.featureArray&&(f.pbrBuffer=c.createVertexBuffer(f.featureArray,CQe.members,!0)),f.segments=to.simpleSegment(0,0,f.vertexArray.length,f.indexArray.length);const y=f.material;y.pbrMetallicRoughness.baseColorTexture&&MT(y.pbrMetallicRoughness.baseColorTexture,c),y.pbrMetallicRoughness.metallicRoughnessTexture&&MT(y.pbrMetallicRoughness.metallicRoughnessTexture,c),y.normalTexture&&MT(y.normalTexture,c),y.occlusionTexture&&MT(y.occlusionTexture,c,h),y.emissionTexture&&MT(y.emissionTexture,c)}function Ice(f,c,h){if(f.meshes)for(const y of f.meshes)MQe(y,c,h);if(f.children)for(const y of f.children)Ice(y,c,h)}function _D(f){if(f.meshes)for(const c of f.meshes)c.indexArray.destroy(),c.vertexArray.destroy(),c.colorArray&&c.colorArray.destroy(),c.normalArray&&c.normalArray.destroy(),c.texcoordArray&&c.texcoordArray.destroy(),c.featureArray&&c.featureArray.destroy();if(f.children)for(const c of f.children)_D(c)}function Pce(f){if(f.meshes)for(const h of f.meshes)h.vertexBuffer&&(h.vertexBuffer.destroy(),h.indexBuffer.destroy(),h.normalBuffer&&h.normalBuffer.destroy(),h.texcoordBuffer&&h.texcoordBuffer.destroy(),h.colorBuffer&&h.colorBuffer.destroy(),h.pbrBuffer&&h.pbrBuffer.destroy(),h.segments.destroy(),h.material&&((c=h.material).pbrMetallicRoughness.baseColorTexture&&c.pbrMetallicRoughness.baseColorTexture.gfxTexture&&c.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),c.pbrMetallicRoughness.metallicRoughnessTexture&&c.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&c.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),c.normalTexture&&c.normalTexture.gfxTexture&&c.normalTexture.gfxTexture.destroy(),c.emissionTexture&&c.emissionTexture.gfxTexture&&c.emissionTexture.gfxTexture.destroy(),c.occlusionTexture&&c.occlusionTexture.gfxTexture&&c.occlusionTexture.gfxTexture.destroy()));var c;if(f.children)for(const h of f.children)Pce(h)}function eb(f,c){const h=f.json.bufferViews[c.bufferView],y=fD[c.componentType];return new y(f.buffers[h.buffer],(c.byteOffset||0)+(h.byteOffset||0),c.count*(h.byteStride&&h.byteStride!==ST[c.type]*y.BYTES_PER_ELEMENT?h.byteStride/y.BYTES_PER_ELEMENT:ST[c.type]))}function Lce(f,c,h,y){const b=fD[c.componentType],M=function(Z){switch(Z){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(b),E=f.json.bufferViews[c.bufferView],L=E.byteStride?E.byteStride/b.BYTES_PER_ELEMENT:ST[c.type],z=h.float32,V=z.length/h.capacity;for(let Z=0,Q=0;Z0){for(let Ce=0;Ce0){M.texcoordArray=new of;const ee=c.json.accessors[b.TEXCOORD_0];M.texcoordArray.resize(ee.count);const ne=eb(c,ee);Lce(c,ee,M.texcoordArray,ne)}if(b._FEATURE_ID_RGBA4444!==void 0){const ee=c.json.accessors[b._FEATURE_ID_RGBA4444];c.json.extensionsUsed&&c.json.extensionsUsed.includes("EXT_meshopt_compression")&&(M.featureData=eb(c,ee))}b._FEATURE_RGBA4444!==void 0&&(M.featureData=new Uint32Array(eb(c,c.json.accessors[b._FEATURE_RGBA4444]).buffer));const Q=f.material;return M.material=function(ee,ne){const{emissiveFactor:le=[0,0,0],alphaMode:xe="OPAQUE",alphaCutoff:Ce=.5,normalTexture:Ne,occlusionTexture:Fe,emissiveTexture:Be,doubleSided:Je,name:yt}=ee,{baseColorFactor:mt=[1,1,1,1],metallicFactor:kt=1,roughnessFactor:It=1,baseColorTexture:Rt,metallicRoughnessTexture:tr}=ee.pbrMetallicRoughness||{},$t=Fe?ne[Fe.index]:void 0;if(Fe&&Fe.extensions&&Fe.extensions.KHR_texture_transform&&$t){const or=Fe.extensions.KHR_texture_transform;$t.offsetScale=[or.offset[0],or.offset[1],or.scale[0],or.scale[1]]}return{name:yt,pbrMetallicRoughness:{baseColorFactor:new Aa(...mt),metallicFactor:kt,roughnessFactor:It,baseColorTexture:Rt?ne[Rt.index]:void 0,metallicRoughnessTexture:tr?ne[tr.index]:void 0},doubleSided:Je,emissiveFactor:new Aa(...le),alphaMode:xe,alphaCutoff:Ce,normalTexture:Ne?ne[Ne.index]:void 0,occlusionTexture:$t,emissionTexture:Be?ne[Be.index]:void 0,defined:ee.defined===void 0}}(Q!==void 0?c.json.materials[Q]:{defined:!1},h),M}function G2e(f,c,h){const{matrix:y,rotation:b,translation:M,scale:E,mesh:L,extras:z,children:V,name:Z}=f,Q={};if(Q.name=Z,Q.localMatrix=y||function(ee,ne,le,xe){var Ce=ne[0],Ne=ne[1],Fe=ne[2],Be=ne[3],Je=Ce+Ce,yt=Ne+Ne,mt=Fe+Fe,kt=Ce*Je,It=Ce*yt,Rt=Ce*mt,tr=Ne*yt,$t=Ne*mt,or=Fe*mt,mr=Be*Je,fr=Be*yt,wr=Be*mt,kr=xe[0],xr=xe[1],_r=xe[2];return ee[0]=(1-(tr+or))*kr,ee[1]=(It+wr)*kr,ee[2]=(Rt-fr)*kr,ee[3]=0,ee[4]=(It-wr)*xr,ee[5]=(1-(kt+or))*xr,ee[6]=($t+mr)*xr,ee[7]=0,ee[8]=(Rt+fr)*_r,ee[9]=($t-mr)*_r,ee[10]=(1-(kt+tr))*_r,ee[11]=0,ee[12]=le[0],ee[13]=le[1],ee[14]=le[2],ee[15]=1,ee}([],b||[0,0,0,1],M||[0,0,0],E||[1,1,1]),Q.globalMatrix=w(Q.localMatrix),L!==void 0){Q.meshes=h[L];const ee=Q.anchor=[0,0];for(const ne of Q.meshes){const{min:le,max:xe}=ne.aabb;ee[0]+=le[0]+xe[0],ee[1]+=le[1]+xe[1]}ee[0]=Math.floor(ee[0]/Q.meshes.length/2),ee[1]=Math.floor(ee[1]/Q.meshes.length/2)}if(z&&(z.id&&(Q.id=z.id),z.lights&&(Q.lights=function(ee){if(!ee.length)return[];const ne=function(Fe){const Be=atob(Fe),Je=new Uint8Array(Be.length);for(let yt=0;yt1&&y[y.length-1].equals(y[0])&&y.pop();let b=0;for(let E=0;E0&&y.reverse();const M=VS(y.flatMap(E=>[E.x,E.y]),[]);return M.length===0?null:{vertices:y,indices:M}}function IQe(f,c){const h=[],y=[];let b=0;const M=[];for(const E of f){b=h.length;const L=E.vertexArray.float32,z=E.indexArray.uint16;for(let V=0;V0&&([y[E+1],y[E+2]]=[y[E+2],y[E+1]])}return{vertices:h,indices:y}}function Dce(f){const c=function(z,V){const Z=[],Q=WebGL2RenderingContext;if(z.json.textures)for(const ee of z.json.textures){const ne={magFilter:Q.LINEAR,minFilter:Q.NEAREST,wrapS:Q.REPEAT,wrapT:Q.REPEAT};ee.sampler!==void 0&&Object.assign(ne,z.json.samplers[ee.sampler]),Z.push({image:V[ee.source],sampler:ne,uploaded:!1})}return Z}(f,f.images),h=function(z,V){const Z=[];for(const Q of z.json.meshes){const ee=[];for(const ne of Q.primitives)ee.push(TQe(ne,z,V));Z.push(ee)}return Z}(f,c),{scenes:y,scene:b,nodes:M}=f.json,E=y?y[b||0].nodes:[...M.keys()],L=[];for(const z of E)L.push(G2e(M[z],f,h));return function(z,V,Z){const Q={},ee=new Set;for(let ne=0;ne0){const ne=Array.from(ee.values()).sort((le,xe)=>le-xe);for(let le=ne.length-1;le>=0;le--)z.splice(ne[le],1)}}(L,E,f.json.nodes),L}function PQe(f){f.heightmap=new Float32Array(4096),f.heightmap.fill(-1);const c=f.vertexArray.float32,h=f.aabb.min[0]-1,y=f.aabb.min[1]-1,b=J_/(f.aabb.max[0]-h+2),M=J_/(f.aabb.max[1]-y+2);for(let E=0;Ef.heightmap[V*J_+z]&&(f.heightmap[V*J_+z]=L)}}function K2e(f,c,h,y,b){h.reserve(h.length+4*f.length),y.reserve(y.length+10*f.length),b.reserve(b.length+10*f.length);let M=y.length;for(const E of f){const L=Math.min(10,Math.max(4,1.3*E.height))*c,z=[-E.normal[1],E.normal[0],0],V=Math.min(.29,.1*E.width/E.depth),Z=E.width-2*E.depth*c*(V+.01),Q=Ze([],E.pos,z,Z/2),ee=Ze([],E.pos,z,-Z/2),ne=[Q[0],Q[1],Q[2]+E.height],le=[ee[0],ee[1],ee[2]+E.height],xe=Ze([],E.normal,z,V);Me(xe,xe,L);const Ce=Ze([],E.normal,z,-V);Me(Ce,Ce,L),ce(xe,Q,xe),ce(Ce,ee,Ce),Q[2]+=.1,ee[2]+=.1,y.emplaceBack(xe[0],xe[1],xe[2]),y.emplaceBack(Ce[0],Ce[1],Ce[2]),y.emplaceBack(Q[0],Q[1],Q[2]),y.emplaceBack(ee[0],ee[1],ee[2]),y.emplaceBack(ne[0],ne[1],ne[2]),y.emplaceBack(le[0],le[1],le[2]),y.emplaceBack(Q[0],Q[1],Q[2]),y.emplaceBack(ee[0],ee[1],ee[2]),y.emplaceBack(xe[0],xe[1],xe[2]),y.emplaceBack(Ce[0],Ce[1],Ce[2]);const Ne=Z/L/2;b.emplaceBack(-Ne-V,-1,Ne,.8),b.emplaceBack(Ne+V,-1,Ne,.8),b.emplaceBack(-Ne,0,Ne,1.3),b.emplaceBack(Ne,0,Ne,1.3),b.emplaceBack(Ne+V,-.8,Ne,.7),b.emplaceBack(Ne+V,-.8,Ne,.7),b.emplaceBack(0,0,Ne,1.3),b.emplaceBack(0,0,Ne,1.3),b.emplaceBack(Ne+V,-1.2,Ne,.8),b.emplaceBack(Ne+V,-1.2,Ne,.8),h.emplaceBack(6+M,4+M,8+M),h.emplaceBack(7+M,9+M,5+M),h.emplaceBack(0+M,1+M,2+M),h.emplaceBack(1+M,3+M,2+M),M+=10}}function LQe(f,c){const h={};h.indexArray=new rl,h.vertexArray=new Xu,h.colorArray=new Lg,K2e(f,c,h.indexArray,h.vertexArray,h.colorArray);const y={defined:!0};y.emissiveFactor=Aa.black;const b={};return b.baseColorFactor=Aa.white,y.pbrMetallicRoughness=b,h.material=y,h.aabb=new js([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),h}const Z2e=Xn([{name:"a_pos_3f",components:3,type:"Float32"}]),DQe=Xn([{name:"a_normal_3",components:3,type:"Int16"}]),OQe=Xn([{name:"a_centroid_3",components:3,type:"Int16"}]),Y2e=Xn([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),RQe=Xn([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),FQe=Xn([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),zQe=Xn([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),BQe=Xn([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),$Qe=Xn([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),X2e=zt.types,bD=32767;function UQe(f,c){const h=Br+c;for(const y of f)for(const b of y)if(b.x<-c||b.x>h||b.y<-c||b.y>h)return!1;return!0}function VQe(f){switch(f){case"flat":return 3;case"hipped":return 1;case"gabled":return 2;case"parapet":return 0;case"mansard":return 4;case"skillion":return 5;case"pyramidal":return 6;default:throw new Error(`Unknown roof shape: ${f}`)}}class Oce{constructor(){this.layoutVertexArray=new Xu,this.layoutAttenuationArray=new Lg,this.layoutColorArray=new Qu,this.indexArray=new rl,this.indexArrayForConflation=new rl,this.segmentsBucket=new to}}class Rce{constructor(c){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new to,this.entranceBloom=new Oce;const h=66560;this.layoutVertexArray=new Xu,this.layoutVertexArray.reserve(h),this.layoutNormalArray=new H0,this.layoutNormalArray.reserve(h),this.layoutCentroidArray=new H0,this.layoutCentroidArray.reserve(h),this.layoutColorArray=new Qu,this.layoutColorArray.reserve(h),this.layoutFloodLightDataArray=new Dg,this.layoutFloodLightDataArray.reserve(h),this.layoutAOArray=new ES,this.layoutAOArray.reserve(h),this.indexArray=new rl,this.indexArray.reserve(66560),this.indexArrayForConflation=new rl,this.segmentsBucket=new to,this.entranceBloom=new Oce,c&&(this.layoutFacadePaintArray=new Qu,this.layoutFacadeDataArray=new Jx,this.layoutFacadeVerticalRangeArray=new Qu)}reserve(c,h,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(h),y&&(this.layoutFacadePaintArray.reserveForAdditional(c),this.layoutFacadeDataArray.reserveForAdditional(c),this.layoutFacadeVerticalRangeArray.reserveForAdditional(c))}}class Q2e{constructor(c){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new of,this.footprintsIndices=new Dg,this.footprintsMin=new dr(1/0,1/0),this.footprintsMax=new dr(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Rce(!1),this.buildingWithFacade=new Rce(!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(h=>h.fqid),this.index=c.index,this.hasPattern=!1,this.worldview=c.worldview,this.lut=c.lut,this.programConfigurations=new gm(c.layers,{zoom:c.zoom,lut:c.lut}),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.projection=c.projection,this.groundEffect=new vce(c),this.groundEffect.groundRadiusArray=new up,this.hasAppearances=null}updateFootprints(c,h){const y=new iD([],[],1),b={vertices:[],indices:new Uint32Array(0),grid:y,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};h.push({footprint:b,id:c})}updateAppearances(c,h,y,b){}prepare(){return function(){if(mD!=null||I2e!=null)return null;if(KS!=null)return KS;const c=fetch(Gn.BUILDING_GEN_URL);return KS=function(h){let y,b,M,E,L;function z(){y=new Uint8Array(L.buffer),b=new Int16Array(L.buffer),M=new Int32Array(L.buffer),E=new Float32Array(L.buffer)}function V(){throw new Error("Unexpected BuildingGen error.")}const Z=()=>{},Q={a:{a:V,f:function(ee){const ne=y.length,le=Math.max(ee>>>0,Math.ceil(1.2*ne)),xe=Math.ceil((le-ne)/65536);try{return L.grow(xe),z(),!0}catch{return!1}},g:V,b:Z,c:Z,d:Z,e:Z}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(h,Q):h.then(ee=>ee.arrayBuffer()).then(ee=>WebAssembly.instantiate(ee,Q))).then(ee=>{const ne=ee.instance.exports;return(0,ne.g)(),L=ne.f,z(),new fQe({setStyle:ne.h,setAOOptions:ne.i,setMetricOptions:ne.j,setStructuralOptions:ne.k,setFacadeOptions:ne.l,setFauxFacadeOptions:ne.m,setFacadeClassifierOptions:ne.n,addFeature:ne.o,addFacade:ne.p,generateMesh:ne.q,getLastError:ne.r,getOuterRingLength:ne.s,getMeshCount:ne.t,getPositionsPtr:ne.u,getPositionsLength:ne.v,getNormalsPtr:ne.w,getNormalsLength:ne.x,getAOPtr:ne.y,getAOLength:ne.z,getUVPtr:ne.A,getUVLength:ne.B,getFauxFacadePtr:ne.C,getFauxFacadeLength:ne.D,getIndicesPtr:ne.E,getIndicesLength:ne.F,getBuildingPart:ne.G,getRingCount:ne.H,getRingPtr:ne.I,getRingLength:ne.J,malloc:ne.K,free:ne.L,heapU8:y,heap16:b,heap32:M,heapF32:E})})}(c).then(h=>(KS=null,mD=h,mD)).catch(h=>{ts("Could not load building-gen"),KS=null,I2e=h}),KS}()}populate(c,h,y,b){const M=pQe();if(!M)return;const E=Oe(y);this.tileToMeter=E,this.brightness=h.brightness,M.setStyle({normalScale:[1,-1,E],tileToMeters:E}),M.setAOOptions(!1,.3),M.setMetricOptions(!1,16),M.setStructuralOptions(!0),M.setFacadeClassifierOptions(3);const L=new Map,z=new Map;let V=0;for(const{feature:Ne}of c){if(X2e[Ne.type]!=="LineString"){L.set(Ne.id,Ne.properties.source_id);continue}const Fe=this.layers[0]._featureFilter.needGeometry;if(Fe&&!this.layers[0]._featureFilter.filter(new bi(this.zoom),Ne,y))continue;const Be=Bt(Ne,Fe);if(!Fe&&!this.layers[0]._featureFilter.filter(new bi(this.zoom),Be,y))continue;const Je=Fe?Be.geometry:At(Ne,y,b),yt=[];for(const Rt of Je)for(const tr of Rt)yt.push(tr.x),yt.push(tr.y);const mt={coordinates:yt,crossPerc:Ne.properties.cross_perc,distanceToRoad:Ne.properties.distance_to_road,entrances:Ne.properties.entrances,sourceId:0},kt=Ne.properties.source_id;let It=z.get(kt);It||(It=[],z.set(kt,It)),It.push(mt),++V}this.maxHeight=0;const Z=new Array,Q=new Set,ee=Ne=>{Ne!=null&&Q.add(Ne)},ne=(Ne,Fe)=>{Ne!=null&&Z.push({buildingId:Ne,footprintIndex:Fe})},le=64*(c.length-V),xe=le/2;this.buildingWithFacade.reserve(le,xe,!0),this.buildingWithoutFacade.reserve(2*le,2*xe,!1),this.footprintsIndices.reserve(16*(c.length-V)),this.footprintsVertices.reserve(8*(c.length-V));for(const{feature:Ne,id:Fe,index:Be,sourceLayerIndex:Je}of c){if(X2e[Ne.type]==="LineString")continue;const yt=this.layers[0]._featureFilter.needGeometry;if(yt&&!this.layers[0]._featureFilter.filter(new bi(this.zoom),Ne,y))continue;let mt=null;if(Ne.properties&&Ne.properties.hasOwnProperty("building_id")&&(mt=Ne.properties.building_id,Q.has(mt)))continue;const kt=Bt(Ne,yt);if(!yt&&!this.layers[0]._featureFilter.filter(new bi(this.zoom),kt,y))continue;const It=yt?kt.geometry:At(Ne,y,b),Rt=xT(It,500);let tr=!1;for(const zs of Rt)if(zs.length!==1){tr=!0;break}if(tr){ee(mt);continue}if(!UQe(It,163)){ee(mt);continue}const $t=this.layers[0],or=VQe($t.layout.get("building-roof-shape").evaluate(Ne,{},y)),mr=$t.layout.get("building-base").evaluate(Ne,{},y),fr=$t.layout.get("building-height").evaluate(Ne,{},y),wr=$t.layout.get("building-flood-light-ground-radius").evaluate(Ne,{},y),kr=$t.paint.get("building-ambient-occlusion-intensity"),xr=wr/this.tileToMeter;Ne.properties["building-part"]="roof";const _r=$t.paint.get("building-color").evaluate(Ne,{},this.canonical).toPremultipliedRenderColor(this.lut),ir=$t.paint.get("building-emissive-strength").evaluate(Ne,{},this.canonical);Ne.properties["building-part"]="wall";const sr=$t.paint.get("building-color").evaluate(Ne,{},this.canonical).toPremultipliedRenderColor(this.lut),br=$t.paint.get("building-emissive-strength").evaluate(Ne,{},this.canonical);Ne.properties["building-part"]="window";const Vr=$t.paint.get("building-color").evaluate(Ne,{},this.canonical).toPremultipliedRenderColor(this.lut),Ar=$t.paint.get("building-emissive-strength").evaluate(Ne,{},this.canonical);Ne.properties["building-part"]="door";const Ns=$t.paint.get("building-color").evaluate(Ne,{},this.canonical).toPremultipliedRenderColor(this.lut),Jr=$t.paint.get("building-emissive-strength").evaluate(Ne,{},this.canonical);let as=$t.layout.get("building-flood-light-wall-radius").evaluate(Ne,{},y);as=ye(as,0,2048);const xs=as/2048*bD,In=L.get(Fe),Pr=z.get(In)||[],ys=Pr.length!==0&&$t.layout.get("building-facade").evaluate(Ne,{},y);M.setFacadeOptions(4,!0),M.setFauxFacadeOptions(ys,!1,1);let sn=0,na=0,ca=0,_n=0,ei=0,pt=0,vt=0,lr=0,jr=0,Zr=0,Yr=0;if(ys){let zs=Math.round($t.layout.get("building-facade-floors").evaluate(Ne,{},y));if(mr===0){zs=Math.max(1,zs-(Pr.length>0?1:0));let Wa=4;if(fr>100){const Oi=[10,13,15];Wa=Oi[Ne.id?Ne.id%Oi.length:0]}else fr<=10&&(Wa=3);M.setFacadeOptions(Wa,!0),ei=(fr<15?1.3:1.61803)*Wa/E}else ei=mr/E;pt=fr/E,ei=Math.min(ei,pt),ca=$t.layout.get("building-facade-unit-width").evaluate(Ne,{},y)/E,_n=(pt-ei)/zs,M.setFauxFacadeOptions(!0,!0,ca);const no=$t.layout.get("building-facade-window").evaluate(Ne,{},y);sn=no[0],na=no[1],vt=Math.floor(65535*Math.min(1,ei/Br)),lr=Math.floor(65535*Math.min(1,pt/Br)),jr=Math.floor(255*sn)<<8|Math.floor(255*na),Zr=Math.floor(65535*Math.min(1,ca/Br)),Yr=Math.floor(65535*Math.min(1,_n/Br))}const Ms=Array(Rt.length),Es={x:1/0,y:1/0},xn={x:-1/0,y:-1/0},Sn={x:0,y:0};let En=0;for(let zs=0;zs0){const Wa=[],Oi=Array(no.length+1);Oi[0]=0;for(let al=0;alBr||Es.y<0||xn.y>Br)&&this.featuresOnBorder.push({featureId:Ne.id,footprintIndex:this.footprints.length});{const zs=VS(ni,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+zs.length),this.footprintsIndices.uint16.set(zs,Fs),this.buildingIds.add(mt??Ne.id),this.footprintsMin.x=Math.min(this.footprintsMin.x,pi.x),this.footprintsMin.y=Math.min(this.footprintsMin.y,pi.y),this.footprintsMax.x=Math.max(this.footprintsMax.x,wi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,wi.y);const no={footprintVertexOffset:Jn,footprintVertexLength:this.footprintsVertices.length-Jn,footprintIndexOffset:Fs,footprintIndexLength:this.footprintsIndices.length-Fs,min:pi,max:wi,hiddenFlags:0,indicesOffset:Fa,indicesLength:Hi,bloomIndicesOffset:Ha,bloomIndicesLength:ci,groundEffectVertexOffset:Co,groundEffectVertexLength:yi,hasFauxFacade:ys,height:Cn,promoteId:Fe,feature:kt,parts:ka,buildingBloom:Na},Wa=this.footprints.length;Ne.id!==void 0&&this.featureFootprintLookup.set(Ne.id,Wa),ne(mt,Wa),this.footprints.push(no)}this.programConfigurations.populatePaintArrays(Bs.layoutVertexArray.length,Ne,Be,{},h.availableImages,y,h.brightness),this.groundEffect.addPaintPropertiesData(Ne,Be,{},h.availableImages,y,h.brightness),h.featureIndex.insert(Ne,It,Be,Je,this.index,ti)}Z.forEach(({buildingId:Ne,footprintIndex:Fe})=>{Q.has(Ne)&&(this.footprints[Fe].hiddenFlags|=4)});const Ce=new Set;this.buildingIds.forEach((Ne,Fe,Be)=>{Q.has(Ne)||Ce.add(Ne)}),this.buildingIds=Ce,this.groundEffect.prepareBorderSegments()}update(c,h,y,b,M,E,L){this.programConfigurations.updatePaintArrays(c,h,M,y,b,E,L),this.groundEffect.update(c,h,M,y,b,E,L),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 h=y=>{y.layoutVertexBuffer=c.createVertexBuffer(y.layoutVertexArray,Z2e.members),y.layoutNormalBuffer=c.createVertexBuffer(y.layoutNormalArray,DQe.members),y.layoutCentroidBuffer=c.createVertexBuffer(y.layoutCentroidArray,OQe.members),y.layoutFloodLightDataBuffer=c.createVertexBuffer(y.layoutFloodLightDataArray,$Qe.members),y.layoutFacadeDataArray&&y.layoutFacadeDataArray.length&&(y.layoutFacadeDataBuffer=c.createVertexBuffer(y.layoutFacadeDataArray,FQe.members)),y.layoutFacadeVerticalRangeArray&&y.layoutFacadeVerticalRangeArray.length&&(y.layoutFacadeVerticalRangeBuffer=c.createVertexBuffer(y.layoutFacadeVerticalRangeArray,zQe.members)),y.entranceBloom.layoutVertexArray.length&&(y.entranceBloom.layoutVertexBuffer=c.createVertexBuffer(y.entranceBloom.layoutVertexArray,Z2e.members),y.entranceBloom.layoutAttenuationBuffer=c.createVertexBuffer(y.entranceBloom.layoutAttenuationArray,BQe.members)),this.uploadUpdatedColorBuffer(c),this.uploadUpdatedIndexBuffer(c)};this.uploaded||(h(this.buildingWithoutFacade),h(this.buildingWithFacade),this.groundEffect.upload(c)),this.groundEffect.uploadPaintProperties(c),this.programConfigurations.upload(c),this.uploaded=!0}destroy(){const c=h=>{h.layoutVertexBuffer&&(h.layoutVertexBuffer.destroy(),h.layoutNormalBuffer.destroy(),h.layoutColorBuffer.destroy(),h.segmentsBucket.destroy(),h.indexBuffer&&h.indexBuffer.destroy(),h.entranceBloom.layoutVertexBuffer&&(h.entranceBloom.layoutVertexBuffer.destroy(),h.entranceBloom.layoutColorBuffer.destroy(),h.entranceBloom.layoutAttenuationBuffer.destroy(),h.entranceBloom.indexBuffer.destroy(),h.entranceBloom.segmentsBucket.destroy()))};c(this.buildingWithoutFacade),c(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(c,h,y=!0){let b=!1;const M=y?h:0,E=0|(y?-1:~h);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const L of c){const z=this.footprints[L],V=z.hiddenFlags&E|M;z.hiddenFlags!==V&&(z.hiddenFlags=V,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 h=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))};h(this.buildingWithoutFacade),h(this.buildingWithFacade);for(const b of this.footprints){const M=b.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,E=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 h=y=>{y.layoutColorBuffer?y.layoutColorBuffer.updateData(y.layoutColorArray):y.layoutColorBuffer=c.createVertexBuffer(y.layoutColorArray,Y2e.members,!0),y.layoutFacadePaintArray&&(y.layoutFacadePaintBuffer?y.layoutFacadePaintBuffer.updateData(y.layoutFacadePaintArray):y.layoutFacadePaintBuffer=c.createVertexBuffer(y.layoutFacadePaintArray,RQe.members,!0)),y.entranceBloom.layoutColorBuffer?y.entranceBloom.layoutColorBuffer.updateData(y.entranceBloom.layoutColorArray):y.entranceBloom.layoutColorBuffer=c.createVertexBuffer(y.entranceBloom.layoutColorArray,Y2e.members,!0)};h(this.buildingWithoutFacade),h(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(c,h){const y=c.paint.get("building-ambient-occlusion-intensity");for(const b of this.footprints){if(4&b.hiddenFlags)continue;const M=h[b.promoteId],E=b.feature;E.properties["building-part"]="roof";const L=c.paint.get("building-color").evaluate(E,M,this.canonical).toPremultipliedRenderColor(this.lut),z=c.paint.get("building-emissive-strength").evaluate(E,M,this.canonical);E.properties["building-part"]="wall";const V=c.paint.get("building-color").evaluate(E,M,this.canonical).toPremultipliedRenderColor(this.lut),Z=c.paint.get("building-emissive-strength").evaluate(E,M,this.canonical);E.properties["building-part"]="window";const Q=c.paint.get("building-color").evaluate(E,M,this.canonical).toPremultipliedRenderColor(this.lut),ee=c.paint.get("building-emissive-strength").evaluate(E,M,this.canonical);E.properties["building-part"]="door";const ne=c.paint.get("building-color").evaluate(E,M,this.canonical).toPremultipliedRenderColor(this.lut),le=c.paint.get("building-emissive-strength").evaluate(E,M,this.canonical),xe=b.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const Ne of b.parts){let Fe,Be=L;Ne.part===1?(Be=L,Fe=z):Ne.part===0?(Be=V,Fe=Z):Ne.part===2?(Be=Q,Fe=ee):Ne.part===3&&(Be=ne,Fe=le),Fe=ye(Fe,0,1);for(let Je=0;JeE.max.x||z.max.xE.max.y||z.max.yL.max.x||L.min.x>c||h>L.max.y||L.min.y>h||L.height<=y||qQe(E,this.footprintsVertices.float32.subarray(2*L.footprintVertexOffset,2*(L.footprintVertexOffset+L.footprintVertexLength)),this.footprintsIndices.uint16.subarray(L.footprintIndexOffset,L.footprintIndexOffset+L.footprintIndexLength))&&(y=L.height,this.footprintLookup[M]=L,b=L.hiddenFlags!==0);if(y!==Number.NEGATIVE_INFINITY)return{height:y,hidden:b};this.footprintLookup[M]=void 0}}function qQe(f,c,h){for(let y=0;y1&&(z=c[++L]);const Z=Math.abs(V-z.left),Q=Math.abs(V-z.right),ee=Math.min(Z,Q);let ne;const le=M/y*(b+1);if(z.isDash){const xe=b-Math.abs(le);ne=Math.sqrt(ee*ee+xe*xe)}else ne=b-Math.sqrt(ee*ee+le*le);this.image.data[E+V]=Math.max(0,Math.min(255,ne+128))}}}addRegularDash(c,h){for(let z=c.length-1;z>=0;--z){const V=c[z],Z=c[z+1];V.zeroLength?c.splice(z,1):Z&&Z.isDash===V.isDash&&(Z.left=V.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 M=this.width*this.nextRow;let E=0,L=c[E];for(let z=0;z1&&(L=c[++E]);const V=Math.abs(z-L.left),Z=Math.abs(z-L.right),Q=Math.min(V,Z);this.image.data[M+z]=Math.max(0,Math.min(255,(L.isDash?Q:-Q)+h+128))}}addDash(c,h){const y=this.getKey(c,h);if(this.positions[y])return this.positions[y];const b=h==="round",M=b?7:0,E=2*M+1;if(this.nextRow+E>this.height)return ts("LineAtlas out of space"),null;c.length===0&&c.push(1);let L=0;for(let Z=0;Zh.fqid),this.index=c.index,this.projection=c.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(h=>{this.gradients[h.id]={}}),this.layoutVertexArray=new kS,this.layoutVertexArray2=new Xu,this.patternVertexArray=new Xu,this.indexArray=new rl,this.programConfigurations=new gm(c.layers,{zoom:c.zoom,lut:c.lut}),this.segments=new to,this.maxLineLength=0,this.zOffsetVertexArray=new Xu,this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.id),this.tessellationStep=c.tessellationStep?c.tessellationStep:Br/64,this.worldview=c.worldview,this.hasAppearances=null}updateFootprints(c,h){}updateAppearances(c,h,y,b){}populate(c,h,y,b){this.hasPattern=dce("line",this.layers,this.pixelRatio,h);const M=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Oe(y);const E=this.layers[0].layout.get("line-elevation-reference");if(E==="hd-road-markup")this.elevationType="road";else{const ee=this.layers[0].layout.get("line-z-offset"),ne=ee.isConstant()&&!ee.constantOr(0);this.elevationType=E!=="sea"&&E!=="ground"&&ne?"none":"offset",this.elevationType==="offset"&&E==="none"&&ts(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const L=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&L!==void 0;const z=[];for(const{feature:ee,id:ne,index:le,sourceLayerIndex:xe}of c){const Ce=this.layers[0]._featureFilter.needGeometry,Ne=Bt(ee,Ce);if(!this.layers[0]._featureFilter.filter(new bi(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Ne,y))continue;const Fe=M?M.evaluate(Ne,{},y):void 0,Be={id:ne,properties:ee.properties,type:ee.type,sourceLayerIndex:xe,index:le,geometry:Ce?Ne.geometry:At(ee,y,b),patterns:{},sortKey:Fe};z.push(Be)}M&&z.sort((ee,ne)=>ee.sortKey-ne.sortKey);const{lineAtlas:V,featureIndex:Z}=h,Q=this.addConstantDashes(V);for(const ee of z){const{geometry:ne,index:le,sourceLayerIndex:xe}=ee;if(Q&&this.addFeatureDashes(ee,V),this.hasPattern){const Ce=uce("line",this.layers,ee,this.zoom,this.pixelRatio,h);this.patternFeatures.push(Ce)}else this.addFeature(ee,ne,le,y,V.positions,h.availableImages,h.brightness,h.elevationFeatures);Z.insert(c[le].feature,ne,le,xe,this.index)}}addConstantDashes(c){let h=!1;for(const y of this.layers){const b=y.paint.get("line-dasharray").value,M=y.layout.get("line-cap").value;if(b.kind!=="constant"||M.kind!=="constant")h=!0;else{const E=M.value,L=b.value;if(!L)continue;c.addDash(L,E)}}return h}addFeatureDashes(c,h){const y=this.zoom;for(const b of this.layers){const M=b.paint.get("line-dasharray").value,E=b.layout.get("line-cap").value;if(M.kind==="constant"&&E.kind==="constant")continue;let L,z;if(M.kind==="constant"){if(L=M.value,!L)continue}else L=M.evaluate({zoom:y},c);z=E.kind==="constant"?E.value:E.evaluate({zoom:y},c),h.addDash(L,z),c.patterns[b.id]=[h.getKey(L,z)]}}update(c,h,y,b,M,E,L,z){this.programConfigurations.updatePaintArrays(c,h,M,y,b,E,L,z)}addFeatures(c,h,y,b,M,E){for(const L of this.patternFeatures)this.addFeature(L,L.geometry,L.index,h,y,b,E,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,YQe)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=c.createVertexBuffer(this.patternVertexArray,QQe)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,GQe.members,!0)),this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,KQe),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,h){let y,b;if(h&&h>0?(y=`mapbox_clip_start_${h}`,b=`mapbox_clip_end_${h}`):(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,h,y,b,M,E,L,z){const V=this.layers[0].layout,Z=V.get("line-join").evaluate(c,{}),Q=V.get("line-cap").evaluate(c,{}),ee=V.get("line-miter-limit"),ne=V.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=V.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 Ce=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(c,h,b,z,Z,Q,ee,ne)){const[Ne,Fe]=this.clipRuntimeLinesToTile(h,1);for(let Be=0;Be0?yt.parentIndex:null)}this.fillNonElevatedRoadSegment(Ce)}}else for(let Ce=0;Ce0?Ce:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,c,y,M,E,b,L,void 0,this.worldview)}computeSegNextDir(c,h){return c.nextPoint.sub(h.at(-2)).unit()}computeSegPrevDir(c,h){return h[1].sub(c.prevPoint).unit()}clipLinesToTile(c,h){return uD(c,-h,-h,Br+h,Br+h)}clipRuntimeLinesToTile(c,h){const y=[];return[uD(c,-h,-h,Br+h,Br+h,y),y]}addElevatedRoadFeature(c,h,y,b,M,E,L,z){const V=[],Z=Oa.getElevationFeature(c,b);if(Z){const Q=this.clipLinesToTile(h,1),ee=this.prepareElevatedLines(Q,Z,y);for(const ne of ee)V.push({geometry:ne,elevation:Z,elevationTileID:y,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(V.length===0)return!1;for(const Q of V){const ee=this.layoutVertexArray.length;this.addLine(Q.geometry,c,y,M,E,L,z);const ne=new Xa(y,Q.elevationTileID);if(Q.elevation)for(let le=ee;le>1,this.layoutVertexArray.int16[6*le+1]>>1),Ce=ne.pointElevation(xe,Q.elevation,.05);this.updateHeightRange(Ce),this.zOffsetVertexArray.emplaceBack(Ce,0,0)}else this.fillNonElevatedRoadSegment(ee)}return!0}prepareElevatedLines(c,h,y){if(h.constantHeight!=null)return c;const b=[],M=1/Oe(y);for(const E of c)uQe(E,new ja(h,M),0,b);return b}fillNonElevatedRoadSegment(c){for(let h=c;h0,ee=z&&z.progress.max<1;if(this.lineClips){let Rt={min:this.lineClips.start,max:this.lineClips.end},tr=1;if(z){const mr=this.lineClips.end-this.lineClips.start;Rt=function(fr,wr,kr){return{min:Ja(fr.min,wr,kr),max:Ja(fr.max,wr,kr)}}(z.progress,{min:0,max:1},Rt),mr>0&&(tr=(Rt.max-Rt.min)/mr)}const $t=+h.properties.mapbox_clip_feature_len,or=+h.properties.mapbox_clip_seg_len;if(Number.isNaN($t)||Number.isNaN(or)){for(let fr=0;fr=2&&c[le-1].equals(c[le-2]);)le--;let xe=0;for(;xe0,ir=this.overscaling<=16?15*Br/(512*this.overscaling):0;if(tr&&$t==="round"){if(wrE&&($t="bevel"),$t==="bevel"&&(wr>2&&($t="flipbevel"),wr2*ir){const Vr=Ne.sub(Ne.sub(Fe)._mult(ir/sr)._round());this.updateDistance(Fe,Vr),this.addCurrentVertex(Vr,Je,0,0,Ce,It),Fe=Vr}this.updateDistance(Fe,Ne),mr._mult(wr),this.addCurrentVertex(Ne,mr,0,0,Ce,It);const br=Ne.dist(Be);if(br>2*ir){const Vr=Ne.add(Be.sub(Ne)._mult(ir/br)._round());this.updateDistance(Ne,Vr),this.addCurrentVertex(Vr,yt,0,0,Ce,It),Ne=Vr}}else mr._mult(wr),this.addCurrentVertex(Ne,mr,0,0,Ce,It);else if($t==="flipbevel"){if(wr>100)mr=yt.mult(-1);else{const sr=wr*Je.add(yt).mag()/Je.sub(yt).mag();mr._perp()._mult(sr*(_r?-1:1))}this.addCurrentVertex(Ne,mr,0,0,Ce,It),this.addCurrentVertex(Ne,mr.mult(-1),0,0,Ce,It)}else if($t==="bevel"||$t==="fakeround"){It!=null&&Fe&&this.addCurrentVertex(Ne,kt||Je,-1,-1,Ce,It);const sr=Ne.dist(Fe)<=2*ir&&$t!=="bevel",br=mr.mult(_r?1:-1);br._mult(wr);const Vr=yt.mult(_r?-1:1),Ar=Je.mult(_r?-1:1),Ns=this.evaluateLineProgressFeatures(this.distance);if(It==null&&(this.addHalfVertex(Ne,br.x,br.y,!1,!_r,0,Ce,Ns),sr||this.addHalfVertex(Ne,br.x+2*Ar.x,br.y+2*Ar.y,!1,_r,0,Ce,Ns)),$t==="fakeround"){const Jr=Math.round(180*kr/Math.PI/20);this.addHalfVertex(Ne,Ar.x,Ar.y,!1,_r,0,Ce,Ns);for(let as=0;as1){this.lineSoFar=c.w;const xe=(h.x-c.x)/Q,Ce=(h.y-c.y)/Q,Ne=(h.z-c.z)/Q,Fe=(h.w-c.w)/Q;for(let Be=1;Be=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,Z),z.primitiveLength++),E?this.e2=Z:this.e1=Z,V!=null&&this.zOffsetVertexArray.emplaceBack(V.zOffset,V.variableWidth,V.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,h){this.prevDistance=this.distance,this.distance+=c.dist(h),this.updateScaledDistance()}}function zce(f,c,h){return f.xh||f.yh}let rje,sje;function nje(f,c,h){return c*(Br/(f.tileSize*Math.pow(2,h-f.tileID.overscaledZ)))}ms(Fce,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const aje=(f,c,h)=>(1-h)*f+h*c;function ije(f,c){return 1/nje(f,1,c.tileZoom)}function oje(f,c,h,y){return f.translatePosMatrix(y||c.tileID.projMatrix,c,h.paint.get("line-translate"),h.paint.get("line-translate-anchor"))}const lje=f=>{const c=[];cje(f)&&c.push("RENDER_LINE_DASH"),f.paint.get("line-gradient")&&c.push("RENDER_LINE_GRADIENT");const h=f.paint.get("line-trim-offset");h[0]===0&&h[1]===0||c.push("RENDER_LINE_TRIM_OFFSET"),f.paint.get("line-border-width").constantOr(1)!==0&&c.push("RENDER_LINE_BORDER");const y=f.layout.get("line-join").constantOr("miter")==="none",b=!!f.paint.get("line-pattern").constantOr(1);return y&&b&&c.push("LINE_JOIN_NONE"),c};function cje(f){const c=f.paint.get("line-dasharray").value;return c.kind!=="constant"||c.value}let Bce;const dje=()=>Bce||(Bce={layout:rje||(rje=new mo({"line-cap":new Wr(qt.layout_line["line-cap"]),"line-join":new Wr(qt.layout_line["line-join"]),"line-miter-limit":new Dr(qt.layout_line["line-miter-limit"]),"line-round-limit":new Dr(qt.layout_line["line-round-limit"]),"line-sort-key":new Wr(qt.layout_line["line-sort-key"]),"line-z-offset":new Wr(qt.layout_line["line-z-offset"]),"line-elevation-reference":new Dr(qt.layout_line["line-elevation-reference"]),"line-cross-slope":new Dr(qt.layout_line["line-cross-slope"]),visibility:new Dr(qt.layout_line.visibility),"line-width-unit":new Dr(qt.layout_line["line-width-unit"])})),paint:sje||(sje=new mo({"line-opacity":new Wr(qt.paint_line["line-opacity"]),"line-color":new Wr(qt.paint_line["line-color"]),"line-translate":new Dr(qt.paint_line["line-translate"]),"line-translate-anchor":new Dr(qt.paint_line["line-translate-anchor"]),"line-width":new Wr(qt.paint_line["line-width"]),"line-gap-width":new Wr(qt.paint_line["line-gap-width"]),"line-offset":new Wr(qt.paint_line["line-offset"]),"line-blur":new Wr(qt.paint_line["line-blur"]),"line-dasharray":new Wr(qt.paint_line["line-dasharray"]),"line-pattern":new Wr(qt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Dr(qt.paint_line["line-pattern-cross-fade"]),"line-gradient":new Yx(qt.paint_line["line-gradient"]),"line-trim-offset":new Dr(qt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Dr(qt.paint_line["line-trim-fade-range"]),"line-trim-color":new Dr(qt.paint_line["line-trim-color"]),"line-emissive-strength":new Wr(qt.paint_line["line-emissive-strength"]),"line-border-width":new Wr(qt.paint_line["line-border-width"]),"line-border-color":new Wr(qt.paint_line["line-border-color"]),"line-occlusion-opacity":new Dr(qt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"})}))},Bce);class rJe extends Wr{possiblyEvaluate(c,h){return h=new bi(Math.floor(h.zoom),{now:h.now,fadeDuration:h.fadeDuration,transition:h.transition,worldview:h.worldview}),super.possiblyEvaluate(c,h)}evaluate(c,h,y,b){return h=Object.assign({},h,{zoom:Math.floor(h.zoom)}),super.evaluate(c,h,y,b)}}let TT;function uje(f,c){return c>0?c+2*f:f}const sJe=Xn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),nJe=Xn([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),aJe=Xn([{name:"a_projected_pos",components:4,type:"Float32"}],4);Xn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const iJe=Xn([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),oJe=Xn([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),lJe=Xn([{name:"a_texb",components:2,type:"Uint16"}]),cJe=Xn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),dJe=Xn([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);Xn([{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 hje=Xn([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),uJe=Xn([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Xn([{name:"triangle",components:3,type:"Uint16"}]),Xn([{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"}]),Xn([{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"}]),Xn([{type:"Float32",name:"offsetX"}]),Xn([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Tl=24;function hJe(f,c,h){return f.sections.forEach(y=>{y.text=function(b,M,E){const L=M.layout.get("text-transform").evaluate(E,{});return L==="uppercase"?b=b.toLocaleUpperCase():L==="lowercase"&&(b=b.toLocaleLowerCase()),dp.applyArabicShaping&&(b=dp.applyArabicShaping(b)),b}(y.text,c,h)}),f}const AT={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function mJe(f){return f==="︶"||f==="﹈"||f==="︸"||f==="﹄"||f==="﹂"||f==="︾"||f==="︼"||f==="︺"||f==="︘"||f==="﹀"||f==="︐"||f==="︓"||f==="︔"||f==="`"||f===" ̄"||f==="︑"||f==="︒"}function fJe(f){return f==="︵"||f==="﹇"||f==="︷"||f==="﹃"||f==="﹁"||f==="︽"||f==="︻"||f==="︹"||f==="︗"||f==="︿"}const $ce=4294967296,mje=1/$ce,fje=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let wD=class{constructor(f=new Uint8Array(16)){this.buf=ArrayBuffer.isView(f)?f:new Uint8Array(f),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(f,c,h=this.length){for(;this.pos>3,M=this.pos;this.type=7&y,f(b,c,this),this.pos===M&&this.skip(y)}return c}readMessage(f,c){return this.readFields(f,c,this.readVarint()+this.pos)}readFixed32(){const f=this.dataView.getUint32(this.pos,!0);return this.pos+=4,f}readSFixed32(){const f=this.dataView.getInt32(this.pos,!0);return this.pos+=4,f}readFixed64(){const f=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*$ce;return this.pos+=8,f}readSFixed64(){const f=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*$ce;return this.pos+=8,f}readFloat(){const f=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,f}readDouble(){const f=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,f}readVarint(f){const c=this.buf;let h,y;return y=c[this.pos++],h=127&y,y<128?h:(y=c[this.pos++],h|=(127&y)<<7,y<128?h:(y=c[this.pos++],h|=(127&y)<<14,y<128?h:(y=c[this.pos++],h|=(127&y)<<21,y<128?h:(y=c[this.pos],h|=(15&y)<<28,function(b,M,E){const L=E.buf;let z,V;if(V=L[E.pos++],z=(112&V)>>4,V<128||(V=L[E.pos++],z|=(127&V)<<3,V<128)||(V=L[E.pos++],z|=(127&V)<<10,V<128)||(V=L[E.pos++],z|=(127&V)<<17,V<128)||(V=L[E.pos++],z|=(127&V)<<24,V<128)||(V=L[E.pos++],z|=(1&V)<<31,V<128))return YS(b,z,M);throw new Error("Expected varint not more than 10 bytes")}(h,f,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const f=this.readVarint();return f%2==1?(f+1)/-2:f/2}readBoolean(){return!!this.readVarint()}readString(){const f=this.readVarint()+this.pos,c=this.pos;return this.pos=f,f-c>=12&&fje?fje.decode(this.buf.subarray(c,f)):function(h,y,b){let M="",E=y;for(;E239?4:L>223?3:L>191?2:1;if(E+ee>b)break;ee===1?L<128&&(Q=L):ee===2?(z=h[E+1],(192&z)==128&&(Q=(31&L)<<6|63&z,Q<=127&&(Q=null))):ee===3?(z=h[E+1],V=h[E+2],(192&z)==128&&(192&V)==128&&(Q=(15&L)<<12|(63&z)<<6|63&V,(Q<=2047||Q>=55296&&Q<=57343)&&(Q=null))):ee===4&&(z=h[E+1],V=h[E+2],Z=h[E+3],(192&z)==128&&(192&V)==128&&(192&Z)==128&&(Q=(15&L)<<18|(63&z)<<12|(63&V)<<6|63&Z,(Q<=65535||Q>=1114112)&&(Q=null))),Q===null?(Q=65533,ee=1):Q>65535&&(Q-=65536,M+=String.fromCharCode(Q>>>10&1023|55296),Q=56320|1023&Q),M+=String.fromCharCode(Q),E+=ee}return M}(this.buf,c,f)}readBytes(){const f=this.readVarint()+this.pos,c=this.buf.subarray(this.pos,f);return this.pos=f,c}readPackedVarint(f=[],c){const h=this.readPackedEnd();for(;this.pos127;);else if(c===2)this.pos=this.readVarint()+this.pos;else if(c===5)this.pos+=4;else{if(c!==1)throw new Error(`Unimplemented type: ${c}`);this.pos+=8}}writeTag(f,c){this.writeVarint(f<<3|c)}realloc(f){let c=this.length||16;for(;c268435455||f<0?function(c,h){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");h.realloc(10),function(M,E,L){L.buf[L.pos++]=127&M|128,M>>>=7,L.buf[L.pos++]=127&M|128,M>>>=7,L.buf[L.pos++]=127&M|128,M>>>=7,L.buf[L.pos++]=127&M|128,L.buf[L.pos]=127&(M>>>=7)}(y,0,h),function(M,E){const L=(7&M)<<4;E.buf[E.pos++]|=L|((M>>>=3)?128:0),M&&(E.buf[E.pos++]=127&M|((M>>>=7)?128:0),M&&(E.buf[E.pos++]=127&M|((M>>>=7)?128:0),M&&(E.buf[E.pos++]=127&M|((M>>>=7)?128:0),M&&(E.buf[E.pos++]=127&M|((M>>>=7)?128:0),M&&(E.buf[E.pos++]=127&M)))))}(b,h)}(f,this):(this.realloc(4),this.buf[this.pos++]=127&f|(f>127?128:0),f<=127||(this.buf[this.pos++]=127&(f>>>=7)|(f>127?128:0),f<=127||(this.buf[this.pos++]=127&(f>>>=7)|(f>127?128:0),f<=127||(this.buf[this.pos++]=f>>>7&127))))}writeSVarint(f){this.writeVarint(f<0?2*-f-1:2*f)}writeBoolean(f){this.writeVarint(+f)}writeString(f){f=String(f),this.realloc(4*f.length),this.pos++;const c=this.pos;this.pos=function(y,b,M){for(let E,L,z=0;z55295&&E<57344){if(!L){E>56319||z+1===b.length?(y[M++]=239,y[M++]=191,y[M++]=189):L=E;continue}if(E<56320){y[M++]=239,y[M++]=191,y[M++]=189,L=E;continue}E=L-55296<<10|E-56320|65536,L=null}else L&&(y[M++]=239,y[M++]=191,y[M++]=189,L=null);E<128?y[M++]=E:(E<2048?y[M++]=E>>6|192:(E<65536?y[M++]=E>>12|224:(y[M++]=E>>18|240,y[M++]=E>>12&63|128),y[M++]=E>>6&63|128),y[M++]=63&E|128)}return M}(this.buf,f,this.pos);const h=this.pos-c;h>=128&&pje(c,h,this),this.pos=c-1,this.writeVarint(h),this.pos+=h}writeFloat(f){this.realloc(4),this.dataView.setFloat32(this.pos,f,!0),this.pos+=4}writeDouble(f){this.realloc(8),this.dataView.setFloat64(this.pos,f,!0),this.pos+=8}writeBytes(f){const c=f.length;this.writeVarint(c),this.realloc(c);for(let h=0;h=128&&pje(h,y,this),this.pos=h-1,this.writeVarint(y),this.pos+=y}writeMessage(f,c,h){this.writeTag(f,2),this.writeRawMessage(c,h)}writePackedVarint(f,c){c.length&&this.writeMessage(f,pJe,c)}writePackedSVarint(f,c){c.length&&this.writeMessage(f,gJe,c)}writePackedBoolean(f,c){c.length&&this.writeMessage(f,vJe,c)}writePackedFloat(f,c){c.length&&this.writeMessage(f,xJe,c)}writePackedDouble(f,c){c.length&&this.writeMessage(f,yJe,c)}writePackedFixed32(f,c){c.length&&this.writeMessage(f,_Je,c)}writePackedSFixed32(f,c){c.length&&this.writeMessage(f,bJe,c)}writePackedFixed64(f,c){c.length&&this.writeMessage(f,wJe,c)}writePackedSFixed64(f,c){c.length&&this.writeMessage(f,jJe,c)}writeBytesField(f,c){this.writeTag(f,2),this.writeBytes(c)}writeFixed32Field(f,c){this.writeTag(f,5),this.writeFixed32(c)}writeSFixed32Field(f,c){this.writeTag(f,5),this.writeSFixed32(c)}writeFixed64Field(f,c){this.writeTag(f,1),this.writeFixed64(c)}writeSFixed64Field(f,c){this.writeTag(f,1),this.writeSFixed64(c)}writeVarintField(f,c){this.writeTag(f,0),this.writeVarint(c)}writeSVarintField(f,c){this.writeTag(f,0),this.writeSVarint(c)}writeStringField(f,c){this.writeTag(f,2),this.writeString(c)}writeFloatField(f,c){this.writeTag(f,5),this.writeFloat(c)}writeDoubleField(f,c){this.writeTag(f,1),this.writeDouble(c)}writeBooleanField(f,c){this.writeVarintField(f,+c)}};function YS(f,c,h){return h?4294967296*c+(f>>>0):4294967296*(c>>>0)+(f>>>0)}function pje(f,c,h){const y=c<=16383?1:c<=2097151?2:c<=268435455?3:Math.floor(Math.log(c)/(7*Math.LN2));h.realloc(y);for(let b=h.pos-1;b>=f;b--)h.buf[b+y]=h.buf[b]}function pJe(f,c){for(let h=0;h=0&&y>=c&&jD[this.text.charCodeAt(y)];y--)h--;this.text=this.text.substring(c,h),this.sectionIndex=this.sectionIndex.slice(c,h)}substring(c,h){const y=new XS;return y.text=this.text.substring(c,h),y.sectionIndex=this.sectionIndex.slice(c,h),y.sections=this.sections,y}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((c,h)=>Math.max(c,this.sections[h].scale),0)}addTextSection(c,h){this.text+=c.text,this.sections.push(ET.forText(c.scale,c.fontStack||h));const y=this.sections.length-1;for(let b=0;b=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Vce(f,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe=1){const Ce=XS.fromFeature(f,b,xe);Q===th.vertical&&Ce.verticalizePunctuation(ee);let Ne=[];const Fe=function(kt,It,Rt,tr,$t,or){if(!kt)return[];const mr=[],fr=function(_r,ir,sr,br,Vr,Ar){let Ns=0;for(let Jr=0;Jr<_r.length();Jr++){const as=_r.getSection(Jr);Ns+=xje(_r.getCodePoint(Jr),as,br,Vr,ir,Ar)}return Ns/Math.max(1,Math.ceil(Ns/sr))}(kt,It,Rt,tr,$t,or),wr=kt.text.indexOf("​")>=0;let kr=0;for(let _r=0;_r0&&Na>_n&&(_n=Na)}else{const _a=Rt[jr.fontStack];if(!_a)continue;_a[Yr]&&(xn=_a[Yr]);const ka=It[jr.fontStack];if(!ka)continue;const Na=ka.glyphs[Yr];if(!Na)continue;if(Es=Na.metrics,En=Yr!==8203?Tl:0,Ar){const Ha=ka.ascender!==void 0?Math.abs(ka.ascender):0,ci=ka.descender!==void 0?Math.abs(ka.descender):0,ti=(Ha+ci)*Ms;ei-h/2;){if(E--,E<0)return!1;L-=f[E].dist(M),M=f[E]}L+=f[E].dist(f[E+1]),E++;const z=[];let V=0;for(;Ly;)V-=z.shift().angleDelta;if(V>b)return!1;E++,L+=Z.dist(Q)}return!0}function Sje(f){let c=0;for(let h=0;hV){const le=(V-z)/ne,xe=Gs(Q.x,ee.x,le),Ce=Gs(Q.y,ee.y,le),Ne=new ny(xe,Ce,0,ee.angleTo(Q),Z);return!E||Nje(f,Ne,L,E,c)?Ne:void 0}z+=ne}}function AJe(f,c,h,y,b,M,E,L,z){const V=Cje(y,M,E),Z=Mje(y,b),Q=Z*E,ee=f[0].x===0||f[0].x===z||f[0].y===0||f[0].y===z;return c-Q=0&&Je=0&&yt=0&&ee+V<=Z){const mt=new ny(Je,yt,0,Fe,le);y&&!Nje(f,mt,M,y,b)||ne.push(mt)}}Q+=Ne}return L||ne.length||E||(ne=Tje(f,Q/2,h,y,b,M,E,!0,z)),ne}function Aje(f){let c=0,h=0;for(const E of f)c+=E.w*E.h,h=Math.max(h,E.w);f.sort((E,L)=>L.h-E.h);const y=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(c/.95)),h),h:1/0}];let b=0,M=0;for(const E of f)for(let L=y.length-1;L>=0;L--){const z=y[L];if(!(E.w>z.w||E.h>z.h)){if(E.x=z.x,E.y=z.y,M=Math.max(M,E.y+E.h),b=Math.max(b,E.x+E.w),E.w===z.w&&E.h===z.h){const V=y.pop();V&&L1?le-1:le,Xc.copy(Q.data,V,{x:0,y:0},{x:xe,y:Ce},Q.data,y),Xc.copy(Q.data,V,{x:0,y:Fe-le},{x:xe,y:Ce-le},{width:Ne,height:le},y),Xc.copy(Q.data,V,{x:0,y:0},{x:xe,y:Ce+Fe},{width:Ne,height:le},y),Xc.copy(Q.data,V,{x:Ne-le,y:0},{x:xe-le,y:Ce},{width:le,height:Fe},y),Xc.copy(Q.data,V,{x:0,y:0},{x:xe+Ne,y:Ce},{width:le,height:Fe},y),Xc.copy(Q.data,V,{x:Ne-le,y:Fe-le},{x:xe-le,y:Ce-le},{width:le,height:le},y),Xc.copy(Q.data,V,{x:0,y:Fe-le},{x:xe+Ne,y:Ce-le},{width:le,height:le},y),Xc.copy(Q.data,V,{x:0,y:0},{x:xe+Ne,y:Ce+Fe},{width:le,height:le},y),Xc.copy(Q.data,V,{x:Ne-le,y:0},{x:xe-le,y:Ce+Fe},{width:le,height:le},y)}this.lut=y,this.image=V,this.iconPositions=b,this.patternPositions=M}addImages(c,h,y,b){for(const[M,E]of c.entries()){const{bin:L,imagePosition:z,imageVariant:V}=Kce(M,E,y);h.set(M,z),b.push(L),E.hasRenderCallback&&this.haveRenderCallbacks.push(V.id)}}patchUpdatedImages(c,h,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 M of this.iconPositions.keys()){const E=sp.parse(M);if(Ta.isEqual(E.id,b)){const L=c.getImage(b,y);this.patchUpdatedImage(this.iconPositions.get(M),L,h,null)}}for(const M of this.patternPositions.keys()){const E=sp.parse(M);if(Ta.isEqual(E.id,b)){const L=c.getImage(b,y);this.patchUpdatedImage(this.patternPositions.get(M),L,h,this.lut)}}}}patchUpdatedImage(c,h,y,b=null){if(!c||!h||c.version===h.version)return;c.version=h.version;const[M,E]=c.tl,L=c.sdf;if(this.lut||L){const z={width:h.data.width,height:h.data.height},V=new Xc(z);Xc.copy(h.data,V,{x:0,y:0},{x:0,y:0},z,b,L),y.update(V,{position:{x:M,y:E}})}else y.update(h.data,{position:{x:M,y:E}})}}ms(IT,"ImagePosition"),ms(Eje,"ImageAtlas");const PT=1e20;function Ije(f,c,h,y,b,M,E,L,z){for(let V=c;V-1);z++,M[z]=L,E[z]=V,E[z+1]=PT}for(let L=0,z=0;L{let z=this.entries[M];z||(z=this.entries[M]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let V=z.glyphs[E];if(V!==void 0)return void L(null,{stack:M,id:E,glyph:V});if(V=this._tinySDF(z,M,E),V)return z.glyphs[E]=V,void L(null,{stack:M,id:E,glyph:V});const Z=Math.floor(E/256);if(256*Z>65535)return ts("glyphs > 65535 not supported"),void L(null,{stack:M,id:E,glyph:V});if(z.ranges[Z])return void L(null,{stack:M,id:E,glyph:V});let Q=z.requests[Z];Q||(Q=z.requests[Z]=[],eC.loadGlyphRange(M,Z,b,this.requestManager,(ee,ne)=>{if(ne){z.ascender=ne.ascender,z.descender=ne.descender;for(const le in ne.glyphs)this._doesCharSupportLocalGlyph(+le)||(z.glyphs[+le]=ne.glyphs[+le]);z.ranges[Z]=!0}for(const le of Q)le(ee,ne);delete z.requests[Z]})),Q.push((ee,ne)=>{ee?L(ee):ne&&L(null,{stack:M,id:E,glyph:ne.glyphs[E]||null})})},(M,E)=>{if(M)h(M);else if(E){const L={};for(const{stack:z,id:V,glyph:Z}of E)L[z]===void 0&&(L[z]={}),L[z].glyphs===void 0&&(L[z].glyphs={}),L[z].glyphs[V]=Z&&{id:Z.id,bitmap:Z.bitmap.clone(),metrics:Z.metrics},L[z].ascender=this.entries[z].ascender,L[z].descender=this.entries[z].descender;h(null,L)}})}_doesCharSupportLocalGlyph(c){return this.localGlyphMode!==Zce.none&&(this.localGlyphMode===Zce.all?!!this.localFontFamily:!!this.localFontFamily&&(Rs["CJK Unified Ideographs"](c)||Rs["Hangul Syllables"](c)||Rs.Hiragana(c)||Rs.Katakana(c)||Rs["CJK Symbols and Punctuation"](c)||Rs["CJK Unified Ideographs Extension A"](c)||Rs["CJK Unified Ideographs Extension B"](c)||Rs.Osage(c)))}_tinySDF(c,h,y){const b=this.localFontFamily;if(!b||!this._doesCharSupportLocalGlyph(y))return;let M=c.tinySDF;if(!M){let xe="400";/bold/i.test(h)?xe="900":/medium/i.test(h)?xe="500":/light/i.test(h)&&(xe="200"),M=c.tinySDF=new eC.TinySDF({fontFamily:b,fontWeight:xe,fontSize:24*bp,buffer:3*bp,radius:8*bp}),M.fontWeight=xe}if(this.localGlyphs[M.fontWeight][y])return this.localGlyphs[M.fontWeight][y];const E=String.fromCodePoint(y),{data:L,width:z,height:V,glyphWidth:Z,glyphHeight:Q,glyphLeft:ee,glyphTop:ne,glyphAdvance:le}=M.draw(E);return this.localGlyphs[M.fontWeight][y]={id:y,bitmap:new tv({width:z,height:V},L),metrics:{width:Z/bp,height:Q/bp,left:ee/bp,top:ne/bp-27,advance:le/bp,localGlyph:!0}}}}eC.loadGlyphRange=function(f,c,h,y,b){const M=256*c,E=M+255,L=y.transformRequest(y.normalizeGlyphsURL(h).replace("{fontstack}",f).replace("{range}",`${M}-${E}`),rp.Glyphs);Ku(L,(z,V)=>{if(z)b(z);else if(V){const Z={},Q=function(ee){return new wD(ee).readFields(kJe,{})}(V);for(const ee of Q.glyphs)Z[ee.id]=ee;b(null,{glyphs:Z,ascender:Q.ascender,descender:Q.descender})}})},eC.TinySDF=class{constructor({fontSize:f=24,buffer:c=3,radius:h=8,cutoff:y=.25,fontFamily:b="sans-serif",fontWeight:M="normal",fontStyle:E="normal",lang:L=null}={}){this.buffer=c,this.cutoff=y,this.radius=h,this.lang=L;const z=this.size=f+4*c,V=this._createCanvas(z),Z=this.ctx=V.getContext("2d",{willReadFrequently:!0});Z.font=`${E} ${M} ${f}px ${b}`,Z.textBaseline="alphabetic",Z.textAlign="left",Z.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(f){const c=document.createElement("canvas");return c.width=c.height=f,c}draw(f){const{width:c,actualBoundingBoxAscent:h,actualBoundingBoxDescent:y,actualBoundingBoxLeft:b,actualBoundingBoxRight:M}=this.ctx.measureText(f),E=Math.ceil(h),L=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(M-b))),z=Math.min(this.size-this.buffer,E+Math.ceil(y)),V=L+2*this.buffer,Z=z+2*this.buffer,Q=Math.max(V*Z,0),ee=new Uint8ClampedArray(Q),ne={data:ee,width:V,height:Z,glyphWidth:L,glyphHeight:z,glyphTop:E,glyphLeft:0,glyphAdvance:c};if(L===0||z===0)return ne;const{ctx:le,buffer:xe,gridInner:Ce,gridOuter:Ne}=this;this.lang&&(le.lang=this.lang),le.clearRect(xe,xe,L,z),le.fillText(f,xe,xe+E);const Fe=le.getImageData(xe,xe,L,z);Ne.fill(PT,0,Q),Ce.fill(0,0,Q);for(let Be=0;Be0?kt*kt:0,Ce[mt]=kt<0?kt*kt:0}}Ije(Ne,0,0,V,Z,V,this.f,this.v,this.z),Ije(Ce,xe,xe,L,z,V,this.f,this.v,this.z);for(let Be=0;Be{const wr=SD($t.stretch-Fe,Be,Z,f.left*b),kr=CD($t.fixed-mt,kt,$t.stretch,le),xr=SD(or.stretch-Je,yt,Q,f.top*b),_r=CD(or.fixed-It,Rt,or.stretch,xe),ir=SD(mr.stretch-Fe,Be,Z,f.left*b),sr=CD(mr.fixed-mt,kt,mr.stretch,le),br=SD(fr.stretch-Je,yt,Q,f.top*b),Vr=CD(fr.fixed-It,Rt,fr.stretch,xe),Ar=new dr(wr,xr),Ns=new dr(ir,xr),Jr=new dr(ir,br),as=new dr(wr,br),xs=new dr(kr/L,_r/L),In=new dr(sr/L,Vr/L),Pr=c*Math.PI/180;if(Pr){const ei=Math.sin(Pr),pt=Math.cos(Pr),vt=[pt,-ei,ei,pt];Ar._matMult(vt),Ns._matMult(vt),as._matMult(vt),Jr._matMult(vt)}const ys=$t.stretch+$t.fixed,sn=mr.stretch+mr.fixed,na=or.stretch+or.fixed,ca=fr.stretch+fr.fixed,_n=f.imageSecondary;return{tl:Ar,tr:Ns,bl:as,br:Jr,texPrimary:{x:E.paddedRect.x+zg+ys,y:E.paddedRect.y+zg+na,w:sn-ys,h:ca-na},texSecondary:_n?{x:_n.paddedRect.x+zg+ys,y:_n.paddedRect.y+zg+na,w:sn-ys,h:ca-na}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:xs,pixelOffsetBR:In,minFontScaleX:kt/L/Z,minFontScaleY:Rt/L/Q,isSDF:h}};if(y&&(E.stretchX||E.stretchY)){const $t=Dje(ee,Ce,le),or=Dje(ne,Ne,xe);for(let mr=0;mr<$t.length-1;mr++){const fr=$t[mr],wr=$t[mr+1];for(let kr=0;krM)&&(M=le.x),(!ne||le.y>E)&&(E=le.y)}const z=Math.min(M-y,E-b);let V=z/2;const Z=new qN([],LJe);if(z===0)return new dr(y,b);for(let ne=y;neQ.d||!Q.d)&&(Q=ne,h&&console.log("found best %d after %d probes",Math.round(1e4*ne.d)/1e4,ee)),ne.max-Q.d<=c||(V=ne.h/2,Z.push(new tC(ne.p.x-V,ne.p.y-V,V,f)),Z.push(new tC(ne.p.x+V,ne.p.y-V,V,f)),Z.push(new tC(ne.p.x-V,ne.p.y+V,V,f)),Z.push(new tC(ne.p.x+V,ne.p.y+V,V,f)),ee+=4)}return h&&(console.log(`num probes: ${ee}`),console.log(`best distance: ${Q.d}`)),Q.p}function LJe(f,c){return c.max-f.max}class tC{constructor(c,h,y,b){this.p=new dr(c,h),this.h=y,this.d=function(M,E){let L=!1,z=1/0;for(let V=0;VM.y!=xe.y>M.y&&M.x<(xe.x-le.x)*(M.y-le.y)/(xe.y-le.y)+le.x&&(L=!L),z=Math.min(z,bo(M,le,xe))}}return(L?1:-1)*Math.sqrt(z)}(this.p,b),this.max=this.d+this.h*Math.SQRT2}}const DJe=Object.keys,Xce=Number.POSITIVE_INFINITY,OJe=Math.sqrt(2);function sv(f,c,h,y,b){const M=Hce(f)&&f.collisionPadding?f.collisionPadding:[0,0,0,0],E={top:f.top-M[1],bottom:f.bottom+M[3],left:f.left-M[0],right:f.right+M[2],scaled:!1};return y!==void 0&&function(L,z){L.top*=z,L.bottom*=z,L.left*=z,L.right*=z,L.scaled=!0}(E,y),h&&function(L,z){if(!z)return;const V=Qs(z),Z=new dr(L.left,L.top),Q=new dr(L.right,L.top),ee=new dr(L.left,L.bottom),ne=new dr(L.right,L.bottom),le=new dr(0,0);Z._rotateAround(V,le),Q._rotateAround(V,le),ee._rotateAround(V,le),ne._rotateAround(V,le),L.left=Math.min(Z.x,Q.x,ee.x,ne.x),L.right=Math.max(Z.x,Q.x,ee.x,ne.x),L.top=Math.min(Z.y,Q.y,ee.y,ne.y),L.bottom=Math.max(Z.y,Q.y,ee.y,ne.y)}(E,h),b&&(E.left+=b[0],E.right+=b[0],E.top+=b[1],E.bottom+=b[1]),c?{top:Math.min(c.top,E.top),bottom:Math.max(c.bottom,E.bottom),left:Math.min(c.left,E.left),right:Math.max(c.right,E.right),scaled:c.scaled||E.scaled}:E}function Rje(f,[c,h]){let y=0,b=0;if(h===Xce){c<0&&(c=0);const M=c/OJe;switch(f){case"top-right":case"top-left":b=M-7;break;case"bottom-right":case"bottom-left":b=7-M;break;case"bottom":b=7-c;break;case"top":b=c-7}switch(f){case"top-right":case"bottom-right":y=-M;break;case"top-left":case"bottom-left":y=M;break;case"left":y=c;break;case"right":y=-c}}else{switch(c=Math.abs(c),h=Math.abs(h),f){case"top-right":case"top-left":case"top":b=h-7;break;case"bottom-right":case"bottom-left":case"bottom":b=7-h}switch(f){case"top-right":case"bottom-right":case"right":y=-c;break;case"top-left":case"bottom-left":case"left":y=c}}return[y,b]}function RJe(f,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne){const le=f.layers[0],xe=le.appearances;if(xe.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Ce={iconBBox:null,iconVerticalBBox:null},Ne={textBBox:null,textVerticalBBox:null},{baseIconRotate:Fe,baseTextRotate:Be,iconScaleFactor:Je}=function(mt,kt,It){const Rt=mt.get("icon-rotate").evaluate(kt,{},It),tr=mt.get("text-rotate").evaluate(kt,{},It),[$t,or]=mt.get("icon-size-scale-range");return{baseIconRotate:Rt,baseTextRotate:tr,iconScaleFactor:ye(1,$t,or)}}(y,b,M);c&&(Ce.iconBBox=sv(c,Ce.iconBBox,Fe,E),h)&&(Ce.iconVerticalBBox=sv(h,Ce.iconVerticalBBox,Fe+90,E));const yt=TD(Q.horizontal);yt&&(Ne.textBBox=sv(yt,Ne.textBBox,Be,1,ne)),Q.vertical&&(Ne.textVerticalBBox=sv(Q.vertical,Ne.textVerticalBBox,Be+90,1,ne));for(const mt of xe)mt.hasIconProperties()&&FJe(Ce,f,le,mt,b,M,L,Fe,E,z,c,V,Je,Z),mt.hasTextProperties()&&zJe(Ne,le,mt,b,M,ne,Be,ee,yt,Q.vertical);return{iconBBox:Ce.iconBBox,iconVerticalBBox:Ce.iconVerticalBBox,textBBox:Ne.textBBox,textVerticalBBox:Ne.textVerticalBBox}}function FJe(f,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne){const{appearanceIconOffset:le,appearanceIconRotate:xe,appearanceIconSize:Ce}=function(Je,yt,mt,kt,It,Rt,tr,$t){const or=Je.hasProperty("icon-offset")?yt.getAppearanceValueAndResolveTokens(Je,"icon-offset",mt,kt,[]):null,mr=or&&Array.isArray(or)?or:It,fr=Je.hasProperty("icon-rotate")?yt.getAppearanceValueAndResolveTokens(Je,"icon-rotate",mt,kt,[]):null,wr=typeof fr=="number"?fr:Rt,kr=Je.hasProperty("icon-size")?yt.getAppearanceValueAndResolveTokens(Je,"icon-size",mt,kt,[]):null;return{appearanceIconOffset:mr,appearanceIconRotate:wr,appearanceIconSize:typeof kr=="number"?kr*$t.iconScaleFactor:tr}}(y,h,b,M,E,L,z,V);let Ne=null,Fe=null,Be=null;y.hasProperty("icon-image")?Be=function(Je,yt,mt,kt,It,Rt,tr){let $t=null;const or=yt.getAppearanceValueAndResolveTokens(mt,"icon-image",kt,It,[]);if(or){const mr=Je.getResolvedImageFromTokens(or),fr=mt.getUnevaluatedProperty("icon-size"),wr=LT(mr,QS(Je.zoom,fr,Je.worldview),fr,It,Je.zoom,kt,Je.pixelRatio,tr,Je.worldview);$t=Rt.get(wr.iconPrimary.toString())}return $t}(c,h,y,b,M,Q,ee):Z&&(Be=Z.imagePrimary),Be&&(Ne=kD(Be,null,le,ne),c.allowVerticalPlacement&&(Fe=kD(Be,null,le,ne))),Ne&&(f.iconBBox=sv(Ne,f.iconBBox,xe,Ce)),Fe&&(f.iconVerticalBBox=sv(Fe,f.iconVerticalBBox,xe+90,Ce))}function zJe(f,c,h,y,b,M,E,L,z,V){const{appearanceTextOffset:Z,appearanceTextRotate:Q,appearanceTextSize:ee}=function(le,xe,Ce,Ne,Fe,Be,Je){const yt=le.hasProperty("text-offset")?xe.getAppearanceValueAndResolveTokens(le,"text-offset",Ce,Ne,[]):null,mt=yt&&Array.isArray(yt)?[yt[0]*Tl,yt[1]*Tl]:Fe,kt=le.hasProperty("text-rotate")?xe.getAppearanceValueAndResolveTokens(le,"text-rotate",Ce,Ne,[]):null,It=typeof kt=="number"?kt:Be,Rt=le.hasProperty("text-size")?xe.getAppearanceValueAndResolveTokens(le,"text-size",Ce,Ne,[]):null;return{appearanceTextOffset:mt,appearanceTextRotate:It,appearanceTextSize:typeof Rt=="number"?Rt:Je}}(h,c,y,b,M,E,L),ne=ee/L;z&&(f.textBBox=sv(z,f.textBBox,Q,ne,Z)),V&&(f.textVerticalBBox=sv(V,f.textVerticalBBox,Q+90,ne,Z))}function MD(f,c,h,y,b,M,E,L,z){if(!c||!c.usvg)return;const V=kje(y),Z=kje(b),Q=M!=="both"&&M!=="width"||!wje(y)?1:Z.width/V.width,ee=M!=="both"&&M!=="height"||!jje(y)?1:Z.height/V.height;h.scaleSelf(Q,ee);const ne=h.toString();E.set(ne,h),L.set(ne,c);const{imagePosition:le}=Kce(ne,c,tb);z.set(ne,le)}function Fje(f,c,h,y,b,M,E,L,z){if(!f)return;const V=function(Z,Q,ee,ne,le,xe){if(Z.kind==="camera")return Z.maxSize;if(Z.kind==="composite"){const Ce=Q.possiblyEvaluate(new bi(Z.maxZoom,{worldview:xe}),ee).evaluate(le,{},ee),Ne=Q.possiblyEvaluate(new bi(Z.minZoom,{worldview:xe}),ee).evaluate(le,{},ee);return Math.max(Ce,Ne)}return Q.possiblyEvaluate(new bi(ne,{worldview:xe})).evaluate(le,{},ee)}(c,h,y,b,M,z);return f.scaleSelf(V*L*E)}function LT(f,c,h,y,b,M,E,L,z){return{iconPrimary:Fje(f.getPrimary(),c,h,y,b,M,E,L,z),iconSecondary:Fje(f.getSecondary(),c,h,y,b,M,E,L,z)}}function BJe(f,c,h){if(!c)return;const y=h.get(f.toString()),b=h.get(c.toString());y&&b&&(y.paddedRect.w===b.paddedRect.w&&y.paddedRect.h===b.paddedRect.h||ts(`Mismatch in icon variant sizes: ${f.toString()} and ${c.toString()}`),y.usvg!==b.usvg&&ts(`Mismatch in icon variant image types: ${f.id} and ${c.id}`))}function zje(f,c,h,y){if(!f)return;const b=c.get(h.toString());if(f.imagePrimary=b,y){const M=c.get(y.toString());f.imageSecondary=M}}function $Je(f,c){for(const h in f.horizontal)Bje(f.horizontal[h],c);Bje(f.vertical,c)}function Bje(f,c){if(f){for(const h of f.positionedLines)for(const y of h.positionedGlyphs)if(y.image!==null){const b=y.image.toString();y.rect=c.get(b).paddedRect}}}function Qce(f){switch(f){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function UJe(f,c,h,y,b,M,E,L,z){const V=TD(M.horizontal)||M.vertical,Z=h.get("icon-text-fit-padding").evaluate(y,{},b);let Q,ee=c;return c&&z!=="none"&&(f.allowVerticalPlacement&&M.vertical&&(Q=Wce(c,M.vertical,z,Z,L,E)),V&&(ee=Wce(c,V,z,Z,L,E))),{defaultShapedIcon:ee,verticallyShapedIcon:Q}}function VJe(f,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe,Be,Je,yt,mt,kt){let It=E.textMaxSize.evaluate(c,{},ee);It===void 0?It=L*E.textScaleFactor:It*=E.textScaleFactor;const Rt=f.layers[0].layout,tr=Tl,$t=L*E.textScaleFactor/tr,or=TD(h.horizontal)||h.vertical;if(Ce!=="none"&&f.appearanceFeatureData&&c.index18&&br>2&&(br>>=1),Math.max(Br/(512*br),1)*Rt.get("symbol-spacing")),kr=Rt.get("text-padding")*f.tilePixelRatio,xr=Rt.get("icon-padding")*f.tilePixelRatio,_r=Qs(Rt.get("text-max-angle")),ir=Rt.get("icon-rotation-alignment")==="map"&&Be!=="point",sr=wr/2;var br;f.hasAnyIconTextFit===!1&&Ce!=="none"&&(f.hasAnyIconTextFit=!0);const Vr=c.properties?+c.properties[nr]:null,Ar=Vr&&f.elevationFeatureIdToIndex?f.elevationFeatureIdToIndex.get(Vr):65535,Ns=(Jr,as,xs)=>{if(as.x<0||as.x>=Br||as.y<0||as.y>=Br)return;let In=null;if(mr){const{x:Pr,y:ys,z:sn}=ne.projectTilePoint(as.x,as.y,xs);In={anchor:new ny(Pr,ys,sn,0,void 0),up:ne.upVector(xs,as.x,as.y)}}(function(Pr,ys,sn,na,ca,_n,ei,pt,vt,lr,jr,Zr,Yr,Ms,Es,xn,Sn,En,Qn,Bs,en,_a,ka,Na,Ha,ci,ti,Ia,Fa,Cn,la,Hi,Fs){const Jn=Pr.addToLineVertexArray(ys,na);let ni,pi,wi,Co,yi,zs,no,Wa=0,Oi=0,al=0,Al=0,Wo=-1,Go=-1;const yl={};let au=vr("");const vi=sn?sn.anchor:ys,wo=Ia!=="none";let Mo=0,ju=0;if(vt._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Pc=vt.layout.get("text-offset").evaluate(en,{},Ha);Mo=Pc[0]*Tl,ju=Pc[1]*Tl}else Mo=vt.layout.get("text-radial-offset").evaluate(en,{},Ha)*Tl,ju=Xce;if(Pr.allowVerticalPlacement&&ca.vertical){const Pc=ca.vertical;if(Es)zs=Jce(Pc),pt&&(no=Jce(pt));else{const Fd=vt.layout.get("text-rotate").evaluate(en,{},Ha)+90;wi=AD(lr,vi,ys,jr,Zr,Yr,Pc,Ms,Fd,xn,Hi),pt&&(Co=AD(lr,vi,ys,jr,Zr,Yr,pt,En,Fd,null,la))}}if(_n){const Pc=Pr.iconSizeData,Fd=vt.layout.get("icon-rotate").evaluate(en,{},Ha),rh=Yce(_n,Fd,ka,wo,_a.iconScaleFactor),iv=pt?Yce(pt,Fd,ka,wo,_a.iconScaleFactor):void 0;pi=AD(lr,vi,ys,jr,Zr,Yr,_n,En,Fd,null,Cn);const lC=function(Np,QT,aNe,stt,iNe,oNe,ntt,att){const lNe=Np.layers[0],cNe=lNe.appearances;let cC=QT.length;if(aNe&&(cC=Math.max(cC,aNe.length)),cNe.length===0)return cC;const[itt,ott]=stt.get("icon-size-scale-range"),ltt=ye(1,itt,ott);for(const dNe of cNe){const uNe=dNe.getUnevaluatedProperties();if(uNe._values["icon-image"].value!==void 0){const hNe=lNe.getAppearanceValueAndResolveTokens(dNe,"icon-image",iNe,oNe,[]);if(hNe){const mNe=Np.getResolvedImageFromTokens(hNe);if(mNe){const fNe=uNe._values["icon-size"],ctt=LT(mNe,QS(Np.zoom,fNe,Np.worldview),fNe,oNe,Np.zoom,iNe,Np.pixelRatio,ltt,Np.worldview),dtt=ntt.get(ctt.iconPrimary.toString());cC=Math.max(cC,EJe(dtt,att))}}}}return cC}(Pr,rh,iv,vt.layout,en,Ha,Pr.iconAtlasPositions,wo);Wa=4*lC;let kp=null;Pc.kind==="source"?(kp=[_p*vt.layout.get("icon-size").evaluate(en,{},Ha)*_a.iconScaleFactor],kp[0]>ay&&ts(`${Pr.layerIds[0]}: Value for "icon-size" is >= ${DT}. Reduce your "icon-size".`)):Pc.kind==="composite"&&(kp=[_p*_a.compositeIconSizes[0].evaluate(en,{},Ha)*_a.iconScaleFactor,_p*_a.compositeIconSizes[1].evaluate(en,{},Ha)*_a.iconScaleFactor],(kp[0]>ay||kp[1]>ay)&&ts(`${Pr.layerIds[0]}: Value for "icon-size" is >= ${DT}. Reduce your "icon-size".`)),Pr.addSymbols(Pr.icon,rh,kp,Bs,Qn,en,void 0,sn,ys,Jn.lineStartIndex,Jn.lineLength,-1,Na,Ha,ci,ti,Pr.symbolInstances.length,lC),Wo=Pr.icon.placedSymbolArray.length-1,iv&&(Oi=4*lC,Pr.addSymbols(Pr.icon,iv,kp,Bs,Qn,en,th.vertical,sn,ys,Jn.lineStartIndex,Jn.lineLength,-1,Na,Ha,ci,ti,Pr.symbolInstances.length,lC),Go=Pr.icon.placedSymbolArray.length-1)}for(const Pc in ca.horizontal){const Fd=Pc,rh=ca.horizontal[Fd];ni||(au=vr(rh.text),Es?yi=Jce(rh):ni=AD(lr,vi,ys,jr,Zr,Yr,rh,Ms,vt.layout.get("text-rotate").evaluate(en,{},Ha),xn,Hi));const iv=rh.positionedLines.length===1;if(al+=$je(Pr,sn,ys,rh,ei,vt,Es,en,xn,Jn,ca.vertical?th.horizontal:th.horizontalOnly,iv?DJe(ca.horizontal):[Fd],yl,Wo,_a,Na,Ha,Pr.symbolInstances.length,ci),iv)break}ca.vertical&&(Al+=$je(Pr,sn,ys,ca.vertical,ei,vt,Es,en,xn,Jn,th.vertical,["vertical"],yl,Go,_a,Na,Ha,Pr.symbolInstances.length,ci));let il=-1;const uf=(Pc,Fd)=>Pc?Math.max(Pc,Fd):Fd;il=uf(yi,il),il=uf(zs,il),il=uf(no,il);const Bg=il>-1?1:0;Pr.glyphOffsetArray.length>=65535&&ts("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),en.sortKey!==void 0&&Pr.addToSortKeyRanges(Pr.symbolInstances.length,en.sortKey),Pr.symbolInstances.emplaceBack(ys.x,ys.y,vi.x,vi.y,vi.z,yl.right>=0?yl.right:-1,yl.center>=0?yl.center:-1,yl.left>=0?yl.left:-1,yl.vertical>=0?yl.vertical:-1,Wo,Go,au,ni!==void 0?ni:Pr.collisionBoxArray.length,ni!==void 0?ni+1:Pr.collisionBoxArray.length,wi!==void 0?wi:Pr.collisionBoxArray.length,wi!==void 0?wi+1:Pr.collisionBoxArray.length,pi!==void 0?pi:Pr.collisionBoxArray.length,pi!==void 0?pi+1:Pr.collisionBoxArray.length,Co||Pr.collisionBoxArray.length,Co?Co+1:Pr.collisionBoxArray.length,jr,al,Al,Wa,Oi,Bg,0,Mo,ju,il,0,wo?1:0,Fa)})(f,as,In,Jr,h,y,M,b,f.layers[0],f.collisionBoxArray,c.index,c.sourceLayerIndex,f.index,kr,Fe,V,0,xr,ir,Ne,c,E,Z,Q,ee,le,xe,Ce,Ar,Je,yt,mt)};if(Be==="line")for(const Jr of uD(c.geometry,0,0,Br,Br)){const as=AJe(Jr,wr,_r,h.vertical||or,y,tr,fr,f.overscaling,Br);for(const xs of as)or&&qJe(f,or.text,sr,xs)||Ns(Jr,xs,ee)}else if(Be==="line-center"){for(const Jr of c.geometry)if(Jr.length>1){const as=TJe(Jr,_r,h.vertical||or,y,tr,fr);as&&Ns(Jr,as,ee)}}else if(c.type==="Polygon")for(const Jr of xT(c.geometry,0)){const as=PJe(Jr,16);Ns(Jr[0],new ny(as.x,as.y,0,0,void 0),ee)}else if(c.type==="LineString")for(const Jr of c.geometry)Ns(Jr,new ny(Jr[0].x,Jr[0].y,0,0,void 0),ee);else if(c.type==="Point")for(const Jr of c.geometry)for(const as of Jr)Ns([as],new ny(as.x,as.y,0,0,void 0),ee)}const DT=255,ay=DT*_p;function $je(f,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe){const Be=function(mt,kt,It,Rt,tr,$t,or,mr){const fr=[];if(kt.positionedLines.length===0)return fr;const wr=Rt.layout.get("text-rotate").evaluate($t,{})*Math.PI/180,kr=function(br){const Vr=br[0],Ar=br[1],Ns=Vr*Ar;return Ns>0?[Vr,-Ar]:Ns<0?[-Vr,Ar]:Vr===0?[Ar,Vr]:[Ar,-Vr]}(It);let xr=Math.abs(kt.top-kt.bottom);for(const br of kt.positionedLines)xr-=br.lineOffset;const _r=kt.positionedLines.length,ir=xr/_r;let sr=kt.top-It[1];for(let br=0;br<_r;++br){const Vr=kt.positionedLines[br];sr=IJe(kt,ir,sr,br);for(const Ar of Vr.positionedGlyphs){if(!Ar.rect)continue;const Ns=Ar.rect||{};let Jr=gje+1,as=!0,xs=1,In=0;if(Ar.image){const Sn=or.get(Ar.image.toString());if(!Sn)continue;if(Sn.sdf){ts("SDF images are not supported in formatted text and will be ignored.");continue}as=!1,xs=Sn.pixelRatio,Jr=tb/xs}const Pr=(tr||mr)&&Ar.vertical,ys=Ar.metrics.advance*Ar.scale/2,sn=Ar.metrics,na=Ar.rect;if(na===null)continue;mr&&kt.verticalizable&&(In=Ar.image?ys-Ar.metrics.width*Ar.scale/2:0);const ca=tr?[Ar.x+ys,Ar.y]:[0,0];let _n=[0,0],ei=[0,0],pt=!1;tr||(Pr?(ei=[Ar.x+ys+kr[0],Ar.y+kr[1]-In],pt=!0):_n=[Ar.x+ys+It[0],Ar.y+It[1]-In]);const vt=na.w*Ar.scale/(xs*(Ar.localGlyph?bp:1)),lr=na.h*Ar.scale/(xs*(Ar.localGlyph?bp:1));let jr,Zr,Yr,Ms;if(Pr){const Sn=Ar.y-sr,En=new dr(-ys,ys-Sn),Qn=-Math.PI/2,Bs=new dr(...ei);jr=new dr(-ys+_n[0],_n[1]),jr._rotateAround(Qn,En)._add(Bs),jr.x+=-Sn+ys,jr.y-=(sn.left-Jr)*Ar.scale;const en=Ar.image?sn.advance*Ar.scale:Tl*Ar.scale,_a=String.fromCodePoint(Ar.glyph);mJe(_a)?jr.x+=(1-Jr)*Ar.scale:fJe(_a)?jr.x+=en-sn.height*Ar.scale+(-Jr-1)*Ar.scale:jr.x+=Ar.image||sn.width+2*Jr===na.w&&sn.height+2*Jr===na.h?(en-lr)/2:(en-(sn.height+2*Jr)*Ar.scale)/2,Zr=new dr(jr.x,jr.y-vt),Yr=new dr(jr.x+lr,jr.y),Ms=new dr(jr.x+lr,jr.y-vt)}else{const Sn=(sn.left-Jr)*Ar.scale-ys+_n[0],En=(-sn.top-Jr)*Ar.scale+_n[1],Qn=Sn+vt,Bs=En+lr;jr=new dr(Sn,En),Zr=new dr(Qn,En),Yr=new dr(Sn,Bs),Ms=new dr(Qn,Bs)}if(wr){let Sn;Sn=tr?new dr(0,0):pt?new dr(kr[0],kr[1]):new dr(It[0],It[1]),jr._rotateAround(wr,Sn),Zr._rotateAround(wr,Sn),Yr._rotateAround(wr,Sn),Ms._rotateAround(wr,Sn)}const Es=new dr(0,0),xn=new dr(0,0);fr.push({tl:jr,tr:Zr,bl:Yr,br:Ms,texPrimary:Ns,texSecondary:void 0,writingMode:kt.writingMode,glyphOffset:ca,sectionIndex:Ar.sectionIndex,isSDF:as,pixelOffsetTL:Es,pixelOffsetBR:xn,minFontScaleX:0,minFontScaleY:0})}}return fr}(0,y,z,M,E,L,b,f.allowVerticalPlacement),Je=f.textSizeData;let yt=null;Je.kind==="source"?(yt=[_p*M.layout.get("text-size").evaluate(L,{},Ce)*le.textScaleFactor],yt[0]>ay&&ts(`${f.layerIds[0]}: Value for "text-size" is >= ${DT}. Reduce your "text-size".`)):Je.kind==="composite"&&(yt=[_p*le.compositeTextSizes[0].evaluate(L,{},Ce)*le.textScaleFactor,_p*le.compositeTextSizes[1].evaluate(L,{},Ce)*le.textScaleFactor],(yt[0]>ay||yt[1]>ay)&&ts(`${f.layerIds[0]}: Value for "text-size" is >= ${DT}. Reduce your "text-size".`)),f.addSymbols(f.text,Be,yt,z,E,L,Z,c,h,V.lineStartIndex,V.lineLength,ne,xe,Ce,Fe,!1,Ne,Be.length);for(const mt of Q)ee[mt]=f.text.placedSymbolArray.length-1;return 4*Be.length}function TD(f){for(const c in f)return f[c];return null}function AD(f,c,h,y,b,M,E,L,z,V,Z){let Q,ee,ne,le;if(Q=Z?Z.top:E.top,ee=Z?Z.bottom:E.bottom,ne=Z?Z.left:E.left,le=Z?Z.right:E.right,Hce(E)&&E.collisionPadding){const xe=E.collisionPadding;ne-=xe[0],Q-=xe[1],le+=xe[2],ee+=xe[3]}if(z){const xe=new dr(ne,Q),Ce=new dr(le,Q),Ne=new dr(ne,ee),Fe=new dr(le,ee),Be=Qs(z);let Je=new dr(0,0);V&&(Je=new dr(V[0],V[1])),xe._rotateAround(Be,Je),Ce._rotateAround(Be,Je),Ne._rotateAround(Be,Je),Fe._rotateAround(Be,Je),ne=Math.min(xe.x,Ce.x,Ne.x,Fe.x),le=Math.max(xe.x,Ce.x,Ne.x,Fe.x),Q=Math.min(xe.y,Ce.y,Ne.y,Fe.y),ee=Math.max(xe.y,Ce.y,Ne.y,Fe.y)}return f.emplaceBack(c.x,c.y,c.z,h.x,h.y,ne,Q,le,ee,L,y,b,M),f.length-1}function Jce(f){Hce(f)&&f.collisionPadding&&(f.top-=f.collisionPadding[1],f.bottom+=f.collisionPadding[3]);const c=f.bottom-f.top;return c>0?Math.max(10,c):null}function qJe(f,c,h,y){const b=f.compareText;if(c in b){const M=b[c];for(let E=M.length-1;E>=0;E--)if(y.dist(M[E])Be&&(Je(mt,fr,It,Rt,or,mr),Je(fr,kt,or,mr,tr,$t))}Je(Q,ee,y,M,b,M),Je(ee,ne,b,M,b,E),Je(ne,le,b,E,y,E),Je(le,Q,y,E,y,M),xe-=Be,Ce-=Be,Ne+=Be,Fe+=Be;const yt=1/Math.max(Ne-xe,Fe-Ce);return{scale:yt,x:xe*yt,y:Ce*yt,x2:Ne*yt,y2:Fe*yt,projection:c}}function Vje(f,{x:c,y:h},y=0){return new dr(((c-y)*f.scale-f.x)*Br,(h*f.scale-f.y)*Br)}const HJe=S(new Float32Array(16));class nv{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,h){return{x:0,y:0,z:0}}unproject(c,h){return new x(0,0)}projectTilePoint(c,h,y){return{x:c,y:h,z:0}}locationPoint(c,h,y,b=!0){return c._coordinatePoint(c.locationCoordinate(h,y),b)}pixelsPerMeter(c,h){return J(1,c)*h}pixelSpaceConversion(c,h,y){return 1}farthestPixelDistance(c){return Uje(c,c.pixelsPerMeter)}pointCoordinate(c,h,y,b){const M=c.horizonLineFromTop(!1),E=new dr(h,Math.max(M,y));return c.rayIntersectionCoordinate(c.pointRayIntersection(E,b))}pointCoordinate3D(c,h,y){const b=new dr(h,y);if(c.elevation)return c.elevation.pointCoordinate(b);{const M=this.pointCoordinate(c,b.x,b.y,0);return[M.x,M.y,M.z]}}isPointAboveHorizon(c,h){if(c.elevation&&c.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(c,h.x,h.y);const y=c.horizonLineFromTop();return h.y0?h<-rC+y&&(h=-rC+y):h>rC-y&&(h=rC-y);const E=M/Math.pow(ID(h),b);let L=E*Math.sin(b*c),z=M-E*Math.cos(b*c);return L=.5*(L/Math.PI+.5),z=.5*(z/Math.PI+.5),{x:L,y:this.southernCenter?z:1-z,z:0}}unproject(c,h){c=(2*c-.5)*Math.PI,this.southernCenter&&(h=1-h),h=(2*(1-h)-.5)*Math.PI;const{n:y,f:b}=this,M=b-h,E=Math.sign(M),L=Math.sign(y)*Math.sqrt(c*c+M*M);let z=Math.atan2(c,Math.abs(M))*E;M*y<0&&(z-=Math.PI*Math.sign(c)*E);const V=ye(ao(z/y)+this.center[0],-180,180),Z=ye(ao(2*Math.atan(Math.pow(b/L,1/y))-rC),-fe,fe);return new x(V,this.southernCenter?-Z:Z)}}class qje extends nv{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,h){return{x:U(c),y:G(h),z:0}}unproject(c,h){const y=te(c),b=me(h);return new x(y,b)}}const Hje=Qs(fe);class YJe extends nv{project(c,h){const y=(h=Qs(h))*h,b=y*y;return{x:.5*((c=Qs(c))*(.8707-.131979*y+b*(b*(.003971*y-.001529*b)-.013791))/Math.PI+.5),y:1-.5*(h*(1.007226+y*(.015085+b*(.028874*y-.044475-.005916*b)))/Math.PI+1),z:0}}unproject(c,h){c=(2*c-.5)*Math.PI;let y=h=(2*(1-h)-1)*Math.PI,b=25,M=0,E=y*y;do{E=y*y;const V=E*E;M=(y*(1.007226+E*(.015085+V*(.028874*E-.044475-.005916*V)))-h)/(1.007226+E*(.045255+V*(.259866*E-.311325-.005916*11*V))),y=ye(y-M,-Hje,Hje)}while(Math.abs(M)>1e-6&&--b>0);E=y*y;const L=ye(ao(c/(.8707+E*(E*(E*E*E*(.003971-.001529*E)-.013791)-.131979))),-180,180),z=ao(y);return new x(L,z)}}const Wje=Qs(fe);class XJe extends nv{project(c,h){h=Qs(h),c=Qs(c);const y=Math.cos(h),b=2/Math.PI,M=Math.acos(y*Math.cos(c/2)),E=Math.sin(M)/M,L=.5*(c*b+2*y*Math.sin(c/2)/E)||0,z=.5*(h+Math.sin(h)/E)||0;return{x:.5*(L/Math.PI+.5),y:1-.5*(z/Math.PI+1),z:0}}unproject(c,h){let y=c=(2*c-.5)*Math.PI,b=h=(2*(1-h)-1)*Math.PI,M=25;const E=1e-6;let L=0,z=0;do{const V=Math.cos(b),Z=Math.sin(b),Q=2*Z*V,ee=Z*Z,ne=V*V,le=Math.cos(y/2),xe=Math.sin(y/2),Ce=2*le*xe,Ne=xe*xe,Fe=1-ne*le*le,Be=Fe?1/Fe:0,Je=Fe?Math.acos(V*le)*Math.sqrt(1/Fe):0,yt=.5*(2*Je*V*xe+2*y/Math.PI)-c,mt=.5*(Je*Z+b)-h,kt=.5*Be*(ne*Ne+Je*V*le*ee)+1/Math.PI,It=Be*(Ce*Q/4-Je*Z*xe),Rt=.125*Be*(Q*xe-Je*Z*ne*Ce),tr=.5*Be*(ee*le+Je*Ne*V)+.5,$t=It*Rt-tr*kt;L=(mt*It-yt*tr)/$t,z=(yt*Rt-mt*kt)/$t,y=ye(y-L,-Math.PI,Math.PI),b=ye(b-z,-Wje,Wje)}while((Math.abs(L)>E||Math.abs(z)>E)&&--M>0);return new x(ao(y),ao(b))}}class Gje extends nv{constructor(c){super(c),this.center=c.center||[0,0],this.parallels=c.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Qs(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(c,h){const{scale:y,cosPhi:b}=this;return{x:Qs(c)*b*y+.5,y:-Math.sin(Qs(h))/b*y+.5,z:0}}unproject(c,h){const{scale:y,cosPhi:b}=this,M=-(h-.5)/y,E=ye(ao((c-.5)/y)/b,-180,180),L=Math.asin(ye(M*b,-1,1)),z=ye(ao(L),-fe,fe);return new x(E,z)}}class QJe extends qje{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,h,y){const b=uT(c,h,y);return st(b,b,rD(ym(y))),{x:b[0],y:b[1],z:b[2]}}locationPoint(c,h,y){const b=X0(h.lat,h.lng),M=Ie([],b),E=y?c._centerAltitude+y:c.elevation?c.elevation.getAtPointOrZero(c.locationCoordinate(h),c._centerAltitude):c._centerAltitude;Ze(b,b,M,J(1,0)*Br*E);const L=S(new Float64Array(16));return C(L,c.pixelMatrix,c.globeMatrix),st(b,b,L),new dr(b[0],b[1])}pixelsPerMeter(c,h){return J(1,0)*h}pixelSpaceConversion(c,h,y){const b=J(1,c)*h,M=Gs(J(1,45)*h,b,y);return this.pixelsPerMeter(c,h)/M}createTileMatrix(c,h,y){const b=nce(ym(y.canonical));return C(new Float64Array(16),c.globeMatrix,b)}createInversionMatrix(c,h){const{center:y}=c,b=rD(ym(h));return B(b,b,Qs(y.lng)),D(b,b,Qs(y.lat)),R(b,b,[c._pixelsPerMercatorPixel,c._pixelsPerMercatorPixel,1]),Float32Array.from(b)}pointCoordinate(c,h,y,b){return J0(c,h,y,!0)||new Ge(0,0)}pointCoordinate3D(c,h,y){const b=this.pointCoordinate(c,h,y,0);return[b.x,b.y,b.z]}isPointAboveHorizon(c,h){return!J0(c,h.x,h.y,!1)}farthestPixelDistance(c){const h=function(b,M){const E=b.cameraToCenterDistance,L=b._centerAltitude*M,z=b._camera,V=b._camera.forward(),Z=ce([],Me([],V,-E),[0,0,L]),Q=b.worldSize/(2*Math.PI),ee=[0,0,-Q],ne=b.width/b.height,le=Math.tan(b.fovAboveCenter),xe=Me([],z.up(),le),Ce=Me([],z.right(),le*ne),Ne=Ie([],ce([],ce([],V,xe),Ce)),Fe=[];let Be;if(new ps(Z,Ne).closestPointOnSphere(ee,Q,Fe)){const Je=ce([],Fe,ee),yt=je([],Je,Z);Be=Math.cos(b.fovAboveCenter)*pe(yt)}else{const Je=je([],Z,ee),yt=je([],ee,Z);Ie(yt,yt);const mt=pe(Je)-Q;Be=Math.sqrt(mt*(mt+2*Q));const kt=Math.acos(Be/(Q+mt))-Math.acos(We(V,yt));Be*=Math.cos(kt)}return 1.01*Be}(c,this.pixelsPerMeter(c.center.lat,c.worldSize)),y=ev(c.zoom);if(y>0){const b=Uje(c,J(1,c.center.lat)*c.worldSize),M=c.worldSize/(2*Math.PI),E=Math.max(c.width,c.height)/c.worldSize*Math.PI;return Gs(h,b+M*(1-Math.cos(E)),Math.pow(y,10))}return h}upVector(c,h,y){return uT(h,y,c,1)}upVectorScale(c){return{metersToTile:cf(tD(ym(c)))}}}function Kje(f){const c=f.parallels,h=!!c&&Math.abs(c[0]+c[1])<.01;switch(f.name){case"mercator":return new qje(f);case"equirectangular":return new KJe(f);case"naturalEarth":return new YJe(f);case"equalEarth":return new GJe(f);case"winkelTripel":return new XJe(f);case"albers":return h?new Gje(f):new WJe(f);case"lambertConformalConic":return h?new Gje(f):new ZJe(f);case"globe":return new QJe(f)}throw new Error(`Invalid projection name: ${f.name}`)}const JJe=zt.types,eet=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function $T(f,c,h,y,b,M,E,L,z,V,Z,Q,ee){const ne=L?Math.min(ay,Math.round(L[0])):0,le=L?Math.min(ay,Math.round(L[1])):0;f.emplaceBack(c,h,Math.round(32*y),Math.round(32*b),M,E,(ne<<1)+(z?1:0),0+(le<<1),16*V,16*Z,256*Q,256*ee)}function UT(f,c,h){f.emplaceBack(c,h)}function VT(f,c,h,y,b,M,E){f.emplaceBack(c,h,y,b,M,E)}const PD=(f,c,h,y)=>{for(let b=0;b0&&(this.iconTransitioningVertexBuffer=c.createVertexBuffer(this.iconTransitioningVertexArray,lJe.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=c.createVertexBuffer(this.globeExtVertexArray,nJe.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||M)&&(this.zOffsetVertexBuffer=c.createVertexBuffer(this.zOffsetVertexArray,iJe.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=c.createVertexBuffer(this.orientationVertexArray,oJe.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())}}ms(ede,"SymbolBuffers");class tde{constructor(c,h,y){this.layoutVertexArray=new c,this.layoutAttributes=h,this.indexArray=new y,this.segments=new to,this.collisionVertexArray=new YM,this.collisionVertexArrayExt=new Lg}upload(c){this.layoutVertexBuffer=c.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=c.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=c.createVertexBuffer(this.collisionVertexArray,cJe.members,!0),this.collisionVertexBufferExt=c.createVertexBuffer(this.collisionVertexArrayExt,dJe.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}ms(tde,"CollisionBuffers");class LD{constructor(c){this.collisionBoxArray=c.collisionBoxArray,this.zoom=c.zoom,this.overscaling=c.overscaling,this.layers=c.layers,this.layerIds=this.layers.map(E=>E.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=S([]),this.placementViewportMatrix=S([]);const h=this.layers[0]._unevaluatedLayout._values;this.worldview=c.worldview,this.localizable=c.localizable,this.textSizeData=QS(this.zoom,h["text-size"],this.worldview),this.iconSizeData=QS(this.zoom,h["icon-size"],this.worldview);const y=this.layers[0].layout,b=y.get("symbol-sort-key"),M=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=M!=="viewport-y"&&b.constantOr(1)!==void 0,this.sortFeaturesByY=(M==="viewport-y"||M==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=y.get("text-writing-mode").map(E=>th[E]),this.stateDependentLayerIds=this.layers.filter(E=>E.isStateDependent()).map(E=>E.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 h=this.layers[0].getAppearances();return!(!h||h.length===0)&&h.some(y=>y.getProperty(c)!=null)}createArrays(){this.text=new ede(new gm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("text")||c.startsWith("symbol"))),this.icon=new ede(new gm(this.layers,{zoom:this.zoom,lut:this.lut},c=>c.startsWith("icon")||c.startsWith("symbol"))),this.glyphOffsetArray=new LS,this.lineVertexArray=new YL,this.symbolInstances=new sT}calculateGlyphDependencies(c,h,y,b,M){for(const E of c){const L=E.codePointAt(0);if(L===void 0)break;if(h[L]=!0,b&&M&&L<=65535){const z=AT[E];z&&(h[z.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(c,h,y,b,M,E){let L=1;const z=c.getUnevaluatedProperties()._values["icon-size"],V=QS(this.zoom,z,this.worldview),Z=JS(V,h);if(V.kind!=="constant"&&V.kind!=="camera"||(L=Z.uSize),V.kind==="composite"){const{minZoom:Q,maxZoom:ee}=V,ne=z.possiblyEvaluate(new bi(Q,{worldview:this.worldview}),b),le=z.possiblyEvaluate(new bi(ee,{worldview:this.worldview}),b),xe=ne.evaluate(y,{},b,M);L=xe+(le.evaluate(y,{},b,M)-xe)*Z.uSizeT}return V.kind==="source"&&(L=z.possiblyEvaluate(new bi(this.zoom,{worldview:this.worldview}),b).evaluate(y,{},b,M)),L*E}updateFootprints(c,h){}updateReplacement(c,h){if(h.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=h.updateTime;const y=h.getReplacementRegionsForTile(c.toUnwrapped(),!0);return!lD(this.activeReplacements,y)&&(this.activeReplacements=y,!0)}getResolvedImageFromTokens(c){return typeof c=="string"?Pd.build(c):c}populate(c,h,y,b){const M=this.layers[0],E=M.layout,L=this.projection.name==="globe",z=E.get("text-font"),V=E.get("text-field"),Z=E.get("icon-image"),[Q,ee]=E.get("icon-size-scale-range"),ne=ye(h.scaleFactor||1,Q,ee),le=(V.value.kind!=="constant"||V.value.value instanceof Id&&!V.value.value.isEmpty()||V.value.value.toString().length>0)&&(z.value.kind!=="constant"||z.value.value.length>0),xe=Z.value.kind!=="constant"||!!Z.value.value||Object.keys(Z.parameters).length>0,Ce=this.hasAnyAppearanceProperty("icon-image"),Ne=E.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!le&&!xe&&!Ce)return;const Fe=h.iconDependencies,Be=h.glyphDependencies,Je=h.availableImages,yt=new bi(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),mt=kt=>{const It=kt.id.toString();Fe.has(It)?Fe.get(It).push(kt):Fe.set(It,[kt])};for(const kt of c){const{feature:It,id:Rt,index:tr,sourceLayerIndex:$t}=kt,or=M._featureFilter.needGeometry,mr=Bt(It,or);if(!M._featureFilter.filter(yt,mr,y))continue;if(or||(mr.geometry=At(It,y,b)),L&&It.type!==1&&y.z<=5){const br=mr.geometry,Vr=.98078528056,Ar=(Ns,Jr)=>We(uT(Ns.x,Ns.y,y,1),uT(Jr.x,Jr.y,y,1)){if(!br.getProperty("icon-image"))return;const Vr=this.getCombinedIconPrimary(br,kr,mr,y,Je,ir,ne);Vr&&mt(Vr)}),fr){const br=z.evaluate(mr,{},y).join(","),Vr=E.get("text-rotation-alignment")==="map"&&E.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(th.vertical)>=0;for(const Ar of fr.sections)if(Ar.image){const Ns=Ar.image.getPrimary().scaleSelf(this.pixelRatio),Jr=Ns.id.toString(),as=Fe.get(Jr)||[];as.push(Ns),Fe.set(Jr,as)}else{const Ns=O_(fr.toString()),Jr=Ar.fontStack||br,as=Be[Jr]=Be[Jr]||{};this.calculateGlyphDependencies(Ar.text,as,Vr,this.allowVerticalPlacement,Ns)}}}if(E.get("symbol-placement")==="line"&&(this.features=function(kt){const It={},Rt={},tr=[];let $t=0;function or(kr){tr.push(kt[kr]),$t++}function mr(kr,xr,_r){const ir=Rt[kr];return delete Rt[kr],Rt[xr]=ir,tr[ir].geometry[0].pop(),tr[ir].geometry[0]=tr[ir].geometry[0].concat(_r[0]),ir}function fr(kr,xr,_r){const ir=It[xr];return delete It[xr],It[kr]=ir,tr[ir].geometry[0].shift(),tr[ir].geometry[0]=_r[0].concat(tr[ir].geometry[0]),ir}function wr(kr,xr,_r){const ir=_r?xr[0][xr[0].length-1]:xr[0][0];return`${kr}:${ir.x}:${ir.y}`}for(let kr=0;krkr.geometry)}(this.features)),E.get("symbol-elevation-reference")==="hd-road-markup"){if(this.elevationType="road",h.elevationFeatures){!this.elevationFeatures&&h.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const kt of h.elevationFeatures)this.elevationFeatureIdToIndex.set(kt.id,this.elevationFeatures.length),this.elevationFeatures.push(kt)}}else E.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((kt,It)=>kt.sortKey-It.sortKey)}getCombinedIconPrimary(c,h,y,b,M,E,L){let z,V;const Z=c.getUnevaluatedProperties();if(Z._values["icon-image"].value!==void 0){const Q=h.getAppearanceValueAndResolveTokens(c,"icon-image",y,b,M);z=this.getResolvedImageFromTokens(Q)}else{const Q=h.getValueAndResolveTokens("icon-image",y,b,M);z=this.getResolvedImageFromTokens(Q)}if(z){const Q=Z._values["icon-size"]||h._unevaluatedLayout._values["icon-size"];V=LT(z,QS(this.zoom,Q,this.worldview),Q,b,this.zoom,E,this.pixelRatio,L,this.worldview).iconPrimary}return V}updateAppearanceBasedIconTextures(c,h,y,b){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const M=this.layers[0];let E=!1,L=0;const z=M.layout,[V,Z]=z.get("icon-size-scale-range"),Q=ye(1,V,Z);for(let ee=0;ee=0){const Ce=xe.id,Ne=h&&Ce!==void 0?h[String(Ce)]:void 0,Fe={type:"Point",id:xe.id,properties:xe.properties,geometry:[]},Be=this.layers[0].appearances&&this.layers[0].appearances.find(Je=>Je.isActive({globals:b,feature:Fe,canonical:c,featureState:Ne}));if(xe.activeAppearance===Be){L+=ne.numIconVertices;continue}if(Be){xe.activeAppearance=Be;const Je=this.getCombinedIconPrimary(Be,M,Fe,c,y,{sortKey:void 0,text:void 0,icon:null,index:ne.featureIndex,sourceLayerIndex:ne.featureIndex,geometry:[],properties:xe.properties,type:"Point",id:xe.id},Q);if(!Je)continue;const yt=Je.toString(),mt=this.iconAtlasPositions&&this.iconAtlasPositions.get(yt);if(mt){const kt=M.getAppearanceValueAndResolveTokens(Be,"icon-offset",Fe,c,y),It=kt&&Array.isArray(kt)?kt:[0,0];let Rt=kD(mt,void 0,It,M.layout.get("icon-anchor").evaluate(Fe,{},c));const tr=M.getAppearanceValueAndResolveTokens(Be,"icon-rotate",Fe,c,y),$t=typeof tr=="number"?tr:0,or=mt.sdf,mr=M.layout.get("icon-text-fit").constantOr("none");mr!=="none"&&xe.textShaping&&xe.iconTextFitPadding&&xe.fontScale&&(Rt=Wce(Rt,xe.textShaping,mr,xe.iconTextFitPadding,It,xe.fontScale));const fr=this.calculateEffectiveAppearanceIconSize(Be,b.zoom,Fe,c,y,Q),wr=0,kr=1+(Math.min(ay,Math.round(fr*_p))<<1),xr=Yce(Rt,$t,or,mr!=="none",Q);xe.isUsingAppearanceVertexData||(xe.isUsingAppearanceVertexData=!0,xe.layoutBasedVertexData=this.icon.getIconVertexData(L,ne.numIconVertices));for(let ir=0;ir0&&(this.icon.updateIconVertexData(L,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(L+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(L+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(L+3,0,0,0,0,0,0,0,0,0,0,0,0),E=!0),L+=ne.numIconVertices,xe.activeAppearance=null;else if(xe.isUsingAppearanceVertexData){const yt=xe.layoutBasedVertexData.length/12;for(let mt=0;mt0||ee>0,Ce=ne>0,Ne=this.elevationFeatures[z.elevationFeatureIndex];if(Ne){const Fe=new dr(z.tileAnchorX,z.tileAnchorY),Be=.075+Ne.pointElevation(Fe);z.zOffset!==Be&&(h=!0,z.zOffset=Be),Be!==0&&(this.hasAnyZOffset=!0);const Je=Ne.computeSlopeNormal(Fe,b),yt=Mr(ut(),ie(0,0,1),Je);$e(V,V,yt),$e(Z,Z,yt),V[2]*=y,Z[2]*=y,V[0]===1&&V[1]===0&&V[2]===0&&Z[0]===0&&Z[1]===1&&Z[2]===0||(M=M||xe,E=E||Ce)}if(xe&&(PD(this.text.orientationVertexArray,Q,V,Z),PD(this.text.orientationVertexArray,ee,V,Z)),Ce){const{placedIconSymbolIndex:Fe,verticalPlacedIconSymbolIndex:Be}=z;Fe>=0&&PD(this.icon.orientationVertexArray,ne,V,Z),Be>=0&&PD(this.icon.orientationVertexArray,le,V,Z)}}M||(this.text.orientationVertexArray=void 0),E||(this.icon.orientationVertexArray=void 0),h&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const c=(M,E,L)=>{y+=E,y>M.length&&M.resize(y);for(let z=-E;z<0;z++)M.emplace(z+y,L)},h=(M,E,L)=>{b+=E,b>M.length&&M.resize(b);for(let z=-E;z<0;z++)M.emplace(z+b,L)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let y=0,b=0;for(let M=0;M0;if((L>0||z>0)&&(c(this.text.zOffsetVertexArray,L,Z),c(this.text.zOffsetVertexArray,z,Z)),Q){const{placedIconSymbolIndex:ee,verticalPlacedIconSymbolIndex:ne}=E;ee>=0&&h(this.icon.zOffsetVertexArray,V,Z),ne>=0&&h(this.icon.zOffsetVertexArray,E.numVerticalIconVertices,Z)}}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,h,y,b,M){!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(E=>E.appearances&&E.appearances.length>0)),this.icon.upload(c,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(c,h,y,b){return!!(c&&h&&y)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(c,h,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=Kje(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(c,h){const y=this.lineVertexArray.length;if(c.segment!==void 0)for(const{x:b,y:M}of h)this.lineVertexArray.emplaceBack(b,M);return{lineStartIndex:y,lineLength:this.lineVertexArray.length-y}}addSymbols(c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe,Ce,Ne,Fe){const Be=c.indexArray,Je=c.layoutVertexArray,yt=c.globeExtVertexArray,mt=c.segments.prepareSegment(4*Fe,Je,Be,this.canOverlap?E.sortKey:void 0),kt=this.glyphOffsetArray.length,It=mt.vertexLength,Rt=this.allowVerticalPlacement&&L===th.vertical?Math.PI/2:0,tr=E.text&&E.text.sections;for(let mr=0;mr=0?h.rightJustifiedTextSymbolIndex:h.centerJustifiedTextSymbolIndex>=0?h.centerJustifiedTextSymbolIndex:h.leftJustifiedTextSymbolIndex>=0?h.leftJustifiedTextSymbolIndex:h.verticalPlacedTextSymbolIndex>=0?h.verticalPlacedTextSymbolIndex:b),E=Gce(this.textSizeData,c,M)/Tl;return this.tilePixelRatio*E}getSymbolInstanceIconSize(c,h,y){const b=this.icon.placedSymbolArray.get(y),M=Gce(this.iconSizeData,c,b);return this.tilePixelRatio*M}_commitDebugCollisionVertexUpdate(c,h,y,b){c.emplaceBack(h,-y,-y,b),c.emplaceBack(h,y,-y,b),c.emplaceBack(h,y,y,b),c.emplaceBack(h,-y,y,b)}_updateTextDebugCollisionBoxes(c,h,y,b,M,E,L){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,h){const y=c.placedSymbolArray.get(h),b=y.vertexStartIndex+4*y.numGlyphs;for(let M=y.vertexStartIndex;Mb[L]-b[z]||M[z]-M[L]),E}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let c=0;cthis.symbolInstances.get(h).zOffset-this.symbolInstances.get(c).zOffset)}addToSortKeyRanges(c,h){const y=this.sortKeyRanges[this.sortKeyRanges.length-1];y&&y.sortKey===h?y.symbolInstanceEnd=c+1:this.sortKeyRanges.push({sortKey:h,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 h of this.symbolInstanceIndexes){const y=this.symbolInstances.get(h);this.featureSortOrder.push(y.featureIndex);const{rightJustifiedTextSymbolIndex:b,centerJustifiedTextSymbolIndex:M,leftJustifiedTextSymbolIndex:E,verticalPlacedTextSymbolIndex:L,placedIconSymbolIndex:z,verticalPlacedIconSymbolIndex:V}=y;b>=0&&this.addIndicesForPlacedSymbol(this.text,b),M>=0&&M!==b&&this.addIndicesForPlacedSymbol(this.text,M),E>=0&&E!==M&&E!==b&&this.addIndicesForPlacedSymbol(this.text,E),L>=0&&this.addIndicesForPlacedSymbol(this.text,L),z>=0&&this.addIndicesForPlacedSymbol(this.icon,z),V>=0&&this.addIndicesForPlacedSymbol(this.icon,V)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(c){const h=this.symbolInstances.get(this.text.symbolInstanceIndices[c]).elevationFeatureIndex;let y;return this.elevationFeatures&&hy in f?String(f[y]):"")}let Yje,Xje,rde;ms(LD,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),LD.addDynamicAttributes=sC;class Qje{constructor(c){this.type=c.property.overrides?c.property.overrides.runtimeType:um,this.defaultValue=c}evaluate(c){if(c.formattedSection){const h=this.defaultValue.property.overrides;if(h&&h.hasOverride(c.formattedSection))return h.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}}ms(Qje,"FormatSectionOverride",{omit:["defaultValue"]});const sde=()=>rde||(rde={layout:Yje||(Yje=new mo({"symbol-placement":new Dr(qt.layout_symbol["symbol-placement"]),"symbol-spacing":new Dr(qt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Dr(qt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Wr(qt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Dr(qt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Dr(qt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Dr(qt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Dr(qt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Dr(qt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Dr(qt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Dr(qt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Wr(qt.layout_symbol["icon-size"]),"icon-size-scale-range":new Dr(qt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new Wr(qt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Wr(qt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Wr(qt.layout_symbol["icon-image"]),"icon-image-use-theme":new Dr({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new Wr(qt.layout_symbol["icon-rotate"]),"icon-padding":new Dr(qt.layout_symbol["icon-padding"]),"icon-keep-upright":new Dr(qt.layout_symbol["icon-keep-upright"]),"icon-offset":new Wr(qt.layout_symbol["icon-offset"]),"icon-anchor":new Wr(qt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Dr(qt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Dr(qt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Dr(qt.layout_symbol["text-rotation-alignment"]),"text-field":new Wr(qt.layout_symbol["text-field"]),"text-font":new Wr(qt.layout_symbol["text-font"]),"text-size":new Wr(qt.layout_symbol["text-size"]),"text-size-scale-range":new Dr(qt.layout_symbol["text-size-scale-range"]),"text-max-width":new Wr(qt.layout_symbol["text-max-width"]),"text-line-height":new Wr(qt.layout_symbol["text-line-height"]),"text-letter-spacing":new Wr(qt.layout_symbol["text-letter-spacing"]),"text-justify":new Wr(qt.layout_symbol["text-justify"]),"text-radial-offset":new Wr(qt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Dr(qt.layout_symbol["text-variable-anchor"]),"text-anchor":new Wr(qt.layout_symbol["text-anchor"]),"text-max-angle":new Dr(qt.layout_symbol["text-max-angle"]),"text-writing-mode":new Dr(qt.layout_symbol["text-writing-mode"]),"text-rotate":new Wr(qt.layout_symbol["text-rotate"]),"text-padding":new Dr(qt.layout_symbol["text-padding"]),"text-keep-upright":new Dr(qt.layout_symbol["text-keep-upright"]),"text-transform":new Wr(qt.layout_symbol["text-transform"]),"text-offset":new Wr(qt.layout_symbol["text-offset"]),"text-allow-overlap":new Dr(qt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Dr(qt.layout_symbol["text-ignore-placement"]),"text-optional":new Dr(qt.layout_symbol["text-optional"]),visibility:new Dr(qt.layout_symbol.visibility)})),paint:Xje||(Xje=new mo({"icon-opacity":new Wr(qt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new Wr(qt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new Wr(qt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Wr(qt.paint_symbol["text-emissive-strength"]),"icon-color":new Wr(qt.paint_symbol["icon-color"]),"icon-halo-color":new Wr(qt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Wr(qt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Wr(qt.paint_symbol["icon-halo-blur"]),"icon-translate":new Dr(qt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Dr(qt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Dr(qt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Wr(qt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new Wr(qt.paint_symbol["text-occlusion-opacity"]),"text-color":new Wr(qt.paint_symbol["text-color"],{runtimeType:tu,getOverride:f=>f.textColor,hasOverride:f=>!!f.textColor}),"text-halo-color":new Wr(qt.paint_symbol["text-halo-color"]),"text-halo-width":new Wr(qt.paint_symbol["text-halo-width"]),"text-halo-blur":new Wr(qt.paint_symbol["text-halo-blur"]),"text-translate":new Dr(qt.paint_symbol["text-translate"]),"text-translate-anchor":new Dr(qt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Dr(qt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Dr(qt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Dr(qt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Dr(qt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new Wr(qt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"})}))},rde);class DD extends Od{constructor(c,h,y,b){super(c,sde(),h,y,b,c.layout?c.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=S([]),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,h){super.recalculate(c,h),this.appearances&&this.appearances.forEach(b=>{b.recalculate(c,h,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 M of y)b.indexOf(M)<0&&b.push(M);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,h,y,b){return this._saturation===c&&this._contrast===h&&this._brightnessMin===y&&this._brightnessMax===b||(this._colorAdjustmentMatrix=function(M,E,L,z){M=Ui(M),E=da(E);const V=k(),Z=M/3,Q=1-2*Z,ee=[Q,Z,Z,0,Z,Q,Z,0,Z,Z,Q,0,0,0,0,1],ne=.5-.5*E,le=z-L;return C(V,[le,0,0,0,0,le,0,0,0,0,le,0,L,L,L,1],[E,0,0,0,0,E,0,0,0,0,E,0,ne,ne,ne,1]),C(V,V,ee),V}(c,h,y,b),this._saturation=c,this._contrast=h,this._brightnessMin=y,this._brightnessMax=b),this._colorAdjustmentMatrix}getValueAndResolveTokens(c,h,y,b){const M=this.layout.get(c).evaluate(h,{},y,b),E=this._unevaluatedLayout._values[c];return E.isDataDriven()||L_(E.value)||!M?M:Zje(h.properties,M)}getAppearanceValueAndResolveTokens(c,h,y,b,M){const E=c.getProperty(h);if(!E)return;const L=E.evaluate(y,{},b,M),z=c.getUnevaluatedProperties()._values[h];return z.isDataDriven()||L_(z.value)||!L||typeof L!="string"?L:Zje(y.properties,L)}createBucket(c){return new LD(c)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const c of sde().paint.overridableProperties){if(!DD.hasPaintOverride(this.layout,c))continue;const h=this.paint.get(c),y=new Qje(h),b=new dS(y,h.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let M=null;M=h.value.kind==="constant"||h.value.kind==="source"?new U0("source",b):new Wx("composite",b,h.value.zoomStops,h.value.interpolationType),this.paint._values[c]=new Kx(h.property,M,h.parameters)}}_handleOverridablePaintPropertyUpdate(c,h,y){return!(!this.layout||h.isDataDriven()||y.isDataDriven())&&DD.hasPaintOverride(this.layout,c)}static hasPaintOverride(c,h){const y=c.get("text-field"),b=sde().paint.properties[h];let M=!1;const E=L=>{for(const z of L)if(b.overrides&&b.overrides.hasOverride(z))return void(M=!0)};if(y.value.kind==="constant"&&y.value.value instanceof Id)E(y.value.value.sections);else if(y.value.kind==="source"){const L=V=>{M||(V instanceof np&&Ml(V.value)===v_?E(V.value.sections):V instanceof ef?E(V.sections):V.eachChild(L))},z=y.value;z._styleExpression&&L(z._styleExpression.expression)}return M}getProgramIds(){return["symbol"]}getDefaultProgramParams(c,h,y){return{config:new Og(this,{zoom:h,lut:y}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let Jje,eke,tke,rke;var nde=Xn([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function OD(f,c,h,y,b,M,E,L){const z=[f,c,1,h,y,1,b,M,1],V=[E,L,1],Z=v([],z),[Q,ee,ne]=ue(V,V,Z);return _(z,z,[Q,0,0,0,ee,0,0,0,ne])}function ske(f,c,h,y,b,M,E,L){const z=function(V,Z,Q,ee,ne,le,xe,Ce){const Ne=OD(0,0,1,0,1,1,0,1),Fe=OD(V,Z,Q,ee,ne,le,xe,Ce);return _(Fe,Fe,v([],Ne))}(f,c,h,y,b,M,E,L);return[z[2]/z[8]/Br,z[5]/z[8]/Br]}function RD(f){return[f[0],Math.min(Math.max(f[1],-fe),fe)]}class nke extends Kn{constructor(c,h,y,b){super(),this.id=c,this.dispatcher=y,this.coordinates=h.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=h,this._dirty=!1}load(c,h){if(this._loaded=h||!1,this.fire(new Hr("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return c&&(this.coordinates=c),this._loaded=!0,void this._finishLoading();this._imageRequest=C0(this.map._requestManager.transformRequest(this.url,rp.Image),(y,b)=>{this._imageRequest=null,this._loaded=!0,y?this.fire(new pn(y)):b&&(this.image=b instanceof HTMLImageElement?tl.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 CT(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 Hr("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 CT||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 h=c[0][1],y=c[0][1];for(const M of c)M[1]>y&&(y=M[1]),M[1]fe?this.onNorthPole=!0:b<-fe&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const M=c.map(Ge.fromLngLat);this.tileID=function(E){let L=1/0,z=1/0,V=-1/0,Z=-1/0;for(const xe of E)L=Math.min(L,xe.x),z=Math.min(z,xe.y),V=Math.max(V,xe.x),Z=Math.max(Z,xe.y);const Q=Math.max(V-L,Z-z),ee=Math.max(0,Math.floor(-Math.log2(Q))),ne=Math.pow(2,ee);let le=Math.floor((L+V)/2*ne);return le>1&&(le-=1),new li(ee,le,Math.floor((z+Z)/2*ne))}(M),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Hr("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof CT||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(c){for(const Ne in this.tiles){const Fe=this.tiles[Ne];Fe.state!=="loaded"&&(Fe.state="loaded",Fe.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const h=OT(new li(0,0,0),this.map.transform.projection),y=[h.projection.project(this.coordinates[0][0],this.coordinates[0][1]),h.projection.project(this.coordinates[1][0],this.coordinates[1][1]),h.projection.project(this.coordinates[2][0],this.coordinates[2][1]),h.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(Ne){const Fe=Ne[1].x-Ne[0].x,Be=Ne[1].y-Ne[0].y,Je=Ne[2].x-Ne[1].x,yt=Ne[2].y-Ne[1].y,mt=Ne[3].x-Ne[2].x,kt=Ne[3].y-Ne[2].y,It=Ne[0].x-Ne[3].x,Rt=Ne[0].y-Ne[3].y,tr=Fe*yt-Je*Be,$t=Je*kt-mt*yt,or=mt*Rt-It*kt,mr=It*Be-Fe*Rt;return tr>0&&$t>0&&or>0&&mr>0||tr<0&&$t<0&&or<0&&mr<0}(y))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const b=OT(this.tileID,this.map.transform.projection),[M,E,L,z]=this.coordinates.map(Ne=>{const Fe=b.projection.project(Ne[0],Ne[1]);return Vje(b,Fe)._round()});this.perspectiveTransform=ske(M.x,M.y,E.x,E.y,L.x,L.y,z.x,z.y);const V=this._boundsArray=new W0;V.emplaceBack(M.x,M.y,0,0),V.emplaceBack(E.x,E.y,Br,0),V.emplaceBack(z.x,z.y,0,Br),V.emplaceBack(L.x,L.y,Br,Br),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=c.createVertexBuffer(V,nde.members),this.boundsSegments=to.simpleSegment(0,0,4,2);const Z=[],Q=[RD((ee=this.coordinates)[0]),RD(ee[1]),RD(ee[2]),RD(ee[3])];var ee;const[ne,le,xe,Ce]=function(Ne){let Fe=Ne[0][0],Be=Fe,Je=Ne[0][1],yt=Je;for(let mt=1;mtBe&&(Be=Ne[mt][0]),Ne[mt][1]yt&&(yt=Ne[mt][1]);return[Fe,Je,Be-Fe,yt-Je]}(Q);{const Ne=new W0,[Fe,Be,Je,yt]=function(xr){let _r=xr[0].x,ir=_r,sr=xr[0].y,br=sr;for(let Vr=1;Vrir&&(ir=xr[Vr].x),xr[Vr].ybr&&(br=xr[Vr].y);return[_r,sr,ir-_r,br-sr]}(y),mt=xr=>[(xr.x-Fe)/Je,(xr.y-Be)/yt],[kt,It,Rt,tr]=y.map(mt),$t=function(xr,_r,ir,sr,br,Vr,Ar,Ns){const Jr=OD(0,0,1,0,1,1,0,1);return _(Jr,Jr,v([],OD(xr,_r,ir,sr,br,Vr,Ar,Ns)))}(kt[0],kt[1],It[0],It[1],Rt[0],Rt[1],tr[0],tr[1]);this.elevatedGlobePerspectiveTransform=ske(kt[0],kt[1],It[0],It[1],Rt[0],Rt[1],tr[0],tr[1]);const or=(xr,_r)=>{Z.push(xr.lng);const ir=Math.round((xr.lng-ne)/xe*Br),sr=Math.round((xr.lat-le)/Ce*Br),br=mt(_r),Vr=ue([],[br[0],br[1],1],$t),Ar=Math.round(Vr[0]/Vr[2]*Br),Ns=Math.round(Vr[1]/Vr[2]*Br);Ne.emplaceBack(ir,sr,Ar,Ns)},mr=y[3].x-y[0].x,fr=y[3].y-y[0].y,wr=y[2].x-y[1].x,kr=y[2].y-y[1].y;for(let xr=0;xr<65;xr++){const _r=xr/64,ir=[y[0].x+_r*mr,y[0].y+_r*fr],sr=[y[1].x+_r*wr,y[1].y+_r*kr],br=sr[0]-ir[0],Vr=sr[1]-ir[1];for(let Ar=0;Ar<65;Ar++){const Ns=Ar/64,Jr={x:ir[0]+br*Ns,y:ir[1]+Vr*Ns};or(h.projection.unproject(Jr.x,Jr.y),Jr)}}this.elevatedGlobeVertexBuffer=c.createVertexBuffer(Ne,nde.members)}{this.maxLongitudeTriangleSize=0;let Ne=[],Fe=new rl;const Be=(Je,yt,mt)=>{Fe.emplaceBack(Je,yt,mt);const kt=Z[Je],It=Z[yt],Rt=Z[mt],tr=Math.min(Math.min(kt,It),Rt),$t=Math.max(Math.max(kt,It),Rt)-tr;$t>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=$t),Ne.push(tr+$t/2)};for(let Je=0;Je<64;Je++)for(let yt=0;yt<64;yt++){const mt=65*Je+yt,kt=mt+1,It=mt+65,Rt=It+1;Be(mt,It,kt),Be(kt,It,Rt)}[Ne,Fe]=function(Je,yt){const mt=Array.from({length:Je.length},(Rt,tr)=>tr);mt.sort((Rt,tr)=>Je[Rt]-Je[tr]);const kt=[],It=new rl;for(let Rt=0;Rt{E.segments.push({vertexOffset:0,primitiveOffset:Q,vertexLength:h.segments[0].vertexLength,primitiveLength:ee,sortKey:void 0,vaos:{}})},z=.51*this.maxLongitudeTriangleSize;if(Math.abs(y[0]-b)<=z){const Q=$i(y,0,y.length,b+z);return Q===y.length||L(Q,Do(y,Q+1,y.length,b+360-z)-Q),E}bBr?b-Br:b,new dr(Math.trunc(b),Math.trunc(y[h+1]))}translationForInstance(c){const h=16*c,y=this.instancedDataArray.float32;return[y[h+4],y[h+5],y[h+6]]}rotationScaleForInstance(c){const h=16*c,y=this.instancedDataArray.float32;return[y[h+7],y[h+8],y[h+9],y[h+10],y[h+11],y[h+12],y[h+13],y[h+14],y[h+15]]}transformForInstance(c){const h=16*c,y=this.instancedDataArray.float32;return[y[h+7],y[h+8],y[h+9],y[h+4],y[h+10],y[h+11],y[h+12],y[h+5],y[h+13],y[h+14],y[h+15],y[h+6],0,0,0,1]}}class ode{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(h=>h.fqid),this.projection=c.projection,this.index=c.index,this.worldview=c.worldview,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(h=>h.isStateDependent()).map(h=>h.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,h){}updateAppearances(c,h,y,b){}populate(c,h,y,b){this.tileToMeter=Oe(y);const M=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:E,id:L,index:z,sourceLayerIndex:V}of c){const Z=L??(E.properties&&E.properties.hasOwnProperty("id")?E.properties.id:void 0),Q=Bt(E,M);if(!this.layers[0]._featureFilter.filter(new bi(this.zoom,{worldview:this.worldview,activeFloors:h.activeFloors}),Q,y))continue;const ee={id:Z,sourceLayerIndex:V,index:z,geometry:M?Q.geometry:At(E,y,b),properties:E.properties,type:E.type,patterns:{}},ne=this.addFeature(ee,ee.geometry,Q);ne&&h.featureIndex.insert(E,ee.geometry,z,V,this.index,this.instancesPerModel[ne].instancedDataArray.length,Br/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const c=this.layers[0].modelManager,h=this.layers[0].scope;let y=0;for(const b of this.modelUris){const M=c.getModel(b,h);if(!M)continue;const E=this.instancesPerModel[b];if(E){const L=.5*Ae(M.aabb.max,M.aabb.min)*E.maxScale+E.maxXYTranslationDistance,z=Math.min(Br,Math.max(L/this.tileToMeter,Br/32));y=Math.max(z,y)}}return y}update(c,h,y,b){for(const M in this.instancesPerModel){const E=this.instancesPerModel[M];for(const L in c)E.idToFeaturesIndex.hasOwnProperty(L)&&(this.evaluate(E.features[E.idToFeaturesIndex[L]],c[L],E,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let c=!1;for(const h in this.instancesPerModel){const y=this.instancesPerModel[h];for(const b of y.features){const M=this.layers[0],E=b.feature,L=this.canonical,z=M.paint.get("model-rotation").evaluate(E,{},L),V=M.paint.get("model-scale").evaluate(E,{},L),Z=M.paint.get("model-translation").evaluate(E,{},L);rt(b.rotation,z)&&rt(b.scale,V)&&rt(b.translation,Z)||(this.evaluate(b,b.featureStates,y,!0),c=!0)}}return c}updateReplacement(c,h,y,b){if(h.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=h.updateTime;const M=h.getReplacementRegionsForTile(c.toUnwrapped(),!0);if(lD(this.activeReplacements,M))return!1;this.activeReplacements=M;let E=!1;for(const L in this.instancesPerModel){const z=this.instancesPerModel[L],V=z.instancedDataArray;for(const Z of z.features){const Q=Z.instancedDataOffset,ee=Z.instancedDataCount;for(let ne=0;neBr;xe=Ce?xe-Br:xe;const Ne=Math.floor(xe),Fe=Math.floor(V.float32[le+1]);let Be=!1;for(const Je of this.activeReplacements)if(!e2e(Je,y,hke.Model,b)&&!(Je.min.x>Ne||Ne>Je.max.x||Je.min.y>Fe||Fe>Je.max.y)&&(Be=a2e(n2e(Ne,Fe,c.canonical,Je.footprintTileId.canonical),Je.footprint),Be))break;V.float32[le]=Be?xe+Br:xe,E=E||Be!==Ce}}}return E}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 h in this.instancesPerModel){const y=this.instancesPerModel[h];y.instancedDataArray.length<0||y.instancedDataArray.length===0||(y.instancedDataBuffer?y.instancedDataBuffer.updateData(y.instancedDataArray):y.instancedDataBuffer=c.createVertexBuffer(y.instancedDataArray,SQe.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 h=this.layers[0].modelManager;if(c&&h&&this.modelUris&&this.modelsRequested)for(const y of this.modelUris)h.removeModel(y,"",!0)}addFeature(c,h,y){const b=this.layers[0],M=b.layout.get("model-id").evaluate(y,{},this.canonical);if(!M)return ts(`modelId is not evaluated for layer ${b.id} and it is not going to get rendered.`),M;(ide(M,!1)||this.styleDefinedModelURLs[M]!==void 0)&&(this.modelUris.includes(M)||this.modelUris.push(M)),this.instancesPerModel[M]||(this.instancesPerModel[M]=new fke);const E=this.instancesPerModel[M],L=E.instancedDataArray,z=new mke(y,L.length);for(const V of h)for(const Z of V){if(Z.x<0||Z.x>=Br||Z.y<0||Z.y>=Br)continue;if(this.lookupDim!==0){const ee=(this.lookupDim-1)/Br,ne=this.lookupDim*(Z.y*ee|0)+Z.x*ee|0;if(this.lookup){if(this.lookup[ne]!==0)continue;this.lookup[ne]=1}}this.instanceCount++;const Q=L.length;L.resize(Q+1),E.instancesEvaluatedElevation.push(0),L.float32[16*Q]=Z.x,L.float32[16*Q+1]=Z.y}return z.instancedDataCount=E.instancedDataArray.length-z.instancedDataOffset,z.instancedDataCount>0&&(c.id&&(E.idToFeaturesIndex[c.id]=E.features.length),E.features.push(z),this.evaluate(z,{},E,!1)),M}getModelUris(){return this.modelUris}evaluate(c,h,y,b){const M=this.layers[0],E=c.feature,L=this.canonical,z=c.rotation=M.paint.get("model-rotation").evaluate(E,h,L),V=c.scale=M.paint.get("model-scale").evaluate(E,h,L),Z=c.translation=M.paint.get("model-translation").evaluate(E,h,L),Q=Object.assign({},M.paint.get("model-color").evaluate(E,h,L));Q.a=M.paint.get("model-color-mix-intensity").evaluate(E,h,L);const ee=[];this.maxVerticalOffset0?Math.sqrt(ne):0;y.maxScale=Math.max(Math.max(y.maxScale,V[0]),Math.max(V[1],V[2])),y.maxXYTranslationDistance=Math.max(y.maxXYTranslationDistance,le),this.maxScale=Math.max(Math.max(this.maxScale,V[0]),Math.max(V[1],V[2])),H2e(ee,z,V);const xe=Math.round(100*Q.a)+Q.b/1.05;for(let Ce=0;Ce10?this.tileToMeter:Oe(L,yt)),Be[Fe+4]=Z[0],Be[Fe+5]=Z[1],Be[Fe+6]=Z[2]+Je,Be[Fe+7]=ee[0],Be[Fe+8]=ee[1],Be[Fe+9]=ee[2],Be[Fe+10]=ee[4],Be[Fe+11]=ee[5],Be[Fe+12]=ee[6],Be[Fe+13]=ee[8],Be[Fe+14]=ee[9],Be[Fe+15]=ee[10],y.instancesEvaluatedElevation[Ne]=Z[2]}}}let pke,gke;ms(ode,"ModelBucket",{omit:["layers"]}),ms(fke,"PerModelAttributes"),ms(mke,"ModelFeature");class nC{constructor(c,h,y){this._demTile=c,this._dem=this._demTile.dem,this._scale=h,this._offset=y}static create(c,h,y){const b=y||c.findDEMTileFor(h);if(!b||!b.dem)return;const M=b.dem,E=b.tileID,L=1<V.fqid),this.stateDependentLayerIds=this.layers.filter(V=>V.isStateDependent()).map(V=>V.id),this.modelTraits|=ZS.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,b&&(this.modelTraits|=ZS.HasMapboxMeshFeatures),M&&(this.modelTraits|=ZS.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=E,this.worldview=z,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const V of h)this.nodesInfo.push(new _ke(V)),yke(V,L.featureIndexArray.length,L.grid),L.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,L.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(c,h){for(const y of this.getNodesInfo()){const b=y.node;b.footprint&&h.push({footprint:b.footprint,id:c})}}updateAppearances(c,h,y,b){}update(c){const h=Object.keys(c).length!==0;if(h&&!this.stateDependentLayers.length)return;const y=h?this.stateDependentLayers:this.layers;if(!$a(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 h=this.getNodesInfo();for(const y of h){const b=y.node;this.uploaded?this.updatePbrBuffer(b):Ice(b,c,!0)}for(const y of h)_D(y.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(c){let h=!1;if(!c.meshes)return h;for(const y of c.meshes)y.pbrBuffer&&(y.pbrBuffer.updateData(y.featureArray),h=!0);return h}needsReEvaluation(c,h,y){const b=c.transform.projectionOptions,M=c.style.getBrightness(),E=this.brightness!==M;if(!this.uploaded||this.dirty||b.name!==this.projection.name||qT(y.paint.get("model-color").value,E)||qT(y.paint.get("model-color-mix-intensity").value,E)||qT(y.paint.get("model-roughness").value,E)||qT(y.paint.get("model-emissive-strength").value,E)||qT(y.paint.get("model-height-based-emissive-strength-multiplier").value,E)){this.projection=b,this.brightness=M;const L=this.getNodesInfo();for(const z of L)z.state=null;return!0}return!1}evaluateTransform(c,h){if(c.transform.zoom===this.zoom)return;this.zoom=c.transform.zoom;const y=this.getNodesInfo(),b=this.id.canonical;for(const M of y){const E=M.feature;M.evaluatedTranslation=h.paint.get("model-translation").evaluate(E,{},b),M.evaluatedScale=h.paint.get("model-scale").evaluate(E,{},b)}}evaluate(c,h){const y=this.getNodesInfo();for(const b of y){if(!b.node.meshes)continue;const M=b.feature,E=h&&h[M.id];if($a(E,b.state))continue;b.state=structuredClone(E);const L=b.node.meshes&&b.node.meshes[0].featureData,z=b.evaluatedColor[2],V=b.evaluatedRMEA[2],Z=this.id.canonical;if(b.hasTranslucentParts=!1,L){for(let Q=0;Q=mt)continue;const xr=lde[kr],_r=Math.abs(xr);_r>$t&&(tr=xr,$t=_r,or=wr,mr=fr)}if($t>.1){const fr=1-(mt+.5*Math.abs(or*mr))/le;let wr=h._dem.get(It,kt)+tr*fr;const kr=h._dem.get(It+or,kt+mr),xr=h._dem.get(It-or,kt-mr,!0);(wr-kr)*(wr-xr)>0&&(wr=(kr+xr)/2),lde[Rt]=h._dem.set(It,kt,wr),rb[Rt]=mt}}}}}L&&(h._demTile.needsDEMTextureUpload=!0,h._dem._timestamp=tl.now())}setFilter(c){this.filter=c?vS(c):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(c=>this.filter.filter(new bi(this.id.overscaledZ,{worldview:this.worldview}),c.feature,this.id.canonical)):this.nodesInfo}destroy(){const c=this.getNodesInfo();for(const h of c)_D(h.node),Pce(h.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(c,h){if(h.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=h.updateTime;const y=h.getReplacementRegionsForTile(c.toUnwrapped());for(const b of this.getNodesInfo()){const M=b.node.footprint;b.hiddenByReplacement=!!M&&!y.find(E=>E.footprint===M)}}getHeightAtTileCoord(c,h){const y=[],b=[0,0,0],M=S([]);for(const E of this.getNodesInfo()){const L=E.node.meshes[0],z=L.transformedAabb;if(cz.max[0]||h>z.max[1])continue;if(E.node.hidden===!0)return{height:1/0,maxHeight:E.feature.properties.height,hidden:!1,verticalScale:E.evaluatedScale[2]};T(M,E.node.globalMatrix),b[0]=c,b[1]=h,st(b,b,M);const V=(b[0]-L.aabb.min[0])/(L.aabb.max[0]-L.aabb.min[0])*J_|0,Z=Math.min(63,(b[1]-L.aabb.min[1])/(L.aabb.max[1]-L.aabb.min[1])*J_|0)*J_+Math.min(63,V),Q=L.heightmap[Z];if(!(Q<0&&E.node.footprint))return E.hiddenByReplacement?void 0:{height:Q,maxHeight:E.feature.properties.height,hidden:!1,verticalScale:E.evaluatedScale[2]};if(E.node.footprint.grid.query(new dr(c,h),new dr(c,h),y),y.length>0)return{height:void 0,maxHeight:E.feature.properties.height,hidden:E.hiddenByReplacement,verticalScale:E.evaluatedScale[2]}}}}function qT(f,c){return f instanceof U0&&!f.isLightConstant&&c}function net(f,c,h,y,b,M,E,L){let z=(61440&c|(61440&c)>>4)>>8,V=(3840&c|(3840&c)>>4)>>4,Z=240&c|(240&c)>>4;h[3]>0&&(z=Gs(z,255*h[0],h[3]),V=Gs(V,255*h[1],h[3]),Z=Gs(Z,255*h[2],h[3]));const Q=z<<8|V,ee=Z<<8|Math.floor(255*y[3]),ne=function(mt){const kt=ye(mt,0,2);return Math.min(Math.round(.5*kt*255),255)}(y[2])<<8|15*y[0]<<4|15*y[1],le=ye(b[0],0,1),xe=ye(b[1],0,1),Ce=ye(b[2],0,1),Ne=ye(b[3],0,1);let Fe,Be,Je,yt;if(le!==xe&&E!==M&&xe!==le){const mt=E-M;Be=1/(mt*(xe-le)),Je=-(M+mt*le)/(mt*(xe-le));const kt=ye(b[4],-1,1);yt=Math.pow(10,kt),Fe=255*Ce<<8|255*Ne}else Fe=65535,Be=0,Je=1,yt=1;if(f.emplaceBack(Q,ee,ne,Fe,Be,Je,yt),L){const mt=L.length;L.clear();for(let kt=0;kt>16&65535,Z=M?z>>16&65535:65535&z,Q=(15&Z)<8?15&Z:0,ee=f.evaluatedRMEA[Q],ne=f.evaluatedColor[Q],le=f.emissionHeightBasedParams[Q];let xe;if(L&&Q===2&&y.lights&&(xe=new AS,xe.resize(10*y.lights.length)),net(E.featureArray,V,ne,ee,le,E.aabb.min[2],E.aabb.max[2],xe),xe&&L){L=!1;const Ce=y.meshes[y.lightMeshIndex];Ce.featureArray=xe,Ce.featureArray._trim()}}E.featureArray._trim(),b++}}ms(zD,"Tiled3dModelBucket",{omit:["layers"]}),ms(_ke,"Tiled3dModelFeature");const iet=["id","tile","layer","source","sourceLayer","state"];class sb{constructor(c,h,y,b,M){this.type="Feature",this._vectorTileFeature=c,this._z=h,this._x=y,this._y=b,this.properties=c?c.properties:{},this.id=M}clone(){const c=new sb(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 h of iet)this[h]!==void 0&&(c[h]=this[h]);return c}}class nb extends Kn{constructor(c,h,y,b){super(),this.id=c,this.type="model",this.models=[],this._loaded=!1,this._options=h,this._modelsInfo=new Map}load(){const c=[];for(const h in this._options.models){const y=this._options.models[h],b=this._modelsInfo.get(h);if(b){const M=b.model;M.position=y.position!=null?new x(y.position[0],y.position[1]):new x(0,0),M.orientation=y.orientation!=null?y.orientation:[0,0,0],b.modelSpec=y,nb.applyModelSpecification(M,y),M.computeBoundsAndApplyParent(),this.models.push(M)}else{const M=$2e(this.map._requestManager.transformRequest(y.uri,rp.Model).url).then(E=>{if(!E)return;const L=Dce(E),z=new W2e(h,y.uri,y.position,y.orientation,L);nb.applyModelSpecification(z,y),z.computeBoundsAndApplyParent(),this.models.push(z),this._modelsInfo.set(h,{modelSpec:y,model:z})}).catch(E=>{this.fire(new pn(new Error(`Could not load model ${h} from ${y.uri}: ${E.message}`)))});c.push(M)}}Promise.allSettled(c).then(()=>{this._loaded=!0,this.fire(new Hr("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(h=>{this._loaded=!0,this.fire(new pn(new Error(`Could not load models: ${h.message}`)))})}static applyModelSpecification(c,h){h.nodeOverrides&&nb.convertNodeOverrides(c,h.nodeOverrides),h.materialOverrides&&nb.convertMaterialOverrides(c,h.materialOverrides),h.nodeOverrideNames&&(c.nodeOverrideNames=[...h.nodeOverrideNames]),h.materialOverrideNames&&(c.materialOverrideNames=[...h.materialOverrideNames]),h.featureProperties&&(c.featureProperties=h.featureProperties)}static convertNodeOverrides(c,h){if(Array.isArray(h)&&h.every(y=>typeof y=="string")){c.nodeOverrideNames=[];for(const y of h)c.nodeOverrideNames.push(y)}else Object.entries(h).forEach(([y,b])=>{const M={orientation:[0,0,0]};if(b.hasOwnProperty("orientation")){const E=b.orientation;E&&(M.orientation=E)}c.nodeOverrides.set(y,M)})}static convertMaterialOverrides(c,h){if(Array.isArray(h)&&h.every(y=>typeof y=="string")){c.materialOverrideNames=[];for(const y of h)c.materialOverrideNames.push(y)}else Object.entries(h).forEach(([y,b])=>{const M={color:new Aa(1,1,1),colorMix:0,emissionStrength:0,opacity:1},E=b["model-color"];E!==void 0&&(M.color.r=E[0],M.color.g=E[1],M.color.b=E[2]);const L=b["model-color-mix-intensity"];L!==void 0&&(M.colorMix=L);const z=b["model-emissive-strength"];z!==void 0&&(M.emissionStrength=z);const V=b["model-opacity"];V!==void 0&&(M.opacity=V),c.materialOverrides.set(y,M)})}onAdd(c){this.map=c,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(c,h){}serialize(){return this._options}setProperty(c,h){return!1}reload(){const c=pm(this.id,this.scope);this.map.style.clearSource(c),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(c){this.models=[];const h=new Map;for(const y in c){const b=c[y];if(this._modelsInfo.has(y)){const M=this._modelsInfo.get(y);M&&M.modelSpec.uri===b.uri&&h.set(y,M)}}this._modelsInfo=h,this._options.models=c,this._loaded=!1,this.load()}}function cde(f,c,h,y){const b=1<Je.polygon).flat());const Ce=ne?L:null,[Ne,Fe]=T2e(M,y,Q,Z,V,E,Ce,ee,le,M.center.lat,f.tileID.canonical),Be=f.queryGeometry;return M2e(Ne,Fe,Be.isPointQuery()?Be.screenBounds:Be.screenGeometry)}},building:class extends Od{constructor(f,c,h,y){super(f,{layout:J2e||(J2e=new mo({visibility:new Dr(qt.layout_building.visibility),"building-facade":new Wr(qt.layout_building["building-facade"]),"building-facade-floors":new Wr(qt.layout_building["building-facade-floors"]),"building-facade-unit-width":new Wr(qt.layout_building["building-facade-unit-width"]),"building-facade-window":new Wr(qt.layout_building["building-facade-window"]),"building-roof-shape":new Wr(qt.layout_building["building-roof-shape"]),"building-height":new Wr(qt.layout_building["building-height"]),"building-base":new Wr(qt.layout_building["building-base"]),"building-flood-light-wall-radius":new Wr(qt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new Wr(qt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new Wr(qt.layout_building["building-flip-roof-orientation"])})),paint:eje||(eje=new mo({"building-opacity":new Dr(qt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Dr(qt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Dr(qt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Dr(qt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Dr(qt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Dr(qt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Dr(qt.paint_building["building-cast-shadows"]),"building-color":new Wr(qt.paint_building["building-color"]),"building-emissive-strength":new Wr(qt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Dr(qt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Dr(qt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Dr(qt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Dr(qt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Dr(qt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new Wr({type:"string",default:"default","property-type":"data-driven"})}))},c,h,y),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(f){return new Q2e(f)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(f){return!0}queryRadius(f){return 0}queryIntersectsFeature(f,c,h,y,b,M,E,L,z){let V=this.layout.get("building-height").evaluate(c,h);const Z=this.layout.get("building-base").evaluate(c,h),Q=f.tile.getBucket(this).getFootprint(c);if(Q){if(Q.hiddenFlags!==0)return!1;V=Q.height}const[ee,ne]=T2e(M,y,Z,V,new dr(0,0),E,null,[0,0],1,M.center.lat,f.tileID.canonical),le=f.queryGeometry;return M2e(ee,ne,le.isPointQuery()?le.screenBounds:le.screenGeometry)}},line:class extends Od{constructor(f,c,h,y){const b=dje();super(f,b,c,h,y),b.layout&&(this.layout=new Zx(b.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(f){if(f==="line-gradient"){const c=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=c._styleExpression&&c._styleExpression.expression instanceof M_,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}emissiveStrengthExpression(){return this._transitionablePaint._values["line-emissive-strength"].value.expression}recalculate(f,c){super.recalculate(f,c),this.paint._values["line-floorwidth"]=(()=>{if(TT)return TT;const h=dje();return TT=new rJe(h.paint.properties["line-width"].specification),TT.useIntegerZoom=!0,TT})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,f)}createBucket(f){return new Fce(f)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(f,c,h){const y=lje(this);return{config:new Og(this,{zoom:c,lut:h}),defines:y,overrideFog:!1}}queryRadius(f){const c=f,h=uje(Yc("line-width",this,c),Yc("line-gap-width",this,c)),y=Yc("line-offset",this,c);return h/2+Math.abs(y)+nc(this.paint.get("line-translate"))}queryIntersectsFeature(f,c,h,y,b,M){if(f.queryGeometry.isAboveHorizon)return!1;const E=Ju(f.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),M.angle,f.pixelToTileUnitsFactor),L=f.pixelToTileUnitsFactor/2*uje(this.paint.get("line-width").evaluate(c,h),this.paint.get("line-gap-width").evaluate(c,h)),z=this.paint.get("line-offset").evaluate(c,h);return z&&(y=function(V,Z){const Q=[],ee=new dr(0,0);for(let ne=0;ne=3){for(let le=0;le>16&255)/255,(f>>8&255)/255,(255&f)/255,1)}function wet(f,c,h){f===1?(c.rgb_color=VD(h.readVarint()),c.paint="rgb_color"):f===2?(c.linear_gradient_idx=h.readVarint(),c.paint="linear_gradient_idx"):f===3?(c.radial_gradient_idx=h.readVarint(),c.paint="radial_gradient_idx"):f===5?h.readPackedFloat(c.dasharray):f===6?c.dashoffset=h.readFloat():f===7?c.miterlimit=h.readFloat():f===8?c.opacity=h.readVarint():f===9?c.width=h.readFloat():f===10?c.linecap=h.readVarint():f===11&&(c.linejoin=h.readVarint())}function jet(f,c,h){f===1?c.transform=UD(h,h.readVarint()+h.pos):f===2?c.spread_method=h.readVarint():f===3?c.stops.push(kke(h,h.readVarint()+h.pos)):f===4?c.x1=h.readFloat():f===5?c.y1=h.readFloat():f===6?c.x2=h.readFloat():f===7&&(c.y2=h.readFloat())}function kke(f,c){return f.readFields(ket,{offset:0,opacity:255,rgb_color:dde},c)}function ket(f,c,h){f===1?c.offset=h.readFloat():f===2?c.opacity=h.readVarint():f===3&&(c.rgb_color=VD(h.readVarint()))}function Net(f,c,h){f===1?c.transform=UD(h,h.readVarint()+h.pos):f===2?c.spread_method=h.readVarint():f===3?c.stops.push(kke(h,h.readVarint()+h.pos)):f===4?c.cx=h.readFloat():f===5?c.cy=h.readFloat():f===6?c.r=h.readFloat():f===7?c.fx=h.readFloat():f===8?c.fy=h.readFloat():f===9&&(c.fr=h.readFloat())}function Cet(f,c,h){f===1?c.transform=UD(h,h.readVarint()+h.pos):f===2?c.clip_path_idx=h.readVarint():f===3&&c.children.push($D(h,h.readVarint()+h.pos))}function Met(f,c,h){f===1?c.left=c.top=h.readFloat():f===2?c.width=c.height=h.readFloat():f===3?c.top=h.readFloat():f===4?c.height=h.readFloat():f===5?c.mask_type=h.readVarint():f===6?c.mask_idx=h.readVarint():f===7&&c.children.push($D(h,h.readVarint()+h.pos))}class Tet{static calculate(c={},h=[]){const y=new Map,b=new Map;if(Object.keys(c).length===0)return y;h.forEach(M=>{b.set(M.name,M.rgb_color||new Aa(0,0,0))});for(const[M,E]of Object.entries(c))b.has(M)?y.set(b.get(M).toString(),E):console.warn(`Ignoring unknown image variable "${M}"`);return y}}function aC(f,c=255,h){const y=c/255,b=f.toString(),M=h.has(b)?h.get(b).clone():f.clone();return M.a*=y,M.toString()}function WT(f,c){if(!Ch()){const h=document.createElement("canvas");return h.width=f,h.height=c,h}return new OffscreenCanvas(f,c)}let mde,GT=null;function fde(f,c,h,y,b){for(const M of y.children)Nke(f,c,h,M,b)}function Nke(f,c,h,y,b){y.group?(f.save(),function(M,E,L,z,V){const Z=z.mask_idx!=null?L.masks[z.mask_idx]:null,Q=z.clip_path_idx!=null?L.clip_paths[z.clip_path_idx]:null;if(z.transform&&(E=iC(z.transform).preMultiplySelf(E)),!function(le,xe,Ce){return le.opacity!==255||xe||Ce}(z,Q!=null,Z!=null))return void fde(M,E,L,z,V);const ee=WT(M.canvas.width,M.canvas.height),ne=ee.getContext("2d");fde(ne,E,L,z,V),Q&&Ike(ne,E,L,Q),Z&&Pke(ne,E,L,Z,V),M.globalAlpha=z.opacity/255,M.drawImage(ee,0,0)}(f,c,h,y.group,b),f.restore()):y.path&&(f.save(),function(M,E,L,z,V){M.setTransform(E),z.paint_order===det.PAINT_ORDER_FILL_AND_STROKE?(Ske(M,L,z,V),Mke(M,L,z,V)):(Mke(M,L,z,V),Ske(M,L,z,V))}(f,c,h,y.path,b),f.restore())}function Ske(f,c,h,y){const b=h.fill;if(!b)return;const M=b.opacity/255;switch(f.save(),f.beginPath(),Lke(h,f),b.paint){case"rgb_color":f.fillStyle=aC(b.rgb_color,b.opacity,y);break;case"linear_gradient_idx":{const E=c.linear_gradients[b.linear_gradient_idx];E.transform&&f.setTransform(iC(E.transform).preMultiplySelf(f.getTransform())),f.fillStyle=Tke(f,E,M,y);break}case"radial_gradient_idx":{const E=c.radial_gradients[b.radial_gradient_idx];E.transform&&f.setTransform(iC(E.transform).preMultiplySelf(f.getTransform())),f.fillStyle=Ake(f,E,M,y)}}f.fill(Cke(h)),f.restore()}function Cke(f){return f.rule===ude.PATH_RULE_NON_ZERO?"nonzero":f.rule===ude.PATH_RULE_EVEN_ODD?"evenodd":void 0}function Mke(f,c,h,y){const b=h.stroke;if(!b)return;const M=Dke(h);f.lineWidth=b.width,f.miterLimit=b.miterlimit,f.setLineDash(b.dasharray),f.lineDashOffset=b.dashoffset;const E=b.opacity/255;switch(b.paint){case"rgb_color":f.strokeStyle=aC(b.rgb_color,b.opacity,y);break;case"linear_gradient_idx":f.strokeStyle=Tke(f,c.linear_gradients[b.linear_gradient_idx],E,y,!0);break;case"radial_gradient_idx":f.strokeStyle=Ake(f,c.radial_gradients[b.radial_gradient_idx],E,y,!0)}switch(b.linejoin){case BD.LINE_JOIN_MITER_CLIP:case BD.LINE_JOIN_MITER:f.lineJoin="miter";break;case BD.LINE_JOIN_ROUND:f.lineJoin="round";break;case BD.LINE_JOIN_BEVEL:f.lineJoin="bevel"}switch(b.linecap){case hde.LINE_CAP_BUTT:f.lineCap="butt";break;case hde.LINE_CAP_ROUND:f.lineCap="round";break;case hde.LINE_CAP_SQUARE:f.lineCap="square"}f.stroke(M)}function Tke(f,c,h,y,b=!1){if(c.stops.length===1){const ee=c.stops[0];return aC(ee.rgb_color,ee.opacity*h,y)}const{x1:M,y1:E,x2:L,y2:z}=c;let V=new DOMPoint(M,E),Z=new DOMPoint(L,z);if(b){const ee=iC(c.transform);V=ee.transformPoint(V),Z=ee.transformPoint(Z)}const Q=f.createLinearGradient(V.x,V.y,Z.x,Z.y);for(const ee of c.stops)Q.addColorStop(ee.offset,aC(ee.rgb_color,ee.opacity*h,y));return Q}function Ake(f,c,h,y,b=!1){if(c.stops.length===1){const Ne=c.stops[0];return aC(Ne.rgb_color,Ne.opacity*h,y)}const M=iC(c.transform),{fx:E,fy:L,fr:z,cx:V,cy:Z,r:Q}=c;let ee=new DOMPoint(E,L),ne=new DOMPoint(V,Z),le=z,xe=Q;if(b){ee=M.transformPoint(ee),ne=M.transformPoint(ne);const Ne=(M.a+M.d)/2;le=z*Ne,xe=c.r*Ne}const Ce=f.createRadialGradient(ee.x,ee.y,le,ne.x,ne.y,xe);for(const Ne of c.stops)Ce.addColorStop(Ne.offset,aC(Ne.rgb_color,Ne.opacity*h,y));return Ce}function Eke(f,c,h,y){const b=y.transform?iC(y.transform).preMultiplySelf(c):c,M=WT(f.canvas.width,f.canvas.height),E=M.getContext("2d");for(const z of y.children)if(z.group)Eke(E,b,h,z.group);else if(z.path){const V=z.path,Z=new Path2D;Z.addPath(Dke(V),b),E.fill(Z,Cke(V))}const L=y.clip_path_idx!=null?h.clip_paths[y.clip_path_idx]:null;L&&Ike(E,b,h,L),f.globalCompositeOperation="source-over",f.drawImage(M,0,0)}function Ike(f,c,h,y){const b=WT(f.canvas.width,f.canvas.height);Eke(b.getContext("2d"),c,h,y),f.globalCompositeOperation="destination-in",f.drawImage(b,0,0)}function Pke(f,c,h,y,b){if(y.children.length===0)return;const M=y.mask_idx!=null?h.masks[y.mask_idx]:null;M&&Pke(f,c,h,M,b);const E=f.canvas.width,L=f.canvas.height,z=WT(E,L),V=z.getContext("2d"),Z=y.width,Q=y.height,ee=y.left,ne=y.top,le=new Path2D,xe=new Path2D;xe.rect(ee,ne,Z,Q),le.addPath(xe,c),V.clip(le);for(const Fe of y.children)Nke(V,c,h,Fe,b);const Ce=V.getImageData(0,0,E,L),Ne=Ce.data;if(y.mask_type===bke.MASK_TYPE_LUMINANCE)for(let Fe=0;Fec[E])return null}else{const L=1/y[E];let z=(f[E]-h[E])*L,V=(c[E]-h[E])*L;if(z>V){const Z=z;z=V,V=Z}if(z>b&&(b=z),VM)return null}return b}function Fke(f,c,h,y,b,M,E,L,z,V,Z){const Q=y-f,ee=b-c,ne=M-h,le=E-f,xe=L-c,Ce=z-h,Ne=Z[1]*Ce-Z[2]*xe,Fe=Z[2]*le-Z[0]*Ce,Be=Z[0]*xe-Z[1]*le,Je=Q*Ne+ee*Fe+ne*Be;if(Math.abs(Je)<1e-15)return null;const yt=1/Je,mt=V[0]-f,kt=V[1]-c,It=V[2]-h,Rt=(mt*Ne+kt*Fe+It*Be)*yt;if(Rt<0||Rt>1)return null;const tr=kt*ne-It*ee,$t=It*Q-mt*ne,or=mt*ee-kt*Q,mr=(Z[0]*tr+Z[1]*$t+Z[2]*or)*yt;return mr<0||Rt+mr>1?null:(le*tr+xe*$t+Ce*or)*yt}function zke(f,c,h){return(f-c)/(h-c)}function Bke(f,c,h,y,b,M,E,L,z){const V=1<{const Fe=Ce?1:0,Be=(ne+1)*xe-Fe,Je=le*xe,yt=(le+1)*xe-Fe;Ne[0]=ne*xe,Ne[1]=Je,Ne[2]=Be,Ne[3]=yt};let Q=new Oke(z);const ee=[];for(let ne=0;ne=1;z/=2){const ne=L[L.length-1];Q=new Oke(z);for(let le=0;le0;){const{idx:le,t:xe,nodex:Ce,nodey:Ne,depth:Fe}=ne.pop();if(this.leaves[le]){Bke(Ce,Ne,Fe,c,h,y,b,Q,ee);const Je=1<=kr[2])return xe}continue}let Be=0;for(let Je=0;Je=V[Z[It]]&&(Z.splice(It,0,Je),kt=!0);kt||(Z[Be]=Je),Be++}}for(let Je=0;Je=this.dim+1||h<-1||h>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(h+1)*this.stride+(c+1)}static pack(c,h){const y=[0,0,0,0],b=HD.getUnpackVector(h);let M=Math.floor((c+b[3])/b[2]);return y[2]=M%256,M=Math.floor(M/256),y[1]=M%256,M=Math.floor(M/256),y[0]=M,y}getPixels(){return new Owe({width:this.stride,height:this.stride},this.pixels)}backfillBorder(c,h,y){if(this.dim!==c.dim)throw new Error("dem dimension mismatch");let b=h*this.dim,M=h*this.dim+this.dim,E=y*this.dim,L=y*this.dim+this.dim;switch(h){case-1:b=M-1;break;case 1:M=b+1}switch(y){case-1:E=L-1;break;case 1:L=E+1}const z=-h*this.dim,V=-y*this.dim;for(let Z=E;Z=1;y--){const b=y===1?1:0,M=y===2?1:0;for(let E=0;E>>1^-(1&f[c]);return f}function Vet(f,c){switch(c){case"uint32":return f;case"uint16":for(let h=0;h>4|(61440&y)>>8|(240&b)<<4|61440&b,f[h+1]=15&y|(3840&y)>>4|(15&b)<<8|(3840&b)<<4}return f;case"uint8":for(let h=0;h>6|(192&b)>>4|(192&M)>>2|192&E,f[h+1]=(48&y)>>4|(48&b)>>2|48&M|(48&E)<<2,f[h+2]=(12&y)>>2|12&b|(12&M)<<2|(12&E)<<4,f[h+3]=3&y|(3&b)<<2|(3&M)<<4|(3&E)<<6}return f;default:throw new Error(`Invalid pixel format, "${c}"`)}}ms(HD,"DEMData"),ms($ke,"DemMinMaxQuadTree",{omit:["dem"]});var vm=Uint8Array,KT=Uint16Array,qet=Int32Array,Vke=new vm([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]),qke=new vm([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]),Het=new vm([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Hke=function(f,c){for(var h=new KT(31),y=0;y<31;++y)h[y]=c+=1<>1|(21845&xl)<<1;Kke[xl]=((65280&(oC=(61680&(oC=(52428&oC)>>2|(13107&oC)<<2))>>4|(3855&oC)<<4))>>8|(255&oC)<<8)>>1}var ZT=function(f,c,h){for(var y=f.length,b=0,M=new KT(c);b>z]=V;return E},YT=new vm(288);for(xl=0;xl<144;++xl)YT[xl]=8;for(xl=144;xl<256;++xl)YT[xl]=9;for(xl=256;xl<280;++xl)YT[xl]=7;for(xl=280;xl<288;++xl)YT[xl]=8;var Zke=new vm(32);for(xl=0;xl<32;++xl)Zke[xl]=5;var Ket=ZT(YT,9),Zet=ZT(Zke,5),gde=function(f){for(var c=f[0],h=1;hc&&(c=f[h]);return c},wp=function(f,c,h){var y=c/8|0;return(f[y]|f[y+1]<<8)>>(7&c)&h},xde=function(f,c){var h=c/8|0;return(f[h]|f[h+1]<<8|f[h+2]<<16)>>(7&c)},Yet=["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"],jp=function(f,c,h){var y=new Error(c||Yet[f]);if(y.code=f,Error.captureStackTrace&&Error.captureStackTrace(y,jp),!h)throw y;return y},Xet=new vm(0),Qet=typeof TextDecoder<"u"&&new TextDecoder;try{Qet.decode(Xet,{stream:!0})}catch{}const Jet={gzip_data:"gzip"};class df extends Error{constructor(c){super(c),this.name="MRTError"}}const ett={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},Yke={uint32:1,uint16:2,uint8:4},ttt={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let yde;class WD{constructor(c=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=c}getLayer(c){const h=this.layers[c];if(!h)throw new df(`Layer '${c}' not found`);return h}getHeaderLength(c){const h=new Uint8Array(c),y=new DataView(c);if(h[0]!==13)throw new df("File is not a valid MRT.");return y.getUint32(1,!0)}parseHeader(c){const h=new Uint8Array(c),y=this.getHeaderLength(c);if(h.length= ${y} but got buffer of length ${h.length}`);const b=new yde(h.subarray(0,y)).readFields(Pet,{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 df(`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 M of b.layers)this.layers[M.name]=new Xke(M,{cacheSize:this._cacheSize});return this}createDecodingTask(c){const h=[],y=this.getLayer(c.layerName);for(let b of c.blockIndices){const M=y.dataIndex[b],E=M.firstByte-c.firstByte,L=M.lastByte-c.firstByte;if(y._blocksInProgress.has(b))continue;const z={layerName:y.name,firstByte:E,lastByte:L,pixelFormat:y.pixelFormat,blockIndex:b,blockShape:[M.bands.length].concat(y.bandShape),buffer:y.buffer,codec:M.codec.codec,filters:M.filters.map(V=>V.filter)};y._blocksInProgress.add(b),h.push(z)}return new Qke(h,()=>{h.forEach(b=>y._blocksInProgress.delete(b.blockIndex))},(b,M)=>{if(h.forEach(E=>y._blocksInProgress.delete(E.blockIndex)),b)throw b;M.forEach(E=>{this.getLayer(E.layerName).processDecodedData(E)})})}}class Xke{constructor({version:c,name:h,units:y,tileSize:b,pixelFormat:M,buffer:E,dataIndex:L},z){if(this.version=c,this.version!==1)throw new df(`Cannot parse raster layer encoded with MRT version ${c}`);this.name=h,this.units=y,this.tileSize=b,this.buffer=E,this.pixelFormat=ett[M],this.dataIndex=L,this.bandShape=[b+2*E,b+2*E,Yke[this.pixelFormat]],this._decodedBlocks=new qD(z?z.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return Yke[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:c})=>c).flat()}processDecodedData(c){const h=c.blockIndex.toString();this._decodedBlocks.get(h)||this._decodedBlocks.put(h,c.data)}getBlockForBand(c){let h=0;switch(typeof c){case"string":for(const[y,b]of this.dataIndex.entries()){for(const[M,E]of b.bands.entries())if(E===c)return{bandIndex:h+M,blockIndex:y,blockBandIndex:M};h+=b.bands.length}break;case"number":for(const[y,b]of this.dataIndex.entries()){if(c>=h&&cthis.cacheSize)throw new df(`Number of blocks to decode (${M.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:h,lastByte:y,blockIndices:b}}hasBand(c){const{blockIndex:h}=this.getBlockForBand(c);return h>=0}hasDataForBand(c){const{blockIndex:h}=this.getBlockForBand(c);return h>=0&&!!this._decodedBlocks.get(h.toString())}getBandView(c){const{blockIndex:h,blockBandIndex:y}=this.getBlockForBand(c);if(h<0)throw new df(`Band not found: ${JSON.stringify(c)}`);const b=this._decodedBlocks.get(h.toString());if(!b)throw new df(`Data for band ${JSON.stringify(c)} of layer "${this.name}" not decoded.`);const M=this.dataIndex[h],E=this.bandShape.reduce((V,Z)=>V*Z,1),L=y*E,z=b.subarray(L,L+E);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:M.offset,scale:M.scale}}}WD.setPbf=function(f){yde=f};class Qke{constructor(c,h,y){this.tasks=c,this._onCancel=h,this._onComplete=y,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(c,h){this._finalized||(this._onComplete(c,h),this._finalized=!0)}}WD.performDecoding=function(f,c){const h=new Uint8Array(f);return Promise.all(c.tasks.map(y=>{const{layerName:b,firstByte:M,lastByte:E,pixelFormat:L,blockShape:z,blockIndex:V,filters:Z,codec:Q}=y,ee=h.subarray(M,E+1),ne=new Uint32Array(z[0]*z[1]*z[2]);let le;if(Q!=="gzip_data")throw new df(`Unhandled codec: ${Q}`);return le=function(xe,Ce){if(!globalThis.DecompressionStream&&Ce==="gzip_data")return Promise.resolve(((Je=function(kt){kt[0]==31&&kt[1]==139&&kt[2]==8||jp(6,"invalid gzip data");var It=kt[3],Rt=10;4&It&&(Rt+=2+(kt[10]|kt[11]<<8));for(var tr=(It>>3&1)+(It>>4&1);tr>0;tr-=!kt[Rt++]);return Rt+(2&It)}(Be=xe))+8>Be.length&&jp(6,"invalid gzip data"),function(kt,It,Rt,tr){var $t=kt.length;if(!$t||It.f&&!It.l)return Rt||new vm(0);var or=!Rt,mr=or||It.i!=2,fr=It.i;or&&(Rt=new vm(3*$t));var wr,kr,xr=function(ti){var Ia=Rt.length;if(ti>Ia){var Fa=new vm(Math.max(2*Ia,ti));Fa.set(Rt),Rt=Fa}},_r=It.f||0,ir=It.p||0,sr=It.b||0,br=It.l,Vr=It.d,Ar=It.m,Ns=It.n,Jr=8*$t;do{if(!br){_r=wp(kt,ir,1);var as=wp(kt,ir+1,3);if(ir+=3,!as){var xs=kt[(lr=4+((ir+7)/8|0))-4]|kt[lr-3]<<8,In=lr+xs;if(In>$t){fr&&jp(0);break}mr&&xr(sr+xs),Rt.set(kt.subarray(lr,In),sr),It.b=sr+=xs,It.p=ir=8*In,It.f=_r;continue}if(as==1)br=Ket,Vr=Zet,Ar=9,Ns=5;else if(as==2){var Pr=wp(kt,ir,31)+257,ys=wp(kt,ir+10,15)+4,sn=Pr+wp(kt,ir+5,31)+1;ir+=14;for(var na=new vm(sn),ca=new vm(19),_n=0;_n>4)<16)na[_n++]=lr;else{var Zr=0,Yr=0;for(lr==16?(Yr=3+wp(kt,ir,3),ir+=2,Zr=na[_n-1]):lr==17?(Yr=3+wp(kt,ir,7),ir+=3):lr==18&&(Yr=11+wp(kt,ir,127),ir+=7);Yr--;)na[_n++]=Zr}}var Ms=na.subarray(0,Pr),Es=na.subarray(Pr);Ar=gde(Ms),Ns=gde(Es),br=ZT(Ms,Ar),Vr=ZT(Es,Ns)}else jp(1);if(ir>Jr){fr&&jp(0);break}}mr&&xr(sr+131072);for(var xn=(1<>4;if((ir+=15&Zr)>Jr){fr&&jp(0);break}if(Zr||jp(2),Qn<256)Rt[sr++]=Qn;else{if(Qn==256){En=ir,br=null;break}var Bs=Qn-254;Qn>264&&(Bs=wp(kt,ir,(1<<(ka=Vke[_n=Qn-257]))-1)+Gke[_n],ir+=ka);var en=Vr[xde(kt,ir)&Sn],_a=en>>4;if(en||jp(3),ir+=15&en,Es=Get[_a],_a>3){var ka=qke[_a];Es+=xde(kt,ir)&(1<Jr){fr&&jp(0);break}mr&&xr(sr+131072);var Na=sr+Bs;if(srwr.length)&&(kr=wr.length),new vm(wr.subarray(0,kr))):Rt.subarray(0,sr)}(Be.subarray(Je,-8),{i:2},new vm(((Ne=Be)[(Fe=Ne.length)-4]|Ne[Fe-3]<<8|Ne[Fe-2]<<16|Ne[Fe-1]<<24)>>>0))));var Ne,Fe,Be,Je;const yt=Jet[Ce];if(!yt)throw new Error(`Unhandled codec: ${Ce}`);const mt=new globalThis.DecompressionStream(yt);return new Response(new Blob([xe]).stream().pipeThrough(mt)).arrayBuffer().then(kt=>new Uint8Array(kt))}(ee,Q).then(xe=>(function(Ce,Ne){Ce.readFields(zet,Ne)}(new yde(xe),ne),new ttt[L](ne.buffer))),le.then(xe=>{for(let Ce=Z.length-1;Ce>=0;Ce--)switch(Z[Ce]){case"delta_filter":$et(xe,z);break;case"zigzag_filter":Uet(xe);break;case"bitshuffle_filter":Vet(xe,L);break;default:throw new df(`Unhandled filter "${Z[Ce]}"`)}return{layerName:b,blockIndex:V,data:xe}}).catch(xe=>{throw xe})}))},ms(Qke,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),ms(WD,"MapboxRasterTile"),ms(Xke,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class Jke{constructor(c){this._stringToNumber={},this._numberToString=[];for(let h=0;h=0&&ee[3]>=0&&V.insert(z,ee[0],ee[1],ee[2],ee[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Kt(new wD(this.rawTileData)).layers,this.sourceLayerCoder=new Jke(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const c in this.vtLayers)this.vtFeatures[c]=[]}return this.vtLayers}query(c,h){const{tilespaceGeometry:y,transform:b,tileTransform:M,pixelPosMatrix:E,availableImages:L,worldview:z}=h;this.loadVTLayers(),this.serializedLayersCache.clear();const V=h.queryRadius?h.queryRadius:0,Z=y.bufferedTilespaceBounds,Q=this.grid.query(Z.min.x,Z.min.y,Z.max.x,Z.max.y,(xe,Ce,Ne,Fe)=>Rd(y.bufferedTilespaceGeometry,xe-V,Ce-V,Ne+V,Fe+V));Q.sort(rtt);let ee=null;b.elevation&&Q.length>0&&(ee=nC.create(b.elevation,this.tileID));const ne={};let le;for(let xe=0;xe(Fe||(Fe=At(Be,this.tileID.canonical,M)),Je.queryIntersectsFeature(y,Be,yt,Fe,this.z,b,E,ee,mt)))}return ne}loadMatchingFeature(c,h,y,b,M,E){const{featureIndex:L,bucketIndex:z,sourceLayerIndex:V,layoutVertexArrayOffset:Z}=h,Q=this.bucketLayerIDs[z],ee=y.layers,ne=Object.keys(ee);if(ne.length&&!ss(ne,Q))return;const le=y.sourceCache,xe=this.sourceLayerCoder.decode(V),Ce=this.vtLayers[xe].feature(L),Ne=this.getId(Ce,xe);for(let Fe=0;Fe`${L.key}: ${L.message}`).join(", ");return void ts(`Failed to create expression for promoteId: ${E}`)}this.promoteIdExpression=M.value}y=this.promoteIdExpression.evaluate({zoom:0},c)}else y=c.properties[b];typeof y=="boolean"&&(y=Number(y))}return y}}function tNe(f,c,h,y,b){return Yt(f,(M,E)=>{const L=c instanceof Zx?c.get(E):null;return L&&L.evaluate?L.evaluate(h,y,void 0,b):L})}function rtt(f,c){return c-f}ms(eNe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const rNe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class vde{static from(c){if(!(c instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[h,y]=new Uint8Array(c,0,2);if(h!==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 M=rNe[15&y];if(!M)throw new Error("Unrecognized array type.");const[E]=new Uint16Array(c,2,1),[L]=new Uint32Array(c,4,1);return new vde(L,E,M,c)}constructor(c,h=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(+h,2),65535),this.ArrayType=y,this.IndexArrayType=c<65536?Uint16Array:Uint32Array;const M=rNe.indexOf(this.ArrayType),E=2*c*this.ArrayType.BYTES_PER_ELEMENT,L=c*this.IndexArrayType.BYTES_PER_ELEMENT,z=(8-L%8)%8;if(M<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+L+z,2*c),this._pos=2*c,this._finished=!0):(this.data=new ArrayBuffer(8+E+L+z),this.ids=new this.IndexArrayType(this.data,8,c),this.coords=new this.ArrayType(this.data,8+L+z,2*c),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+M]),new Uint16Array(this.data,2,1)[0]=h,new Uint32Array(this.data,4,1)[0]=c)}add(c,h){const y=this._pos>>1;return this.ids[y]=y,this.coords[this._pos++]=c,this.coords[this._pos++]=h,y}finish(){const c=this._pos>>1;if(c!==this.numItems)throw new Error(`Added ${c} items when expected ${this.numItems}.`);return _de(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(c,h,y,b){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:M,coords:E,nodeSize:L}=this,z=[0,M.length-1,0],V=[];for(;z.length;){const Z=z.pop()||0,Q=z.pop()||0,ee=z.pop()||0;if(Q-ee<=L){for(let Ce=ee;Ce<=Q;Ce++){const Ne=E[2*Ce],Fe=E[2*Ce+1];Ne>=c&&Ne<=y&&Fe>=h&&Fe<=b&&V.push(M[Ce])}continue}const ne=ee+Q>>1,le=E[2*ne],xe=E[2*ne+1];le>=c&&le<=y&&xe>=h&&xe<=b&&V.push(M[ne]),(Z===0?c<=le:h<=xe)&&(z.push(ee),z.push(ne-1),z.push(1-Z)),(Z===0?y>=le:b>=xe)&&(z.push(ne+1),z.push(Q),z.push(1-Z))}return V}within(c,h,y){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:b,coords:M,nodeSize:E}=this,L=[0,b.length-1,0],z=[],V=y*y;for(;L.length;){const Z=L.pop()||0,Q=L.pop()||0,ee=L.pop()||0;if(Q-ee<=E){for(let Ce=ee;Ce<=Q;Ce++)nNe(M[2*Ce],M[2*Ce+1],c,h)<=V&&z.push(b[Ce]);continue}const ne=ee+Q>>1,le=M[2*ne],xe=M[2*ne+1];nNe(le,xe,c,h)<=V&&z.push(b[ne]),(Z===0?c-y<=le:h-y<=xe)&&(L.push(ee),L.push(ne-1),L.push(1-Z)),(Z===0?c+y>=le:h+y>=xe)&&(L.push(ne+1),L.push(Q),L.push(1-Z))}return z}}function _de(f,c,h,y,b,M){if(b-y<=h)return;const E=y+b>>1;sNe(f,c,E,y,b,M),_de(f,c,h,y,E-1,1-M),_de(f,c,h,E+1,b,1-M)}function sNe(f,c,h,y,b,M){for(;b>y;){if(b-y>600){const V=b-y+1,Z=h-y+1,Q=Math.log(V),ee=.5*Math.exp(2*Q/3),ne=.5*Math.sqrt(Q*ee*(V-ee)/V)*(Z-V/2<0?-1:1);sNe(f,c,h,Math.max(y,Math.floor(h-Z*ee/V+ne)),Math.min(b,Math.floor(h+(V-Z)*ee/V+ne)),M)}const E=c[2*h+M];let L=y,z=b;for(XT(f,c,y,h),c[2*b+M]>E&&XT(f,c,y,b);LE;)z--}c[2*y+M]===E?XT(f,c,y,z):(z++,XT(f,c,z,b)),z<=h&&(y=z+1),h<=z&&(b=z-1)}}function XT(f,c,h,y){bde(f,h,y),bde(c,2*h,2*y),bde(c,2*h+1,2*y+1)}function bde(f,c,h){const y=f[c];f[c]=f[h],f[h]=y}function nNe(f,c,h,y){const b=f-h,M=c-y;return b*b+M*M}i.$=FN,i.A=sp,i.B=pm,i.C=2,i.D=HS,i.E=Kn,i.F=IT,i.G=Aje,i.H=RN,i.I=Ta,i.J=FL,i.K=ks,i.L=A0,i.M=lS,i.N=P_,i.O=NL,i.P=dr,i.Q=L_,i.R=rp,i.S=yS,i.T=Tce,i.U=Eg,i.V=FD,i.W=zM,i.X=D0,i.Y=L0,i.Z=C_,i._=Ld,i.a=function(f){return Gn.API_CDN_URL_REGEX.test(f)},i.a$=me,i.a0=Js,i.a1=Ul,i.a2=nf,i.a3=class extends FD{},i.a4=cS,i.a5=kL,i.a6=qt,i.a7=function(f){const c=f.value;return c?Js(c)?ide(c,!0)?[]:[new FD(f.key,c,`invalid url "${c}"`)]:[new FD(f.key,c,`string expected, "${ks(c)}" found`)]:[]},i.a8=LL,i.a9=mo,i.aA=ye,i.aB=C,i.aC=ot,i.aD=Kc,i.aE=oi,i.aF=U,i.aG=Ke,i.aH=function(f,c){const h={};for(let y=0;y{y(M,E)},c):y(M,E),()=>{}}return b.callbacks.push(y),b.cancel||(b.cancel=h((M,E)=>{b.result=[M,E];for(const L of b.callbacks)this.scheduler?this.scheduler.add(()=>{L(M,E)},c):L(M,E);setTimeout(()=>delete this.entries[f],3e3)})),()=>{b.result||(b.callbacks=b.callbacks.filter(M=>M!==y),b.callbacks.length||(b.cancel(),delete this.entries[f]))}}},i.aL=function(f,c,h){const y=JSON.stringify(f.request);return f.data&&(this.deduped.entries[y]={result:[null,f.data]}),this.deduped.request(y,{type:"parseTile",isSymbolTile:f.isSymbolTile,zoom:f.tileZoom},b=>{const M=Ku(f.request,(E,L,z)=>{E?b(E):L&&b(null,{rawData:L,vectorTile:h?void 0:new Kt(new wD(L)),responseHeaders:new Map(z.entries())})});return()=>{M.cancel(),b()}},c)},i.aM=function(f){return f?{cacheControl:f.get("Cache-Control"),expires:f.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=Ed,i.aO=function(f){fd++,fd>k0&&(f.getActor().send("enforceCacheSizeLimit",j0),fd=0)},i.aP=function(f){return f<=1?1:Math.pow(2,Math.floor(Math.log2(f)))},i.aQ=oo,i.aR=ake,i.aS=uke,i.aT=x,i.aU=nke,i.aV=function(f,c){const h=document.createElement("video");h.muted=!0,h.onloadstart=function(){c(null,h)};for(let y=0;y{}}},i.aW=CT,i.aX=nb,i.aY=Ft,i.aZ=OT,i.a_=te,i.aa=Dr,i.ab=class{constructor(f){this.specification=f}possiblyEvaluate(f,c){return hn(f.expression.evaluate(c))}interpolate(f,c,h){return{x:Gs(f.x,c.x,h),y:Gs(f.y,c.y,h),z:Gs(f.z,c.z,h),azimuthal:Gs(f.azimuthal,c.azimuthal,h),polar:Gs(f.polar,c.polar,h)}}},i.ac=bi,i.ad=Wx,i.ae=Ge,i.af=st,i.ag=pe,i.ah=De,i.ai=Zx,i.aj=ev,i.ak=Gs,i.al=Br,i.am=lM,i.an=Qs,i.ao=Aa,i.ap=class{constructor(f){this.specification=f}possiblyEvaluate(f,c){return function([h,y]){const b=hn([1,h,y]);return{x:b.x,y:b.y,z:b.z}}(f.expression.evaluate(c))}interpolate(f,c,h){return{x:Gs(f.x,c.x,h),y:Gs(f.y,c.y,h),z:Gs(f.z,c.z,h)}}},i.aq=function(f,c,h=0,y=!0){const b=new dr(h,h),M=f.sub(b),E=c.add(b),L=[M,new dr(E.x,M.y),E,new dr(M.x,E.y)];return y&&L.push(M.clone()),L},i.ar=function(f,c){const h=[];for(let y=0;y1)return!1;const h=c.getSource().maxzoom,y=1<1)return c;const b=y.getSource().maxzoom,M=1<{const L=this.getAtTileOffset(f,b,M,E),z=y.upVector(f.canonical,b.x,b.y);return Me(z,z,L*y.upVectorScale(f.canonical,c,h).metersToTile),z}}getForTilePoints(f,c,h,y){if(this.isUsingMockSource())return!1;const b=nC.create(this,f,y);return!!b&&(c.forEach(M=>{M[2]=this.exaggeration()*b.getElevationAt(M[0],M[1],h)}),!0)}getMinMaxForTile(f){if(this.isUsingMockSource())return null;const c=this.findDEMTileFor(f);if(!c||!c.dem)return null;const h=c.dem.tree,y=c.tileID,b=1<0&&(y+=(f[b]-0)*(f[b]-0)),c[b]<0&&(y+=(0-c[b])*(0-c[b]));return y},i.c0=a2e,i.c1=qce,i.c2=Rje,i.c3=Qce,i.c4=vde,i.c5=Me,i.c6=Se,i.c7=ft,i.c8=function(f,c,h){h*=.5;var y=c[0],b=c[1],M=c[2],E=c[3],L=Math.sin(h),z=Math.cos(h);return f[0]=y*z+b*L,f[1]=b*z-y*L,f[2]=M*z+E*L,f[3]=E*z-M*L,f},i.c9=ct,i.cA=oe,i.cB=Ea,i.cC=V2e,i.cD=li,i.cE=_we,i.cF=function(f,c,h,y,b,M,E,L,z){if(z.name==="globe")return _we(f,c,new li(h,y,b),!1);const V=OT({z:h,x:y,y:b},z);return new js([(M+V.x/V.scale)*c,c*(V.y/V.scale),E],[(M+V.x2/V.scale)*c,c*(V.y2/V.scale),L])},i.cG=function(f,c,h){return f[0]=Math.min(c[0],h[0]),f[1]=Math.min(c[1],h[1]),f[2]=Math.min(c[2],h[2]),f[3]=Math.min(c[3],h[3]),f},i.cH=function(f,c,h){return f[0]=Math.max(c[0],h[0]),f[1]=Math.max(c[1],h[1]),f[2]=Math.max(c[2],h[2]),f[3]=Math.max(c[3],h[3]),f},i.cI=function(f){const c=Math.round((f+45+360)%360/90)%4;return Mc[c]},i.cJ=fe,i.cK=Qe,i.cL=US,i.cM=function(f){const c=S(new Float64Array(16));C(c,f.pixelMatrix,f.globeMatrix);const h=[0,Ph,0],y=[0,Lh,0];return st(h,h,c),st(y,y,c),[h[0]>0&&h[0]<=f.width&&h[1]>0&&h[1]<=f.height&&!ice(f,new x(f.center.lat,90)),y[0]>0&&y[0]<=f.width&&y[1]>0&&y[1]<=f.height&&!ice(f,new x(f.center.lat,-90))]},i.cN=function(f,c){const{scale:h}=f.tileTransform,y=h*Br/(f.tileSize*Math.pow(2,c.zoom-f.tileID.overscaledZ+f.tileID.canonical.z));return function(b,M,E){var L=M[1],z=M[2],V=M[3],Z=E[0],Q=E[1];return b[0]=M[0]*Z,b[1]=L*Z,b[2]=z*Q,b[3]=V*Q,b}(new Float32Array(4),c.inverseAdjustmentMatrix,[y,y])},i.cO=gD,i.cP=ae,i.cQ=U2e,i.cR=function(f){const c=U2e(f,!0);return p([],[c[0],c[1],c[4],c[5]])},i.cS=R,i.cT=Qr,i.cU=D,i.cV=function(f){const{x:c,y:h}=f.point,{lng:y,lat:b}=f._center;return jwe(c,h,f.worldSize,y,b)},i.cW=Te,i.cX=ao,i.cY=so,i.cZ=Ic,i.c_=Ih,i.ca=Ma,i.cb=function(f,c){return f[0]=-c[0],f[1]=-c[1],f[2]=-c[2],f[3]=c[3],f},i.cc=re,i.cd=function(f,c,h,y,b){var M=1/Math.tan(c/2);if(f[0]=M/h,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=M,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[11]=-1,f[12]=0,f[13]=0,f[15]=0,b!=null&&b!==1/0){var E=1/(y-b);f[10]=(b+y)*E,f[14]=2*b*y*E}else f[10]=-1,f[14]=-2*y;return f},i.ce=function(f,c,h,y,b,M,E){var L=1/(c-h),z=1/(y-b),V=1/(M-E);return f[0]=-2*L,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=-2*z,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=2*V,f[11]=0,f[12]=(c+h)*L,f[13]=(b+y)*z,f[14]=(E+M)*V,f[15]=1,f},i.cf=J,i.cg=function(f,c,h){f[4*c+0]=h[0],f[4*c+1]=h[1],f[4*c+2]=h[2],f[4*c+3]=h[3]},i.ch=FS,i.ci=V_,i.cj=sl,i.ck=lf,i.cl=H_,i.cm=Kje,i.cn=function(){var f=new m(4);return m!=Float32Array&&(f[1]=0,f[2]=0),f[0]=1,f[3]=1,f},i.co=function(f,c,h){var y=c[0],b=c[1],M=c[2],E=c[3],L=Math.sin(h),z=Math.cos(h);return f[0]=y*z+M*L,f[1]=b*z+E*L,f[2]=y*-L+M*z,f[3]=b*-L+E*z,f},i.cp=function(f,c){return f[0]===c[0]&&f[1]===c[1]&&f[2]===c[2]&&f[3]===c[3]},i.cq=rt,i.cr=function(f){var c=f[0],h=f[1],y=f[2],b=f[3];return Math.sqrt(c*c+h*h+y*y+b*b)},i.cs=cr,i.ct=$e,i.cu=Oo,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=Pe,i.d=function(f){return Gn.API_TILEJSON_REGEX.test(f)},i.d$=class{constructor(f,c,h,y){this.context=f,this.format=y,this.size=h,this.texture=f.gl.createTexture();const[b,M,E]=this.size,{gl:L}=f;L.bindTexture(L.TEXTURE_3D,this.texture),f.pixelStoreUnpackFlipY.set(!1),f.pixelStoreUnpack.set(1),f.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in c&&c.data&&L.texImage3D(L.TEXTURE_3D,0,this.format,b,M,E,0,Cce(this.format),Mce(this.format),c.data)}bind(f,c){const{context:h}=this,{gl:y}=h;y.bindTexture(y.TEXTURE_3D,this.texture),f!==this.minFilter&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MAG_FILTER,f),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_MIN_FILTER,f),this.minFilter=f),c!==this.wrapS&&(y.texParameteri(y.TEXTURE_3D,y.TEXTURE_WRAP_S,c),y.texParameteri(y.TEXTURE_3D,y.TEXTURE_WRAP_T,c),this.wrapS=c)}destroy(){const{gl:f}=this.context;f.deleteTexture(this.texture),this.texture=null}},i.d0=function(f){return f*f*f*f*f},i.d1=F,i.d2=45,i.d3=zS,i.d4=function(f,c,h){const y=Math.sqrt(f*f+c*c+h*h),b=y>0?Math.acos(h/y)*Ei:0;let M=f!==0||c!==0?Math.atan2(-c,-f)*Ei+90:0;return M<0&&(M+=360),[y,M,b]},i.d5=ie,i.d6=hn,i.d7=Oe,i.d8=ce,i.d9=js,i.dA=function(f){return f({pluginStatus:Dd,pluginURL:cp}),gS.on("pluginStateChange",f),f},i.dB=q_,i.dC=class extends hp{constructor(f){super(f),this.current=BS}set(f,c,h){if(this.fetchUniformLocation(f,c)){for(let y=0;y<9;y++)if(h[y]!==this.current[y]){this.current=h,this.gl.uniformMatrix3fv(this.location,!1,h);break}}}},i.dD=No,i.dE=function(f,c,h){const y=ev(h.zoom),b=f.style.map._antialias,M=f.terrain&&f.terrain.exaggeration()>0;return y===0&&!b&&!M},i.dF=function(f){const c=f.pixelsPerMeter,h=c/J(1,f.center.lat),y=S(new Float64Array(16));return I(y,y,[f.point.x,f.point.y,0]),R(y,y,[h,h,c]),Float32Array.from(y)},i.dG=eD,i.dH=function(f){const c=fe-5;f=ye(f,-c,c)/c*90;const h=Math.pow(Math.abs(Math.sin(Qs(f))),3);return Math.round(h*(dT.length-1))},i.dI=function(f,c,h,y){const b=c.getNorth(),M=c.getSouth(),E=c.getWest(),L=c.getEast(),z=1<0){const le=180/y;_(ne,ne,[le/V+1,0,0,0,le/Z+1,0,-.5*le/Q,.5*le/ee,1])}return ne[2]=z,ne[5]=f.x,ne[8]=f.y,ne},i.dJ=ym,i.dK=function(f,c,h){const y=S(new Float64Array(16)),b=(c/(1<({u_matrix:new H_(f),u_texsize:new lf(f),u_pixels_to_tile_units:new $S(f),u_device_pixel_ratio:new sl(f),u_width_scale:new sl(f),u_floor_width_scale:new sl(f),u_image:new FS(f),u_units_to_pixels:new lf(f),u_tile_units_to_pixels:new sl(f),u_alpha_discard_threshold:new sl(f),u_trim_offset:new lf(f),u_trim_fade_range:new lf(f),u_trim_color:new zS(f),u_zbias_factor:new sl(f),u_tile_to_meter:new sl(f),u_ground_shadow_factor:new V_(f),u_pattern_transition:new sl(f)}),i.dX=f=>({u_matrix:new H_(f),u_pixels_to_tile_units:new $S(f),u_device_pixel_ratio:new sl(f),u_width_scale:new sl(f),u_floor_width_scale:new sl(f),u_units_to_pixels:new lf(f),u_dash_image:new FS(f),u_gradient_image:new FS(f),u_image_height:new sl(f),u_texsize:new lf(f),u_tile_units_to_pixels:new sl(f),u_alpha_discard_threshold:new sl(f),u_trim_offset:new lf(f),u_trim_fade_range:new lf(f),u_trim_color:new zS(f),u_zbias_factor:new sl(f),u_tile_to_meter:new sl(f),u_ground_shadow_factor:new V_(f)}),i.dY=f=>({u_camera_to_center_distance:new sl(f),u_extrude_scale:new $S(f),u_device_pixel_ratio:new sl(f),u_matrix:new H_(f),u_inv_rot_matrix:new H_(f),u_merc_center:new lf(f),u_tile_id:new V_(f),u_zoom_transition:new sl(f),u_up_dir:new V_(f),u_emissive_strength:new sl(f)}),i.dZ=TS,i.d_=uJe,i.da=ge,i.db=function(f){return[Math.pow(f[0],1/2.2),Math.pow(f[1],1/2.2),Math.pow(f[2],1/2.2)]},i.dc=$2e,i.dd=Dce,i.de=W2e,i.df=ide,i.dg=function(f,c){return f.readFields(uet,{icons:[]},c)},i.dh=hD,i.di=eC,i.dj=Zce,i.dk=S0,i.dl=R_,i.dm=_g,i.dn=vr,i.dp=hr,i.dq=function(f){const c=f.indexOf(Qx);return c>=0?f.slice(0,c):f},i.dr=function(f){return f.indexOf(Qx)>=0},i.ds=function(f){const c=f.lastIndexOf(Qx);return c>=0?f.slice(c+1):""},i.dt=function(f){const c=[],h=f.id;return h===void 0&&c.push({message:`layers.${h}: missing required property "id"`}),f.render===void 0&&c.push({message:`layers.${h}: missing required method "render"`}),f.renderingMode&&f.renderingMode!=="2d"&&f.renderingMode!=="3d"&&c.push({message:`layers.${h}: property "renderingMode" must be either "2d" or "3d"`}),c},i.du=function(f,c,h,y){return f.type==="custom"?new set(f,c):new cet[f.type](f,c,h,y)},i.dv=yr,i.dw=function(f){const c=f.indexOf(Qx);return c>=0?f.slice(c+1):""},i.dx=class extends sb{constructor(f,c){super(f._vectorTileFeature,f._z,f._x,f._y,f.id),f.state&&(this.state=Object.assign({},f.state)),this.target=c.target,this.namespace=c.namespace,c.properties&&(this.properties=c.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=f.source,this.sourceLayer=f.sourceLayer,this.layer=f.layer)}toJSON(){const f=super.toJSON();return f.target=this.target,f.namespace=this.namespace,f}},i.dy=gS,i.dz=Xm,i.e=Gn,i.e$=de,i.e0=Swe,i.e1=(f,c,h,y,b,M)=>{const E=f.transform,L=E.projection.name==="globe";let z;if(M.paint.get("circle-pitch-alignment")==="map")if(L){const Z=wwe(E.zoom,c.canonical)*E._pixelsPerMercatorPixel;z=Float32Array.from([Z,0,0,Z])}else z=E.calculatePixelsToTileUnitsMatrix(h);else z=new Float32Array([E.pixelsToGLUnits[0],0,0,E.pixelsToGLUnits[1]]);const V={u_camera_to_center_distance:f.transform.getCameraToCenterDistance(E.projection),u_matrix:f.translatePosMatrix(c.projMatrix,h,M.paint.get("circle-translate"),M.paint.get("circle-translate-anchor")),u_device_pixel_ratio:tl.devicePixelRatio,u_extrude_scale:z,u_inv_rot_matrix:CXe,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:M.paint.get("circle-emissive-strength")};if(L){V.u_inv_rot_matrix=y,V.u_merc_center=b,V.u_tile_id=[c.canonical.x,c.canonical.y,1<{const Z=f.transform,Q=Z.pitch<15?aje(.07,.7,ye((14-Z.zoom)/5,0,1)):.07,ee=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:oje(f,c,h,y),u_texsize:c.imageAtlasTexture?c.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:Z.calculatePixelsToTileUnitsMatrix(c),u_device_pixel_ratio:b,u_width_scale:M,u_floor_width_scale:E,u_image:0,u_tile_units_to_pixels:ije(c,Z),u_units_to_pixels:[1/Z.pixelsToGLUnits[0],1/Z.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:L,u_trim_fade_range:h.paint.get("line-trim-fade-range"),u_trim_color:h.paint.get("line-trim-color").toPremultipliedRenderColor(ee?null:h.lut).toArray01(),u_zbias_factor:Q,u_tile_to_meter:Oe(c.tileID.canonical,0),u_ground_shadow_factor:z,u_pattern_transition:V}},i.e5=(f,c,h,y,b,M,E,L,z,V)=>{const Z=f.transform,Q=Z.calculatePixelsToTileUnitsMatrix(c),ee=h.paint.get("line-trim-color-use-theme").constantOr("default")==="none",ne=Z.pitch<15?aje(.07,.7,ye((14-Z.zoom)/5,0,1)):.07;return{u_matrix:oje(f,c,h,y),u_pixels_to_tile_units:Q,u_device_pixel_ratio:M,u_width_scale:E,u_floor_width_scale:L,u_units_to_pixels:[1/Z.pixelsToGLUnits[0],1/Z.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:b,u_texsize:cje(h)&&c.lineAtlasTexture?c.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:ije(c,f.transform),u_alpha_discard_threshold:0,u_trim_offset:z,u_trim_fade_range:h.paint.get("line-trim-fade-range"),u_trim_color:h.paint.get("line-trim-color").toPremultipliedRenderColor(ee?null:h.lut).toArray01(),u_zbias_factor:ne,u_tile_to_meter:Oe(c.tileID.canonical,0),u_ground_shadow_factor:V}},i.e6=Gt,i.e7=hT,i.e8=he,i.e9=Oh,i.eA=function(f,c){var h=2*Math.acos(c[3]),y=Math.sin(h/2);return y>d?(f[0]=c[0]/y,f[1]=c[1]/y,f[2]=c[2]/y):(f[0]=1,f[1]=0,f[2]=0),h},i.eB=cde,i.eC=vD,i.eD=yD,i.eE=[1,1,1],i.eF=nC,i.eG=et,i.eH=function(f,c,h,y){var b=c[0],M=c[1],E=c[2],L=c[3];return f[0]=b+y*(h[0]-b),f[1]=M+y*(h[1]-M),f[2]=E+y*(h[2]-E),f[3]=L+y*(h[3]-L),f},i.eI=ZS,i.eJ=Qu,i.eK=of,i.eL=function(f,c,h,y,b,M,E,L,z,V,Z,Q,ee,ne,le,xe){var Ce=new m(16);return Ce[0]=f,Ce[1]=c,Ce[2]=h,Ce[3]=y,Ce[4]=b,Ce[5]=M,Ce[6]=E,Ce[7]=L,Ce[8]=z,Ce[9]=V,Ce[10]=Z,Ce[11]=Q,Ce[12]=ee,Ce[13]=ne,Ce[14]=le,Ce[15]=xe,Ce},i.eM=j,i.eN=K0,i.eO=eT,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new dr(1/0,1/0),max:new dr(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(f,c=!1){const h=r2e(new dr(0,0),new dr(Br,Br),f),y=[];if(c&&!pce(h,this._globalClipBounds))return y;for(const b of this._activeRegions){if(b.hiddenByOverlap||!pce(h,b))continue;const M=rQe(b.min,b.max,f);y.push({min:M.min,max:M.max,sourceId:this._sourceIds[b.priority],footprint:b.footprint,footprintTileId:b.tileId,order:b.order,clipMask:b.clipMask,clipScope:b.clipScope})}return y}setSources(f){this._setSources(f.map(c=>({getSourceId:()=>c.cache.id,getFootprints:()=>{const h=[];for(const y of c.cache.getVisibleCoordinates()){const b=c.cache.getTile(y).buckets[c.layer];b&&b.updateFootprints(y.toUnwrapped(),h)}return h},getOrder:()=>c.order,getClipMask:()=>c.clipMask,getClipScope:()=>c.clipScope})))}_addSource(f){const c=f.getFootprints();if(c.length===0)return;const h=f.getOrder(),y=f.getClipMask(),b=f.getClipScope();for(const M of c){if(!M.footprint)continue;const E=r2e(M.footprint.min,M.footprint.max,M.id);this._activeRegions.push({min:E.min,max:E.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:M.id,footprint:M.footprint,order:h,clipMask:y,clipScope:b})}this._sourceIds.push(f.getSourceId())}_computeReplacement(){this._activeRegions.sort((c,h)=>c.priority-h.priority||oD(c.min,h.min)||oD(c.max,h.max)||c.order-h.order||c.clipMask-h.clipMask||function(y,b){const M=(E,L)=>E+L;return y.length-b.length||y.reduce(M,"").localeCompare(b.reduce(M,""))}(c.clipScope,h.clipScope));let f=this._activeRegions.length!==this._prevRegions.length;if(!f){let c=0;for(;!f&&c!==this._activeRegions.length;){const h=this._activeRegions[c],y=this._prevRegions[c];f=h.priority!==y.priority||!t2e(h,y)||h.order!==y.order||h.clipMask!==y.clipMask||!$a(h.clipScope,y.clipScope),this._activeRegions[c].hiddenByOverlap=y.hiddenByOverlap,++c}}if(f){++this._updateTime;for(const h of this._activeRegions)h.order!==yT&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,h.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,h.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,h.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,h.max.y));const c=h=>{const y=this._activeRegions;if(h>=y.length)return h;const b=y[h].priority;for(;h1){let h=0,y=c(h);for(;h!==y;){let b=h;const M=h;for(;b!==y;){const E=this._activeRegions[b];E.hiddenByOverlap=!1;for(let L=0;L=0;c--)this._addSource(f[c]);this._computeReplacement()}},i.eQ=yT,i.eR=class{constructor(f){this._createGrid(f),this._createPoles(f)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const f of this._poleSegments)f.destroy();for(const f of this._gridSegments)f.withSkirts.destroy(),f.withoutSkirts.destroy()}_fillGridMeshWithLods(f,c){const h=new Pg,y=new rl,b=[],M=f+1+2,E=c[0]+1,L=c[0]+1+(1+c.length),z=(V,Z,Q)=>{let ee=V===M-1?V-2:V===0?V:V-1;return ee+=Q?24575:0,[ee,Z]};for(let V=0;V0?(Ce=2*Math.sqrt(xe+1),f[3]=.25*Ce,f[0]=(Q-ne)/Ce,f[1]=(ee-z)/Ce,f[2]=(L-V)/Ce):E>Z&&E>le?(Ce=2*Math.sqrt(1+E-Z-le),f[3]=(Q-ne)/Ce,f[0]=.25*Ce,f[1]=(L+V)/Ce,f[2]=(ee+z)/Ce):Z>le?(Ce=2*Math.sqrt(1+Z-E-le),f[3]=(ee-z)/Ce,f[0]=(L+V)/Ce,f[1]=.25*Ce,f[2]=(Q+ne)/Ce):(Ce=2*Math.sqrt(1+le-E-Z),f[3]=(L-V)/Ce,f[0]=(ee+z)/Ce,f[1]=(Q+ne)/Ce,f[2]=.25*Ce),f},i.f=function(f){return btoa(encodeURIComponent(f).replace(/%([0-9A-F]{2})/g,(c,h)=>String.fromCharCode(+("0x"+h))))},i.f0=function([f,c,h]){const y=Math.hypot(f,c,h),b=Math.atan2(f,h),M=.5*Math.PI-Math.acos(-c/y);return new x(ao(b),ao(M))},i.f1=He,i.f2=Ace,i.f3=function(f){const c=f.navigator?f.navigator.userAgent:null;return!!function(h){if(Eo==null){const y=h.navigator?h.navigator.userAgent:null;Eo=!!h.safari||!(!y||!(/\b(iPad|iPhone|iPod)\b/.test(y)||y.match("Safari")&&!y.match("Chrome")))}return Eo}(f)&&!(!c||!(c.match("Version/15.4")||c.match("Version/15.5")||c.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},i.f4=function(f,c){j0=f,k0=c},i.f5=ice,i.f6=kwe,i.f7=function(f){const c=[0,0,0],h=S(new Float64Array(16));return C(h,f.pixelMatrix,f.globeMatrix),st(c,c,h),new dr(c[0],c[1])},i.f8=function(){const f=kT;f&&(f.isPreloaded()&&f.numActive()===1?(f.release(bce),kT=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(){hD().acquire(bce)},i.fA=HD,i.fB=zt,i.fC=function(f){let c=0;if(new Uint32Array(f,0,1)[0]!==O2e){const h=new Uint32Array(f,0,7),[,,y,b,M,E]=h;c=h.byteLength+b+M+E+M,(y!==f.byteLength||c>=f.byteLength)&&ts("Invalid b3dm header information.")}return B2e(f,c)},i.fD=function(f,c){const h=Dce(f);for(const y of h){for(const b of y.meshes)PQe(b);y.lights&&(y.lightMeshIndex=y.meshes.length,y.meshes.push(LQe(y.lights,c)))}return h},i.fE=zD,i.fF=ra,i.fG=E2e,i.fH=dp,i.fI=wu,i.fJ=function(f){Ec(),Wu!=null&&Wu.then(c=>{c.keys().then(h=>{for(let y=0;yts(b.message))}).catch(h=>ts(h.message))}).catch(c=>ts(c.message))},i.fa=F_,i.fb=function(f,c,h=!1){if(Dd===wu.deferred||Dd===wu.loading||Dd===wu.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");cp=tl.resolveURL(f),Dd=wu.deferred,VM=c,pS(),h||PL()},i.fc=function(f){WS=tl.resolveURL(f),GS||(GS=new HS(hD(),new Kn)),GS.broadcast("setMeshoptUrl",WS)},i.fd=L2e,i.fe=function(f){kce=tl.resolveURL(f),GS||(GS=new HS(hD(),new Kn)),GS.broadcast("setDracoUrl",kce)},i.ff=P2e,i.fg=jT,i.fh=function(f){const c=_u();if(!c)return;const h=c.delete(w0);f&&h.then(()=>f()).catch(f)},i.fi=Q_,i.fj=ms,i.fk=tv,i.fl=bp,i.fm=Jke,i.fn=eNe,i.fo=tje,i.fp=nr,i.fq="hd_road_elevation",i.fr=Oa,i.fs=Yt,i.ft=ry,i.fu=Kce,i.fv=tb,i.fw=function(f,c,h,y,b,M,E,L=1,z,V,Z){f.createArrays(),f.tilePixelRatio=Br/(512*f.overscaling),f.compareText={},f.iconsNeedLinear=!1;const Q=f.layers[0].layout,ee=f.layers[0]._unevaluatedLayout._values,ne={};ne.scaleFactor=L,ne.textSizeScaleRange=Q.get("text-size-scale-range"),ne.iconSizeScaleRange=Q.get("icon-size-scale-range");const[le,xe]=ne.textSizeScaleRange,[Ce,Ne]=ne.iconSizeScaleRange;ne.textScaleFactor=ye(ne.scaleFactor,le,xe),ne.iconScaleFactor=ye(ne.scaleFactor,Ce,Ne);const Fe=ee["text-size"],Be=ee["icon-size"];if(f.textSizeData.kind==="composite"){const{minZoom:Rt,maxZoom:tr}=f.textSizeData;ne.compositeTextSizes=[Fe.possiblyEvaluate(new bi(Rt,{worldview:Z}),M),Fe.possiblyEvaluate(new bi(tr,{worldview:Z}),M)]}if(f.iconSizeData.kind==="composite"){const{minZoom:Rt,maxZoom:tr}=f.iconSizeData;ne.compositeIconSizes=[Be.possiblyEvaluate(new bi(Rt,{worldview:Z}),M),Be.possiblyEvaluate(new bi(tr,{worldview:Z}),M)]}ne.layoutTextSize=Fe.possiblyEvaluate(new bi(E+1,{worldview:Z}),M),ne.layoutIconSize=Be.possiblyEvaluate(new bi(E+1,{worldview:Z}),M),ne.textMaxSize=Fe.possiblyEvaluate(new bi(18,{worldview:Z}),M);const Je=Q.get("symbol-placement"),yt=Q.get("text-rotation-alignment")==="map"&&Je!=="point",mt=Q.get("text-size");let kt=!1;const It=[];for(const Rt of f.features){const tr=Q.get("text-font").evaluate(Rt,{},M).join(","),$t=mt.evaluate(Rt,{},M)*ne.textScaleFactor,or=ne.layoutTextSize.evaluate(Rt,{},M)*ne.textScaleFactor,mr=ne.layoutIconSize.evaluate(Rt,{},M)*ne.iconScaleFactor,fr={horizontal:{},vertical:void 0},wr=Rt.text;let kr,xr=[0,0];if(wr){const _n=wr.toString(),ei=Q.get("text-letter-spacing").evaluate(Rt,{},M)*Tl,pt=Q.get("text-line-height").evaluate(Rt,{},M)*Tl,vt=$M(_n)?ei:0,lr=Q.get("text-anchor").evaluate(Rt,{},M),jr=Q.get("text-variable-anchor");if(!jr){const xn=Q.get("text-radial-offset").evaluate(Rt,{},M);if(xn)xr=Rje(lr,[xn*Tl,Xce]);else{const Sn=Q.get("text-offset").evaluate(Rt,{},M);xr=[Sn[0]*Tl,Sn[1]*Tl]}}let Zr=yt?"center":Q.get("text-justify").evaluate(Rt,{},M);const Yr=Je==="point",Ms=Yr?Q.get("text-max-width").evaluate(Rt,{},M)*Tl:1/0,Es=xn=>{f.allowVerticalPlacement&&O_(_n)&&(fr.vertical=Vce(wr,c,h,b,tr,Ms,pt,lr,xn,vt,xr,th.vertical,!0,or,$t,z))};if(!yt&&jr){const xn=Zr==="auto"?jr.map(En=>Qce(En)):[Zr];let Sn=!1;for(let En=0;En=0||!O_(_n)){const xn=Vce(wr,c,h,b,tr,Ms,pt,lr,Zr,vt,xr,th.horizontal,!1,or,$t,z);xn&&(fr.horizontal[Zr]=xn)}Es(Yr?"left":Zr)}}let _r,ir,sr,br,Vr,Ar,Ns=!1;const Jr=Q.get("icon-text-fit").evaluate(Rt,{},M);if(Rt.icon&&Rt.icon.hasPrimary()){const _n=LT(Rt.icon,f.iconSizeData,ee["icon-size"],M,f.zoom,Rt,z,ne.iconScaleFactor,Z);_r=_n.iconPrimary,sr=_n.iconSecondary;const ei=_r.toString();if(ir=y.get(ei),ir&&(Vr=Q.get("icon-offset").evaluate(Rt,{},M),Ar=Q.get("icon-anchor").evaluate(Rt,{},M),kr=kD(b.get(ei),sr?b.get(sr.toString()):void 0,Vr,Ar),Ns=ir.sdf,f.sdfIcons===void 0?f.sdfIcons=ir.sdf:f.sdfIcons!==ir.sdf&&ts("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(ir.pixelRatio!==f.pixelRatio||Q.get("icon-rotate").constantOr(1)!==0)&&(f.iconsNeedLinear=!0)),sr){const pt=sr.toString();br=y.get(pt)}}kt=kt||!(!Rt.icon||!Rt.icon.hasSecondary());const as=TD(fr.horizontal)||fr.vertical;f.iconsInText||(f.iconsInText=!!as&&as.iconsInText);const xs=or*ne.textScaleFactor/Tl,{defaultShapedIcon:In,verticallyShapedIcon:Pr}=UJe(f,kr,Q,Rt,M,fr,xs,Vr,Jr);Jr!=="none"&&kr&&(wje(kr)||jje(kr))&&(MD(0,ir,_r,kr,In,Jr,V,y,b),MD(0,br,sr,kr,In,Jr,V,y,b),Pr&&(MD(0,ir,_r,kr,Pr,Jr,V,y,b),MD(0,br,sr,kr,Pr,Jr,V,y,b))),kr=In;const{iconBBox:ys,iconVerticalBBox:sn,textBBox:na,textVerticalBBox:ca}=RJe(f,kr,Pr,Q,Rt,M,mr,Vr,ne,b,Ar,fr,or,xr);It.push({feature:Rt,shapedTextOrientations:fr,shapedText:as,shapedIcon:kr,iconPrimary:_r,iconSecondary:sr,iconOffset:Vr,iconAnchor:Ar,verticallyShapedIcon:Pr,layoutTextSize:or,layoutIconSize:mr,textOffset:xr,isSDFIcon:Ns,iconTextFit:Jr,iconCollisionBounds:ys,iconVerticalCollisionBounds:sn,textCollisionBounds:na,textVerticalCollisionBounds:ca})}return{featureData:It,sizes:ne,hasAnySecondaryIcon:kt,textAlongLine:yt,symbolPlacement:Je}},i.fx=Eje,i.fy=function(f,c,h,y,b,M,E,L,z,V){f.iconAtlasPositions=V.iconPositions;const{featureData:Z,hasAnySecondaryIcon:Q,sizes:ee,textAlongLine:ne,symbolPlacement:le}=c;for(const xe of Z){const{shapedIcon:Ce,verticallyShapedIcon:Ne,feature:Fe,shapedTextOrientations:Be,shapedText:Je,layoutTextSize:yt,textOffset:mt,isSDFIcon:kt,iconPrimary:It,iconSecondary:Rt,iconTextFit:tr,iconOffset:$t,iconCollisionBounds:or,iconVerticalCollisionBounds:mr,textCollisionBounds:fr}=xe;zje(Ce,V.iconPositions,It,Rt),zje(Ne,V.iconPositions,It,Rt),$Je(Be,V.iconPositions),BJe(It,Rt,V.iconPositions),(Je||Ce)&&VJe(f,Fe,Be,Ce,Ne,z,ee,yt,0,mt,kt,y,b,E,L,Q,tr,$t,ne,le,or,mr,fr)}h&&f.generateCollisionDebugBuffers(M,f.collisionBoxArray,ee.textScaleFactor)},i.fz=Kt,i.g=function(f,c){return Xm(Object.assign(f,{method:"GET"}),c)},i.h=function(f){return f.indexOf("mapbox:")===0},i.i=function(f){return Gn.API_STYLE_REGEX.test(f)&&!Cl(f)},i.j=Vi,i.k=Zo,i.l=function(f){return decodeURIComponent(atob(f).split("").map(c=>"%"+("00"+c.charCodeAt(0).toString(16)).slice(-2)).join(""))},i.m=function(f,c){return Xm(Object.assign(f,{type:"json"}),c)},i.n=C0,i.o=tl,i.p=function(f,c){return Xm(Object.assign(f,{method:"POST"}),c)},i.q=Xc,i.r=Ch,i.s=function(f){try{const c=self[f];return c.setItem("_mapbox_test_",1),c.removeItem("_mapbox_test_"),!0}catch{return!1}},i.t=function(){return wce||(wce=new Q_("ImageRasterizer")),wce},i.u=function(){return function f(c){return c?(c^Math.random()*(16>>c/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,f)}()},i.v=function(f){return!!f&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(f)},i.w=ts,i.x=pde,i.y=pn,i.z=Hr}),o(["./shared"],function(i){function d(nt){const ye=nt?nt.url.toString():void 0;return ye?performance.getEntriesByName(ye):[]}function m(nt){if(typeof nt=="number"||typeof nt=="boolean"||typeof nt=="string"||nt==null)return JSON.stringify(nt);if(Array.isArray(nt)){let De="[";for(const Xe of nt)De+=`${m(Xe)},`;return`${De}]`}let ye="{";for(const De of Object.keys(nt).sort())ye+=`${De}:${m(nt[De])},`;return`${ye}}`}function p(nt){let ye="";for(const De of i.bx)ye+=`/${m(nt[De])}`;return ye}class g{constructor(ye){this.keyCache={},this._layers={},this._layerConfigs={},ye&&this.replace(ye)}replace(ye,De){this._layerConfigs={},this._layers={},this.update(ye,[],De)}update(ye,De,Xe){this._options=Xe;for(const jt of ye)this._layerConfigs[jt.id]=jt,(this._layers[jt.id]=i.du(jt,this.scope,null,this._options)).compileFilter(Xe),this.keyCache[jt.id]&&delete this.keyCache[jt.id];for(const jt of De)delete this.keyCache[jt],delete this._layerConfigs[jt],delete this._layers[jt];this.familiesBySource={};const Ct=function(jt,Dt){const Gt={};for(let Yt=0;Ytthis._layers[ss.id]),Gt=Dt[0];if(Gt.visibility==="none")continue;const Ft=Gt.source||"";let Yt=this.familiesBySource[Ft];Yt||(Yt=this.familiesBySource[Ft]={});const yr=Gt.sourceLayer||"_geojsonTileLayer";let hr=Yt[yr];hr||(hr=Yt[yr]=[]),hr.push(Dt)}}}const v=1*i.fl;class _{constructor(ye){const De={},Xe=[];for(const Gt in ye){const Ft=ye[Gt],Yt=De[Gt]={};for(const yr in Ft.glyphs){const hr=Ft.glyphs[+yr];if(!hr||hr.bitmap.width===0||hr.bitmap.height===0)continue;const ss=hr.metrics.localGlyph?v:1,Is={x:0,y:0,w:hr.bitmap.width+2*ss,h:hr.bitmap.height+2*ss};Xe.push(Is),Yt[yr]=Is}}const{w:Ct,h:jt}=i.G(Xe),Dt=new i.fk({width:Ct||1,height:jt||1});for(const Gt in ye){const Ft=ye[Gt];for(const Yt in Ft.glyphs){const yr=Ft.glyphs[+Yt];if(!yr||yr.bitmap.width===0||yr.bitmap.height===0)continue;const hr=De[Gt][Yt],ss=yr.metrics.localGlyph?v:1;i.fk.copy(yr.bitmap,Dt,{x:0,y:0},{x:hr.x+ss,y:hr.y+ss},yr.bitmap)}}this.image=Dt,this.positions=De}}function k(nt,ye,De){nt[ye]?De&&(nt[ye].center=De):nt[ye]={floorIds:new Set,center:De||[0,0],floors:{}}}function w(nt,ye,De,Xe){for(const Ct of ye)k(nt,Ct),nt[Ct].floors[De]=Xe,nt[Ct].floorIds.add(De)}function S(nt){return{id:nt.properties.id.toString(),center:nt.properties.center.toString().split(";").map(Number)}}function T(nt){return{id:nt.properties.id.toString(),isDefault:!!nt.properties.is_default&&nt.properties.is_default,connections:nt.properties.connected_floor_ids?new Set(nt.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:nt.properties.conflicted_floor_ids?new Set(nt.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:nt.properties.building_ids?new Set(nt.properties.building_ids.toString().split(";")):new Set,name:nt.properties.name.toString(),zIndex:nt.properties.z_index}}function C(nt,ye){return ye.every(De=>nt.properties&&nt.properties[De]!=null)}function I(nt){return C(nt,["type","id","name"])&&nt.properties.type==="building"}function R(nt){return C(nt,["type","id","name","z_index"])&&nt.properties.type==="floor"}i.fj(_,"GlyphAtlas");class D{constructor(ye){this.tileID=new i.aQ(ye.tileID.overscaledZ,ye.tileID.wrap,ye.tileID.canonical.z,ye.tileID.canonical.x,ye.tileID.canonical.y),this.tileZoom=ye.tileZoom,this.uid=ye.uid,this.zoom=ye.zoom,this.lut=ye.lut,this.canonical=ye.tileID.canonical,this.pixelRatio=ye.pixelRatio,this.tileSize=ye.tileSize,this.source=ye.source,this.scope=ye.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=ye.showCollisionBoxes,this.collectResourceTiming=!!ye.request&&ye.request.collectResourceTiming,this.promoteId=ye.promoteId,this.isSymbolTile=ye.isSymbolTile,this.tileTransform=i.aZ(ye.tileID.canonical,ye.projection),this.projection=ye.projection,this.worldview=ye.worldview,this.localizableLayerIds=ye.localizableLayerIds,this.brightness=ye.brightness,this.extraShadowCaster=!!ye.extraShadowCaster,this.tessellationStep=ye.tessellationStep,this.scaleFactor=ye.scaleFactor,this.worldview=ye.worldview,this.indoor=ye.indoor}parse(ye,De,Xe,Ct,jt,Dt){this.status="parsing",this.data=ye,this.collisionBoxArray=new i.b3;const Gt=new i.fm(Object.keys(ye.layers).sort()),Ft=new i.fn(this.tileID,this.promoteId);Ft.bucketLayerIDs=[];const Yt={},yr=new i.fo(256,256),hr={featureIndex:Ft,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:yr,availableImages:Xe,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const yn=this.indoor.indoorState.activeFloorsVisible,vn=function(hn,ra,eo){const Eo=function($i,da){if(!$i)return i.w("No source layers defined in indoor specification"),da;if($i.size===0)return da;const Ui=$i.difference(da);for(const Ja of Ui)i.w(`Missing source layer required in indoor specification: ${Ja}`);return da.intersection(da)}(ra.sourceLayers,new Set(Object.keys(hn.layers))),Ma=ra.indoorState,Do=function($i,da,Ui,Ja){const Gn=new Set,Vi=new Set,Cl=new Set,$l=new Map,hd={},Ym=el=>{const Jd=$l.get(el)||new Set;for(const Ac of Gn)if(($l.get(Ac)||new Set).has(el)||Jd.has(Ac))return!0;return!1};for(const el of da){const Jd=$i.layers[el];if(Jd)for(let Ac=0;Ac=Ui.maxzoom||Ui.visibility==="none")continue;B(da,this.zoom,hr.brightness,Xe,this.worldview);const Ja=Yt[Ui.id]=Ui.createBucket({index:Ft.bucketLayerIDs.length,layers:da,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Eo,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:Ct,worldview:this.worldview,localizable:Do});Ft.bucketLayerIDs.push(da.map(Vi=>i.B(Vi.id,Vi.scope)));let Gn=Ja.prepare?Ja.prepare():null;Gn!=null?(Gn=Gn.then(()=>Ja.populate(Ma,hr,this.tileID.canonical,this.tileTransform)),ss.push(Gn)):Ja.populate(Ma,hr,this.tileID.canonical,this.tileTransform)}}const ts=()=>{let yn,vn,hn,ra,eo,Eo;yr.trim();const Ma={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},Do=()=>{if(yn)return this.status="done",Dt(yn);if(this.extraShadowCaster)this.status="done",Dt(null,{buckets:Object.values(Yt).filter(da=>!da.isEmpty()),featureIndex:Ft,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:hr.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(vn&&hn&&ra){const da=new _(vn),Ui=new Map;for(const[Vi,Cl]of hn.entries()){const{imagePosition:$l}=i.fu(Vi,Cl,i.fv);Ui.set(Vi,$l)}const Ja={};for(const Vi in Yt){const Cl=Yt[Vi];Cl instanceof i.b4&&(B(Cl.layers,this.zoom,hr.brightness,Xe,this.worldview),Ja[Vi]=i.fw(Cl,vn,da.positions,hn,Ui,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,eo,this.worldview))}const Gn={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(jt,hn,eo,()=>{Gn.iconsPending=!1,$i(Ja,da,Gn)}),this.rasterizeIfNeeded(jt,ra,Eo,()=>{Gn.patternsPending=!1,$i(Ja,da,Gn)})}},$i=(da,Ui,Ja,Gn)=>{if(Ja.iconsPending||Ja.patternsPending)return;const Vi=new i.fx(hn,ra,this.lut);for(const Cl in Yt){const $l=Yt[Cl];if(Cl in da)i.fy($l,da[Cl],this.showCollisionBoxes,Xe,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,hn,Vi);else if($l.hasPattern&&($l instanceof i.ba||$l instanceof i.bb||$l instanceof i.ea)){B($l.layers,this.zoom,hr.brightness,Xe,this.worldview);const hd=Object.fromEntries(Vi.patternPositions);$l.addFeatures(hr,this.tileID.canonical,hd,Xe,this.tileTransform,this.brightness)}}this.status="done",Dt(null,{buckets:Object.values(Yt).filter(Cl=>!Cl.isEmpty()),featureIndex:Ft,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ui.image,lineAtlas:yr,imageAtlas:Vi,brightness:hr.brightness})};if(!this.extraShadowCaster){const da=i.fs(hr.glyphDependencies,Gn=>Object.keys(Gn).map(Number));Object.keys(da).length?jt.send("getGlyphs",{uid:this.uid,stacks:da},(Gn,Vi)=>{yn||(yn=Gn,vn=Vi,Do())},void 0,!1,Ma):vn={};const Ui=Array.from(hr.iconDependencies.keys()).map(Gn=>i.I.parse(Gn));Ui.length?jt.send("getImages",{images:Ui,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(Gn,Vi)=>{yn||(yn=Gn,hn=new Map,eo=this.updateImageMapAndGetImageTaskQueue(hn,Vi,hr.iconDependencies),Do())},void 0,!1,Ma):(hn=new Map,eo=new Map);const Ja=Array.from(hr.patternDependencies.keys()).map(Gn=>i.I.parse(Gn));Ja.length?jt.send("getImages",{images:Ja,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(Gn,Vi)=>{yn||(yn=Gn,ra=new Map,Eo=this.updateImageMapAndGetImageTaskQueue(ra,Vi,hr.patternDependencies),Do())},void 0,!1,Ma):(ra=new Map,Eo=new Map)}if(hr.elevationFeatures&&hr.elevationFeatures.length>0){const da=[];for(const Ja of Object.values(Yt))if(Ja instanceof i.bb){const Gn=Ja.getUnevaluatedPortalGraph();Gn&&da.push(Gn)}const Ui=i.ft.evaluate(da);for(const Ja of Object.values(Yt))if(Ja instanceof i.bb){const Gn=ye.layers[Gt.decode(Ja.sourceLayerIndex)];Ja.setEvaluatedPortalGraph(Ui,Gn,this.tileID.canonical,hr.availableImages,hr.brightness)}}Do()};ss.length>0?Promise.allSettled(ss).then(ts).catch(Dt):ts()}updateParameters(ye){this.scaleFactor=ye.scaleFactor,this.showCollisionBoxes=ye.showCollisionBoxes,this.projection=ye.projection,this.brightness=ye.brightness,this.tileTransform=i.aZ(ye.tileID.canonical,ye.projection),this.extraShadowCaster=ye.extraShadowCaster,this.lut=ye.lut,this.worldview=ye.worldview,this.indoor=ye.indoor}rasterizeIfNeeded(ye,De,Xe,Ct){Array.from(De.values()).some(jt=>jt.usvg)?this.rasterize(ye,De,Xe,Ct):Ct()}updateImageMapAndGetImageTaskQueue(ye,De,Xe){const Ct=new Map;for(const jt of De.keys()){const Dt=Xe.get(jt)||[];for(const Gt of Dt){const Ft=Gt.toString(),Yt=De.get(Gt.id.toString());Yt.usvg?Ct.has(Ft)||(Ct.set(Ft,Gt),ye.set(Ft,Object.assign({},Yt))):ye.set(Ft,Yt)}}return Ct}rasterize(ye,De,Xe,Ct){this.rasterizeTask=ye.send("rasterizeImages",{scope:this.scope,tasks:Xe},(jt,Dt)=>{if(!jt)for(const[Gt,Ft]of Dt.entries()){const Yt=Object.assign(De.get(Gt),{data:Ft});De.set(Gt,Yt)}Ct()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function B(nt,ye,De,Xe,Ct){const jt=new i.ac(ye,{brightness:De,worldview:Ct});for(const Dt of nt)Dt.recalculate(jt,Xe)}class $ extends i.E{constructor(ye,De,Xe,Ct,jt,Dt,Gt){super(),this.actor=ye,this.layerIndex=De,this.availableImages=Xe,this.availableModels=Ct,this.loadVectorData=Dt||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(ye.scheduler),this.isSpriteLoaded=jt,this.scheduler=ye.scheduler,this.brightness=Gt}loadTile(ye,De){const Xe=ye.uid,Ct=ye&&ye.request,jt=Ct&&Ct.collectResourceTiming,Dt=this.loading[Xe]=new D(ye);Dt.abort=this.loadVectorData(ye,(Gt,Ft)=>{const Yt=!this.loading[Xe];if(delete this.loading[Xe],Dt.cancelRasterize(),Yt||Gt||!Ft)return Dt.status="done",Yt||(this.loaded[Xe]=Dt),De(Gt);const yr=Ft.rawData,hr={},ss=i.aM(Ft.responseHeaders);ss&&ss.expires&&(hr.expires=ss.expires),ss&&ss.cacheControl&&(hr.cacheControl=ss.cacheControl),Dt.vectorTile=Ft.vectorTile||new i.fz(new i.bt(yr));const Is=()=>{Dt.parse(Dt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(ts,yn)=>{if(ts||!yn)return De(ts);const vn={};if(jt){const hn=d(Ct);hn.length>0&&(vn.resourceTiming=JSON.parse(JSON.stringify(hn)))}De(null,Object.assign({rawTileData:yr.slice(0),responseHeaders:Ft.responseHeaders},yn,hr,vn))})};this.isSpriteLoaded?Is():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Is,{type:"parseTile",isSymbolTile:ye.isSymbolTile,zoom:ye.tileZoom}):Is()}),this.loaded=this.loaded||{},this.loaded[Xe]=Dt})}reloadTile(ye,De){const Xe=this.loaded,Ct=ye.uid;if(Xe&&Xe[Ct]){const jt=Xe[Ct];jt.updateParameters(ye);const Dt=(Gt,Ft)=>{const Yt=jt.reloadCallback;Yt&&(delete jt.reloadCallback,jt.parse(jt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Yt)),De(Gt,Ft)};jt.status==="parsing"?jt.reloadCallback=Dt:jt.status==="done"&&(jt.vectorTile?jt.parse(jt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Dt):Dt())}else De(null,void 0)}abortTile(ye,De){const Xe=ye.uid,Ct=this.loading[Xe];Ct&&(Ct.abort&&Ct.abort(),delete this.loading[Xe]),De()}removeTile(ye,De){const Xe=this.loaded,Ct=ye.uid;Xe&&Xe[Ct]&&delete Xe[Ct],De()}}class q{loadTile(ye,De){const{uid:Xe,encoding:Ct,rawImageData:jt,padding:Dt}=ye,Gt=ImageBitmap&&jt instanceof ImageBitmap?this.getImageData(jt,Dt):jt;De(null,new i.fA(Xe,Gt,Ct,Dt<1))}reloadTile(ye,De){De(null,null)}abortTile(ye,De){De()}removeTile(ye,De){De()}getImageData(ye,De){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(ye.width,ye.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=ye.width,this.offscreenCanvas.height=ye.height,this.offscreenCanvasContext.drawImage(ye,0,0,ye.width,ye.height);const Xe=this.offscreenCanvasContext.getImageData(-De,-De,ye.width+2*De,ye.height+2*De);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Xe}}i.bs.setPbf(i.bt);class W{constructor(ye){this._mrt=new i.bs(ye.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=ye.uid,this.tileID=ye.tileID,this.source=ye.source}parse(ye,De){const Xe=this._mrt;this.status="parsing",this._entireBuffer=ye;try{Xe.parseHeader(ye),this._isHeaderLoaded=!0;const Ct=[];for(const jt in Xe.layers){const Dt=Xe.getLayer(jt),Gt=Dt.getDataRange(Dt.getBandList()),Ft=Xe.createDecodingTask(Gt),Yt=ye.slice(Gt.firstByte,Gt.lastByte+1),yr=i.bs.performDecoding(Yt,Ft).then(hr=>Ft.complete(null,hr)).catch(hr=>Ft.complete(hr,null));Ct.push(yr)}Promise.allSettled(Ct).then(()=>De(null,Xe)).catch(jt=>De(jt))}catch(Ct){De(Ct)}}}class K{constructor(ye){this.actor=ye,this.loading={},this.loaded={}}loadTile(ye,De){const Xe=ye.uid,Ct=ye.request,jt=this.loading[Xe]=new W(ye),{cancel:Dt}=i.bu(Ct,(Gt,Ft,Yt)=>{const yr=!this.loading[Xe];if(delete this.loading[Xe],yr||Gt||!Ft)return jt.status="done",yr||(this.loaded[Xe]=jt),De(Gt);jt.parse(Ft,(hr,ss)=>{if(hr||!ss)return De(hr);De(null,ss,Yt)}),this.loaded[Xe]=jt});jt.abort=Dt}reloadTile(ye,De){De(null,void 0)}abortTile(ye,De){const Xe=ye.uid,Ct=this.loading[Xe];Ct&&(Ct.abort&&Ct.abort(),delete this.loading[Xe]),De()}removeTile(ye,De){const Xe=ye.uid;this.loaded[Xe]&&delete this.loaded[Xe],De()}decodeRasterArray(ye,De){i.bs.performDecoding(ye.buffer,ye.task).then(Xe=>De(null,Xe)).catch(Xe=>De(Xe))}}const re=i.fB.prototype.toGeoJSON;class ae{constructor(ye){this._feature=ye,this.extent=i.al,this.type=ye.type,this.properties=ye.tags,"id"in ye&&!isNaN(ye.id)&&(this.id=parseInt(ye.id,10))}loadGeometry(){if(this._feature.type===1){const ye=[];for(const De of this._feature.geometry)ye.push([new i.P(De[0],De[1])]);return ye}{const ye=[];for(const De of this._feature.geometry){const Xe=[];for(const Ct of De)Xe.push(new i.P(Ct[0],Ct[1]));ye.push(Xe)}return ye}}toGeoJSON(ye,De,Xe){return re.call(this,ye,De,Xe)}}class oe{constructor(ye,De){this.name=ye,this.extent=i.al,this.length=De.length,this._jsonFeatures=De}feature(ye){return new ae(this._jsonFeatures[ye])}}class se{constructor(ye){this.layers={},this.extent=i.al;for(const De of Object.keys(ye))this.layers[De]=new oe(De,ye[De])}}const pe=64/4096,ie=128;class de{constructor(){this.features=new Map}clear(){this.features.clear()}load(ye=[],De){for(const Xe of ye){const Ct=Xe.id;if(Ct==null)continue;let jt=this.features.get(Ct);jt&&this.updateCache(jt,De),Xe.geometry?(jt=ge(Xe),this.updateCache(jt,De),this.features.set(Ct,jt)):this.features.delete(Ct),this.updateCache(jt,De)}}updateCache(ye,De){for(const{canonical:Xe,uid:Ct}of Object.values(De)){const{z:jt,x:Dt,y:Gt}=Xe;ce(ye,Math.pow(2,jt),Dt,Gt)&&delete De[Ct]}}getTile(ye,De,Xe){const Ct=Math.pow(2,ye),jt=[];for(const Dt of this.features.values())ce(Dt,Ct,De,Xe)&&jt.push(Me(Dt,Ct,De,Xe));return{features:jt}}getFeatures(){return[...this.features.values()]}}function ce({minX:nt,minY:ye,maxX:De,maxY:Xe},Ct,jt,Dt){return nt<(jt+1+pe)/Ct&&ye<(Dt+1+pe)/Ct&&De>(jt-pe)/Ct&&Xe>(Dt-pe)/Ct}function ge(nt){const{id:ye,geometry:De,properties:Xe}=nt;if(!De)return;if(De.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:Ct,coordinates:jt}=De,Dt={id:ye,type:1,geometry:[],tags:Xe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Gt=Dt.geometry;if(Ct==="Point")Te(jt,Gt,Dt);else if(Ct==="MultiPoint")for(const Ft of jt)Te(Ft,Gt,Dt);else if(Ct==="LineString")Dt.type=2,_e(jt,Gt,Dt);else if(Ct==="MultiLineString")Dt.type=2,ve(jt,Gt,Dt);else if(Ct==="Polygon")Dt.type=3,ve(jt,Gt,Dt,!0);else{if(Ct!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Dt.type=3;for(const Ft of jt)ve(Ft,Gt,Dt,!0)}return Dt}function Te([nt,ye],De,Xe){const Ct=i.aF(nt);let jt=i.aJ(ye);jt=jt<0?0:jt>1?1:jt,De.push(Ct,jt),Xe.minX=Math.min(Xe.minX,Ct),Xe.minY=Math.min(Xe.minY,jt),Xe.maxX=Math.max(Xe.maxX,Ct),Xe.maxY=Math.max(Xe.maxY,jt)}function _e(nt,ye,De,Xe=!1,Ct=!1){const jt=[];for(const Dt of nt)Te(Dt,jt,De);ye.push(jt),Xe&&function(Dt,Gt){let Ft=0;for(let Yt=0,yr=Dt.length,hr=yr-2;Yt0===Gt)for(let Yt=0,yr=Dt.length;Yt=Dt&&hr>=Dt||(Yt>=Dt?(yr+=Math.round(ts*((Dt-Yt)/Is)),Yt=Dt):hr>=Dt&&(ss=yr+Math.round(ts*((Dt-Yt)/Is)),hr=Dt),yr>=Dt&&ss>=Dt||(yr>=Dt?(Yt+=Math.round(Is*((Dt-yr)/ts)),yr=Dt):ss>=Dt&&(hr=Yt+Math.round(Is*((Dt-yr)/ts)),ss=Dt),Gt&&Yt===Gt[Gt.length-1][0]&&yr===Gt[Gt.length-1][1]||(Gt=[[Yt,yr]],Ct.push(Gt)),Gt.push([hr,ss])))))}}function Ae(nt,ye,De,Xe,Ct){const jt=(De-pe)/ye,Dt=(Xe-pe)/ye,Gt=(De+1+pe)/ye,Ft=(Xe+1+pe)/ye;function Yt(ss,Is){let ts=0;return ssGt&&(ts|=2),IsFt&&(ts|=8),ts}let yr=[];for(let ss=1;ss<=8;ss*=2){let Is=nt[nt.length-2],ts=nt[nt.length-1],yn=!(Yt(Is,ts)&ss);for(let vn=0;vn>31}function wt(nt,ye){const{geometry:De,type:Xe}=nt;let Ct=0,jt=0;if(Xe===1){ye.writeVarint(Ie(1,De.length));for(const Dt of De){const Gt=Dt[0]-Ct,Ft=Dt[1]-jt;ye.writeVarint(We(Gt)),ye.writeVarint(We(Ft)),Ct+=Gt,jt+=Ft}}else for(const Dt of De){ye.writeVarint(Ie(1,1));const Gt=Dt.length-(Xe===3?1:0);for(let Ft=0;Ftnt},ue=Math.fround||($e=new Float32Array(1),nt=>($e[0]=+nt,$e[0]));var $e;const tt=3,rt=5,je=6;class it{constructor(ye){this.options=Object.assign(Object.create(st),ye),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(ye){const{log:De,minZoom:Xe,maxZoom:Ct}=this.options;De&&console.time("total time");const jt=`prepare ${ye.length} points`;De&&console.time(jt),this.points=ye;const Dt=[];for(let Ft=0;Ft=Xe;Ft--){const Yt=+Date.now();Gt=this.trees[Ft]=this._createTree(this._cluster(Gt,Ft)),De&&console.log("z%d: %d clusters in %dms",Ft,Gt.numItems,+Date.now()-Yt)}return De&&console.timeEnd("total time"),this}getClusters(ye,De){let Xe=((ye[0]+180)%360+360)%360-180;const Ct=Math.max(-90,Math.min(90,ye[1]));let jt=ye[2]===180?180:((ye[2]+180)%360+360)%360-180;const Dt=Math.max(-90,Math.min(90,ye[3]));if(ye[2]-ye[0]>=360)Xe=-180,jt=180;else if(Xe>jt){const hr=this.getClusters([Xe,Ct,180,Dt],De),ss=this.getClusters([-180,Ct,jt,Dt],De);return hr.concat(ss)}const Gt=this.trees[this._limitZoom(De)],Ft=Gt.range(Qe(Xe),He(Dt),Qe(jt),He(Ct)),Yt=Gt.data,yr=[];for(const hr of Ft){const ss=this.stride*hr;yr.push(Yt[ss+rt]>1?Se(Yt,ss,this.clusterProps):this.points[Yt[ss+tt]])}return yr}getChildren(ye){const De=this._getOriginId(ye),Xe=this._getOriginZoom(ye),Ct="No cluster with the specified id.",jt=this.trees[Xe];if(!jt)throw new Error(Ct);const Dt=jt.data;if(De*this.stride>=Dt.length)throw new Error(Ct);const Gt=this.options.radius/(this.options.extent*Math.pow(2,Xe-1)),Ft=jt.within(Dt[De*this.stride],Dt[De*this.stride+1],Gt),Yt=[];for(const yr of Ft){const hr=yr*this.stride;Dt[hr+4]===ye&&Yt.push(Dt[hr+rt]>1?Se(Dt,hr,this.clusterProps):this.points[Dt[hr+tt]])}if(Yt.length===0)throw new Error(Ct);return Yt}getLeaves(ye,De,Xe){const Ct=[];return this._appendLeaves(Ct,ye,De=De||10,Xe=Xe||0,0),Ct}getTile(ye,De,Xe){const Ct=this.trees[this._limitZoom(ye)],jt=Math.pow(2,ye),{extent:Dt,radius:Gt}=this.options,Ft=Gt/Dt,Yt=(Xe-Ft)/jt,yr=(Xe+1+Ft)/jt,hr={features:[]};return this._addTileFeatures(Ct.range((De-Ft)/jt,Yt,(De+1+Ft)/jt,yr),Ct.data,De,Xe,jt,hr),De===0&&this._addTileFeatures(Ct.range(1-Ft/jt,Yt,1,yr),Ct.data,jt,Xe,jt,hr),De===jt-1&&this._addTileFeatures(Ct.range(0,Yt,Ft/jt,yr),Ct.data,-1,Xe,jt,hr),hr.features.length?hr:null}getClusterExpansionZoom(ye){let De=this._getOriginZoom(ye)-1;for(;De<=this.options.maxZoom;){const Xe=this.getChildren(ye);if(De++,Xe.length!==1)break;ye=Xe[0].properties.cluster_id}return De}_appendLeaves(ye,De,Xe,Ct,jt){const Dt=this.getChildren(De);for(const Gt of Dt){const Ft=Gt.properties;if(Ft&&Ft.cluster?jt+Ft.point_count<=Ct?jt+=Ft.point_count:jt=this._appendLeaves(ye,Ft.cluster_id,Xe,Ct,jt):jt1;let yr,hr,ss;if(Yt)yr=et(De,Ft,this.clusterProps),hr=De[Ft],ss=De[Ft+1];else{const yn=this.points[De[Ft+tt]];yr=yn.properties;const[vn,hn]=yn.geometry.coordinates;hr=Qe(vn),ss=He(hn)}const Is={type:1,geometry:[[Math.round(this.options.extent*(hr*jt-Xe)),Math.round(this.options.extent*(ss*jt-Ct))]],tags:yr};let ts;ts=Yt||this.options.generateId?De[Ft+tt]:this.points[De[Ft+tt]].id,ts!==void 0&&(Is.id=ts),Dt.features.push(Is)}}_limitZoom(ye){return Math.max(this.options.minZoom,Math.min(Math.floor(+ye),this.options.maxZoom+1))}_cluster(ye,De){const{radius:Xe,extent:Ct,reduce:jt,minPoints:Dt}=this.options,Gt=Xe/(Ct*Math.pow(2,De)),Ft=ye.data,Yt=[],yr=this.stride;for(let hr=0;hrDe&&(vn+=Ft[ra+rt])}if(vn>yn&&vn>=Dt){let hn,ra=ss*yn,eo=Is*yn,Eo=-1;const Ma=(hr/yr<<5)+(De+1)+this.points.length;for(const Do of ts){const $i=Do*yr;if(Ft[$i+2]<=De)continue;Ft[$i+2]=De;const da=Ft[$i+rt];ra+=Ft[$i]*da,eo+=Ft[$i+1]*da,Ft[$i+4]=Ma,jt&&(hn||(hn=this._map(Ft,hr,!0),Eo=this.clusterProps.length,this.clusterProps.push(hn)),jt(hn,this._map(Ft,$i)))}Ft[hr+4]=Ma,Yt.push(ra/vn,eo/vn,1/0,Ma,-1,vn),jt&&Yt.push(Eo)}else{for(let hn=0;hn1)for(const hn of ts){const ra=hn*yr;if(!(Ft[ra+2]<=De)){Ft[ra+2]=De;for(let eo=0;eo>5}_getOriginZoom(ye){return(ye-this.points.length)%32}_map(ye,De,Xe){if(ye[De+rt]>1){const Dt=this.clusterProps[ye[De+je]];return Xe?Object.assign({},Dt):Dt}const Ct=this.points[ye[De+tt]].properties,jt=this.options.map(Ct);return Xe&&jt===Ct?Object.assign({},jt):jt}}function Se(nt,ye,De){return{type:"Feature",id:nt[ye+tt],properties:et(nt,ye,De),geometry:{type:"Point",coordinates:[(Xe=nt[ye],360*(Xe-.5)),ot(nt[ye+1])]}};var Xe}function et(nt,ye,De){const Xe=nt[ye+rt],Ct=Xe>=1e4?`${Math.round(Xe/1e3)}k`:Xe>=1e3?Math.round(Xe/100)/10+"k":Xe,jt=nt[ye+je],Dt=jt===-1?{}:Object.assign({},De[jt]);return Object.assign(Dt,{cluster:!0,cluster_id:nt[ye+tt],point_count:Xe,point_count_abbreviated:Ct})}function Qe(nt){return nt/360+.5}function He(nt){const ye=Math.sin(nt*Math.PI/180),De=.5-.25*Math.log((1+ye)/(1-ye))/Math.PI;return De<0?0:De>1?1:De}function ot(nt){const ye=(180-360*nt)*Math.PI/180;return 360*Math.atan(Math.exp(ye))/Math.PI-90}function ut(nt,ye,De,Xe){let Ct=Xe;const jt=ye+(De-ye>>1);let Dt,Gt=De-ye;const Ft=nt[ye],Yt=nt[ye+1],yr=nt[De],hr=nt[De+1];for(let ss=ye+3;ssCt)Dt=ss,Ct=Is;else if(Is===Ct){const ts=Math.abs(ss-jt);tsXe&&(Dt-ye>3&&ut(nt,ye,Dt,Xe),nt[Dt+2]=Ct,De-Dt>3&&ut(nt,Dt,De,Xe))}function ft(nt,ye,De,Xe,Ct,jt){let Dt=Ct-De,Gt=jt-Xe;if(Dt!==0||Gt!==0){const Ft=((nt-De)*Dt+(ye-Xe)*Gt)/(Dt*Dt+Gt*Gt);Ft>1?(De=Ct,Xe=jt):Ft>0&&(De+=Dt*Ft,Xe+=Gt*Ft)}return Dt=nt-De,Gt=ye-Xe,Dt*Dt+Gt*Gt}function ct(nt,ye,De,Xe){const Ct={id:nt??null,type:ye,geometry:De,tags:Xe,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(ye==="Point"||ye==="MultiPoint"||ye==="LineString")Tt(Ct,De);else if(ye==="Polygon")Tt(Ct,De[0]);else if(ye==="MultiLineString")for(const jt of De)Tt(Ct,jt);else if(ye==="MultiPolygon")for(const jt of De)Tt(Ct,jt[0]);return Ct}function Tt(nt,ye){for(let De=0;De0&&(Dt+=Xe?(Ct*yr-Yt*jt)/2:Math.sqrt(Math.pow(Yt-Ct,2)+Math.pow(yr-jt,2))),Ct=Yt,jt=yr}const Gt=ye.length-3;ye[2]=1,ut(ye,0,Gt,De),ye[Gt+2]=1,ye.size=Math.abs(Dt),ye.start=0,ye.end=ye.size}function cr(nt,ye,De,Xe){for(let Ct=0;Ct1?1:De}function Et(nt,ye,De,Xe,Ct,jt,Dt,Gt){if(Xe/=ye,jt>=(De/=ye)&&Dt=Xe)return null;const Ft=[];for(const Yt of nt){const yr=Yt.geometry;let hr=Yt.type;const ss=Ct===0?Yt.minX:Yt.minY,Is=Ct===0?Yt.maxX:Yt.maxY;if(ss>=De&&Is=Xe)continue;let ts=[];if(hr==="Point"||hr==="MultiPoint")Pt(yr,ts,De,Xe,Ct);else if(hr==="LineString")Sr(yr,ts,De,Xe,Ct,!1,Gt.lineMetrics);else if(hr==="MultiLineString")Ws(yr,ts,De,Xe,Ct,!1);else if(hr==="Polygon")Ws(yr,ts,De,Xe,Ct,!0);else if(hr==="MultiPolygon")for(const yn of yr){const vn=[];Ws(yn,vn,De,Xe,Ct,!0),vn.length&&ts.push(vn)}if(ts.length){if(Gt.lineMetrics&&hr==="LineString"){for(const yn of ts)Ft.push(ct(Yt.id,hr,yn,Yt.tags));continue}hr!=="LineString"&&hr!=="MultiLineString"||(ts.length===1?(hr="LineString",ts=ts[0]):hr="MultiLineString"),hr!=="Point"&&hr!=="MultiPoint"||(hr=ts.length===3?"Point":"MultiPoint"),Ft.push(ct(Yt.id,hr,ts,Yt.tags))}}return Ft.length?Ft:null}function Pt(nt,ye,De,Xe,Ct){for(let jt=0;jt=De&&Dt<=Xe&&tn(ye,nt[jt],nt[jt+1],nt[jt+2])}}function Sr(nt,ye,De,Xe,Ct,jt,Dt){let Gt=fs(nt);const Ft=Ct===0?xi:La;let Yt,yr,hr=nt.start;for(let vn=0;vnDe&&(yr=Ft(Gt,hn,ra,Eo,Ma,De),Dt&&(Gt.start=hr+Yt*yr)):Do>Xe?$i=De&&(yr=Ft(Gt,hn,ra,Eo,Ma,De),da=!0),$i>Xe&&Do<=Xe&&(yr=Ft(Gt,hn,ra,Eo,Ma,Xe),da=!0),!jt&&da&&(Dt&&(Gt.end=hr+Yt*yr),ye.push(Gt),Gt=fs(nt)),Dt&&(hr+=Yt)}let ss=nt.length-3;const Is=nt[ss],ts=nt[ss+1],yn=Ct===0?Is:ts;yn>=De&&yn<=Xe&&tn(Gt,Is,ts,nt[ss+2]),ss=Gt.length-3,jt&&ss>=3&&(Gt[ss]!==Gt[0]||Gt[ss+1]!==Gt[1])&&tn(Gt,Gt[0],Gt[1],Gt[2]),Gt.length&&ye.push(Gt)}function fs(nt){const ye=[];return ye.size=nt.size,ye.start=nt.start,ye.end=nt.end,ye}function Ws(nt,ye,De,Xe,Ct,jt){for(const Dt of nt)Sr(Dt,ye,De,Xe,Ct,jt,!1)}function tn(nt,ye,De,Xe){nt.push(ye,De,Xe)}function xi(nt,ye,De,Xe,Ct,jt){const Dt=(jt-ye)/(Xe-ye);return tn(nt,jt,De+(Ct-De)*Dt,1),Dt}function La(nt,ye,De,Xe,Ct,jt){const Dt=(jt-De)/(Ct-De);return tn(nt,ye+(Xe-ye)*Dt,jt,1),Dt}function un(nt,ye){const De=[];for(let Xe=0;Xe0&&ye.size<(Ct?Dt:Xe))return void(De.numPoints+=ye.length/3);const Gt=[];for(let Ft=0;FtDt)&&(De.numSimplified++,Gt.push(ye[Ft],ye[Ft+1])),De.numPoints++;Ct&&function(Ft,Yt){let yr=0;for(let hr=0,ss=Ft.length,Is=ss-2;hr0===Yt)for(let hr=0,ss=Ft.length;hr24)throw new Error("maxZoom should be in the 0-24 range");if(De.promoteId&&De.generateId)throw new Error("promoteId and generateId cannot be used together.");let Ct=function(jt,Dt){const Gt=[];if(jt.type==="FeatureCollection")for(let Ft=0;Ft1&&console.time("creation"),Is=this.tiles[ss]=Yn(ye,De,Xe,Ct,Yt),this.tileCoords.push({z:De,x:Xe,y:Ct}),yr)){yr>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",De,Xe,Ct,Is.numFeatures,Is.numPoints,Is.numSimplified),console.timeEnd("creation"));const da=`z${De}`;this.stats[da]=(this.stats[da]||0)+1,this.total++}if(Is.source=ye,jt==null){if(De===Yt.indexMaxZoom||Is.numPoints<=Yt.indexMaxPoints)continue}else{if(De===Yt.maxZoom||De===jt)continue;if(jt!=null){const da=jt-De;if(Xe!==Dt>>da||Ct!==Gt>>da)continue}}if(Is.source=null,ye.length===0)continue;yr>1&&console.time("clipping");const ts=.5*Yt.buffer/Yt.extent,yn=.5-ts,vn=.5+ts,hn=1+ts;let ra=null,eo=null,Eo=null,Ma=null,Do=Et(ye,hr,Xe-ts,Xe+vn,0,Is.minX,Is.maxX,Yt),$i=Et(ye,hr,Xe+yn,Xe+hn,0,Is.minX,Is.maxX,Yt);ye=null,Do&&(ra=Et(Do,hr,Ct-ts,Ct+vn,1,Is.minY,Is.maxY,Yt),eo=Et(Do,hr,Ct+yn,Ct+hn,1,Is.minY,Is.maxY,Yt),Do=null),$i&&(Eo=Et($i,hr,Ct-ts,Ct+vn,1,Is.minY,Is.maxY,Yt),Ma=Et($i,hr,Ct+yn,Ct+hn,1,Is.minY,Is.maxY,Yt),$i=null),yr>1&&console.timeEnd("clipping"),Ft.push(ra||[],De+1,2*Xe,2*Ct),Ft.push(eo||[],De+1,2*Xe,2*Ct+1),Ft.push(Eo||[],De+1,2*Xe+1,2*Ct),Ft.push(Ma||[],De+1,2*Xe+1,2*Ct+1)}}getTile(ye,De,Xe){ye=+ye,De=+De,Xe=+Xe;const Ct=this.options,{extent:jt,debug:Dt}=Ct;if(ye<0||ye>24)return null;const Gt=1<1&&console.log("drilling down to z%d-%d-%d",ye,De,Xe);let Yt,yr=ye,hr=De,ss=Xe;for(;!Yt&&yr>0;)yr--,hr>>=1,ss>>=1,Yt=this.tiles[Ei(yr,hr,ss)];return Yt&&Yt.source?(Dt>1&&(console.log("found parent tile z%d-%d-%d",yr,hr,ss),console.time("drilling down")),this.splitTile(Yt.source,yr,hr,ss,ye,De,Xe),Dt>1&&console.timeEnd("drilling down"),this.tiles[Ft]?rn(this.tiles[Ft],jt):null):null}}function Ei(nt,ye,De){return 32*((1<Yt.tags&&"3d_elevation_id"in Yt.tags&&"source"in Yt.tags&&Yt.tags.source==="elevation",jt=Xe.features.filter(Yt=>Ct(Yt));let Dt={_geojsonTileLayer:Xe.features};jt.length>0&&(Dt={_geojsonTileLayer:Xe.features.filter(Yt=>!Ct(Yt)),hd_road_elevation:jt});const Gt=new se(Dt),Ft=function(Yt){const yr=new i.bt;for(const hr of Object.keys(Yt))yr.writeMessage(3,Le,{name:hr,features:Yt[hr]});return yr.finish()}(Dt).buffer;ye(null,{vectorTile:Gt,rawData:Ft})}class ao extends ${constructor(ye,De,Xe,Ct,jt,Dt,Gt){super(ye,De,Xe,Ct,jt,Qs,Gt),Dt&&(this.loadGeoJSON=Dt),this._dynamicIndex=new de}loadData(ye,De){const Xe=ye&&ye.request,Ct=Xe&&Xe.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(ye,(jt,Dt)=>{if(jt||!Dt)return De(jt);if(typeof Dt!="object")return De(new Error(`Input data given to '${ye.source}' is not a valid GeoJSON object.`));{try{if(ye.filter){const Ft=i.U(ye.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Ft.result==="error")throw new Error(Ft.value.map(Yt=>`${Yt.key}: ${Yt.message}`).join(", "));Dt.features=Dt.features.filter(Yt=>Ft.value.evaluate({zoom:0},Yt))}ye.dynamic?(Dt.type==="Feature"&&(Dt={type:"FeatureCollection",features:[Dt]}),ye.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Dt.features,this.loaded),ye.cluster&&(Dt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=ye.cluster?new it(function({superclusterOptions:Ft,clusterProperties:Yt}){if(!Yt||!Ft)return Ft;const yr={},hr={},ss={accumulated:null,zoom:0},Is={properties:null},ts=Object.keys(Yt);for(const yn of ts){const[vn,hn]=Yt[yn],ra=i.U(hn),eo=i.U(typeof vn=="string"?[vn,["accumulated"],["get",yn]]:vn);yr[yn]=ra.value,hr[yn]=eo.value}return Ft.map=yn=>{Is.properties=yn;const vn={};for(const hn of ts)vn[hn]=yr[hn].evaluate(ss,Is);return vn},Ft.reduce=(yn,vn)=>{Is.properties=vn;for(const hn of ts)ss.accumulated=yn[hn],yn[hn]=hr[hn].evaluate(ss,Is)},Ft}(ye)).load(Dt.features):ye.dynamic?this._dynamicIndex:function(Ft,Yt){return new xo(Ft,Yt)}(Dt,ye.geojsonVtOptions)}catch(Ft){return De(Ft)}const Gt={};if(Ct){const Ft=d(Xe);Ft&&(Gt.resourceTiming={},Gt.resourceTiming[ye.source]=JSON.parse(JSON.stringify(Ft)))}De(null,Gt)}})}reloadTile(ye,De){const Xe=this.loaded;return Xe&&Xe[ye.uid]?ye.partial?De(null,void 0):super.reloadTile(ye,De):this.loadTile(ye,De)}loadGeoJSON(ye,De){if(ye.request)i.m(ye.request,De);else{if(typeof ye.data!="string")return De(new Error(`Input data given to '${ye.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return De(null,JSON.parse(ye.data))}catch{return De(new Error(`Input data given to '${ye.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(ye,De){try{De(null,this._geoJSONIndex.getClusterExpansionZoom(ye.clusterId))}catch(Xe){De(Xe)}}getClusterChildren(ye,De){try{De(null,this._geoJSONIndex.getChildren(ye.clusterId))}catch(Xe){De(Xe)}}getClusterLeaves(ye,De){try{De(null,this._geoJSONIndex.getLeaves(ye.clusterId,ye.limit,ye.offset))}catch(Xe){De(Xe)}}}class Mc{constructor(ye,De,Xe){this.tileID=new i.aQ(ye.tileID.overscaledZ,ye.tileID.wrap,ye.tileID.canonical.z,ye.tileID.canonical.x,ye.tileID.canonical.y),this.tileZoom=ye.tileZoom,this.uid=ye.uid,this.zoom=ye.zoom,this.canonical=ye.tileID.canonical,this.pixelRatio=ye.pixelRatio,this.tileSize=ye.tileSize,this.source=ye.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=ye.projection,this.brightness=De,this.worldview=Xe}parse(ye,De,Xe,Ct){this.status="parsing";const jt=new i.aQ(Xe.tileID.overscaledZ,Xe.tileID.wrap,Xe.tileID.canonical.z,Xe.tileID.canonical.x,Xe.tileID.canonical.y),Dt=[],Gt=De.familiesBySource[Xe.source],Ft=new i.fn(jt,Xe.promoteId);Ft.bucketLayerIDs=[],Ft.is3DTile=!0,i.fC(ye).then(Yt=>{if(!Yt)return Ct(new Error("Could not parse tile"));const yr=Yt.json.extensionsUsed&&Yt.json.extensionsUsed.includes("MAPBOX_mesh_features")||Yt.json.asset.extras&&Yt.json.asset.extras.MAPBOX_mesh_features,hr=Yt.json.extensionsUsed&&Yt.json.extensionsUsed.includes("EXT_meshopt_compression"),ss=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Is in Gt)for(const ts of Gt[Is]){const yn=ts[0];Ft.bucketLayerIDs.push(ts.map(ra=>i.B(ra.id,ra.scope))),yn.recalculate(ss,[]);const vn=i.fD(Yt,1/i.d7(Xe.tileID.canonical)),hn=new i.fE(ts,vn,jt,yr,hr,this.brightness,Ft,this.worldview);yr||(hn.needsUpload=!0),Dt.push(hn),hn.evaluate(yn)}this.status="done",Ct(null,{buckets:Dt,featureIndex:Ft,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Yt=>Ct(new Error(Yt.message)))}}class No{constructor(ye,De,Xe,Ct,jt,Dt,Gt,Ft){this.actor=ye,this.layerIndex=De,this.availableImages=Xe,this.availableModels=Ct,this.brightness=Gt,this.loading={},this.loaded={},this.worldview=Ft}loadTile(ye,De){const Xe=ye.uid,Ct=this.loading[Xe]=new Mc(ye,this.brightness,this.worldview);i.bu(ye.request,(jt,Dt)=>{const Gt=!this.loading[Xe];return delete this.loading[Xe],Gt||jt?(Ct.status="done",Gt||(this.loaded[Xe]=Ct),De(jt)):Dt&&Dt.byteLength!==0?void Ct.parse(Dt,this.layerIndex,ye,(Ft,Yt)=>{Ct.status="done",this.loaded=this.loaded||{},this.loaded[Xe]=Ct,Ft||!Yt?De(Ft):De(null,Yt)}):(Ct.status="done",this.loaded[Xe]=Ct,De())})}reloadTile(ye,De){const Xe=this.loaded,Ct=ye.uid;if(Xe&&Xe[Ct]){const jt=Xe[Ct];jt.projection=ye.projection,jt.brightness=ye.brightness;const Dt=(Gt,Ft)=>{jt.reloadCallback&&(delete jt.reloadCallback,this.loadTile(ye,De)),De(Gt,Ft)};jt.status==="parsing"?jt.reloadCallback=Dt:jt.status==="done"&&this.loadTile(ye,De)}}abortTile(ye,De){const Xe=ye.uid;this.loading[Xe]&&delete this.loading[Xe],De()}removeTile(ye,De){const Xe=this.loaded,Ct=ye.uid;Xe&&Xe[Ct]&&delete Xe[Ct],De()}}class Tc{constructor(ye){this.self=ye,this.actor=new i.fG(ye,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new i.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=i.cm({name:"mercator"}),this.workerSourceTypes={vector:$,geojson:ao,"raster-dem":q,"raster-array":K,"batched-model":No},this.workerSources={},this.self.registerWorkerSource=(De,Xe)=>{if(this.workerSourceTypes[De])throw new Error(`Worker source with name "${De}" already registered.`);this.workerSourceTypes[De]=Xe},this.self.registerRTLTextPlugin=De=>{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=De.applyArabicShaping,i.fH.processBidirectionalText=De.processBidirectionalText,i.fH.processStyledBidirectionalText=De.processStyledBidirectionalText;for(const Xe of this.rtlPluginParsingListeners)Xe(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(ye,De,Xe){delete this.layerIndexes[ye],delete this.availableImages[ye],delete this.availableModels[ye],delete this.workerSources[ye],Xe()}checkIfReady(ye,De,Xe){Xe()}setReferrer(ye,De){this.referrer=De}spriteLoaded(ye,De){this.isSpriteLoaded[ye]||(this.isSpriteLoaded[ye]={});const{scope:Xe,isLoaded:Ct}=De;if(this.isSpriteLoaded[ye][Xe]=Ct,this.workerSources[ye]&&this.workerSources[ye][Xe])for(const jt in this.workerSources[ye][Xe]){const Dt=this.workerSources[ye][Xe][jt];for(const Gt in Dt){const Ft=Dt[Gt];Ft instanceof $&&(Ft.isSpriteLoaded=Ct,Ft.fire(new i.z("isSpriteLoaded")))}}}setImages(ye,De,Xe){this.availableImages[ye]||(this.availableImages[ye]={});const{scope:Ct,images:jt}=De;if(this.availableImages[ye][Ct]=jt,this.workerSources[ye]&&this.workerSources[ye][Ct]){for(const Dt in this.workerSources[ye][Ct]){const Gt=this.workerSources[ye][Ct][Dt];for(const Ft in Gt)Gt[Ft].availableImages=jt}Xe()}else Xe()}setModels(ye,{scope:De,models:Xe},Ct){if(this.availableModels[ye]||(this.availableModels[ye]={}),this.availableModels[ye][De]=Xe,this.workerSources[ye]&&this.workerSources[ye][De]){for(const jt in this.workerSources[ye][De]){const Dt=this.workerSources[ye][De][jt];for(const Gt in Dt)Dt[Gt].availableModels=Xe}Ct()}else Ct()}setProjection(ye,De){this.projections[ye]=i.cm(De)}setBrightness(ye,De,Xe){this.brightness=De,Xe()}setWorldview(ye,De,Xe){this.worldview=De,Xe()}setLayers(ye,De,Xe){this.getLayerIndex(ye,De.scope).replace(De.layers,De.options),Xe()}updateLayers(ye,De,Xe){this.getLayerIndex(ye,De.scope).update(De.layers,De.removedIds,De.options),Xe()}loadTile(ye,De,Xe){De.projection=this.projections[ye]||this.defaultProjection,this.getWorkerSource(ye,De.type,De.source,De.scope).loadTile(De,Xe)}decodeRasterArray(ye,De,Xe){this.getWorkerSource(ye,De.type,De.source,De.scope).decodeRasterArray(De,Xe)}reloadTile(ye,De,Xe){De.projection=this.projections[ye]||this.defaultProjection,this.getWorkerSource(ye,De.type,De.source,De.scope).reloadTile(De,Xe)}abortTile(ye,De,Xe){this.getWorkerSource(ye,De.type,De.source,De.scope).abortTile(De,Xe)}removeTile(ye,De,Xe){this.getWorkerSource(ye,De.type,De.source,De.scope).removeTile(De,Xe)}removeSource(ye,De,Xe){if(!(this.workerSources[ye]&&this.workerSources[ye][De.scope]&&this.workerSources[ye][De.scope][De.type]&&this.workerSources[ye][De.scope][De.type][De.source]))return;const Ct=this.workerSources[ye][De.scope][De.type][De.source];delete this.workerSources[ye][De.scope][De.type][De.source],Ct.removeSource!==void 0?Ct.removeSource(De,Xe):Xe()}loadWorkerSource(ye,De,Xe){try{this.self.importScripts(De.url),Xe()}catch(Ct){Xe(Ct)}}syncRTLPluginState(ye,De,Xe){if(i.fH.isParsed())Xe(null,!0);else if(i.fH.isParsing())this.rtlPluginParsingListeners.push(Xe);else try{i.fH.setState(De);const Ct=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||Ct==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(Ct),i.fH.isParsed()?Xe(null,!0):this.rtlPluginParsingListeners.push(Xe))}catch(Ct){Xe(Ct)}}setDracoUrl(ye,De){this.dracoUrl=De}getAvailableImages(ye,De){this.availableImages[ye]||(this.availableImages[ye]={});let Xe=this.availableImages[ye][De];return Xe||(Xe=[]),Xe}getAvailableModels(ye,De){this.availableModels[ye]||(this.availableModels[ye]={});let Xe=this.availableModels[ye][De];return Xe||(Xe={}),Xe}getLayerIndex(ye,De){this.layerIndexes[ye]||(this.layerIndexes[ye]={});let Xe=this.layerIndexes[ye][De];return Xe||(Xe=this.layerIndexes[ye][De]=new g,Xe.scope=De),Xe}getWorkerSource(ye,De,Xe,Ct){const jt=this.workerSources;return jt[ye]||(jt[ye]={}),jt[ye][Ct]||(jt[ye][Ct]={}),jt[ye][Ct][De]||(jt[ye][Ct][De]={}),this.isSpriteLoaded[ye]||(this.isSpriteLoaded[ye]={}),jt[ye][Ct][De][Xe]||(jt[ye][Ct][De][Xe]=new this.workerSourceTypes[De]({send:(Dt,Gt,Ft,Yt,yr,hr)=>this.actor.send(Dt,Gt,Ft,ye,yr,hr),scheduler:this.actor.scheduler},this.getLayerIndex(ye,Ct),this.getAvailableImages(ye,Ct),this.getAvailableModels(ye,Ct),this.isSpriteLoaded[ye][Ct],void 0,this.brightness,this.worldview)),jt[ye][Ct][De][Xe]}rasterizeImagesWorker(ye,De,Xe){const Ct=new Map;for(const[jt,{image:Dt,imageVariant:Gt}]of De.tasks.entries()){const Ft=this.imageRasterizer.rasterize(Gt,Dt,De.scope,ye);Ct.set(jt,Ft)}Xe(void 0,Ct)}removeRasterizedImages(ye,De,Xe){this.imageRasterizer.removeImagesFromCacheByIds(De.imageIds,De.scope,ye),Xe()}enforceCacheSizeLimit(ye,De){i.fJ(De)}getWorkerPerformanceMetrics(ye,De,Xe){Xe(void 0,void 0)}}return i.fF(self)&&(self.worker=new Tc(self)),Tc}),o(["./shared"],function(i){var d="3.17.0";const m={create:"create",load:"load",fullLoad:"fullLoad"},p={mark(j){performance.mark(j)},measure(j,u,x){performance.measure(j,u,x)}};function g(j){const u=j.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,_={},k=function(){if(v)return _;function j(N){return!u(N)}function u(N){return typeof window>"u"||typeof document>"u"?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var O,F,U=new Blob([""],{type:"text/javascript"}),G=URL.createObjectURL(U);try{F=new Worker(G),O=!0}catch{O=!1}return F&&F.terminate(),URL.revokeObjectURL(G),O}()?function(){var O=document.createElement("canvas");O.width=O.height=1;var F=O.getContext("2d");if(!F)return!1;var U=F.getImageData(0,0,1,1);return U&&U.width===O.width}()?(x[P=N&&N.failIfMajorPerformanceCaveat]===void 0&&(x[P]=function(O){var F,U=function(G){var J=document.createElement("canvas"),te=Object.create(j.webGLContextAttributes);return te.failIfMajorPerformanceCaveat=G,J.getContext("webgl2",te)}(O);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=j,_.notSupportedReason=u;var x={};return j.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},_}();function w(j,u,x){const N=document.createElement(j);return u!=null&&(N.className=u),x&&x.appendChild(N),N}function S(j,u,x){const N=document.createElementNS("http://www.w3.org/2000/svg",j);for(const P of Object.keys(u))N.setAttributeNS(null,P,String(u[P]));return x&&x.appendChild(N),N}const T=typeof document<"u"?document.documentElement&&document.documentElement.style:null,C=T&&T.userSelect!==void 0?"userSelect":"WebkitUserSelect";let I;function R(){T&&C&&(I=T[C],T[C]="none")}function D(){T&&C&&(T[C]=I)}function B(j){j.preventDefault(),j.stopPropagation(),window.removeEventListener("click",B,!0)}function $(){window.addEventListener("click",B,!0),window.setTimeout(()=>{window.removeEventListener("click",B,!0)},0)}function q(j,u){const x=j.getBoundingClientRect();return re(j,x,u)}function W(j,u){const x=j.getBoundingClientRect(),N=[];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 N=ie(u);return N.params.push(`sdk=js-${d}`),N.path=`/styles/v1${N.path}`,this._makeAPIURL(N,this._customAccessToken||x)}normalizeGlyphsURL(u,x){if(!i.h(u))return u;const N=ie(u);return N.path=`/fonts/v1${N.path}`,this._makeAPIURL(N,this._customAccessToken||x)}normalizeModelURL(u,x){if(!i.h(u))return u;const N=ie(u);return N.path=`/models/v1${N.path}`,this._makeAPIURL(N,this._customAccessToken||x)}normalizeSourceURL(u,x,N,P){if(!i.h(u))return u;const O=ie(u);return O.path=`/v4/${O.authority}.json`,O.params.push("secure"),N&&O.params.push(`language=${N}`),P&&O.params.push(`worldview=${P}`),this._makeAPIURL(O,this._customAccessToken||x)}normalizeIconsetURL(u,x){const N=ie(u);return i.h(u)?(N.path=`/styles/v1${N.path}/iconset.pbf`,this._makeAPIURL(N,this._customAccessToken||x)):de(N)}normalizeSpriteURL(u,x,N,P){const O=ie(u);return i.h(u)?(O.path=`/styles/v1${O.path}/sprite${x}${N}`,this._makeAPIURL(O,this._customAccessToken||P)):(O.path+=`${x}${N}`,de(O))}normalizeTileURL(u,x,N){if(this._isSkuTokenExpired()&&this._createSkuToken(),u&&!i.h(u))return u;const P=ie(u);P.path=P.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${x||N&&P.authority!=="raster"&&N===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 O=this._customAccessToken||function(F){for(const U of F){const G=U.match(/^access_token=(.*)$/);if(G)return G[1]}return null}(P.params)||i.e.ACCESS_TOKEN;return i.e.REQUIRE_ACCESS_TOKEN&&O&&this._skuToken&&P.params.push(`sku=${this._skuToken}`),this._makeAPIURL(P,O)}canonicalizeTileURL(u,x){const N=ie(u);if(!N.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!N.path.match(/\.[\w]+$/))return u;let P="mapbox://";N.path.match(/^\/raster\/v1\//)?P+=`raster/${N.path.replace(`/${i.e.RASTER_URL_PREFIX}/`,"")}`:N.path.match(/^\/rasterarrays\/v1\//)?P+=`rasterarrays/${N.path.replace(`/${i.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:P+=`tiles/${N.path.replace(`/${i.e.TILE_URL_VERSION}/`,"")}`;let O=N.params;return x&&(O=O.filter(F=>!F.match(/^access_token=/))),O.length&&(P+=`?${O.join("&")}`),P}canonicalizeTileset(u,x){const N=!!x&&i.h(x),P=[];for(const O of u.tiles||[])i.j(O)?P.push(this.canonicalizeTileURL(O,N)):P.push(O);return P}_makeAPIURL(u,x){const N="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",P=ie(i.e.API_URL);if(u.protocol=P.protocol,u.authority=P.authority,u.protocol==="http"){const O=u.params.indexOf("secure");O>=0&&u.params.splice(O,1)}if(P.path!=="/"&&(u.path=`${P.path}${u.path}`),!i.e.REQUIRE_ACCESS_TOKEN)return de(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. ${N}`);if(x[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${N}`)}return u.params=u.params.filter(O=>O.indexOf("access_token")===-1),u.params.push(`access_token=${x||""}`),de(u)}}const pe=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ie(j){const u=j.match(pe);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 de(j){const u=j.params.length?`?${j.params.join("&")}`:"";return`${j.protocol}://${j.authority}${j.path}${u}`}const ce="mapbox.eventData";function ge(j){if(!j)return null;const u=j.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 N="";return N=x&&x.u?i.f(x.u):i.e.ACCESS_TOKEN||"",u?`${ce}.${u}:${N}`:`${ce}:${N}`}fetchEventData(){const u=i.s("localStorage"),x=this.getStorageKey(),N=this.getStorageKey("uuid"),P=this.getStorageKey("uuidTimestamp");if(u)try{const O=localStorage.getItem(x);O&&(this.eventData=JSON.parse(O));const F=localStorage.getItem(N);F&&(this.anonId=F);const U=localStorage.getItem(P);U&&(this.anonIdTimestamp=Number(U));const G=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,N,P){if(!i.e.EVENTS_URL)return;const O=ie(i.e.EVENTS_URL);O.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,G={url:de(O),headers:{"Content-Type":"text/plain"},body:JSON.stringify([U])};this.pendingRequest=i.p(G,J=>{this.pendingRequest=null,N(J),this.saveEventData(),this.processRequests(P)})}queueRequest(u,x){this.queue.push(u),this.processRequests(x)}}class _e 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:N}=this.queue.shift();this.postEvent(x,N,()=>{},u)}}const ve=new class extends Te{constructor(j){super("appUserTurnstile"),this._customAccessToken=j}postTurnstileEvent(j,u){i.e.EVENTS_URL&&i.e.ACCESS_TOKEN&&Array.isArray(j)&&j.some(x=>i.h(x)||i.j(x))&&this.queueRequest(Date.now(),u)}processRequests(j){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 N=x!==this.eventData.tokenU;i.v(this.anonId)||(this.refreshUUID(),N=!0);const P=this.queue.shift();if(this.eventData.lastSuccess){const O=new Date(this.eventData.lastSuccess),F=new Date(P),U=(P-this.eventData.lastSuccess)/864e5;N=N||U>=1||U<-1||O.getDate()!==F.getDate()}else N=!0;N?this.postEvent(P,{sdkIdentifier:"mapbox-gl-js",sdkVersion:d,skuId:ae,"enabled.telemetry":!1,userId:this.anonId},O=>{O||(this.eventData.lastSuccess=P,this.eventData.tokenU=x)},j):this.processRequests()}},Me=ve.postTurnstileEvent.bind(ve),Ze=new class extends Te{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(j,u,x,N){this.skuToken=u,this.errorCb=N,i.e.EVENTS_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:j,timestamp:Date.now()},x):this.errorCb(new Error(oe)))}processRequests(j){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:ae,skuToken:this.skuToken,userId:this.anonId},N=>{N?this.errorCb(N):u&&(this.success[u]=!0)},j))}remove(){this.errorCb=null}},Ae=Ze.postMapLoadEvent.bind(Ze),Le=new class extends Te{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(j){let u=this.mapInstanceIdMap.get(j);return u||(u=i.u(),this.mapInstanceIdMap.set(j,u)),u}getEventId(j){const u=this.eventIdPerMapInstanceMap.get(j)||0;return this.eventIdPerMapInstanceMap.set(j,u+1),u}postStyleLoadEvent(j,u){const{map:x,style:N,importedStyles:P}=u;if(!i.e.EVENTS_URL||!j&&!i.e.ACCESS_TOKEN)return;const O=this.getMapInstanceId(x),F={mapInstanceId:O,eventId:this.getEventId(O),style:N};P.length&&(F.importedStyles=P),this.queueRequest({timestamp:Date.now(),payload:F},j)}processRequests(j){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:u,payload:x}=this.queue.shift();this.postEvent(u,x,()=>{},j)}},Ue=Le.postStyleLoadEvent.bind(Le),Ve=new _e({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Ie=Ve.postMetricsEvent.bind(Ve),We=new _e({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),wt=We.postMetricsEvent.bind(We),Pe=new class extends Te{constructor(){super("gljs.performance")}postPerformanceEvent(j,u){i.e.EVENTS_URL&&(j||i.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:u},j)}processRequests(j){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:u,performanceData:x}=this.queue.shift(),N=function(P){const O=performance.getEntriesByType("resource"),F=performance.getEntriesByType("mark"),U=function(fe){const ke={};if(fe){for(const be in fe)if(be!=="other")for(const Re of fe[be]){const Oe=`${be}ResolveRangeMin`,Ge=`${be}ResolveRangeMax`,at=`${be}RequestCount`,Ke=`${be}RequestCachedCount`;ke[Oe]=Math.min(ke[Oe]||1/0,Re.startTime),ke[Ge]=Math.max(ke[Ge]||-1/0,Re.responseEnd);const Nt=xt=>{ke[xt]===void 0&&(ke[xt]=0),++ke[xt]};Re.transferSize!==void 0&&Re.transferSize===0&&Nt(Ke),Nt(at)}}return ke}(function(fe,ke){const be={};if(fe)for(const Re of fe){const Oe=ke(Re);be[Oe]===void 0&&(be[Oe]=[]),be[Oe].push(Re)}return be}(O,g)),G=window.devicePixelRatio,J=navigator.connection||navigator.mozConnection||navigator.webkitConnection,te=J?J.effectiveType:void 0,me={counters:[],metadata:[],attributes:[]},he=(fe,ke,be)=>{be!=null&&fe.push({name:ke,value:be.toString()})};for(const fe in U)he(me.counters,fe,U[fe]);if(P.interactionRange[0]!==1/0&&P.interactionRange[1]!==-1/0&&(he(me.counters,"interactionRangeMin",P.interactionRange[0]),he(me.counters,"interactionRangeMax",P.interactionRange[1])),F)for(const fe of Object.values(m)){const ke=F.find(be=>be.name===fe);ke&&he(me.counters,fe,ke.startTime)}return he(me.counters,"visibilityHidden",P.visibilityHidden),he(me.attributes,"style",function(fe){if(fe)for(const ke of fe){const be=ke.name.split("?")[0];if(i.i(be)){const Re=be.split("/").slice(-2);if(Re.length===2)return`mapbox://styles/${Re[0]}/${Re[1]}`}}}(O)),he(me.attributes,"terrainEnabled",P.terrainEnabled?"true":"false"),he(me.attributes,"fogEnabled",P.fogEnabled?"true":"false"),he(me.attributes,"projection",P.projection),he(me.attributes,"zoom",P.zoom),he(me.metadata,"devicePixelRatio",G),he(me.metadata,"connectionEffectiveType",te),he(me.metadata,"navigatorUserAgent",navigator.userAgent),he(me.metadata,"screenWidth",window.screen.width),he(me.metadata,"screenHeight",window.screen.height),he(me.metadata,"windowWidth",window.innerWidth),he(me.metadata,"windowHeight",window.innerHeight),he(me.metadata,"mapWidth",P.width/G),he(me.metadata,"mapHeight",P.height/G),he(me.metadata,"webglRenderer",P.renderer),he(me.metadata,"webglVendor",P.vendor),he(me.metadata,"sdkVersion",d),he(me.metadata,"sdkIdentifier","mapbox-gl-js"),me}(x);for(const P of N.metadata);for(const P of N.counters);for(const P of N.attributes);this.postEvent(u,N,()=>{},j)}},st=Pe.postPerformanceEvent.bind(Pe),ue=new class extends Te{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(j,u,x,N){if(!i.e.API_URL||!i.e.SESSION_PATH)return;const P=ie(i.e.API_URL+i.e.SESSION_PATH);P.params.push(`sku=${u||""}`),P.params.push(`access_token=${N||i.e.ACCESS_TOKEN||""}`);const O={url:de(P),headers:{"Content-Type":"text/plain"}};this.pendingRequest=i.g(O,F=>{this.pendingRequest=null,x(F),this.saveEventData(),this.processRequests(N)})}getSessionAPI(j,u,x,N){this.skuToken=u,this.errorCb=N,i.e.SESSION_PATH&&i.e.API_URL&&(x||i.e.ACCESS_TOKEN?this.queueRequest({id:j,timestamp:Date.now()},x):this.errorCb(new Error(oe)))}processRequests(j){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,N=>{N?this.errorCb(N):u&&(this.success[u]=!0)},j)}remove(){this.errorCb=null}},$e=ue.getSessionAPI.bind(ue),tt=new Set;function rt(j,u){u?tt.add(j):tt.delete(j)}class je{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 it(j){const{userImage:u}=j;return!!(u&&u.render&&u.render())&&(j.data.replace(new Uint8Array(u.data.buffer)),!0)}class Se 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 N of x.values())N.hasPendingRequests()&&u.push(N);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:N,callback:P}of this.requestors)this._notify(N,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,N){this._validate(u,N)&&this.images.get(x).set(u.toString(),N)}_validate(u,x){let N=!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`))),N=!1),this._validateStretch(x.stretchY,x.data&&x.data.height)||(this.fire(new i.y(new Error(`Image "${u.name}" has invalid "stretchY" value`))),N=!1),this._validateContent(x.content,x)||(this.fire(new i.y(new Error(`Image "${u.name}" has invalid "content" value`))),N=!1),N}_validateStretch(u,x){if(!u)return!0;let N=0;for(const P of u){if(P[0]i.I.from(x))}getImages(u,x,N){const P=[],O=[],F=this.imageProviders.get(x);for(const te of u){if(!te.iconsetId){P.push(te);continue}const me=F.get(te.iconsetId);me&&(this.getImage(te,x)?O.push(te):me.addPendingRequest(te))}if(P.length===0)return void this._notify(O,x,N);let U=!0;const G=!!this.loaded.get(x),J=this.images.get(x);if(!G)for(const te of P)J.has(te.toString())||(U=!1);G||U?this._notify(P,x,N):this.requestors.push({ids:P,scope:x,callback:N})}rasterizeImages(u,x){const N=new Map,{tasks:P,scope:O}=u;for(const[F,U]of P.entries()){const G=this.getImage(U.id,O);G&&N.set(F,{image:G,imageVariant:U})}this._rasterizeImages(O,N,x)}_rasterizeImages(u,x,N){if(i.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:x,scope:u},N);else{const P=new Map;for(const[O,{image:F,imageVariant:U}]of x.entries())P.set(O,this.imageRasterizer.rasterize(U,F,u,0));N(void 0,P)}}getUpdatedImages(u){return this.updatedImages.get(u)||new Set}_notify(u,x,N){const P=this.images.get(x),O=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 G={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(G,{width:U.icon.usvg_tree.width,height:U.icon.usvg_tree.height}),O.set(i.I.toString(F),G)}N(null,O)}getPixelSize(u){const{width:x,height:N}=this.atlasImage.get(u);return{width:x,height:N}}getPattern(u,x,N){const P=u.toString(),O=this.patterns.get(x),F=O.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 G=this.getPatternInFlightId(P,x);if(this.patternsInFlight.has(G))return null;this.patternsInFlight.add(G);const J=new i.A(u).scaleSelf(i.o.devicePixelRatio),te=new Map([[J.toString(),{image:U,imageVariant:J}]]);return this._rasterizeImages(x,te,(me,he)=>this.storePatternImage(J,x,U,N,he)),null}this.storePattern(u,x,U)}return this._updatePatternAtlas(x,N),O.get(P).position}getPatternInFlightId(u,x){return i.B(u,x)}hasPatternsInFlight(){return this.patternsInFlight.size!==0}storePatternImage(u,x,N,P,O){const F=u.toString(),U=O?O.get(F):void 0;U&&(N.data=U,this.storePattern(u.id,x,N),this._updatePatternAtlas(x,P),this.patternsInFlight.delete(this.getPatternInFlightId(u.id.toString(),x)))}storePattern(u,x,N){const P={w:N.data.width+2*i.C,h:N.data.height+2*i.C,x:0,y:0},O=new i.F(P,N,i.C);this.patterns.get(x).set(u.toString(),{bin:P,position:O})}destroyAtlasTextures(){for(const u of this.atlasTexture.values())u&&u.destroy();this.atlasTexture.clear()}bind(u,x){const N=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),N.RGBA8),this.atlasTexture.set(x,P)),P.bind(N.LINEAR,N.CLAMP_TO_EDGE)}_updatePatternAtlas(u,x){const N=this.patterns.get(u),P=Array.from(N.values()).map(({bin:J})=>J),{w:O,h:F}=i.G(P),U=this.atlasImage.get(u);U.resize({width:O||1,height:F||1});const G=this.images.get(u);for(const[J,{bin:te,position:me}]of N.entries()){let he=me.padding;const fe=te.x+he,ke=te.y+he,be=G.get(J).data,Re=be.width,Oe=be.height;he=he>1?he-1:he,i.q.copy(be,U,{x:0,y:0},{x:fe,y:ke},{width:Re,height:Oe},x),i.q.copy(be,U,{x:0,y:Oe-he},{x:fe,y:ke-he},{width:Re,height:he},x),i.q.copy(be,U,{x:0,y:0},{x:fe,y:ke+Oe},{width:Re,height:he},x),i.q.copy(be,U,{x:Re-he,y:0},{x:fe-he,y:ke},{width:he,height:Oe},x),i.q.copy(be,U,{x:0,y:0},{x:fe+Re,y:ke},{width:he,height:Oe},x),i.q.copy(be,U,{x:Re-he,y:Oe-he},{x:fe-he,y:ke-he},{width:he,height:he},x),i.q.copy(be,U,{x:0,y:Oe-he},{x:fe+Re,y:ke-he},{width:he,height:he},x),i.q.copy(be,U,{x:0,y:0},{x:fe+Re,y:ke+Oe},{width:he,height:he},x),i.q.copy(be,U,{x:Re-he,y:0},{x:fe-he,y:ke+Oe},{width:he,height:he},x)}this.dirty=!0}beginFrame(){for(const u of this.images.keys())this.callbackDispatchedThisFrame.set(u,new Set)}dispatchRenderCallbacks(u,x){const N=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 O=N.get(P.toString());it(O)&&this.updateImage(P,x,O)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function et(j){const u=j.value,x=j.valueSpec,N=j.style,P=j.styleSpec,O=j.key,F=j.arrayElementValidator||un;if(!Array.isArray(u))return[new i.V(O,u,`array expected, ${i.K(u)} found`)];if(x.length&&u.length!==x.length)return[new i.V(O,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 He(j){const u=j.key,x=j.value;if(!i.H(x))return[new i.V(u,x,`object expected, ${i.K(x)} found`)];const N=j.valueSpec,P=i.J(x.type);let O,F,U,G={};const J=P!=="categorical"&&x.property===void 0,te=!J,me=function(be){const Re=be.stops;return Array.isArray(Re)&&Array.isArray(Re[0])&&i.H(Re[0][0])}(x),he=ia({key:j.key,value:j.value,valueSpec:j.styleSpec.function,style:j.style,styleSpec:j.styleSpec,objectElementValidators:{stops:function(be){if(P==="identity")return[new i.V(be.key,be.value,'identity function may not have a "stops" property')];let Re=[];const Oe=be.value;return Re=Re.concat(et({key:be.key,value:Oe,valueSpec:be.valueSpec,style:be.style,styleSpec:be.styleSpec,arrayElementValidator:fe})),Array.isArray(Oe)&&Oe.length===0&&Re.push(new i.V(be.key,Oe,"array must have at least one stop")),Re},default:function(be){return un({key:be.key,value:be.value,valueSpec:N,style:be.style,styleSpec:be.styleSpec})}}});return P==="identity"&&J&&he.push(new i.V(j.key,j.value,'missing required property "property"')),P==="identity"||x.stops||he.push(new i.V(j.key,j.value,'missing required property "stops"')),P==="exponential"&&N.expression&&!i.M(N)&&he.push(new i.V(j.key,j.value,"exponential functions not supported")),j.styleSpec.$version>=8&&(te&&!i.N(N)?he.push(new i.V(j.key,j.value,"property functions not supported")):J&&!i.O(N)&&he.push(new i.V(j.key,j.value,"zoom functions not supported"))),P!=="categorical"&&!me||x.property!==void 0||he.push(new i.V(j.key,j.value,'"property" property is required')),he;function fe(be){let Re=[];const Oe=be.value,Ge=be.key;if(!Array.isArray(Oe))return[new i.V(Ge,Oe,`array expected, ${i.K(Oe)} found`)];if(Oe.length!==2)return[new i.V(Ge,Oe,`array length 2 expected, length ${Oe.length} found`)];if(me){if(!i.H(Oe[0]))return[new i.V(Ge,Oe,`object expected, ${i.K(Oe[0])} found`)];const at=Oe[0];if(at.zoom===void 0)return[new i.V(Ge,Oe,"object stop key must have zoom")];if(at.value===void 0)return[new i.V(Ge,Oe,"object stop key must have value")];const Ke=i.J(at.zoom);if(typeof Ke!="number")return[new i.V(Ge,at.zoom,"stop zoom values must be numbers")];if(U&&U>Ke)return[new i.V(Ge,at.zoom,"stop zoom values must appear in ascending order")];Ke!==U&&(U=Ke,F=void 0,G={}),Re=Re.concat(ia({key:`${Ge}[0]`,value:Oe[0],valueSpec:{zoom:{}},style:be.style,styleSpec:be.styleSpec,objectElementValidators:{zoom:Qe,value:ke}}))}else Re=Re.concat(ke({key:`${Ge}[0]`,value:Oe[0],style:be.style,styleSpec:be.styleSpec},Oe));return i.Q(i.S(Oe[1]))?Re.concat([new i.V(`${Ge}[1]`,Oe[1],"expressions are not allowed in function stops.")]):Re.concat(un({key:`${Ge}[1]`,value:Oe[1],valueSpec:N,style:be.style,styleSpec:be.styleSpec}))}function ke(be,Re){const Oe=i.K(be.value),Ge=i.J(be.value),at=be.value!==null?be.value:Re;if(O){if(Oe!==O)return[new i.V(be.key,at,`${Oe} stop domain type must match previous stop domain type ${O}`)]}else O=Oe;if(Oe!=="number"&&Oe!=="string"&&Oe!=="boolean"&&typeof Ge!="number"&&typeof Ge!="string"&&typeof Ge!="boolean")return[new i.V(be.key,at,"stop domain value must be a number, string, or boolean")];if(Oe!=="number"&&P!=="categorical"){let Ke=`number expected, ${Oe} found`;return i.N(N)&&P===void 0&&(Ke+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(be.key,at,Ke)]}return P!=="categorical"||Oe!=="number"||typeof Ge=="number"&&isFinite(Ge)&&Math.floor(Ge)===Ge?P!=="categorical"&&Oe==="number"&&typeof Ge=="number"&&typeof F=="number"&&F!==void 0&&Genew i.V(`${j.key}${N.key}`,j.value,N.message));const x=u.value.expression||u.value._styleExpression.expression;if(j.expressionContext==="property"&&j.propertyKey==="text-font"&&!x.outputDefined())return[new i.V(j.key,j.value,`Invalid data expression for "${j.propertyKey}". Output values must be contained as literals within the expression.`)];if(j.expressionContext==="property"&&j.propertyType==="layout"&&!i.Z(x))return[new i.V(j.key,j.value,'"feature-state" data expressions are not supported with layout properties.')];if(j.expressionContext==="filter")return ut(x,j);if(j.expressionContext==="appearance")return ft(x,j);if(j.expressionContext&&j.expressionContext.indexOf("cluster")===0){if(!i.X(x,["zoom","feature-state"]))return[new i.V(j.key,j.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(j.expressionContext==="cluster-initial"&&!i.Y(x))return[new i.V(j.key,j.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ut(j,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 N=[];return j instanceof i._&&x.has(j.name)?[new i.V(u.key,u.value,`["${j.name}"] expression is not supported in a filter for a ${u.object.type} layer with id: ${u.object.id}`)]:(j.eachChild(P=>{N.push(...ut(P,u))}),N)}function ft(j,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 N=[];return j instanceof i._&&!x.has(j.name)?[new i.V(u.key,u.value,`["${j.name}"] is not an allowed parameter`)]:(j.eachChild(P=>{N.push(...ft(P,u))}),N)}function ct(j){const u=j.key,x=j.value,N=j.valueSpec,P=[];return Array.isArray(N.values)?N.values.indexOf(i.J(x))===-1&&P.push(new i.V(u,x,`expected one of [${N.values.join(", ")}], ${JSON.stringify(x)} found`)):Object.keys(N.values).indexOf(i.J(x))===-1&&P.push(new i.V(u,x,`expected one of [${Object.keys(N.values).join(", ")}], ${JSON.stringify(x)} found`)),P}function Tt(j){return i.a2(i.S(j.value))?ot(Object.assign({},j,{expressionContext:"filter",valueSpec:j.styleSpec[`filter_${j.layerType||"fill"}`]})):Ot(j)}function Ot(j){const u=j.value,x=j.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 N=j.styleSpec;let P=ct({key:`${x}[0]`,value:u[0],valueSpec:N.filter_operator});const O=()=>{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`)),O();break;case"==":case"!=":u.length!==3&&P.push(new i.V(x,u,`filter array for operator "${u[0]}" must have 3 elements`)),O();break;case"in":case"!in":O();break;case"any":case"all":case"none":for(let F=1;F{J in x&&u.push(new i.V(N,x[J],`"${J}" is prohibited for ref layers`))}),P.layers.forEach(J=>{i.J(J.id)===U&&(G=J)}),G?G.ref?u.push(new i.V(N,x.ref,"ref cannot reference another ref layer")):F=i.J(G.type):typeof U=="string"&&u.push(new i.V(N,x.ref,`ref layer "${U}" not found`))}else if(F!=="background"&&F!=="sky"&&F!=="slot")if(x.source)if(i.a0(x.source)){const G=P.sources&&P.sources[x.source],J=G&&i.J(G.type);G?J==="vector"&&F==="raster"?u.push(new i.V(N,x.source,`layer "${x.id}" requires a raster source`)):J==="raster"&&F!=="raster"?u.push(new i.V(N,x.source,`layer "${x.id}" requires a vector source`)):J!=="vector"||x["source-layer"]?J==="raster-dem"&&F!=="hillshade"?u.push(new i.V(N,x.source,"raster-dem source can only be used with layer type 'hillshade'.")):J!=="raster-array"||["raster","raster-particle"].includes(F)?F==="line"&&x.paint&&(x.paint["line-gradient"]||x.paint["line-trim-offset"])&&J==="geojson"&&!G.lineMetrics?u.push(new i.V(N,x,`layer "${x.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):F==="raster-particle"&&J!=="raster-array"&&u.push(new i.V(N,x.source,`layer "${x.id}" requires a 'raster-array' source.`)):u.push(new i.V(N,x.source,"raster-array source can only be used with layer type 'raster'.")):u.push(new i.V(N,x,`layer "${x.id}" must specify a "source-layer"`)):u.push(new i.V(N,x.source,`source "${x.source}" not found`))}else u.push(new i.V(`${N}.source`,x.source,'"source" must be a string'));else u.push(new i.V(N,x,'missing required property "source"'));return u=u.concat(ia({key:N,value:x,valueSpec:O.layer,style:j.style,styleSpec:j.styleSpec,objectElementValidators:{"*":()=>[],type:()=>un({key:`${N}.type`,value:x.type,valueSpec:O.layer.type,style:j.style,styleSpec:j.styleSpec,object:x,objectKey:"type"}),filter:G=>Tt(Object.assign({layerType:F},G)),layout:G=>ia({layer:x,key:G.key,value:G.value,valueSpec:{},style:G.style,styleSpec:G.styleSpec,objectElementValidators:{"*":J=>cr(Object.assign({layerType:F},J))}}),paint:G=>ia({layer:x,key:G.key,value:G.value,valueSpec:{},style:G.style,styleSpec:G.styleSpec,objectElementValidators:{"*":J=>Lr(Object.assign({layerType:F,layer:x},J))}}),appearances(G){const J=et({key:G.key,value:G.value,valueSpec:G.valueSpec,style:G.style,styleSpec:G.styleSpec,arrayElementValidator:he=>function(fe){const{key:ke,layer:be,layerType:Re}=fe,Oe=i.J(fe.value),Ge=i.J(Oe.name),at=i.J(Oe.condition),Ke=ia({key:ke,value:Oe,valueSpec:fe.styleSpec.appearance,style:fe.style,styleSpec:fe.styleSpec,objectElementValidators:{condition:Nt=>function(xt){const bt=[];return bt.push(...ot({key:xt.key,value:xt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),bt}(Object.assign({layer:be,layerType:Re},Nt)),properties:Nt=>function(xt){const bt=[],{styleSpec:gt,layer:ht,layerType:At}=xt,Bt=gt[`paint_${At}`],zt=gt[`layout_${At}`],Jt=xt.object[xt.objectKey];for(const er in Jt){const ur=er in Bt?"paint":er in zt?"layout":void 0;if(!ur){bt.push(new i.V(xt.key,er,`unknown property "${er}" for layer type "${At}"`));continue}const Cr=Object.assign({},xt,{key:`${xt.key}.${er}`,object:Jt,objectKey:er,layer:ht,layerType:At,value:Jt[er],valueSpec:ur==="paint"?Bt[er]:zt[er]});bt.push(...rr(Cr,ur))}return bt}(Object.assign({layer:be,layerType:Re},Nt))}});return Ge!=="hidden"&&at===void 0&&Ke.push(new i.V(fe.key,"name",'Appearance with name different than "hidden" must have a condition')),Ke}(Object.assign({layerType:F,layer:x},he))}),te=Array.isArray(G.value)?G.value:[],me=new Set;return te.forEach((he,fe)=>{const ke=i.J(he.name);if(ke)if(me.has(ke)){const be=i.J(x.id);J.push(new i.V(G.key,ke,`Duplicated appearance name "${ke}" for layer "${be}"`))}else me.add(ke)}),J}}})),u}function As({key:j,value:u}){return i.a0(u)?[]:[new i.V(j,u,`string expected, ${i.K(u)} found`)]}const Et={promoteId:function j({key:u,value:x}){if(i.a0(x))return As({key:u,value:x});if(Array.isArray(x)){const P=[],O=i.S(x),F=i.U(O);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 N=[];for(const P in x)N.push(...j({key:`${u}.${P}`,value:x[P]}));return N}};function Pt(j){const u=j.value,x=j.key,N=j.styleSpec,P=j.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 O=i.J(u.type);let F=[];switch(["vector","raster","raster-dem","raster-array"].includes(O)&&("url"in u||"tiles"in u||F.push(new i.a3(x,u,'Either "url" or "tiles" is required.'))),O){case"vector":case"raster":case"raster-dem":case"raster-array":return F=F.concat(ia({key:x,value:u,valueSpec:N[`source_${O.replace("-","_")}`],style:j.style,styleSpec:N,objectElementValidators:Et})),F;case"geojson":if(F=ia({key:x,value:u,valueSpec:N.source_geojson,style:P,styleSpec:N,objectElementValidators:Et}),"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 G=u.clusterProperties[U];if(!Array.isArray(G))return[new i.V(`${x}.clusterProperties.${U}`,G,"array expected")];const[J,te]=G,me=typeof J=="string"?[J,["accumulated"],["get",U]]:J;F.push(...ot({key:`${x}.${U}.map`,value:te,expressionContext:"cluster-map"})),F.push(...ot({key:`${x}.${U}.reduce`,value:me,expressionContext:"cluster-reduce"}))}}return F;case"video":return ia({key:x,value:u,valueSpec:N.source_video,style:P,styleSpec:N});case"image":return ia({key:x,value:u,valueSpec:N.source_image,style:P,styleSpec:N});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 ct({key:`${x}.type`,value:u.type,valueSpec:{values:Sr(N)}})}}function Sr(j){return j.source.reduce((u,x)=>{const N=j[x];return N.type.type==="enum"&&(u=u.concat(Object.keys(N.type.values||{}))),u},[])}function fs(j){const u=j.value,x=j.styleSpec,N=x.light,P=j.style;if(u===void 0)return[];if(!i.H(u))return[new i.V("light",u,`object expected, ${i.K(u)} found`)];let O=[];for(const F in u){const U=F.match(/^(.*)-transition$/),G=F.match(/^(.*)-use-theme$/);O=O.concat(G&&N[G[1]]?un({key:F,value:u[F],valueSpec:{type:"string"},style:P,styleSpec:x}):U&&N[U[1]]&&N[U[1]].transition?un({key:F,value:u[F],valueSpec:x.transition,style:P,styleSpec:x}):N[F]?un({key:F,value:u[F],valueSpec:N[F],style:P,styleSpec:x}):[new i.V(F,u[F],`unknown property "${F}"`)])}return O}function Ws(j){const u=j.value;if(!u)return[];const x=j.key;if(!i.H(u))return[new i.V(x,u,`object expected, ${i.K(u)} found`)];let N=[];const P=j.styleSpec,O=P["light-3d"],F=j.style,U=j.style.lights;for(const te of["type","id"])if(!(te in u))return N=N.concat([new i.V(x,u,`missing property "${te}"`)]),N;if(!i.a0(u.type))return N=N.concat([new i.V(`${x}.type`,u.type,"string expected")]),N;if(U)for(let te=0;te[],array:et,boolean:function(j){const u=j.value,x=j.key;return i.$(u)?[]:[new i.V(x,u,`boolean expected, ${i.K(u)} found`)]},number:Qe,color:function({key:j,value:u}){return i.a0(u)?i.a1.parseCSSColor(u)===null?[new i.V(j,u,`color expected, "${u}" found`)]:[]:[new i.V(j,u,`color expected, ${i.K(u)} found`)]},enum:ct,filter:Tt,function:He,layer:Mr,object:ia,source:Pt,model:i.a7,light:fs,"light-3d":Ws,terrain:tn,fog:xi,string:As,formatted:function(j){return As(j).length===0?[]:ot(j)},resolvedImage:function(j){return As(j).length===0?[]:ot(j)},projection:function(j){const u=j.value,x=j.styleSpec,N=x.projection,P=j.style;if(i.H(u)){let O=[];for(const F in u)O=O.concat(un({key:F,value:u[F],valueSpec:N[F],style:P,styleSpec:x}));return O}return i.a0(u)?[]:[new i.V("projection",u,`object or string expected, ${i.K(u)} found`)]},import:function(j){const u=j.key,{value:x,styleSpec:N}=j;if(!i.H(x))return[new i.V(u,x,"import must be an object")];const{data:P,...O}=x;Object.defineProperty(O,"__line__",{value:x.__line__,enumerable:!1});let F=ia(Object.assign({},j,{value:O,valueSpec:N.import}));return i.J(O.id)===""&&F.push(new i.V(`${j.key}.id`,O,"import id can't be an empty string")),P&&(F=F.concat(Wn(P,N,{key:`${j.key}.data`}))),F},iconset:function(j){const u=j.value,x=j.key,N=j.styleSpec,P=j.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 O=i.J(u.type);let F=[];if(F=F.concat(ia({key:x,value:u,valueSpec:N[`iconset_${O}`],style:P,styleSpec:N})),function(U,G){return!(U!=="source"||!G.source)}(O,u)){const U=P.sources&&P.sources[u.source],G=U&&i.J(U.type);U?G!=="raster-array"&&F.push(new i.V(x,u.source,`iconset cannot be used with a source of type ${String(G)}, 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 un(j,u=!1){const x=j.value,N=j.valueSpec,P=j.styleSpec;if(N.expression){if(i.a4(i.J(x)))return He(j);if(i.Q(i.S(x)))return ot(j)}if(N.type&&La[N.type]){const O=La[N.type](j);return u===!0&&O.length>0&&Array.isArray(j.value)?ot(j):O}return ia(Object.assign({},j,{valueSpec:N.type?P[N.type]:N}))}function ia(j){const u=j.key,x=j.value,N=j.valueSpec||{},P=j.objectElementValidators||{},O=j.style,F=j.styleSpec;if(!i.H(x))return[new i.V(u,x,`object expected, ${i.K(x)} found`)];let U=[];for(const G in x){const J=G.split(".")[0];let te;P[J]?te=P[J]:N[J]?te=un:P["*"]?te=P["*"]:N["*"]&&(te=un),te?U=U.concat(te({key:(u&&`${u}.`)+G,value:x[G],valueSpec:N[J]||N["*"],style:O,styleSpec:F,object:x,objectKey:G},x)):U.push(new i.a3(u,x[G],`unknown property "${G}"`))}for(const G in N){if(P[G])continue;const J=N[G];J.required&&J.default===void 0&&x[G]===void 0&&U.push(new i.V(u,x,`missing required property "${G}"`))}return U}function rn({key:j,value:u}){const x=As({key:j,value:u});if(x.length)return x;const N=u;return N.indexOf("{fontstack}")===-1&&x.push(new i.V(j,u,'"glyphs" url must include a "{fontstack}" token')),N.indexOf("{range}")===-1&&x.push(new i.V(j,u,'"glyphs" url must include a "{range}" token')),x}function Wn(j,u=i.a6,x={}){return ia({key:x.key||"",value:j,valueSpec:Object.assign(u.$root,{"*":{type:"*"}}),styleSpec:u,style:j,objectElementValidators:{glyphs:rn}})}function Yn(j,u=i.a6){return De(Wn(j,u))}const Pi=j=>De(Pt(j)),dr=j=>De(fs(j)),$a=j=>De(Ws(j)),xo=j=>De(tn(j)),Ei=j=>De(xi(j)),Qs=j=>De(function(u){const x=u.value,N=u.style,P=u.styleSpec,O=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 G=U.match(/^(.*)-transition$/);F=F.concat(G&&O[G[1]]&&O[G[1]].transition?un({key:U,value:x[U],valueSpec:P.transition,style:N,styleSpec:P}):O[U]?un({key:U,value:x[U],valueSpec:O[U],style:N,styleSpec:P}):[new i.a3(U,x[U],`unknown property "${U}"`)])}return F}(j)),ao=j=>De(function(u){const x=u.value,N=u.style,P=u.styleSpec,O=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 G=U.match(/^(.*)-transition$/);F=F.concat(G&&O[G[1]]&&O[G[1]].transition?un({key:U,value:x[U],valueSpec:P.transition,style:N,styleSpec:P}):O[U]?un({key:U,value:x[U],valueSpec:O[U],style:N,styleSpec:P}):[new i.a3(U,x[U],`unknown property "${U}"`)])}return F}(j)),Mc=j=>De(Mr(j)),No=j=>De(Tt(j)),Tc=j=>De(Lr(j)),nt=j=>De(cr(j)),ye=j=>De(i.a7(j));function De(j){return j.slice().sort((u,x)=>u.line&&x.line?u.line-x.line:0)}function Xe(j,u){let x=!1;if(u&&u.length)for(const N of u)N instanceof i.a3?i.w(N.message):(j.fire(new i.y(new Error(N.message))),x=!0);return x}const Ct=i.a6.light;let jt;class Dt extends i.E{constructor(u,x="flat"){super(),this._transitionable=new i.a8(jt||(jt=new i.a9({anchor:new i.aa(Ct.anchor),position:new i.ab(Ct.position),color:new i.aa(Ct.color),intensity:new i.aa(Ct.intensity)}))),this.setLight(u,x),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(u,x,N={}){this._validate(dr,u,N)||(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,N){return(!N||N.validate!==!1)&&Xe(this,u.call(Yn,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Gt=i.a6.terrain;let Ft=class extends i.E{constructor(j,u,x,N,P){super(),this.scope=x,this._transitionable=new i.a8(new i.a9({source:new i.aa(Gt.source),exaggeration:new i.aa(Gt.exaggeration)}),x,N),this._transitionable.setTransitionOrValue(j,N),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=u,this.worldview=P}get(){return this._transitionable.serialize()}set(j,u){this._transitionable.setTransitionOrValue(j,u)}updateTransitions(j){this._transitioning=this._transitionable.transitioned(j,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(j){this.properties=this._transitioning.possiblyEvaluate(j)}getExaggeration(j){return this._transitioning.possiblyEvaluate(new i.ac(j,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const j=this._transitionable._values.exaggeration;if(!j)return null;const u=j.value.expression;if(!u)return null;let x=-1,N=-1,P=1;for(const O of u.zoomStops)P=u.evaluate(new i.ac(O,{worldview:this.worldview})),P>.01?(x=O,N=-1):N=O;return P<.01&&x>0&&N>x?[x,N]:null}isZoomDependent(){const j=this._transitionable._values.exaggeration;return j!=null&&j.value!=null&&j.value.expression!=null&&j.value.expression instanceof i.ad}};const Yt=45,yr=65,hr=.05;function ss(j,u,x,N){const P=i.ah(Yt,yr,x),[O,F]=Is(j,N);let U=1-Math.min(1,Math.exp((u-O)/(F-O)*-6));return U*=U*U,U=Math.min(1,1.00747*U),U*P*j.alpha}function Is(j,u){const x=.5/Math.tan(.5*u);return[j.range[0]+x,j.range[1]+x]}function ts(j,u,x,N,P){const O=i.af([],[u,x,N],P.mercatorFogMatrix);return ss(j,i.ag(O),P.pitch,P._fov)}function yn(j,u,x,N,P,O,F){const U=[[x,N,0],[P,N,0],[P,O,0],[x,O,0]];let G=Number.MAX_VALUE,J=-Number.MAX_VALUE;for(const te of U){const me=i.af([],te,u),he=i.ag(me);G=Math.min(G,he),J=Math.max(J,he)}return[ss(j,G,F.pitch,F._fov),ss(j,J,F.pitch,F._fov)]}const vn=i.a6.fog;class hn extends i.E{constructor(u,x,N,P){super();const O=new i.a9({range:new i.aa(vn.range),color:new i.aa(vn.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(vn["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(vn["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(vn["horizon-blend"]),"star-intensity":new i.aa(vn["star-intensity"]),"vertical-range":new i.aa(vn["vertical-range"])});this._transitionable=new i.a8(O,N,new Map(P)),this.set(u,P),this._transitioning=this._transitionable.untransitioned(),this._transform=x,this.properties=new i.ai(O),this.scope=N}get state(){const u=this._transform,x=u.projection.name==="globe",N=i.aj(u.zoom),P=this.properties.get("range"),O=[.5,3];return{range:x?[i.ak(O[0],P[0],N),i.ak(O[1],P[1],N)]:P,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(u,x,N={}){if(this._validate(Ei,u,N))return;const P=Object.assign({},u);for(const O of Object.keys(vn))P[O]===void 0&&(P[O]=vn[O].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(Yt,yr,u))*x.a}getOpacityAtLatLng(u,x){return this._transform.projection.supportsFog?function(N,P,O){const F=i.ae.fromLngLat(P),U=O.elevation?O.elevation.getAtPointOrZero(F):0;return ts(N,F.x,F.y,U,O)}(this.state,u,x):0}getOpacityForTile(u){if(!this._transform.projection.supportsFog)return[1,1];const x=this._transform.calculateFogTileMatrix(u.toUnwrapped());return yn(this.state,x,0,0,i.al,i.al,this._transform)}getOpacityForBounds(u,x,N,P,O){return this._transform.projection.supportsFog?yn(this.state,u,x,N,P,O,this._transform):[1,1]}getFovAdjustedRange(u){return this._transform.projection.supportsFog?Is(this.state,u):[0,1]}isVisibleOnFrustum(u){if(!this._transform.projection.supportsFog)return!1;const x=[4,5,6,7];for(const N of x){const P=u.points[N];let O;if(P[2]>=0)O=P;else{const F=u.points[N-4];O=i.am(F,P,F[2]/(F[2]-P[2]))}if(ts(this.state,O[0],O[1],0,this._transform)>=hr)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,N){return(!N||N.validate!==!1)&&Xe(this,u.call(Yn,Object.assign({value:x,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let ra,eo,Eo,Ma,Do=class extends i.E{constructor(j,u,x,N){super();const P=ra||(ra=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(N)),this.set(j,N),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(P),this.scope=x}get state(){const j=this.properties.get("opacity"),u=this.properties.get("color"),x=this.properties.get("direction"),N=i.an(x[0]),P=-Math.max(i.an(x[1]),.01),O=[Math.cos(N)*Math.cos(P),Math.sin(N)*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*j),direction:O,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:U}}get(){return this._transitionable.serialize()}set(j,u,x={}){if(this._validate(Qs,j,x))return;const N=Object.assign({},j),P=i.a6.snow;for(const O of Object.keys(P))N[O]===void 0&&(N[O]=P[O].default);this._options=N,this._transitionable.setTransitionOrValue(this._options,u)}updateConfig(j){this._transitionable.setTransitionOrValue(this._options,new Map(j))}updateTransitions(j){this._transitioning=this._transitionable.transitioned(j,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(j){this.properties=this._transitioning.possiblyEvaluate(j)}_validate(j,u,x){return(!x||x.validate!==!1)&&Xe(this,j.call(Yn,Object.assign({value:u,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},$i=class extends i.E{constructor(j,u,x,N){super();const P=eo||(eo=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(N)),this.set(j,N),this._transitioning=this._transitionable.untransitioned(),this.properties=new i.ai(P),this.scope=x}get state(){const j=this.properties.get("opacity"),u=this.properties.get("color"),x=this.properties.get("direction"),N=i.an(x[0]),P=-Math.max(i.an(x[1]),.01),O=[Math.cos(N)*Math.cos(P),Math.sin(N)*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*j),direction:O,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(j,u,x={}){if(this._validate(ao,j,x))return;const N=Object.assign({},j),P=i.a6.rain;for(const O of Object.keys(P))N[O]===void 0&&(N[O]=P[O].default);this._options=N,this._transitionable.setTransitionOrValue(this._options,u)}updateConfig(j){this._transitionable.setTransitionOrValue(this._options,new Map(j))}updateTransitions(j){this._transitioning=this._transitionable.transitioned(j,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(j){this.properties=this._transitioning.possiblyEvaluate(j)}_validate(j,u,x){return(!x||x.validate!==!1)&&Xe(this,j.call(Yn,Object.assign({value:u,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class da extends i.E{constructor(u,x,N,P){super(),this.scope=N,this._options=u,this.properties=new i.ai(x),this._transitionable=new i.a8(x,N,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 Ui{constructor(u,x,N){this.screenBounds=u,this.cameraPoint=N.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=x,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,N)}static createFromScreenPoints(u,x){let N,P;if(u instanceof i.P||typeof u[0]=="number"){const O=i.P.convert(u);N=[O],P=x.isPointAboveHorizon(O)}else{const O=i.P.convert(u[0]),F=i.P.convert(u[1]),U=O.add(F)._div(2);N=[O,F],P=i.aq(O,F).every(G=>x.isPointAboveHorizon(G))&&x.isPointAboveHorizon(U)}return new Ui(N,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],N=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],P=i.aq(x,N,0,!1);return this.cameraPoint.y>N.y&&(this.cameraPoint.x>x.x&&this.cameraPoint.x=N.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],N=this.screenBounds.length===1?this.screenBounds[0].add(new i.P(1,1)):this.screenBounds[1],P=i.aq(x,N,u),O=this.cameraPoint.clone();switch(3*((O.y>x.y)+(O.y>N.y))+((O.x>x.x)+(O.x>N.x))){case 0:P[0]=O,P[4]=O.clone();break;case 1:P.splice(1,0,O);break;case 2:P[1]=O;break;case 3:P.splice(4,0,O);break;case 5:P.splice(2,0,O);break;case 6:P[3]=O;break;case 7:P.splice(3,0,O);break;case 8:P[2]=O}return P}containsTile(u,x,N,P=0){const O=Math.max(u.queryPadding,u.evaluateQueryRenderedFeaturePadding())/x._pixelsPerMercatorPixel+1,F=N?this._bufferedCameraMercator(O,x):this._bufferedScreenMercator(O,x);let U=u.tileID.wrap+(F.unwrapped?P:0);const G=F.polygon.map(Re=>i.as(u.tileTransform,Re,U));if(!i.at(G,0,0,i.al,i.al))return;U=u.tileID.wrap+(this.screenGeometryMercator.unwrapped?P:0);const J=this.screenGeometryMercator.polygon.map(Re=>i.au(u.tileTransform,Re,U)),te=J.map(Re=>new i.P(Re[0],Re[1])),me=x.getFreeCameraOptions().position||new i.ae(0,0,0),he=i.au(u.tileTransform,me,U),fe=J.map(Re=>{const Oe=i.av(Re,Re,he);return i.aw(Oe,Oe),new i.ax(he,Oe)}),ke=i.ay(u,1,x.zoom)*x._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:te,tilespaceRays:fe,bufferedTilespaceGeometry:G,bufferedTilespaceBounds:(be=i.az(G),be.min.x=i.aA(be.min.x,0,i.al),be.min.y=i.aA(be.min.y,0,i.al),be.max.x=i.aA(be.max.x,0,i.al),be.max.y=i.aA(be.max.y,0,i.al),be),tile:u,tileID:u.tileID,pixelToTileUnitsFactor:ke};var be}_bufferedScreenMercator(u,x){const N=Vi(u);if(this._screenRaycastCache[N])return this._screenRaycastCache[N];{let P;return P=x.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(u),x):{polygon:this.bufferedScreenGeometry(u).map(O=>x.pointCoordinate3D(O)),unwrapped:!0},this._screenRaycastCache[N]=P,P}}_bufferedCameraMercator(u,x){const N=Vi(u);if(this._cameraRaycastCache[N])return this._cameraRaycastCache[N];{let P;return P=x.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(u),x):{polygon:this.bufferedCameraGeometry(u).map(O=>x.pointCoordinate3D(O)),unwrapped:!0},this._cameraRaycastCache[N]=P,P}}_projectAndResample(u,x){const N=function(O,F){const U=i.aB([],F.pixelMatrix,F.globeMatrix),G=[0,-i.aD,0,1],J=[0,i.aD,0,1],te=[0,0,0,1];i.aC(G,G,U),i.aC(J,J,U),i.aC(te,te,U);const me=new i.P(G[0]/G[3],G[1]/G[3]),he=new i.P(J[0]/J[3],J[1]/J[3]),fe=i.aE(O,me)&&G[3]1?Ja(O.slice(0,Re),F):[],at=Renew i.P(Gn(bt.x),bt.y)),at=at.map(bt=>new i.P(Gn(bt.x),bt.y));const Ke=[...Ge];Ke.length===0&&Ke.push(at[at.length-1]);const Nt=i.ak(Ke[Ke.length-1].y,(at.length===0?Ge[0]:at[0]).y,Oe);let xt;return xt=fe?[new i.P(0,Nt),new i.P(0,0),new i.P(1,0),new i.P(1,Nt)]:[new i.P(1,Nt),new i.P(1,1),new i.P(0,1),new i.P(0,Nt)],Ke.push(...xt),at.length===0?Ke.push(Ge[0]):Ke.push(...at),{polygon:Ke.map(bt=>new i.ae(bt.x,bt.y)),unwrapped:!1}}(u,x);if(N)return N;const P=function(O,F){let U=!1,G=-1/0,J=0;for(let me=0;meG&&(G=O[me].x,J=me);for(let me=0;me.5&&(fe.x{me.x-=1}),{polygon:O,unwrapped:U}}(Ja(u,x).map(O=>new i.P(Gn(O.x),O.y)),x);return{polygon:P.polygon.map(O=>new i.ae(O.x,O.y)),unwrapped:P.unwrapped}}}function Ja(j,u){return i.aG(j,x=>{const N=u.pointCoordinate3D(x);x.x=N.x,x.y=N.y},1/256)}function Gn(j){return j<0?1+j%1:j%1}function Vi(j){return 100*j|0}function Cl(j,u,x,N,P){const O=function(U,G){if(U)return P(U);if(G){if(j.url&&G.tiles&&j.tiles&&delete j.tiles,G.variants){if(!Array.isArray(G.variants))return P(new Error("variants must be an array"));for(const te of G.variants){if(te==null||typeof te!="object"||te.constructor!==Object)return P(new Error("variant must be an object"));if(!Array.isArray(te.capabilities))return P(new Error("capabilities must be an array"));if(te.capabilities.length===1&&te.capabilities[0]==="meshopt"){G=Object.assign(G,te);break}}}const J=i.aH(Object.assign({},G,j),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);J.tiles=u.canonicalizeTileset(J,j.url),P(null,J)}},F=function(U,G,J){if(!U)return null;if(!G&&!J)return U;J=J||U.worldview_default;const te=Object.values(U.language||{});if(te.length===0)return null;const me=Object.values(U.worldview||{});if(me.length===0)return null;const he=te.every(ke=>ke===G),fe=me.every(ke=>ke===J);return he&&fe?U:G in(U.language_options||{})||J in(U.worldview_options||{})?null:U.language_options&&U.worldview_options?U:null}(j.data,x,N);return F?i.o.frame(()=>O(null,F)):j.url?i.m(u.transformRequest(u.normalizeSourceURL(j.url,null,x,N),i.R.Source),O):i.o.frame(()=>{const{data:U,...G}=j;O(null,G)})}function $l(j,u){const x=Math.pow(2,u.z),N=Math.floor(i.aF(j.getWest())*x),P=Math.floor(i.aJ(j.getNorth())*x),O=Math.ceil(i.aF(j.getEast())*x),F=Math.ceil(i.aJ(j.getSouth())*x);return u.x>=N&&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}`),N&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${N}`),this.fire(new i.y(P));else if(O){if(Object.assign(this,O),this.hasWorldviews=!!O.worldview_options,O.worldview_default&&(this.worldviewDefault=O.worldview_default),O.vector_layers){this.vectorLayers=O.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const F of O.vector_layers)this.vectorLayerIds.push(F.id),O.worldview&&O.worldview[F.source]&&this.localizableLayerIds.add(F.id)}this.tileBounds=hd.fromTileJSON(O),Me(O.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 N=u.tileID.canonical.url(this.tiles,this.scheme),P=this.map._requestManager.normalizeTileURL(N),O=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,G={request:O,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(N)&&(G.localizableLayerIds=this.localizableLayerIds),G.request.collectResourceTiming=this._collectResourceTiming,u.actor&&u.state!=="expired")u.state==="loading"?u.reloadCallback=x:u.request=u.actor.send("reloadTile",G,J.bind(this));else if(u.actor=this._tileWorkers[P]=this._tileWorkers[P]||this.dispatcher.getActor(),this.dispatcher.ready)u.request=u.actor.send("loadTile",G,J.bind(this),void 0,!0);else{const te=i.aL.call({deduped:this._deduped},G,(me,he)=>{if(me||!he)J.call(this,me);else{const fe=i.aM(he.responseHeaders);G.data={rawData:he.rawData.slice(0),expires:fe.expires,cacheControl:fe.cacheControl},u.actor&&u.actor.send("loadTile",G,J.bind(this),void 0,!0)}},!0);u.request={cancel:te}}function J(te,me){return delete u.request,u.aborted?x(null):te&&te instanceof i.aN&&te.status!==404?x(te):(me&&me.resourceTiming&&(u.resourceTiming=me.resourceTiming),this.map._refreshExpiredTiles&&me&&u.setExpiryData(me),u.loadVectorData(me,this.map.painter),i.aO(this.dispatcher),x(null,me),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 el extends i.E{constructor(u,x,N,P){super(),this.id=u,this.dispatcher=N,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=Cl(this._options,this.map._requestManager,null,x,(N,P)=>{this._tileJSONRequest=null,this._loaded=!0,N?this.fire(new i.y(N)):P&&(Object.assign(this,P),P.raster_layers&&(this.rasterLayers=P.raster_layers,this.rasterLayerIds=this.rasterLayers.map(O=>O.id)),this.tileBounds=hd.fromTileJSON(P),Me(P.tiles),this.fire(new i.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))),u&&u(N)})}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 N=i.o.devicePixelRatio>=2,P=this.map._requestManager.normalizeTileURL(u.tileID.canonical.url(this.tiles,this.scheme),N,this.tileSize);u.request=i.n(this.map._requestManager.transformRequest(P,i.R.Tile),(O,F,U)=>{if(delete u.request,u.aborted)return u.state="unloaded",x(null);if(O)return u.state="errored",x(O);if(!F)return x(null);const G=i.aM(U);this.map._refreshExpiredTiles&&u.setExpiryData(G),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 Jd([j,u],x,N,{scaled:P=!0}={}){const{tileSize:O,buffer:F}=N,{x:U,y:G,z:J}=x;if(!isFinite(U)||!isFinite(G)||!isFinite(J))throw new Error("Invalid MRT header");const te=2**J,me=te*i.aF(j),he=te*i.aJ(u);return function([fe,ke],be,{scaled:Re=!0}={}){if(!be)throw new Error("bandView is undefined");const{data:Oe,tileSize:Ge,buffer:at,offset:Ke,scale:Nt,dimension:xt}=be;if(fe<-at||fe>Ge+at||ke<-at||ke>Ge+at)throw new Error(`Point (${fe}, ${ke}) out of bounds for tileSize=${Ge}, buffer=${at}`);const bt=(ke+at)*(Ge+2*at)+(fe+at);if(new Uint32Array(Oe.buffer)[bt]===4294967295)return null;let gt=[];gt=Re?[]:new be.data.constructor(xt);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&&G){const te=i.aM(J);u.setExpiryData(te)}if(this.partial&&u.state!=="expired")u.state="empty";else if(!this.partial){if(!G)return x(null);u.state="loaded",u._isHeaderLoaded=!0,u._mrt=G}x(null)};u.request=this.partial?u.fetchHeader(void 0,F.bind(this)):u.actor.send("loadTile",O,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 N=u.texturePerLayer;if(u.flushAllQueues(),N.size){u.destroy(!1);for(const P of N.values())this.map.painter.saveTileTexture(P)}else u.destroy()}prepareTile(u,x,N,P){u._isHeaderLoaded&&(u.state!=="empty"&&(u.state="reloading"),u.fetchBandForRender(x,N,P,(O,F)=>{if(O)return u.state="errored",this.fire(new i.y(O)),void this.triggerRepaint(u);F&&(u._isHeaderLoaded=!0,u.setTexturePerLayer(N,F,this.map.painter),u.state="loaded",this.triggerRepaint(u))}))}getInitialBand(u){if(!this.rasterLayers)return 0;const x=this.rasterLayers.find(({id:O})=>O===u),N=x&&x.fields,P=N&&N.bands&&N.bands;return P?P[0]:0}getTextureDescriptor(u,x,N){if(!u)return;const P=x.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!P)return;let O=null;x instanceof i.aR?O=x.paint.get("raster-array-band"):x instanceof i.aS&&(O=x.paint.get("raster-particle-array-band"));const F=O||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)&&!N)return;const U=u.textureDescriptorPerLayer.get(x.id);return Object.assign({},U,{texture:u.texturePerLayer.get(x.id)})}getImages(u,x){const N=new Map;for(const P of u)for(const O of x){const[F,U]=O.split("/"),G=P.getLayer(F);if(!G||!G.hasBand(U)||!G.hasDataForBand(U))continue;const{bytes:J,tileSize:te,buffer:me}=G.getBandView(U),he=te+2*me,fe={data:new i.q({width:he,height:he},J),pixelRatio:2,sdf:!1,usvg:!1,version:0};N.set(O,fe)}return N}queryRasterArrayValueByBandId(u,x,N){const P=x._mrt;return new Promise(O=>{const F={},U=new Set;for(const[G,J]of Object.entries(P.layers)){if(N.layerName&&G!==N.layerName)continue;const te={};F[G]=te;for(const{bands:me}of J.dataIndex)for(const he of me)N.bands&&!N.bands.includes(he)||(U.add(i.B(G,he)),x.fetchBand(G,null,he,fe=>{i.o.frame(()=>{te[he]=fe?null:Jd([u.lng,u.lat],P,J.getBandView(he)),U.delete(i.B(G,he)),U.size===0&&O(F)})},!1))}U.size===0&&O(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 N=this.map._requestManager.normalizeTileURL(u.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),P=this.map._requestManager.transformRequest(N,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},(O,F,U)=>{if(O)return this._loadTilePending[u.uid].forEach(G=>G(O,null)),void delete this._loadTilePending[u.uid];if(!F)return this._loadTilePending[u.uid].forEach(G=>G(null,null)),void delete this._loadTilePending[u.uid];if(this.map._refreshExpiredTiles&&F){const G=i.aM(U);u.setExpiryData(G)}u._mrt=F,u._isHeaderLoaded=!0,u.state="loaded",this._loadTilePending[u.uid].forEach(G=>G(null,F)),this._loadTileLoaded[u.uid]=!0,delete this._loadTilePending[u.uid]},void 0,!0)}queryRasterArrayValueByAllBands(u,x,N){return new Promise((P,O)=>{this._loadTileForQuery(x,(F,U)=>{F?O(F):P(U?this.queryRasterArrayValueByBandId(u,x,N):null)})})}queryRasterArrayValue(u,x){const N=i.aT.convert(u),P=this.findLoadedParent(N);return P&&P._mrt?x.bands||!this.partial?this.queryRasterArrayValueByBandId(N,P,x):this.queryRasterArrayValueByAllBands(N,P,x):Promise.resolve(null)}findLoadedParent(u){const x=i.ae.fromLngLat(u,this.map.transform.tileSize),N=this.maxzoom+1,P=1<0&&(U[new i.aQ(j.overscaledZ,P,u.z,N,u.y-1).key]={backfilled:!1},U[new i.aQ(j.overscaledZ,j.wrap,u.z,u.x,u.y-1).key]={backfilled:!1},U[new i.aQ(j.overscaledZ,F,u.z,O,u.y-1).key]={backfilled:!1}),u.y+1{if(this._loaded=!0,this._pendingLoad=null,N)this.fire(new i.y(N));else{const O={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&P&&P.resourceTiming&&P.resourceTiming[this.id]&&(O.resourceTiming=P.resourceTiming[this.id]),j&&(this._partialReload=!0),this.fire(new i.z("data",O)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(j),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const j=i.B(this.id,this.scope);this.map.style.clearSource(j),this._updateWorkerData()}loadTile(j,u){const x=j.actor?"reloadTile":"loadTile";j.actor=this.actor;const N=this.map.style?this.map.style.getLut(this.scope):null,P=N?{image:N.image.clone()}:null,O=this._partialReload,F={type:this.type,uid:j.uid,tileID:j.tileID,tileZoom:j.tileZoom,zoom:j.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:j.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:O,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};j.request=this.actor.send(x,F,(U,G)=>O&&!G?(j.state="loaded",u(null)):(delete j.request,j.destroy(!1),j.aborted?u(null):U?u(U):(j.loadVectorData(G,this.map.painter,x==="reloadTile"),u(null))),void 0,x==="loadTile")}abortTile(j){j.request&&(j.request.cancel(),delete j.request),j.aborted=!0}unloadTile(j,u){this.actor.send("removeTile",{uid:j.uid,type:this.type,source:this.id,scope:this.scope}),j.destroy()}onRemove(j){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(j,u,x,N){super(j,u,x,N),this.roundZoom=!0,this.type="video",this.options=u}load(){this._loaded=!1;const j=this.options;this.urls=[];for(const u of j.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(j){if(this.video){const u=this.video.seekable;ju.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=j}}getVideo(){return this.video}onAdd(j){this.map||(this.map=j,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 j=this.map.painter.context,u=j.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(j,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(j)}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(j,u,x,N){super(),this.type="batched-model",this.id=j,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(N)}onAdd(j){this.map=j,this.load()}reload(){this.cancelTileJSONRequest();const j=i.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(j))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(j){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=Cl(this._options,this.map._requestManager,u,x,(N,P)=>{this._tileJSONRequest=null,this._loaded=!0,N?(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(N))):P&&(Object.assign(this,P),P.bounds&&(this.tileBounds=new hd(P.bounds,this.minzoom,this.maxzoom)),Me(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"}))),j&&j(N)})}hasTransition(){return!1}hasTile(j){return!this.tileBounds||this.tileBounds.contains(j.canonical)}loaded(){return this._loaded}loadTile(j,u){const x=this.map._requestManager.normalizeTileURL(j.tileID.canonical.url(this.tiles,this.scheme)),N={request:this.map._requestManager.transformRequest(x,i.R.Tile),data:void 0,uid:j.uid,tileID:j.tileID,tileZoom:j.tileZoom,zoom:j.tileID.overscaledZ,tileSize:this.tileSize*j.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:j.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:i.o.devicePixelRatio,promoteId:this.promoteId};if(j.actor&&j.state!=="expired")if(j.state==="loading")j.reloadCallback=u;else{if(j.buckets){const O=Object.values(j.buckets);for(const F of O)F.dirty=!0;return void(j.state="loaded")}j.request=j.actor.send("reloadTile",N,P.bind(this))}else j.actor=this.dispatcher.getActor(),j.request=j.actor.send("loadTile",N,P.bind(this),void 0,!0);function P(O,F){return j.aborted?u(null):O&&O.status!==404?u(O):(this.map._refreshExpiredTiles&&F&&j.setExpiryData(F),j.loadModelData(F,this.map.painter),j.state="loaded",void u(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends i.aU{constructor(j,u,x,N){super(j,u,x,N),u.coordinates?Array.isArray(u.coordinates)&&u.coordinates.length===4&&!u.coordinates.some(P=>!Array.isArray(P)||P.length!==2||P.some(O=>typeof O!="number"))||this.fire(new i.y(new i.V(`sources.${j}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.y(new i.V(`sources.${j}`,null,'missing required property "coordinates"'))),u.animate&&typeof u.animate!="boolean"&&this.fire(new i.y(new i.V(`sources.${j}`,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.${j}`,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.${j}`,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(j){this.map=j,this.load(),this.canvas&&this.animate&&this.play()}onRemove(j){this.pause()}prepare(){let j=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,j=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,j=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const u=this.map.painter.context;this.texture?!j&&!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 j of[this.canvas.width,this.canvas.height])if(isNaN(j)||j<=0)return!0;return!1}},custom:class extends i.E{constructor(j,u,x,N){super(),this.id=j,this.type="custom",this._dataType="raster",this._dispatcher=x,this._implementation=u,this.setEventedParent(N),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 hd(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(j){this.map=j,this._loaded=!1,this.fire(new i.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(j),this.load()}onRemove(j){this._implementation.onRemove&&this._implementation.onRemove(j)}hasTile(j){if(this._implementation.hasTile){const{x:u,y:x,z:N}=j.canonical;return this._implementation.hasTile({x:u,y:x,z:N})}return!this.tileBounds||this.tileBounds.contains(j.canonical)}loadTile(j,u){const{x,y:N,z:P}=j.tileID.canonical,O=new AbortController;j.request=Promise.resolve(this._implementation.loadTile({x,y:N,z:P},{signal:O.signal})).then((function(F){return delete j.request,j.aborted?(j.state="unloaded",u(null)):F===void 0?(j.state="errored",u(null)):F===null?(this.loadTileData(j,{width:this.tileSize,height:this.tileSize,data:null}),j.state="loaded",u(null)):function(U){return U instanceof ImageData||U instanceof HTMLCanvasElement||U instanceof ImageBitmap||U instanceof HTMLImageElement}(F)?(this.loadTileData(j,F),j.state="loaded",void u(null)):(j.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"&&(j.state="errored",u(F))}),j.request.cancel=()=>O.abort()}loadTileData(j,u){j.setTexture(u,this.map.painter)}unloadTile(j,u){if(j.texture&&j.texture instanceof i.T?(j.destroy(!1),j.texture&&j.texture instanceof i.T&&this.map.painter.saveTileTexture(j.texture)):j.destroy(),this._implementation.unloadTile){const{x,y:N,z:P}=j.tileID.canonical;this._implementation.unloadTile({x,y:N,z:P})}u&&u()}abortTile(j,u){j.request&&j.request.cancel&&(j.request.cancel(),delete j.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(j=>({x:j.canonical.x,y:j.canonical.y,z:j.canonical.z}))}_clearTiles(){const j=i.B(this.id,this.scope);this.map.style.clearSource(j)}_update(){this.fire(new i.z("data",{dataType:"source",sourceDataType:"content"}))}}},tl=function(j,u,x,N){const P=new Ch[u.type](j,u,x,N);if(P.id!==j)throw new Error(`Expected Source id to be ${j} instead of ${P.id}`);return i.aY(["load","abort","unload","serialize","prepare"],P),P};function ep(j,u,x=""){return`${x}:${u.id||""}:${u.layer.id}:${function(N){if("layerId"in N)return`layer:${N.layerId}`;{const{featuresetId:P,importId:O}=N;return`featureset:${P}${O?`:import:${O}`:""}`}}(j.target)}`}function _g(j,u,x,N=""){if(j.uniqueFeatureID){const P=ep(j,u,N);if(x.has(P))return!0;x.add(P)}return!1}function w0(j,u,x,N,P=!1){const O=u.sourceCache.transform,F=u.sourceCache.tilesIn(j,u.has3DLayers,P);F.sort(lm);const U=[];for(const G of F){const J=G.tile.queryRenderedFeatures(u,G,x,N,O,P);Object.keys(J).length&&U.push({wrappedTileID:G.tile.tileID.wrapped().key,queryResults:J})}for(const G in u.layers){const J=u.layers[G];if(J.styleLayer){const te=J.styleLayer.queryRenderedFeatures(j,u.sourceCache,N);Object.keys(te).length&&U.push({wrappedTileID:0,queryResults:te})}}return U.length===0?{}:function(G){const J={},te={};for(const me of G){const he=me.queryResults,fe=me.wrappedTileID,ke=te[fe]=te[fe]||{};for(const be in he){const Re=he[be],Oe=ke[be]=ke[be]||{},Ge=J[be]=J[be]||[];for(const at of Re)Oe[at.featureIndex]||(Oe[at.featureIndex]=!0,Ge.push(at))}}return J}(U)}function j0(j,u,x,N,P,O){const F={},U=N.queryRenderedSymbols(j),G=[];for(const J of Object.keys(U).map(Number))G.push(P[J]);G.sort(lm);for(const J of G){const te=J.featureIndex.lookupSymbolFeatures(U[J.bucketInstanceId],J.bucketIndex,J.sourceLayerIndex,u,x,O);for(const me in te){const he=F[me]=F[me]||[],fe=te[me];fe.sort((ke,be)=>{const Re=J.featureSortOrder;if(Re){const Oe=Re.indexOf(ke.featureIndex);return Re.indexOf(be.featureIndex)-Oe}return be.featureIndex-ke.featureIndex});for(const ke of fe)he.push(ke)}}return F}function k0(j,u){const x=j.getRenderableIds().map(O=>j.getTileByID(O)),N=[],P={};for(let O=0;Ou.getLayer(O)).filter(Boolean);if(P.length!==0){N.layers=P,N.stateDependentLayerIds&&(N.stateDependentLayers=N.stateDependentLayerIds.map(O=>P.filter(F=>F.id===O)[0]));for(const O of P)x[O.fqid]=N}}return x}const md=32,_u=33,Ec=new Uint16Array(8184);for(let j=0;j<2046;j++){let u=j+2,x=0,N=0,P=0,O=0,F=0,U=0;for(1&u?P=O=F=md:x=N=U=md;(u>>=1)>1;){const J=x+P>>1,te=N+O>>1;1&u?(P=x,O=N,x=F,N=U):(x=P,N=O,P=F,O=U),F=J,U=te}const G=4*j;Ec[G+0]=x,Ec[G+1]=N,Ec[G+2]=P,Ec[G+3]=O}const fd=new Uint16Array(2178),Zo=new Uint8Array(1089),Gu=new Uint16Array(1089);function cm(j){return j===0?-.03125:j===32?.03125:0}const eu={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 tp{constructor(u,x,N,P,O,F){this.tileID=u,this.uid=i.b2(),this.uses=0,this.tileSize=x,this.tileZoom=N,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=O,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;xN)P=!1;else if(x)if(this.expirationTimeN.appearances&&N.appearances.length>0))return!0;return!1}updateBuckets(u,x){if(!this.latestFeatureIndex||!u.style)return;const N=u.style.listImages(),P=u.style.getBrightness();for(const O in this.buckets){if(!u.style.hasLayer(O))continue;const F=this.buckets[O],U=F.layers[0],G=U.sourceLayer||"_geojsonTileLayer",J=u.style.getLayerSourceCache(U);let te={};J&&(te=J._state.getState(G,void 0));const me=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},he=Object.keys(te).length>0&&!x;F.hasAppearances=F.layers.some(be=>be.appearances&&be.appearances.length>0);const fe=he?F.stateDependentLayers:F.layers;if(he&&F.stateDependentLayers.length!==0||x){const be=this.latestFeatureIndex.loadVTLayers();F.update(te,be[G],N,me,fe,x,P)}if(he&&F.stateDependentLayers.length!==0||x||F.hasAppearances){const be={zoom:u.transform.zoom,pitch:u.transform.pitch,brightness:u.style.getBrightness()||0,worldview:u.worldview};F.updateAppearances(this.tileID.canonical,te,N,be)}(F instanceof i.ba||F instanceof i.bb)&&u._terrain&&u._terrain.enabled&&J&&F.uploadPending()&&u._terrain._clearRenderCacheForTile(J.id,this.tileID);const ke=u&&u.style&&u.style.getOwnLayer(O);ke&&(this.queryPadding=Math.max(this.queryPadding,ke.queryRadius(F)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;Re--){const Oe=4*Re,Ge=Ec[Oe+0],at=Ec[Oe+1],Ke=Ec[Oe+2],Nt=Ec[Oe+3],xt=Ge+Ke>>1,bt=at+Nt>>1,gt=xt+bt-at,ht=bt+Ge-xt,At=at*_u+Ge,Bt=Nt*_u+Ke,zt=bt*_u+xt,Jt=Math.hypot((fd[2*At+0]+fd[2*Bt+0])/2-fd[2*zt+0],(fd[2*At+1]+fd[2*Bt+1])/2-fd[2*zt+1])>=16;Zo[zt]=Zo[zt]||(Jt?1:0),Re<1022&&(Zo[zt]=Zo[zt]||Zo[(at+ht>>1)*_u+(Ge+gt>>1)]||Zo[(Nt+ht>>1)*_u+(Ke+gt>>1)])}const me=new i.b1,he=new i.b0;let fe=0;function ke(Re,Oe){const Ge=Oe*_u+Re;return Gu[Ge]===0&&(me.emplaceBack(fd[2*Ge+0],fd[2*Ge+1],Re*i.al/md,Oe*i.al/md),Gu[Ge]=++fe),Gu[Ge]-1}function be(Re,Oe,Ge,at,Ke,Nt){const xt=Re+Ge>>1,bt=Oe+at>>1;if(Math.abs(Re-Ke)+Math.abs(Oe-Nt)>1&&Zo[bt*_u+xt])be(Ke,Nt,Re,Oe,xt,bt),be(Ge,at,Ke,Nt,xt,bt);else{const gt=ke(Re,Oe),ht=ke(Ge,at),At=ke(Ke,Nt);he.emplaceBack(gt,ht,At)}}return be(0,0,md,md,md,0),be(md,md,0,0,0,md),{vertices:me,indices:he}}(this.tileID.canonical,x);P=F.vertices,O=F.indices}else{P=new i.b1,O=new i.b0;for(const{x:U,y:G}of N)P.emplaceBack(U,G,0,0);const F=i.bh(P.int16.subarray(0,4*P.length),void 0,4);for(let U=0;U0&&(G=i.bl(new Float64Array(16),x.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(u,P,x,F,G,U),this._makeGlobeTileDebugTextBuffer(u,P,x,F,G,U)}_globePoint(u,x,N,P,O,F,U){let G=i.bm(u,x,N);if(F){const J=1<.5?fe=-1:he<-.5&&(fe=1);let ke=(u/i.al+N.x)/J+fe,be=(x/i.al+N.y)/J;ke=(ke-te)*P._pixelsPerMercatorPixel+te,be=(be-me)*P._pixelsPerMercatorPixel+me;const Re=[ke*P.worldSize,be*P.worldSize,0];i.af(Re,Re,F),G=i.bn(G,Re,U)}return i.af(G,G,O)}_makeGlobeTileDebugBorderBuffer(u,x,N,P,O,F){const U=new i.bd,G=new i.be,J=new i.bo,te=(he,fe,ke,be,Re)=>{const Oe=(ke-he)/(Re-1),Ge=(be-fe)/(Re-1),at=U.length;for(let Ke=0;Keme*fe+ke;for(let fe=0;fe{if(O)x(O);else try{const G=N.getHeaderLength(F);if(G>u)return void(this.request=this.fetchHeader(G,x));N.parseHeader(F),this._isHeaderLoaded=!0;let J=0;for(const te of Object.values(N.layers))J=Math.max(J,te.dataIndex[te.dataIndex.length-1].lastByte);F.byteLength>=J&&(this.entireBuffer=F),x(null,this.entireBuffer||F,U)}catch(G){x(G)}}),this.request}fetchBandForRender(u,x,N,P){this.fetchBand(u,x,N,O=>{if(O)return void P(O);this.updateTextureDescriptor(u,x,N);const F=this.textureDescriptorPerLayer.get(x);P(null,F?F.img:null)})}fetchBand(u,x,N,P,O=!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 G;const J=i.B(String(N),i.B(this.tileID.key,u));let te=this._taskQueue.get(J);te?te.add(P):(te=new Set,te.add(P),this._taskQueue.set(J,te));const me=(be,Re)=>{G.complete(be,Re),be?P(be):(te.forEach(Oe=>Oe(null,Re)),this._taskQueue.delete(J))},he=(be,Re)=>{if(be)return P(be);const Oe=U.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:Re,task:G},me,void 0,!0);if(x!==null){const Ge=this._workQueuePerLayer.get(x)||[];Ge.push(()=>{Oe&&Oe.cancel(),G.cancel()}),this._workQueuePerLayer.has(x)||this._workQueuePerLayer.set(x,Ge)}};let fe;try{fe=F.getLayer(u)}catch(be){if(this.state==="reloading")return;throw be}if(!fe)return void P(new Error(`Unknown sourceLayer "${u}"`));if(fe.hasDataForBand(N))return te.forEach(be=>be(null,null)),void this._taskQueue.delete(J);const ke=fe.getDataRange([N]);if(G=F.createDecodingTask(ke),!G||G.tasks.length)if(x!==null&&this.flushQueues(x),this.entireBuffer)he(null,this.entireBuffer.slice(ke.firstByte,ke.lastByte+1));else{const be=Object.assign({},this.requestParams,{headers:{Range:`bytes=${ke.firstByte}-${ke.lastByte}`}}),Re=i.bu(be,he);if(x!==null){const Oe=this._fetchQueuePerLayer.get(x)||[];Oe.push(()=>{Re.cancel(),G.cancel()}),this._fetchQueuePerLayer.has(x)||this._fetchQueuePerLayer.set(x,Oe)}}}updateNeeded(u,x){return(!this.textureDescriptorPerLayer.get(u)||this.textureDescriptorPerLayer.get(u).band!==x||this.refreshedUponExpiration)&&this.state!=="errored"}updateTextureDescriptor(u,x,N){if(!this._mrt)return;const P=this._mrt.getLayer(u);if(!P||!P.hasBand(N)||!P.hasDataForBand(N))return;const{bytes:O,tileSize:F,buffer:U,offset:G,scale:J}=P.getBandView(N),te=F+2*U,me=new i.q({width:te,height:te},O),he=this.texturePerLayer.get(x);he&&he instanceof i.T&&he.update(me,{premultiply:!1}),this.textureDescriptorPerLayer.set(x,{layer:u,band:N,img:me,buffer:U,offset:G,tileSize:F,format:P.pixelFormat,mix:[J,256*J,65536*J,16777216*J]})}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 Fx{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,N){const P=u.wrapped().key;this.data[P]===void 0&&(this.data[P]=[]);const O={value:x,timeout:void 0};if(N!==void 0&&(O.timeout=setTimeout(()=>{this.remove(u,O)},N)),this.data[P].push(O),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 N=u.wrapped().key,P=x===void 0?0:this.data[N].indexOf(x),O=this.data[N][P];return this.data[N].splice(P,1),O.timeout&&clearTimeout(O.timeout),this.data[N].length===0&&delete this.data[N],this.onRemove(O.value),this.order.splice(this.order.indexOf(N),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 N in this.data)for(const P of this.data[N])u(P.value)||x.push(P);for(const N of x)this.remove(N.value.tileID,N)}}class rp{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(u,x,N){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],N),this.deletedStates[u]===null){this.deletedStates[u]={};for(const O in this.state[u])O!==P&&(this.deletedStates[u][O]=null)}else if(this.deletedStates[u]&&this.deletedStates[u][P]===null){this.deletedStates[u][P]={};for(const O in this.state[u][P])N[O]||(this.deletedStates[u][P][O]=null)}else for(const O in N)this.deletedStates[u]&&this.deletedStates[u][P]&&this.deletedStates[u][P][O]===null&&delete this.deletedStates[u][P][O]}removeFeatureState(u,x,N){if(this.deletedStates[u]===null)return;const P=String(x);if(this.deletedStates[u]=this.deletedStates[u]||{},N&&x!==void 0)this.deletedStates[u][P]!==null&&(this.deletedStates[u][P]=this.deletedStates[u][P]||{},this.deletedStates[u][P][N]=null);else if(x!==void 0)if(this.stateChanges[u]&&this.stateChanges[u][P])for(N in this.deletedStates[u][P]={},this.stateChanges[u][P])this.deletedStates[u][P][N]=null;else this.deletedStates[u][P]=null;else this.deletedStates[u]=null}getState(u,x){const N=this.state[u]||{},P=this.stateChanges[u]||{},O=this.deletedStates[u];if(O===null)return{};if(x!==void 0){const U=String(x),G=Object.assign({},N[U],P[U]);if(O){const J=O[x];if(J===null)return{};for(const te in J)delete G[te]}return G}const F=Object.assign({},N,P);if(O)for(const U in O)delete F[U];return F}initializeTileState(u,x){u.refreshFeatureState(x)}coalesceChanges(u,x){const N={};for(const P in this.stateChanges){this.state[P]=this.state[P]||{};const O={};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]),O[F]=this.state[P][F];N[P]=O}for(const P in this.deletedStates){this.state[P]=this.state[P]||{};const O={};if(this.deletedStates[P]===null)for(const F in this.state[P])O[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];O[F]=this.state[P][F]}N[P]=N[P]||{},Object.assign(N[P],O)}if(this.stateChanges={},this.deletedStates={},Object.keys(N).length!==0)for(const P in u)u[P].refreshFeatureState(x)}}class Ed extends i.E{constructor(u,x,N){super(),this.id=u,this._onlySymbols=N,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 Fx(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 rp,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 N=this._tiles[x];N.upload(u,this.map?this.map.painter:void 0),N.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(S0).map(u=>u.key)}getRenderableIds(u,x){const N=[];for(const P in this._tiles)this._isIdRenderable(+P,u,x)&&N.push(this._tiles[P]);return u?N.sort((P,O)=>{const F=P.tileID,U=O.tileID,G=new i.P(F.canonical.x,F.canonical.y)._rotate(this.transform.angle),J=new i.P(U.canonical.x,U.canonical.y)._rotate(this.transform.angle);return F.overscaledZ-U.overscaledZ||J.y-G.y||J.x-G.x}).map(P=>P.tileID.key):N.map(P=>P.tileID).sort(S0).map(P=>P.key)}hasRenderableParent(u){const x=this.findLoadedParent(u,0);return!!x&&this._isIdRenderable(x.tileID.key)}_isIdRenderable(u,x,N){return this._tiles[u]&&this._tiles[u].hasData()&&!this._coveredTiles[u]&&(x||!this._tiles[u].holdingForFade())&&(N||!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 N=this._tiles[u];N&&(N.state!=="loading"&&(N.state=x),this._loadTile(N,this._tileLoaded.bind(this,N,u,x)))}_tileLoaded(u,x,N,P,O){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(),N==="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;O&&O.responseHeaders&&(F=O.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+G)===1?F+=G:Math.abs(F-G)===1&&(F-=G)),O.dem&&P.dem&&(P.dem.backfillBorder(O.dem,F,U),P.neighboringTiles&&P.neighboringTiles[J]&&(P.neighboringTiles[J].backfilled=!0)))}}getTile(u){return this.getTileByID(u.key)}getTileByID(u){return this._tiles[u]}_retainLoadedChildren(u,x,N,P){for(const O in this._tiles){let F=this._tiles[O];if(P[O]||!F.hasData()||F.tileID.overscaledZ<=x||F.tileID.overscaledZ>N)continue;let U=F.tileID;for(;F&&F.tileID.overscaledZ>x+1;){const J=F.tileID.scaledTo(F.tileID.overscaledZ-1);F=this._tiles[J.key],F&&F.hasData()&&(U=J)}let G=U;for(;G.overscaledZ>x;)if(G=G.scaledTo(G.overscaledZ-1),u[G.key]){P[U.key]=U;break}}}findLoadedParent(u,x){if(u.key in this._loadedParentTiles){const N=this._loadedParentTiles[u.key];return N&&N.tileID.overscaledZ>=x?N:null}for(let N=u.overscaledZ-1;N>=x;N--){const P=u.scaledTo(N),O=this._getLoadedTile(P);if(O)return O}}_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 N=Math.ceil(u.width/x)+1,P=Math.ceil(u.height/x)+1,O=Math.floor(N*P*5),F=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,O):O,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 N={};for(const P in this._tiles){const O=this._tiles[P];O.tileID=O.tileID.unwrapTo(O.tileID.wrap+x),N[O.tileID.key]=O}this._tiles=N;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,N,P,O){if(this.transform=u,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!N)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,G=this._source.maxzoom;const J=this.map&&this.map.painter?this.map.painter._terrain:null;if(J&&J.sourceCache===this&&J.attenuationRange()){const he=J.attenuationRange()[0],fe=Math.floor(he)-Math.log2(J.getDemUpscale());G>fe&&(G=fe)}if(this.used||this.usedForTerrain){if(this._source.tileID)U=u.getVisibleUnwrappedCoordinates(this._source.tileID).map(he=>new i.aQ(he.canonical.z,he.wrap,he.canonical.z,he.canonical.x,he.canonical.y));else if(this.tileCoverLift!==0){const he=u.clone();he.tileCoverLift=this.tileCoverLift,U=he.coveringTiles({tileSize:x||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:G,roundZoom:this._source.roundZoom&&!N,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:G,roundZoom:this._source.roundZoom&&!N,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:F}),this._source.hasTile){const he=this._source.hasTile.bind(this._source);U=U.filter(fe=>he(fe))}}else U=[];if(U.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Xm(this._source.type)){const he=u.coveringZoomLevel({tileSize:x||this._source.tileSize,roundZoom:this._source.roundZoom&&!N}),fe=Math.min(he,this._source.maxzoom);if(F){const ke=u.extendTileCover(U,fe);for(const be of ke)U.push(be)}else if(O){const ke=u.extendTileCoverToNearPlane(U,this.transform.getFrustum(fe),fe);for(const be of ke)U.push(be)}else if(this.castsShadows&&P){const ke=u.extendTileCover(U,fe,P,16);for(const be of ke)this._shadowCasterTiles[be.key]=!0,U.push(be)}}const te=this._updateRetainedTiles(U);if(Xm(this._source.type)&&U.length!==0){const he={},fe={},ke=Object.keys(te);for(const Re of ke){const Oe=te[Re],Ge=this._tiles[Re];if(!Ge||Ge.fadeEndTime&&Ge.fadeEndTime<=i.o.now())continue;const at=this.findLoadedParent(Oe,Math.max(Oe.overscaledZ-Ed.maxOverzooming,this._source.minzoom));at&&(this._addTile(at.tileID),he[at.tileID.key]=at.tileID),fe[Re]=Oe}const be=U[U.length-1].overscaledZ;for(const Re in this._tiles){const Oe=this._tiles[Re];if(te[Re]||!Oe.hasData())continue;let Ge=Oe.tileID;for(;Ge.overscaledZ>be;){Ge=Ge.scaledTo(Ge.overscaledZ-1);const at=this._tiles[Ge.key];if(at&&at.hasData()&&fe[Ge.key]){te[Re]=Oe.tileID;break}}}for(const Re in he)te[Re]||(this._coveredTiles[Re]=!0,te[Re]=he[Re])}for(const he in te)this._tiles[he].clearFadeHold();const me=i.bv(this._tiles,te);for(const he of me){const fe=this._tiles[he];fe.hasSymbolBuckets&&!fe.holdingForFade()?fe.setHoldDuration(this.map._fadeDuration):fe.hasSymbolBuckets&&!fe.symbolFadeFinished()||this._removeTile(+he)}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 N={},P=u.reduce((J,te)=>Math.min(J,te.overscaledZ),1/0),O=u[0].overscaledZ,F=Math.max(O-Ed.maxOverzooming,this._source.minzoom),U=Math.max(O+Ed.maxUnderzooming,this._source.minzoom),G={};for(const J of u){const te=this._addTile(J);x[J.key]=J,te.hasData()||P=this._source.maxzoom){const he=J.children(this._source.maxzoom)[0],fe=this.getTile(he);if(fe&&fe.hasData()){x[he.key]=he;continue}}else{const he=J.children(this._source.maxzoom);if(x[he[0].key]&&x[he[1].key]&&x[he[2].key]&&x[he[3].key])continue}let me=te.wasRequested();for(let he=J.overscaledZ-1;he>=F;--he){const fe=J.scaledTo(he);if(N[fe.key]||(N[fe.key]=!0,te=this.getTile(fe),!te&&me&&(te=this._addTile(fe)),te&&(x[fe.key]=fe,me=te.wasRequested(),te.hasData())))break}}return x}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const u in this._tiles){const x=[];let N,P=this._tiles[u].tileID;for(;P.overscaledZ>0;){if(P.key in this._loadedParentTiles){N=this._loadedParentTiles[P.key];break}x.push(P.key);const O=P.scaledTo(P.overscaledZ-1);if(N=this._getLoadedTile(O),N)break;P=O}for(const O of x)this._loadedParentTiles[O]=N}}_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 N=!!x;if(!N){const P=this.map?this.map.painter:null,O=this._source.tileSize*u.overscaleFactor();x=this._source.type==="raster-array"?new N0(u,O,this.transform.tileZoom,P,this._isRaster):new tp(u,O,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,N||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 N=x.getExpiryTimeout();N&&(this._timers[u]=setTimeout(()=>{this._reloadTile(u,"expired"),delete this._timers[u]},N))}_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,N){const P=[],O=this.transform;if(!O)return P;const F=O.projection.name==="globe",U=i.aF(O.center.lng);for(const G in this._tiles){const J=this._tiles[G];if(N&&J.clearQueryDebugViz(),J.holdingForFade())continue;let te;if(F){const me=J.tileID.canonical;if(me.z===0){const he=[Math.abs(i.aA(U,...Ku(me,-1))-U),Math.abs(i.aA(U,...Ku(me,1))-U)];te=[0,2*he.indexOf(Math.min(...he))-1]}else{const he=[Math.abs(i.aA(U,...Ku(me,-1))-U),Math.abs(i.aA(U,...Ku(me,0))-U),Math.abs(i.aA(U,...Ku(me,1))-U)];te=[he.indexOf(Math.min(...he))-1]}}else te=[0];for(const me of te){const he=u.containsTile(J,O,x,me);he&&P.push(he)}}return P}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(u){return this._getRenderableCoordinates(u)}_getRenderableCoordinates(u,x){const N=this.getRenderableIds(u,x).map(O=>this._tiles[O].tileID),P=this.transform.projection.name==="globe";for(const O of N)O.projMatrix=this.transform.calculateProjMatrix(O.toUnwrapped()),O.expandedProjMatrix=P?this.transform.calculateProjMatrix(O.toUnwrapped(),!1,!0):O.projMatrix;return N}sortCoordinatesByDistance(u){const x=u.slice(),N=this.transform._camera.position,P=this.transform._camera.forward(),O={};for(const F of x){const U=1/(1<O[F.key]-O[U.key]),x}hasTransition(){if(this._source.hasTransition())return!0;if(Xm(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,N){this._state.updateState(u=u||"_geojsonTileLayer",x,N)}removeFeatureState(u,x,N){this._state.removeFeatureState(u=u||"_geojsonTileLayer",x,N)}getFeatureState(u,x){return this._state.getState(u=u||"_geojsonTileLayer",x)}setDependencies(u,x,N){const P=this._tiles[u];P&&P.setDependencies(x,N)}reloadTilesForDependencies(u,x){for(const N in this._tiles)this._tiles[N].hasDependency(u,x)&&this._reloadTile(+N,"reloading");this._cache.filter(N=>!N.hasDependency(u,x))}_preloadTiles(u,x){if(!this._sourceLoaded){const G=()=>{this._sourceLoaded&&(this._source.off("data",G),this._preloadTiles(u,x))};return void this._source.on("data",G)}const N=new Map,P=Array.isArray(u)?u:[u],O=this.map.painter.terrain,F=this.usedForTerrain&&O?O.getScaledDemTileSize():this._source.tileSize;for(const G of P){const J=G.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 te of J)N.set(te.key,te);this.usedForTerrain&&G.updateElevation(!1)}const U=Array.from(N.values());i.bw(U,(G,J)=>{const te=new tp(G,this._source.tileSize*G.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(te,me=>{this._source.type==="raster-dem"&&te.dem&&this._backfillDEM(te),J(me,te)})},x)}}function S0(j,u){const x=Math.abs(2*j.wrap)-+(j.wrap<0),N=Math.abs(2*u.wrap)-+(u.wrap<0);return j.overscaledZ-u.overscaledZ||N-x||u.canonical.y-j.canonical.y||u.canonical.x-j.canonical.x}function Xm(j){return j==="raster"||j==="image"||j==="video"||j==="custom"}function Ku(j,u){const x=1<0:N.type==="building"?P=!N.isHidden(u)&&N.paint.get("building-opacity")>0:N.type==="model"&&(P=!N.isHidden(u)&&N.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 O=P.layer,F=this.style.getLayerSourceCache(O);let U=1;O.type==="fill-extrusion"?U=P.visible?O.paint.get("fill-extrusion-vertical-scale"):0:O.type==="building"&&(U=P.visible?O.paint.get("building-vertical-scale"):0);let G=F?F.getTile(x):null;if(!G&&F)for(const J in F._tiles){const te=F._tiles[J];if(x.canonical.isChildOf(te.tileID.canonical)){G=te;break}}this.currentBuildingBuckets.push({bucket:G?G.getBucket(O):null,tileID:G?G.tileID:x,verticalScale:U})}u.hasAnyZOffset=!1;let N=!1;for(let P=0;P{N in u&&(x[N]=u[N])}),x}function zx(j){j=j.slice();const u=Object.create(null);for(let x=0;x0?(P-F)/U:0;return this.points[O].mult(1-G).add(this.points[x].mult(G))}}class gn{constructor(u,x,N){const P=this.boxCells=[],O=this.circleCells=[];this.xCellCount=Math.ceil(u/N),this.yCellCount=Math.ceil(x/N);for(let F=0;Fthis.width||P<0||x>this.height)return!O&&[];const U=[];if(u<=0&&x<=0&&this.width<=N&&this.height<=P){if(O)return!0;for(let G=0;G0:U}_queryCircle(u,x,N,P,O){const F=u-N,U=u+N,G=x-N,J=x+N;if(U<0||F>this.width||J<0||G>this.height)return!P&&[];const te=[];return this._forEachCell(F,G,U,J,this._queryCellCircle,te,{hitTest:P,circle:{x:u,y:x,radius:N},seenUids:{box:{},circle:{}}},O),P?te.length>0:te}query(u,x,N,P,O){return this._query(u,x,N,P,!1,O)}hitTest(u,x,N,P,O){return this._query(u,x,N,P,!0,O)}hitTestCircle(u,x,N,P){return this._queryCircle(u,x,N,!0,P)}_queryCell(u,x,N,P,O,F,U,G){const J=U.seenUids,te=this.boxCells[O];if(te!==null){const he=this.bboxes;for(const fe of te)if(!J.box[fe]){J.box[fe]=!0;const ke=4*fe;if(u<=he[ke+2]&&x<=he[ke+3]&&N>=he[ke+0]&&P>=he[ke+1]&&(!G||G(this.boxKeys[fe]))){if(U.hitTest)return F.push(!0),!0;F.push({key:this.boxKeys[fe],x1:he[ke],y1:he[ke+1],x2:he[ke+2],y2:he[ke+3]})}}}const me=this.circleCells[O];if(me!==null){const he=this.circles;for(const fe of me)if(!J.circle[fe]){J.circle[fe]=!0;const ke=3*fe;if(this._circleAndRectCollide(he[ke],he[ke+1],he[ke+2],u,x,N,P)&&(!G||G(this.circleKeys[fe]))){if(U.hitTest)return F.push(!0),!0;{const be=he[ke],Re=he[ke+1],Oe=he[ke+2];F.push({key:this.circleKeys[fe],x1:be-Oe,y1:Re-Oe,x2:be+Oe,y2:Re+Oe})}}}}}_queryCellCircle(u,x,N,P,O,F,U,G){const J=U.circle,te=U.seenUids,me=this.boxCells[O];if(me!==null){const fe=this.bboxes;for(const ke of me)if(!te.box[ke]){te.box[ke]=!0;const be=4*ke;if(this._circleAndRectCollide(J.x,J.y,J.radius,fe[be+0],fe[be+1],fe[be+2],fe[be+3])&&(!G||G(this.boxKeys[ke])))return F.push(!0),!0}}const he=this.circleCells[O];if(he!==null){const fe=this.circles;for(const ke of he)if(!te.circle[ke]){te.circle[ke]=!0;const be=3*ke;if(this._circlesCollide(fe[be],fe[be+1],fe[be+2],J.x,J.y,J.radius)&&(!G||G(this.circleKeys[ke])))return F.push(!0),!0}}}_forEachCell(u,x,N,P,O,F,U,G){const J=this._convertToXCellCoord(u),te=this._convertToYCellCoord(x),me=this._convertToXCellCoord(N),he=this._convertToYCellCoord(P);for(let fe=J;fe<=me;fe++)for(let ke=te;ke<=he;ke++)if(O.call(this,u,x,N,P,this.xCellCount*ke+fe,F,U,G))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,N,P,O,F){const U=P-u,G=O-x,J=N+F;return J*J>U*U+G*G}_circleAndRectCollide(u,x,N,P,O,F,U){const G=(F-P)/2,J=Math.abs(u-(P+G));if(J>G+N)return!1;const te=(U-O)/2,me=Math.abs(x-(O+te));if(me>te+N)return!1;if(J<=G||me<=te)return!0;const he=J-G,fe=me-te;return he*he+fe*fe<=N*N}}const ua={unknown:0,flipRequired:1,flipNotRequired:2},Kn=Math.tan(85*Math.PI/180);function Ta(j,u,x,N,P,O,F){const U=i.bC();if(x)if(O.name==="globe"){const G=i.bD(P,u);i.aB(U,U,G)}else{const G=i.bE([],F);U[0]=G[0],U[1]=G[1],U[4]=G[2],U[5]=G[3],N||i.bB(U,U,P.angle)}else i.aB(U,P.labelPlaneMatrix,j);return U}function dm(j,u,x,N,P,O,F){const U=Ta(j,u,x,N,P,O,F);return O.name==="globe"&&x||(U[2]=U[6]=U[10]=U[14]=0),U}function bu(j,u,x,N,P,O,F){if(x){if(O.name==="globe"){const U=Ta(j,u,x,N,P,O,F);return i.bl(U,U),i.aB(U,j,U),U}{const U=i.bz(j),G=i.bA([]);return G[0]=F[0],G[1]=F[1],G[4]=F[2],G[5]=F[3],i.aB(U,U,G),N||i.bB(U,U,-P.angle),U}}return P.glCoordMatrix}function Ul(j,u,x,N){const P=[j,u,x,1];x?i.aC(P,P,N):Ts(P,P,N);const O=P[3];return P[0]/=O,P[1]/=O,P[2]/=O,P}function Aa(j,u){return Math.min(.5+j/u*.5,1.5)}function PN(j,u){const x=j[0]/j[3],N=j[1]/j[3];return x>=-u[0]&&x<=u[0]&&N>=-u[1]&&N<=u[1]}function tL(j,u,x,N,P,O,F,U,G,J,te=1){const me=x.transform,he=N?j.textSizeData:j.iconSizeData,fe=i.bK(he,x.transform.zoom,te),ke=me.projection.name==="globe",be=[256/x.width*2+1,256/x.height*2+1],Re=N?j.text.dynamicLayoutVertexArray:j.icon.dynamicLayoutVertexArray;Re.clear();let Oe=null;ke&&(Oe=N?j.text.globeExtVertexArray:j.icon.globeExtVertexArray);const Ge=j.lineVertexArray,at=N?j.text.placedSymbolArray:j.icon.placedSymbolArray,Ke=x.transform.width/x.transform.height;let Nt,xt=!1;for(let bt=0;btMath.abs(x)?{useVertical:!0}:j===i.bL.vertical?N>0?{needsFlipping:!0}:null:u!==ua.unknown&&function(P,O){return P===0||Math.abs(O/P)>Kn}(x,N)?u===ua.flipRequired?{needsFlipping:!0}:null:x<0?{needsFlipping:!0}:null}function lM(j,u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re,Oe,Ge,at){const Ke=u/24,Nt=j.lineOffsetX*Ke,xt=j.lineOffsetY*Ke,{lineStartIndex:bt,glyphStartIndex:gt,numGlyphs:ht,segment:At,writingMode:Bt,flipState:zt}=j,Jt=bt+j.lineLength,er=ur=>{if(te){const[nr,Xt,gr]=ur.up,qr=J.length;i.bN(te,qr+0,nr,Xt,gr),i.bN(te,qr+1,nr,Xt,gr),i.bN(te,qr+2,nr,Xt,gr),i.bN(te,qr+3,nr,Xt,gr)}const[Cr,Kt,Lt]=ur.point;i.bO(J,Cr,Kt,Lt,ur.angle)};if(ht>1){const ur=rL(Ke,U,Nt,xt,x,me,he,j,G,O,fe,be,!1,Re,Oe,Ge,at);if(!ur)return{notEnoughRoom:!0};if(N&&!x){let[Cr,Kt,Lt]=ur.first.point,[nr,Xt,gr]=ur.last.point;[Cr,Kt]=Ul(Cr,Kt,Lt,F),[nr,Xt]=Ul(nr,Xt,gr,F);const qr=Gs(Bt,zt,(nr-Cr)*ke,Xt-Kt);if(j.flipState=qr&&qr.needsFlipping?ua.flipRequired:ua.flipNotRequired,qr)return qr}er(ur.first);for(let Cr=gt+1;Cr0?nr:Mh(he,Lt,Cr,1,P,void 0,Re,Oe.canonical),gr=Gs(Bt,zt,(Xt[0]-Cr[0])*ke,Xt[1]-Cr[1]);if(j.flipState=gr&&gr.needsFlipping?ua.flipRequired:ua.flipNotRequired,gr)return gr}const ur=M0(Ke*U.getoffsetX(gt),Nt,xt,x,me,he,At,bt,Jt,G,O,fe,be,!1,!1,Re,Oe,Ge,at);if(!ur)return{notEnoughRoom:!0};er(ur)}return{}}function y_(j,u,x,N,P){const{x:O,y:F,z:U}=N.projectTilePoint(j.x,j.y,u);if(!P)return Ul(O,F,U,x);const[G,J,te]=P.getElevation(j,P.elevation,P.elevationFeature);return Ul(O+G,F+J,U+te,x)}function Mh(j,u,x,N,P,O,F,U){const G=y_(j.sub(u)._unit()._add(j),U,P,F,O);return i.av(G,x,G),i.aw(G,G),i.bH(G,x,G,N)}function M0(j,u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re,Oe,Ge){const at=N?j-u:j+u;let Ke=at>0?1:-1,Nt=0;N&&(Ke*=-1,Nt=Math.PI),Ke<0&&(Nt+=Math.PI);let xt=U+F+(Ke>0?0:1)|0,bt=P,gt=P,ht=0,At=0;const Bt=Math.abs(at),zt=[],Jt=[];let er=O,ur=er,Cr=i.bF([]);const Kt=()=>Mh(ur,er,gt,Bt-ht+1,te,he,be,Re.canonical);for(;ht+At<=Bt;){if(xt+=Ke,xt=G)return null;if(gt=bt,ur=er,zt.push(gt),fe&&Jt.push(ur),er=new i.P(J.getx(xt),J.gety(xt)),bt=me[xt],!bt){const ps=y_(er,Re.canonical,te,be,he);bt=ps[3]>0?me[xt]=ps:Kt()}ht+=At;const Tr=i.av([],bt,gt),vs=i.bG(gt,bt);if(x&&vs>0&&At>0&&i.bJ(Cr,Tr)/(At*vs)0,at),bt=J*xt.perspectiveRatio,gt=(N.x1*x+U.x-N.padding)*bt+xt.point.x,ht=(N.y1*x+U.y-N.padding)*bt+xt.point.y,At=(N.x2*x+U.x+N.padding)*bt+xt.point.x,Bt=(N.y2*x+U.y+N.padding)*bt+xt.point.y,zt=xt.perspectiveRatio<=.55||xt.occluded;return!this.isInsideGrid(gt,ht,At,Bt)||!G&&this.grid.hitTest(gt,ht,At,Bt,me)||zt?{box:[],offscreen:!1,occluded:xt.occluded}:{box:[gt,ht,At,Bt],offscreen:this.isOffscreen(gt,ht,At,Bt),occluded:!1}}placeCollisionCircles(u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re){const Oe=[],Ge=this.transform.elevation,at=u.getProjection(),Ke=u.elevationType==="road",Nt=!!Ge||Ke,xt=i.bV.getAtTileOffsetFunc(Re,this.transform.center.lat,this.transform.worldSize,at),bt=new i.P(N.tileAnchorX,N.tileAnchorY),gt=new i.P(N.tileAnchorX,N.tileAnchorY);let{x:ht,y:At,z:Bt}=at.projectTilePoint(gt.x,gt.y,Re.canonical),zt=null;if(Nt){const vs=Ke?u.getElevationFeatureForText(P):null;zt={getElevation:xt,elevation:Ge,elevationFeature:vs};const[ps,Qr,ns]=xt(bt,Ge,vs);ht+=ps,At+=Qr,Bt+=ns}const Jt=at.name==="globe",er=this.projectAndGetPerspectiveRatio(G,ht,At,Bt,Re,Jt||!!Ge||this.transform.pitch>0,at),{perspectiveRatio:ur}=er,Cr=(he?U/ur:U*ur)/i.bY,Kt=Ul(ht,At,Bt,J),Lt=N.lineOffsetX*Cr,nr=N.lineOffsetY*Cr,Xt=i.an(u.layers[0].layout.get("text-max-angle")),gr=Math.cos(Xt),qr=er.signedDistanceFromCamera>0?rL(Cr,F,Lt,nr,Ke&&N.flipState===1,Kt,gt,N,O,J,{},Nt&&!he?zt:null,he&&Nt,at,Re,he,gr):null;let rs=!1,Or=!1,Tr=!0;if(qr&&!er.occluded){const vs=.5*ke*ur+be,ps=new i.P(-100,-100),Qr=new i.P(this.screenRightBoundary,this.screenBottomBoundary),ns=new pn,{first:Ps,last:mn}=qr,sa=Ps.path.length;let Ea=[];for(let an=sa-1;an>=1;an--)Ea.push(Ps.path[an]);for(let an=1;an(Nt&&!Jt&&(Xa=xt(qaan[3]<=0)&&(Ea=[]));let ja=[];if(Ea.length>0){let an=1/0,Oa=-1/0,Xa=1/0,qa=-1/0;for(const wa of Ea)an=Math.min(an,wa[0]),Xa=Math.min(Xa,wa[1]),Oa=Math.max(Oa,wa[0]),qa=Math.max(qa,wa[1]);Oa>=ps.x&&an<=Qr.x&&qa>=ps.y&&Xa<=Qr.y&&(ja=[Ea.map(wa=>new i.P(wa[0],wa[1]))],(anQr.x||XaQr.y)&&(ja=i.bW(ja,ps.x,ps.y,Qr.x,Qr.y)))}for(const an of ja){ns.reset(an,.25*vs);let Oa=0;Oa=ns.length<=.5*vs?1:Math.ceil(ns.paddedLength/js)+1;for(let Xa=0;Xa0?(i.aC(G,G,u),this.fogState&&O&&U.name!=="globe"&&(J=function(he,fe,ke,be,Re,Oe){const Ge=Oe.calculateFogTileMatrix(Re),at=[fe,ke,be];return i.af(at,at,Ge),ss(he,i.ag(at),Oe.pitch,Oe._fov)}(this.fogState,x,N,P,O.toUnwrapped(),this.transform)>.9)):Ts(G,G,u);const te=G[3];return{point:new i.P((G[0]/te+1)/2*this.transform.width+ha,(-G[1]/te+1)/2*this.transform.height+ha),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(U)/te*.5,1.5),signedDistanceFromCamera:te,occluded:F&&G[2]>te||J}}isOffscreen(u,x,N,P){return N=this.screenRightBoundary||Pthis.screenBottomBoundary}isInsideGrid(u,x,N,P){return N>=0&&u=0&&xN.collisionGroupID===x}}return this.collisionGroups[u]}}function Gc(j,u,x,N,P){const{horizontalAlign:O,verticalAlign:F}=i.c1(j),U=-(O-.5)*u,G=-(F-.5)*x,J=i.c2(j,N);return new i.P(U+J[0]*P,G+J[1]*P)}function Ho(j,u,x,N,P){const O=new i.P(j,u);return x&&O._rotate(N?P:-P),O}class kle{constructor(u,x,N,P,O,F){this.transform=u.clone(),this.projection=u.projection.name,this.collisionIndex=new Ya(this.transform,O),this.buildingIndex=F,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=x,this.retainedQueryData={},this.collisionGroups=new __(N),this.collisionCircleArrays={},this.prevPlacement=P,P&&(P.prevPlacement=void 0),this.placedOrientations={},this.lastReplacementSourceUpdateTime=0}getBucketParts(u,x,N,P,O=1){const F=N.getBucket(x),U=N.latestFeatureIndex;if(!F||!U||x.fqid!==F.layerIds[0])return;const G=F.layers[0].layout,J=F.layers[0].paint,te=N.collisionBoxArray,me=Math.pow(2,this.transform.zoom-N.tileID.overscaledZ),he=N.tileSize/i.al,fe=N.tileID.toUnwrapped();this.transform.setProjection(F.projection);const ke=(be=N.tileID,Re=F.getProjection(),Oe=this.transform,Re.name===this.projection?Oe.calculateProjMatrix(be.toUnwrapped()):St(Oe,Re,be));var be,Re,Oe;const Ge=G.get("text-pitch-alignment")==="map",at=G.get("text-rotation-alignment")==="map";x.compileFilter(x.options);const Ke=x.dynamicFilter(),Nt=x.dynamicFilterNeedsFeature(),xt=this.transform.calculatePixelsToTileUnitsMatrix(N),bt=dm(ke,N.tileID.canonical,Ge,at,this.transform,F.getProjection(),xt);let gt=null;const ht=F.getProjection().createInversionMatrix(this.transform,N.tileID.canonical);if(Ge){const Lt=bu(ke,N.tileID.canonical,Ge,at,this.transform,F.getProjection(),xt);gt=i.aB([],this.transform.labelPlaneMatrix,Lt)}let At=null;Ke&&N.latestFeatureIndex&&(At={unwrappedTileID:fe,dynamicFilter:Ke,dynamicFilterNeedsFeature:Nt}),this.retainedQueryData[F.bucketInstanceId]=new v_(F.bucketInstanceId,U,F.sourceLayerIndex,F.index,N.tileID);const[Bt,zt]=F.layers[0].layout.get("text-size-scale-range"),Jt=i.aA(O,Bt,zt),[er,ur]=G.get("icon-size-scale-range"),Cr=i.aA(O,er,ur),Kt={bucket:F,layout:G,paint:J,posMatrix:ke,invMatrix:ht,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:bt,labelToScreenMatrix:gt,clippingData:At,scale:me,textPixelRatio:he,holdingForFade:N.holdingForFade(),collisionBoxArray:te,partiallyEvaluatedTextSize:i.bK(F.textSizeData,this.transform.zoom,Jt),partiallyEvaluatedIconSize:i.bK(F.iconSizeData,this.transform.zoom,Cr),collisionGroup:this.collisionGroups.get(F.sourceID),latestFeatureIndex:N.latestFeatureIndex};if(P)for(const Lt of F.sortKeyRanges){const{sortKey:nr,symbolInstanceStart:Xt,symbolInstanceEnd:gr}=Lt;u.push({sortKey:nr,symbolInstanceStart:Xt,symbolInstanceEnd:gr,parameters:Kt})}else u.push({symbolInstanceStart:0,symbolInstanceEnd:F.symbolInstances.length,parameters:Kt})}attemptAnchorPlacement(u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re,Oe,Ge,at,Ke,Nt){const{textOffset0:xt,textOffset1:bt,crossTileID:gt}=be,ht=[xt,bt],At=Gc(u,F,U,ht,G),Bt=this.collisionIndex.placeCollisionBox(Oe,G,x,N,P,O,Ho(At.x,At.y,J,te,this.transform.angle),ke,me,he,fe.predicate);if(at){const zt=Oe.getSymbolInstanceIconSize(Nt,this.transform.zoom,be.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Oe,zt,at,N,P,O,Ho(At.x,At.y,J,te,this.transform.angle),ke,me,he,fe.predicate).box.length===0)return}if(Bt.box.length>0){let zt;return this.prevPlacement&&this.prevPlacement.variableOffsets[gt]&&this.prevPlacement.placements[gt]&&this.prevPlacement.placements[gt].text&&(zt=this.prevPlacement.variableOffsets[gt].anchor),this.variableOffsets[gt]={textOffset:ht,width:F,height:U,anchor:u,textScale:G,prevAnchor:zt},this.markUsedJustification(Oe,u,be,Ge),Oe.allowVerticalPlacement&&(this.markUsedOrientation(Oe,Ge,be),this.placedOrientations[gt]=Ge),{shift:At,placedGlyphBoxes:Bt}}}placeLayerBucketPart(u,x,N,P,O=1){const{bucket:F,layout:U,paint:G,posMatrix:J,textLabelPlaneMatrix:te,labelToScreenMatrix:me,clippingData:he,textPixelRatio:fe,mercatorCenter:ke,invMatrix:be,holdingForFade:Re,collisionBoxArray:Oe,partiallyEvaluatedTextSize:Ge,partiallyEvaluatedIconSize:at,collisionGroup:Ke,latestFeatureIndex:Nt}=u.parameters,xt=U.get("text-optional"),bt=U.get("icon-optional"),gt=U.get("text-allow-overlap"),ht=U.get("icon-allow-overlap"),At=U.get("text-rotation-alignment")==="map",Bt=U.get("icon-rotation-alignment")==="map",zt=U.get("text-pitch-alignment")==="map",Jt=G.get("symbol-z-offset"),er=U.get("symbol-elevation-reference")==="sea",ur=U.get("symbol-placement"),[Cr,Kt]=U.get("text-size-scale-range"),[Lt,nr]=U.get("icon-size-scale-range"),Xt=i.aA(O,Cr,Kt),gr=i.aA(O,Lt,nr),qr=U.get("text-variable-anchor"),rs=At&&ur!=="point",Or=Bt&&ur!=="point",Tr=qr&&F.hasTextData(),vs=F.hasIconTextFit()&&Tr&&F.hasIconData();this.transform.setProjection(F.projection);const ps=Tr||rs,Qr=Or||vs;let ns=gt&&(ht||!F.hasIconData()||bt),Ps=ht&&(gt||!F.hasTextData()||xt);const mn=!Jt.isConstant();!F.collisionArrays&&Oe&&F.deserializeCollisionBoxes(Oe),N&&P&&F.updateCollisionDebugBuffers(this.transform.zoom,Oe,Xt,gr);const sa=(js,ja,an)=>{const{crossTileID:Oa,numVerticalGlyphVertices:Xa}=js;let qa=null;if(he&&he.dynamicFilterNeedsFeature||mn){const fo=this.retainedQueryData[F.bucketInstanceId];qa=Nt.loadFeature({featureIndex:js.featureIndex,bucketIndex:fo.bucketIndex,sourceLayerIndex:fo.sourceLayerIndex,layoutVertexArrayOffset:0});const So=qa.properties?qa.properties.worldview:null;if(F.localizable&&F.worldview&&typeof So=="string")if(So==="all")qa.properties.$localized=!0;else{if(!So.split(",").includes(F.worldview))return;qa.properties.$localized=!0,qa.properties.worldview=F.worldview}}if(he&&!(0,he.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:F.worldview},qa,this.retainedQueryData[F.bucketInstanceId].tileID.canonical,new i.P(js.tileAnchorX,js.tileAnchorY),this.transform.calculateDistanceTileData(he.unwrappedTileID)))return this.placements[Oa]=new Ua(!1,!1,!1,!0),void x.add(Oa);const wa=Jt.evaluate(qa,{});if(x.has(Oa))return;if(Re)return void(this.placements[Oa]=new Ua(!1,!1,!1));let kn=!1,Da=!1,io=!0,Di=!1,Ra=!1,pa=null,Nn={box:null,offscreen:null,occluded:null},Si={box:null},bo=null,ro=null,oi=null,Rd=0,Ic=0,nl=0;an.textFeatureIndex?Rd=an.textFeatureIndex:js.useRuntimeCollisionCircles&&(Rd=js.featureIndex),an.verticalTextFeatureIndex&&(Ic=an.verticalTextFeatureIndex);const Zc=F.elevationFeatures?F.elevationFeatures[js.elevationFeatureIndex]:void 0,Yc=fo=>{fo.tileID=this.retainedQueryData[F.bucketInstanceId].tileID;const So=this.transform.elevation;fo.elevation=er?wa:wa+i.bV.getAtTileOffset(fo.tileID,new i.P(fo.tileAnchorX,fo.tileAnchorY),So,Zc),fo.elevation+=js.zOffset},nc=an.textBox;if(nc){Yc(nc);const fo=li=>{let Oo=i.bL.horizontal;if(F.allowVerticalPlacement&&!li&&this.prevPlacement){const oo=this.prevPlacement.placedOrientations[Oa];oo&&(this.placedOrientations[Oa]=oo,Oo=oo,this.markUsedOrientation(F,Oo,js))}return Oo},So=(li,Oo)=>{if(F.allowVerticalPlacement&&Xa>0&&an.verticalTextBox){for(const oo of F.writingModes)if(oo===i.bL.vertical?(Nn=Oo(),Si=Nn):Nn=li(),Nn&&Nn.box&&Nn.box.length)break}else Nn=li()};if(qr){let li=qr;if(this.prevPlacement&&this.prevPlacement.variableOffsets[Oa]){const so=this.prevPlacement.variableOffsets[Oa];li.indexOf(so.anchor)>0&&(li=li.filter(Oh=>Oh!==so.anchor),li.unshift(so.anchor))}const Oo=(so,Oh,K_)=>{const xm=F.getSymbolInstanceTextSize(Ge,js,this.transform.zoom,ja),Z_=(so.x2-so.x1)*xm+2*so.padding,Q0=(so.y2-so.y1)*xm+2*so.padding,cf=js.hasIconTextFit&&!ht?Oh:null;cf&&Yc(cf);let gp={box:[],offscreen:!1,occluded:!1};const J0=gt?2*li.length:li.length;for(let Rg=0;Rg=li.length,js,ja,F,K_,cf,Ge,at);if(xp&&(gp=xp.placedGlyphBoxes,gp&&gp.box&&gp.box.length)){kn=!0,pa=xp.shift;break}}return gp};So(()=>Oo(nc,an.iconBox,i.bL.horizontal),()=>{const so=an.verticalTextBox;return so&&Yc(so),F.allowVerticalPlacement&&!(Nn&&Nn.box&&Nn.box.length)&&Xa>0&&so?Oo(so,an.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Nn&&(kn=Nn.box,io=Nn.offscreen,Di=Nn.occluded);const oo=fo(!(!Nn||!Nn.box));if(!kn&&this.prevPlacement){const so=this.prevPlacement.variableOffsets[Oa];so&&(this.variableOffsets[Oa]=so,this.markUsedJustification(F,so.anchor,js,oo))}}else{const li=(Oo,oo)=>{const so=F.getSymbolInstanceTextSize(Ge,js,this.transform.zoom,ja),Oh=this.collisionIndex.placeCollisionBox(F,so,Oo,ke,be,ps,new i.P(0,0),gt,fe,J,Ke.predicate);return Oh&&Oh.box&&Oh.box.length&&(this.markUsedOrientation(F,oo,js),this.placedOrientations[Oa]=oo),Oh};So(()=>li(nc,i.bL.horizontal),()=>{const Oo=an.verticalTextBox;return F.allowVerticalPlacement&&Xa>0&&Oo?(Yc(Oo),li(Oo,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),fo(!!(Nn&&Nn.box&&Nn.box.length))}}if(bo=Nn,kn=bo&&bo.box&&bo.box.length>0,io=bo&&bo.offscreen,Di=bo&&bo.occluded,js.useRuntimeCollisionCircles){const fo=js.centerJustifiedTextSymbolIndex>=0?js.centerJustifiedTextSymbolIndex:js.verticalPlacedTextSymbolIndex,So=F.text.placedSymbolArray.get(fo),li=i.bM(F.textSizeData,Ge,So),Oo=U.get("text-padding");ro=this.collisionIndex.placeCollisionCircles(F,gt,So,fo,F.lineVertexArray,F.glyphOffsetArray,li,J,te,me,N,zt,Ke.predicate,js.collisionCircleDiameter*li/i.bY,Oo,this.retainedQueryData[F.bucketInstanceId].tileID),kn=gt||ro.circles.length>0&&!ro.collisionDetected,io=io&&ro.offscreen,Di=ro.occluded}if(an.iconFeatureIndex&&(nl=an.iconFeatureIndex),an.iconBox){const fo=So=>{Yc(So);const li=js.hasIconTextFit&&pa?Ho(pa.x,pa.y,At,zt,this.transform.angle):new i.P(0,0),Oo=F.getSymbolInstanceIconSize(at,this.transform.zoom,js.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(F,Oo,So,ke,be,Qr,li,ht,fe,J,Ke.predicate)};Si&&Si.box&&Si.box.length&&an.verticalIconBox?(oi=fo(an.verticalIconBox),Da=oi.box.length>0):(oi=fo(an.iconBox),Da=oi.box.length>0),io=io&&oi.offscreen,Ra=oi.occluded}const Ju=xt||js.numHorizontalGlyphVertices===0&&Xa===0,Dh=bt||js.numIconVertices===0;if(Ju||Dh?Dh?Ju||(Da=Da&&kn):kn=Da&&kn:Da=kn=Da&&kn,kn&&bo&&bo.box&&this.collisionIndex.insertCollisionBox(bo.box,U.get("text-ignore-placement"),F.bucketInstanceId,Si&&Si.box&&Ic?Ic:Rd,Ke.ID),Da&&oi&&this.collisionIndex.insertCollisionBox(oi.box,U.get("icon-ignore-placement"),F.bucketInstanceId,nl,Ke.ID),ro&&(kn&&this.collisionIndex.insertCollisionCircles(ro.circles,U.get("text-ignore-placement"),F.bucketInstanceId,Rd,Ke.ID),N)){const fo=F.bucketInstanceId;let So=this.collisionCircleArrays[fo];So===void 0&&(So=this.collisionCircleArrays[fo]=new LN);for(let li=0;li=0;--ja){const an=js[ja];sa(F.symbolInstances.get(an),an,F.collisionArrays[an])}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 js=F.getSortedIndexesByZOffset();for(let ja=0;ja=0&&(u.text.placedSymbolArray.get(O).crossTileID=me>=0&&O!==me?0:J),F>=0&&(u.text.placedSymbolArray.get(F).crossTileID=me>=0&&F!==me?0:J),U>=0&&(u.text.placedSymbolArray.get(U).crossTileID=me>=0&&U!==me?0:J),G>=0&&(u.text.placedSymbolArray.get(G).crossTileID=me>=0&&G!==me?0:J)}markUsedOrientation(u,x,N){const P=x===i.bL.horizontal||x===i.bL.horizontalOnly?x:0,O=x===i.bL.vertical?x:0,{leftJustifiedTextSymbolIndex:F,centerJustifiedTextSymbolIndex:U,rightJustifiedTextSymbolIndex:G,verticalPlacedTextSymbolIndex:J}=N,te=u.text.placedSymbolArray;F>=0&&(te.get(F).placedOrientation=P),U>=0&&(te.get(U).placedOrientation=P),G>=0&&(te.get(G).placedOrientation=P),J>=0&&(te.get(J).placedOrientation=O)}commit(u){this.commitTime=u,this.zoomAtLastRecencyCheck=this.transform.zoom;const x=this.prevPlacement;let N=!1;this.prevZoomAdjustment=x?x.zoomAdjustment(this.transform.zoom):0;const P=x?x.symbolFadeChange(u):1,O=x?x.opacities:{},F=x?x.variableOffsets:{},U=x?x.placedOrientations:{};for(const G in this.placements){const J=this.placements[G],te=O[G];te?(this.opacities[G]=new Jm(te,P,J.text,J.icon,null,J.clipped),N=N||J.text!==te.text.placed||J.icon!==te.icon.placed):(this.opacities[G]=new Jm(null,P,J.text,J.icon,J.skipFade,J.clipped),N=N||J.text||J.icon)}for(const G in O){const J=O[G];if(!this.opacities[G]){const te=new Jm(J,P,!1,!1);te.isHidden()||(this.opacities[G]=te,N=N||J.text.placed||J.icon.placed)}}for(const G in F)this.variableOffsets[G]||!this.opacities[G]||this.opacities[G].isHidden()||(this.variableOffsets[G]=F[G]);for(const G in U)this.placedOrientations[G]||!this.opacities[G]||this.opacities[G].isHidden()||(this.placedOrientations[G]=U[G]);N?this.lastPlacementChangeTime=u:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=x?x.lastPlacementChangeTime:u)}updateLayerOpacities(u,x,N,P){P&&(this.lastReplacementSourceUpdateTime=P.updateTime);const O=new Set;for(const F of x){const U=F.getBucket(u);U&&F.latestFeatureIndex&&u.fqid===U.layerIds[0]&&(this.updateBucketOpacities(U,O,F,F.collisionBoxArray,N,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,N,P,O,F,U,G){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 J=u.layers[0].layout,te=u.layers[0].paint,me=!!u.layers[0].dynamicFilter(),he=new Jm(null,0,!1,!1,!0),fe=J.get("text-allow-overlap"),ke=J.get("icon-allow-overlap"),be=J.get("text-variable-anchor"),Re=J.get("text-rotation-alignment")==="map",Oe=J.get("text-pitch-alignment")==="map",Ge=te.get("symbol-z-offset"),at=J.get("symbol-elevation-reference")==="sea",Ke=!Ge.isConstant(),Nt=new Jm(null,0,fe&&(ke||!u.hasIconData()||J.get("icon-optional")),ke&&(fe||!u.hasTextData()||J.get("text-optional")),!0);!u.collisionArrays&&P&&(u.hasIconCollisionBoxData()||u.hasTextCollisionBoxData())&&u.deserializeCollisionBoxes(P);const xt=(gt,ht,At)=>{for(let Bt=0;Bt0||Bt>0,qr=Jt>0,rs=this.placedOrientations[zt],Or=rs===i.bL.vertical,Tr=rs===i.bL.horizontal||rs===i.bL.horizontalOnly;!gr&&!qr||Xt.isHidden()||bt++;let vs=!1;if((gr||qr)&&F)for(const ps of u.activeReplacements){if(i.bZ(ps,O,i.b_.Symbol,G)||ps.min.x>er||er>ps.max.x||ps.min.y>ur||ur>ps.max.y)continue;const Qr=i.b$(er,ur,U.canonical,ps.footprintTileId.canonical);if(vs=i.c0(Qr,ps.footprint),vs)break}if(gr){const ps=vs?$x:Pd(Xt.text);xt(u.text,At,Or?$x:ps),xt(u.text,Bt,Tr?$x:ps);const Qr=Xt.text.isHidden(),{leftJustifiedTextSymbolIndex:ns,centerJustifiedTextSymbolIndex:Ps,rightJustifiedTextSymbolIndex:mn,verticalPlacedTextSymbolIndex:sa}=ht,Ea=u.text.placedSymbolArray,js=Qr||Or?1:0;ns>=0&&(Ea.get(ns).hidden=js),Ps>=0&&(Ea.get(Ps).hidden=js),mn>=0&&(Ea.get(mn).hidden=js),sa>=0&&(Ea.get(sa).hidden=Qr||Tr?1:0);const ja=this.variableOffsets[zt];ja&&this.markUsedJustification(u,ja.anchor,ht,rs);const an=this.placedOrientations[zt];an&&(this.markUsedJustification(u,"left",ht,an),this.markUsedOrientation(u,an,ht))}if(qr){const ps=vs?$x:Pd(Xt.icon),{placedIconSymbolIndex:Qr,verticalPlacedIconSymbolIndex:ns}=ht,Ps=u.icon.placedSymbolArray,mn=Xt.icon.isHidden()?1:0;Qr>=0&&(xt(u.icon,Jt,Or?$x:ps),Ps.get(Qr).hidden=mn),ns>=0&&(xt(u.icon,ht.numVerticalIconVertices,Tr?$x:ps),Ps.get(ns).hidden=mn)}if(u.hasIconCollisionBoxData()||u.hasTextCollisionBoxData()){const ps=u.collisionArrays[gt];if(ps){let Qr=new i.P(0,0),ns=!0;if(ps.textBox||ps.verticalTextBox){if(be){const mn=this.variableOffsets[zt];mn?(Qr=Gc(mn.anchor,mn.width,mn.height,mn.textOffset,mn.textScale),Re&&Qr._rotate(Oe?this.transform.angle:-this.transform.angle)):ns=!1}me&&(ns=!Xt.clipped),ps.textBox&&wg(u.textCollisionBox.collisionVertexArray,Xt.text.placed,!ns||Or,Lt,at,Qr.x,Qr.y),ps.verticalTextBox&&wg(u.textCollisionBox.collisionVertexArray,Xt.text.placed,!ns||Tr,Lt,at,Qr.x,Qr.y)}const Ps=ns&&!!(!Tr&&ps.verticalIconBox);ps.iconBox&&wg(u.iconCollisionBox.collisionVertexArray,Xt.icon.placed,Ps,Lt,at,ht.hasIconTextFit?Qr.x:0,ht.hasIconTextFit?Qr.y:0),ps.verticalIconBox&&wg(u.iconCollisionBox.collisionVertexArray,Xt.icon.placed,!Ps,Lt,at,ht.hasIconTextFit?Qr.x:0,ht.hasIconTextFit?Qr.y:0)}}}if(u.fullyClipped=bt===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 gt=this.collisionCircleArrays[u.bucketInstanceId];u.placementInvProjMatrix=gt.invProjMatrix,u.placementViewportMatrix=gt.viewportMatrix,u.collisionCircleArray=gt.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 wg(j,u,x,N,P,O,F){j.emplaceBack(u?1:0,x?1:0,O||0,F||0,N,P?1:0),j.emplaceBack(u?1:0,x?1:0,O||0,F||0,N,P?1:0),j.emplaceBack(u?1:0,x?1:0,O||0,F||0,N,P?1:0),j.emplaceBack(u?1:0,x?1:0,O||0,F||0,N,P?1:0)}const cM=Math.pow(2,25),b_=Math.pow(2,24),DN=Math.pow(2,17),dM=Math.pow(2,16),ON=Math.pow(2,9),Id=Math.pow(2,8),sp=Math.pow(2,1);function Pd(j){if(j.opacity===0&&!j.placed)return 0;if(j.opacity===1&&j.placed)return 4294967295;const u=j.placed?1:0,x=Math.floor(127*j.opacity);return x*cM+u*b_+x*DN+u*dM+x*ON+u*Id+x*sp+u}const $x=0;class T0{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,N,P,O,F){const U=this._bucketParts;for(;this._currentTileIndexG.sortKey-J.sortKey));this._currentPartIndex{const G=i.o.now()-F;return!this._forceFullPlacement&&G>2};for(;this._currentPlacementIndex>=0;){const G=x[u[this._currentPlacementIndex]],J=this.placement.collisionIndex.transform.zoom;if(G.type==="symbol"&&G.visibility!=="none"&&(!G.minzoom||G.minzoom<=J)&&(!G.maxzoom||G.maxzoom>J)){const te=G,me=te.layout.get("symbol-z-elevate"),he=te.layout.get("symbol-sort-key").constantOr(1)!==void 0,fe=te.layout.get("symbol-z-order"),ke=fe==="viewport-y"||fe==="auto"&&!(fe!=="viewport-y"&&he),be=te.layout.get("text-allow-overlap")||te.layout.get("icon-allow-overlap")||te.layout.get("text-ignore-placement")||te.layout.get("icon-ignore-placement"),Re=ke&&be,Oe=this._inProgressLayer=this._inProgressLayer||new T0(te),Ge=i.B(G.source,G.scope);if(Oe.continuePlacement(me||Re?P[Ge]:N[Ge],this.placement,this._showCollisionBoxes,G,U,O))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(u){return this.placement.commit(u),this.placement}}const Th=512/i.al/2;class np{constructor(u,x,N){this.tileID=u,this.bucketInstanceId=N,this.index=new i.c4(x.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const P=u.canonical.x*i.al,O=u.canonical.y*i.al;for(let F=0;FRe-Oe);for(const Re of be){const Oe=this.crossTileIDs[Re];if(this.keys[Re]===te&&!N.has(Oe)){N.add(Oe),J.crossTileID=Oe;break}}}}}class gl{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class uM{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(u){const x=Math.round((u-this.lng)/360);if(x!==0)for(const N in this.indexes){const P=this.indexes[N],O={};for(const F in P){const U=P[F];U.tileID=U.tileID.unwrapTo(U.tileID.wrap+x),O[U.tileID.key]=U}this.indexes[N]=O}this.lng=u}addBucket(u,x,N){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 O=0;Ou.overscaledZ)for(const U in F){const G=F[U];G.tileID.isChildOf(u)&&G.findMatches(x.symbolInstances,u,P)}else{const U=F[u.scaledTo(Number(O)).key];U&&U.findMatches(x.symbolInstances,u,P)}}for(let O=0;O{x[N]=!0});for(const N in this.layerIndexes)x[N]||delete this.layerIndexes[N]}}const ef=771;class wn{constructor(u,x,N,P){this.blendFunction=u,this.blendColor=x.toNonPremultipliedRenderColor(null),this.mask=N,this.blendEquation=P}}wn.Replace=[1,0,1,0],wn.disabled=new wn(wn.Replace,i.ao.transparent,[!1,!1,!1,!1]),wn.unblended=new wn(wn.Replace,i.ao.transparent,[!0,!0,!0,!0]),wn.alphaBlended=new wn([1,ef,1,ef],i.ao.transparent,[!0,!0,!0,!0]),wn.alphaBlendedNonPremultiplied=new wn([770,ef,770,ef],i.ao.transparent,[!0,!0,!0,!0]),wn.multiply=new wn([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),wn.additive=new wn([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class ks{constructor(u,x,N){this.func=u,this.mask=x,this.range=N}}ks.ReadOnly=!1,ks.ReadWrite=!0,ks.disabled=new ks(519,ks.ReadOnly,[0,1]);const RN=7680;class Js{constructor(u,x,N,P,O,F){this.test=u,this.ref=x,this.mask=N,this.fail=P,this.depthFail=O,this.pass=F}}Js.disabled=new Js({func:519,mask:0},0,0,RN,RN,RN);const A0=1029,FN=2305;class Ys{constructor(u,x,N){this.enable=u,this.mode=x,this.frontFace=N}}function tf(j,u){const x=i.ca(j,3);i.cc(j,u),i.cg(j,3,x)}function hM(j,u){const x=i.c7([]);return i.c8(x,x,-u),i.c9(x,x,-j),x}function zN(j,u){const x=[j[0],j[1],0],N=[u[0],u[1],0];if(i.ag(x)>=1e-15){const F=i.aw([],x);i.c5(N,F,i.bJ(N,F)),u[0]=N[0],u[1]=N[1]}const P=i.bI([],u,j);if(i.c6(P)<1e-15)return null;const O=Math.atan2(-P[1],P[0]);return hM(Math.atan2(Math.sqrt(j[0]*j[0]+j[1]*j[1]),-j[2]),O)}Ys.disabled=new Ys(!1,A0,FN),Ys.backCCW=new Ys(!0,A0,FN),Ys.backCW=new Ys(!0,A0,2304),Ys.frontCW=new Ys(!0,1028,2304),Ys.frontCCW=new Ys(!0,1028,FN);class Ld{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,N){if(this.orientation=null,!this.position)return;const P=this.position,O=N||(this._elevation?this._elevation.getAtPointOrZero(i.ae.fromLngLat(u)):0),F=i.ae.fromLngLat(u,O),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=zN(U,x)}setPitchBearing(u,x){this.orientation=hM(i.an(u),i.an(-x))}}class BN{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&&tf(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=hM(u,x),tf(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 N=new Float64Array(16);return i.bl(N,this.getWorldToCamera(u,x)),N}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(u,x,N){const P=this.position;i.c5(P,P,-u);const O=new Float64Array(16);return i.bq(O,[N,N,N]),i.br(O,O,P),O[10]*=x,O}getWorldToCamera(u,x){const N=new Float64Array(16),P=new Float64Array(4),O=this.position;return i.cb(P,this._orientation),i.c5(O,O,-u),i.cc(N,P),i.br(N,N,O),N[1]*=-1,N[5]*=-1,N[9]*=-1,N[13]*=-1,N[8]*=x,N[9]*=x,N[10]*=x,N[11]*=x,N}getCameraToClipPerspective(u,x,N,P){const O=new Float64Array(16);return i.cd(O,u,x,N,P),O}getCameraToClipOrthographic(u,x,N,P,O,F){const U=new Float64Array(16);return i.ce(U,u,x,N,P,O,F),U}getDistanceToElevation(u,x=!1){const N=u===0?0:i.cf(u,x?i.a$(this.position[1]):this.position[1]),P=this.forward();return(N-this.position[2])/P[2]}clone(){return new BN([...this.position],[...this.orientation])}}const Vl={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class $N{constructor(u=0,x=0,N=0,P=0){if(isNaN(u)||u<0||isNaN(x)||x<0||isNaN(N)||N<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=N,this.right=P}interpolate(u,x,N){return x.top!=null&&u.top!=null&&(this.top=i.ak(u.top,x.top,N)),x.bottom!=null&&u.bottom!=null&&(this.bottom=i.ak(u.bottom,x.bottom,N)),x.left!=null&&u.left!=null&&(this.left=i.ak(u.left,x.left,N)),x.right!=null&&u.right!=null&&(this.right=i.ak(u.right,x.right,N)),this}getCenter(u,x){const N=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(N,P)}equals(u){return this.top===u.top&&this.bottom===u.bottom&&this.left===u.left&&this.right===u.right}clone(){return new $N(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const mm=15;class mM{constructor(u,x,N,P,O,F,U){this.tileSize=512,this._renderWorldCopies=O===void 0||O,this._minZoom=u||0,this._maxZoom=x||22,this._minPitch=N??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 $N,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new BN,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 mM(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 N=this._elevation;x||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&N.exaggeration()&&this._centerAltitudeValidForExaggeration!==N.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*N.exaggeration(),this._centerAltitudeValidForExaggeration=N.exaggeration()):(this._centerAltitude=u||0,this._centerAltitudeValidForExaggeration=N.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]],N=this.horizonLineFromTop();let P=0,O=0;for(let F=0;F{const Re=i.cY(he,me,fe,ke,be);G.has(Re)||(O.push(new i.aQ(me,he,fe,ke,be)),G.add(Re))};for(let me=0;mehe.canonical.z)continue;const fe=he.canonical,ke=he.overscaledZ,be=he.wrap,Re=1<0,at=fe.y+10,Nt=he.wrap-(Ge?0:1),xt=he.wrap+(Oe?0:1),bt=Ge?fe.x-1:Re-1,gt=Oe?fe.x+1:0;if(F)N[0]<0?(J(ke,xt,fe.z,gt,fe.y),N[1]<0&&at&&(J(ke,be,fe.z,fe.x,fe.y+1),J(ke,xt,fe.z,gt,fe.y+1)),N[1]>0&&Ke&&(J(ke,be,fe.z,fe.x,fe.y-1),J(ke,xt,fe.z,gt,fe.y-1))):N[0]>0?(J(ke,Nt,fe.z,bt,fe.y),N[1]<0&&at&&(J(ke,be,fe.z,fe.x,fe.y+1),J(ke,Nt,fe.z,bt,fe.y+1)),N[1]>0&&Ke&&(J(ke,be,fe.z,fe.x,fe.y-1),J(ke,Nt,fe.z,bt,fe.y-1))):N[1]<0&&at?J(ke,be,fe.z,fe.x,fe.y+1):Ke&&J(ke,be,fe.z,fe.x,fe.y-1);else{const ht=he.visibleQuadrants;1&ht&&(J(ke,Nt,fe.z,bt,fe.y),Ke&&(J(ke,be,fe.z,fe.x,fe.y-1),J(ke,Nt,fe.z,bt,fe.y-1))),2&ht&&(J(ke,xt,fe.z,gt,fe.y),Ke&&(J(ke,be,fe.z,fe.x,fe.y-1),J(ke,xt,fe.z,gt,fe.y-1))),4&ht&&(J(ke,Nt,fe.z,bt,fe.y),at&&(J(ke,be,fe.z,fe.x,fe.y+1),J(ke,Nt,fe.z,bt,fe.y+1))),8&ht&&(J(ke,xt,fe.z,gt,fe.y),at&&(J(ke,be,fe.z,fe.x,fe.y+1),J(ke,xt,fe.z,gt,fe.y+1)))}}const te=[];for(const me of O)O.some(he=>me.isChildOf(he))||te.push(me);if(O=te.filter(me=>!u.some(he=>!!(me.overscaledZ{const Oe=Re.canonical.x+.5-fe[0],Ge=Re.canonical.y+.5-fe[1];return Oe*Oe+Ge*Ge{const bt=i.cY(at,Ge,Ke,Nt,xt);O.has(bt)||(P.push(new i.aQ(Ge,at,Ke,Nt,xt)),O.add(bt))},U=u.reduce((Ge,at)=>Math.max(Ge,at.overscaledZ),N),G=1<{const Ke=Math.floor(Ge[0]),Nt=Math.floor(Ge[1]),xt=(Ge[0]-Ke)*i.al,bt=(Ge[1]-Nt)*i.al,gt=Math.floor(at[0]),ht=Math.floor(at[1]),At=(at[0]-gt)*i.al,Bt=(at[1]-ht)*i.al;for(let zt=-1;zt<=1;zt++){const Jt=Ke+zt;if(!(Jt<0||Jt>=G)){te.x=xt-zt*i.al,me.x=At-(Jt-gt)*i.al;for(let er=-1;er<=1;er++){const ur=Nt+er;te.y=bt-er*i.al,me.y=Bt-(ur-ht)*i.al,i.cZ(te,me,J)&&F(U,0,N,Jt,ur)}}}},fe=x.points,ke=fe[i.cv],be=fe[i.cw],Re=this._projectToGround(ke,fe[i.cx]),Oe=this._projectToGround(be,fe[i.cy]);return he(ke,Re),he(be,Oe),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 N=x,P=this.elevation&&this.elevation.exaggeration(),O=P&&!u.isTerrainDEM,F=this.projection.name==="mercator";if(u.minzoom!==void 0&&xu.maxzoom&&(x=u.maxzoom);const U=this.locationCoordinate(this.center),G=this.center.lat,J=1<{const Xt=new i.ae(Lt.x+25e-6,Lt.y,Lt.z),gr=new i.ae(Lt.x,Lt.y+25e-6,Lt.z),qr=Lt.toLngLat(),rs=Xt.toLngLat(),Or=gr.toLngLat(),Tr=this.locationCoordinate(qr),vs=this.locationCoordinate(rs),ps=this.locationCoordinate(Or),Qr=Math.hypot(vs.x-Tr.x,vs.y-Tr.y),ns=Math.hypot(ps.x-Tr.x,ps.y-Tr.y);return Math.sqrt(Qr*ns)*bt/25e-6},ht=Lt=>{const nr=Nt,Xt=xt;return{aabb:i.cF(this,J,0,0,0,Lt,Xt,nr,this.projection),zoom:0,x:0,y:0,minZ:Xt,maxZ:nr,wrap:Lt,fullyVisible:!1}},At=[];let Bt=[];const zt=x,Jt=u.reparseOverscaled?N:x,er=(Re-this._centerAltitude)*be,ur=Lt=>{if(!this._elevation||!Lt.tileID||!F)return;const nr=this._elevation.getMinMaxForTile(Lt.tileID),Xt=Lt.aabb;nr?(Xt.min[2]=nr.min,Xt.max[2]=nr.max,Xt.center[2]=(Xt.min[2]+Xt.max[2])/2):(Lt.shouldSplit=Kt(Lt),Lt.shouldSplit||(Xt.min[2]=Xt.max[2]=Xt.center[2]=this._centerAltitude))},Cr=(Lt,nr)=>{if(.707*nr{if(Lt.zoom=.9)return!0}else if(O&&(gr=Lt.aabb.distanceZ(Oe)*be),this.projection.isReprojectedInTileSpace&&N<=5){const ns=Math.pow(2,Lt.zoom),Ps=gt(new i.ae((Lt.x+.5)/ns,(Lt.y+.5)/ns));qr=Ps>.85?1:Ps}if(!F&&!me){const ns=Math.sqrt(nr*nr+Xt*Xt+gr*gr);let Ps=(1<0;){const Lt=At.pop(),nr=Lt.x,Xt=Lt.y;let gr=Lt.fullyVisible;const qr=()=>this.projection.name==="globe"&&(Lt.y===0||Lt.y===(1<>1),vs={aabb:F?Lt.aabb.quadrant(rs):i.cF(this,J,Lt.zoom+1,Or,Tr,Lt.wrap,Lt.minZ,Lt.maxZ,this.projection),zoom:Lt.zoom+1,x:Or,y:Tr,wrap:Lt.wrap,fullyVisible:gr,tileID:void 0,shouldSplit:void 0,minZ:Lt.minZ,maxZ:Lt.maxZ};O&&!me&&(vs.tileID=new i.aQ(Lt.zoom+1===zt?Jt:Lt.zoom+1,Lt.wrap,Lt.zoom+1,Or,Tr),ur(vs)),At.push(vs)}else{const rs=Lt.zoom===zt?Jt:Lt.zoom;if(u.minzoom&&u.minzoom>rs)continue;let Or=0;if(!gr){let Qr=Ge?Lt.aabb.intersectsPrecise(fe):Lt.aabb.intersectsPreciseFlat(fe);if(Qr===0&&qr()){const ns=new i.cD(Lt.zoom,nr,Xt);Qr=i.cE(this,J,ns,!0).intersectsPrecise(fe)}if(Qr===0)continue;if(u.calculateQuadrantVisibility)if(fe.containsPoint(Lt.aabb.center))Or=15;else for(let ns=0;ns<4;ns++)Lt.aabb.quadrant(ns).intersects(fe)!==0&&(Or|=1<{const gr=[0,0,0,1],qr=[i.al,i.al,0,1],rs=this.calculateFogTileMatrix(Xt.tileID.toUnwrapped());i.aC(gr,gr,rs),i.aC(qr,qr,rs);const Or=i.cG([],gr,qr),Tr=i.cH([],gr,qr),vs=i.c$(Or,Tr);if(vs===0)return!0;let ps=!1;const Qr=this._elevation;if(Qr&&vs>Lt&&nr!==0){const ns=this.calculateProjMatrix(Xt.tileID.toUnwrapped());let Ps;u.isTerrainDEM||(Ps=Qr.getMinMaxForTile(Xt.tileID)),Ps||(Ps={min:xt,max:Nt});const mn=i.cI(this.rotation),sa=[mn[0]*i.al,mn[1]*i.al,Ps.max];i.af(sa,sa,ns),ps=(1-sa[1])*this.height*.5Lt.distanceSq-nr.distanceSq).map(Lt=>Lt.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),N=this.projection.project(u.lng,x);return new i.P(N.x*this.worldSize,N.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 N,P;const O=this.centerPoint;if(this.projection.name==="globe"){const U=this.worldSize;N=(x.x-O.x)/U,P=(x.y-O.y)/U}else{const U=this.pointCoordinate(x),G=this.pointCoordinate(O);N=U.x-G.x,P=U.y-G.y}const F=this.locationCoordinate(u);this.setLocation(new i.ae(F.x-N,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 N=x?i.cf(x,u.lat):void 0,P=this.projection.project(u.lng,u.lat);return new i.ae(P.x,P.y,N)}coordinateLocation(u){return this.projection.unproject(u.x,u.y)}pointRayIntersection(u,x){const N=x??this._centerAltitude,P=[u.x,u.y,0,1],O=[u.x,u.y,1,1];i.aC(P,P,this.pixelMatrixInverse),i.aC(O,O,this.pixelMatrixInverse);const F=O[3];i.cK(P,P,1/P[3]),i.cK(O,O,1/F);const U=P[2],G=O[2];return{p0:P,p1:O,t:U===G?0:(N-U)/(G-U)}}screenPointToMercatorRay(u){const x=[u.x,u.y,0,1],N=[u.x,u.y,1,1];return i.aC(x,x,this.pixelMatrixInverse),i.aC(N,N,this.pixelMatrixInverse),i.cK(x,x,1/x[3]),i.cK(N,N,1/N[3]),x[2]=i.cf(x[2],this._center.lat)*this.worldSize,N[2]=i.cf(N[2],this._center.lat)*this.worldSize,i.cK(x,x,1/this.worldSize),i.cK(N,N,1/this.worldSize),new i.ax([x[0],x[1],x[2]],i.aw([],i.av([],N,x)))}rayIntersectionCoordinate(u){const{p0:x,p1:N,t:P}=u,O=i.cf(x[2],this._center.lat),F=i.cf(N[2],this._center.lat);return new i.ae(i.ak(x[0],N[0],P)/this.worldSize,i.ak(x[1],N[1],P)/this.worldSize,i.ak(O,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 N=this.projection.pointCoordinate3D(this,u.x,u.y);if(N)return new i.ae(N[0],N[1],N[2]);let P=0,O=this.horizonLineFromTop();if(u.y>O)return this.pointCoordinate(u,x);const F=.02*O,U=u.clone();for(let G=0;G<10&&O-P>F;G++){U.y=i.ak(P,O,.66);const J=this.projection.pointCoordinate3D(this,U.x,U.y);J?(O=U.y,N=J):P=U.y}return N?new i.ae(N[0],N[1],N[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 N=x&&this.elevation?this.elevation.getAtPointOrZero(u,this._centerAltitude):this._centerAltitude,P=[u.x*this.worldSize,u.y*this.worldSize,N+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,N=this.height-this._edgeInsets.bottom,P=this.width-this._edgeInsets.right,O=this.pointLocation3D(new i.P(x,u)),F=this.pointLocation3D(new i.P(P,u)),U=this.pointLocation3D(new i.P(P,N)),G=this.pointLocation3D(new i.P(x,N));let J=Math.min(O.lng,F.lng,U.lng,G.lng),te=Math.max(O.lng,F.lng,U.lng,G.lng),me=Math.min(O.lat,F.lat,U.lat,G.lat),he=Math.max(O.lat,F.lat,U.lat,G.lat);const fe=Math.pow(2,-this.zoom)/16*270,ke=this.projection.name==="globe"?1:4,be=(Re,Oe,Ge,at,Ke)=>{const Nt=(Re+Ge)/2,xt=(Oe+at)/2,bt=new i.P(Nt,xt),{lng:gt,lat:ht}=this.pointLocation3D(bt),At=Math.max(0,J-gt,me-ht,gt-te,ht-he);J=Math.min(J,gt),te=Math.max(te,gt),me=Math.min(me,ht),he=Math.max(he,ht),(Kefe)&&(be(Re,Oe,Nt,xt,Ke+1),be(Nt,xt,Ge,at,Ke+1))};if(be(x,u,P,u,1),be(P,u,P,N,1),be(P,N,x,N,1),be(x,N,x,u,1),this.projection.name==="globe"){const[Re,Oe]=i.cM(this);Re?(he=90,te=180,J=-180):Oe&&(me=-90,te=180,J=-180)}return new i.aI(new i.aT(J,me),new i.aT(te,he))}_getBoundsRectangular(u,x){const{top:N,left:P}=this._edgeInsets,O=this.height-this._edgeInsets.bottom,F=this.width-this._edgeInsets.right,U=new i.P(P,N),G=new i.P(F,N),J=new i.P(F,O),te=new i.P(P,O);let me=this.pointCoordinate(U,u),he=this.pointCoordinate(G,u);const fe=this.pointCoordinate(J,x),ke=this.pointCoordinate(te,x),be=(Re,Oe)=>(Oe.y-Re.y)/(Oe.x-Re.x);return me.y>1&&he.y>=0?me=new i.ae((1-ke.y)/be(ke,me)+ke.x,1):me.y<0&&he.y<=1&&(me=new i.ae(-ke.y/be(ke,me)+ke.x,0)),he.y>1&&me.y>=0?he=new i.ae((1-fe.y)/be(fe,he)+fe.x,1):he.y<0&&me.y<=1&&(he=new i.ae(-fe.y/be(fe,he)+fe.x,0)),new i.aI().extend(this.coordinateLocation(me)).extend(this.coordinateLocation(he)).extend(this.coordinateLocation(ke)).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((N,P)=>{if(P.dem){const O=P.dem.tree;N.min=Math.min(N.min,O.minimums[0]),N.max=Math.max(N.max,O.maximums[0])}return N},{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,N=this.height/2-x*(1-this._horizonShift);return u?Math.max(0,N):N}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.maxLngme&&(U=me-J),me-tefe&&(F=fe-G),fe-he{for(let Kt=0;Kt<16;Kt++)Jt[Kt]=i.ak(er[Kt],ur[Kt],Cr)})(U,U,G,i.d0(this.pitch>=mm?1:this.pitch/mm))}else U=G;const J=i.cP([],G,F);let te=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(te,te,At),i.aB(J,J,At),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],te,[this.worldSize,this.worldSize,this.worldSize/O,1]),this.projMatrix=te,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 me=i.bl([],U);this.frustumCorners=i.cT.fromInvProjectionMatrix(me,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!x);const he=new Float32Array(16);i.bA(he),i.cS(he,he,[1,-1,1]),i.cU(he,he,this._pitch),i.bB(he,he,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 ke=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;fe[8]=2*-u.x/this.width,fe[9]=2*(u.y+ke)/this.height,this.skyboxMatrix=i.aB(he,fe,he);const be=this.point,Re=be.x,Oe=be.y,Ge=this.width%2/2,at=this.height%2/2,Ke=Math.cos(this.angle),Nt=Math.sin(this.angle),xt=Re-Math.round(Re)+Ke*Ge+Nt*at,bt=Oe-Math.round(Oe)+Ke*at+Nt*Ge,gt=new Float64Array(te);if(i.br(gt,gt,[xt>.5?xt-1:xt,bt>.5?bt-1:bt,0]),this.alignedProjMatrix=gt,te=i.bC(),i.cS(te,te,[this.width/2,-this.height/2,1]),i.br(te,te,[1,-1,0]),this.labelPlaneMatrix=te,te=i.bC(),i.cS(te,te,[1,-1,1]),i.br(te,te,[-1,-1,0]),i.cS(te,te,[2/this.width,2/this.height,1]),this.glCoordMatrix=te,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,J),this._calcFogMatrices(),this._distanceTileDataCache={},te=i.bl(new Float64Array(16),this.pixelMatrix),!te)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=te,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=te;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const u=this.cameraWorldSizeForFog,x=this.cameraPixelsPerMeter,N=this._camera.position,P=1/this.height/this._pixelsPerMercatorPixel,O=[u,u,x];i.c5(O,O,P),i.c5(N,N,-1),i.cW(N,N,O);const F=i.bC();i.br(F,F,N),i.cS(F,F,O),this.mercatorFogMatrix=F,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(u,x,P)}_computeCameraPosition(u){const x=(u=u||this.pixelsPerMeter)/this.pixelsPerMeter,N=this._camera.forward(),P=this.point,O=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*x-u/this.worldSize*this._centerAltitude;return[P.x/this.worldSize-N[0]*O,P.y/this.worldSize-N[1]*O,u/this.worldSize*this._centerAltitude-N[2]*O]}_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),N=this._camera.position[2],P=u[2];let O=1;this.projection.wrap&&(this.center=this.center.wrap()),P>0&&(O=Math.min((x-N)/P,1)),this._camera.position=i.bH([],this._camera.position,u,O),this._updateStateFromCamera()}_updateStateFromCamera(){const u=this._camera.position,x=this._camera.forward(),{pitch:N,bearing:P}=this._camera.getPitchBearing(),O=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]-O)/Math.cos(N),F),G=this._zoomFromMercatorZ(U);i.bH(u,u,x,U),this._pitch=i.aA(N,i.an(this.minPitch),i.an(this.maxPitch)),this.angle=i.bT(P,-Math.PI,Math.PI),this._setZoom(i.aA(G,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,N=i.cL,P=0,O=1/0;for(;N-x>1e-6&&N>x;){const F=x+.5*(N-x),U=this.tileSize*Math.pow(2,F),G=this.getCameraToCenterDistance(this.projection,F,U),J=this.scaleZoom(G/(Math.max(0,u)*this.tileSize)),te=Math.abs(F-J);teJ||he.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 N=i.ag(i.av([],this._camera.position,u)),P=this._zoomFromMercatorZ(N)+x;return N-this._mercatorZfromZoom(P)}getCameraPoint(){if(this.projection.name==="globe"){const u=function([x,N,P],O){const F=[x,N,P,1];i.aC(F,F,O);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,N=this.worldSize){const P=i.cO(u,x,this.width,this.height,1024),O=u.pixelSpaceConversion(this.center.lat,N,P);let F=.5/Math.tan(.5*this._fov)*this.height*O;return this.isOrthographic&&(F=i.ak(1,F,i.d0(this.pitch>=mm?1:this.pitch/mm))),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 jg=(j,u)=>{if(u>0&&j.terrain&&i.w("Cutoff is currently disabled on terrain"),u<=0||j.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const x=j.transform,N=Math.max(Math.abs(x._zoom-(j.minCutoffZoom-1)),1),P=x.isLODDisabled(!1)?i.ah(60,45,x.pitch):i.ah(30,15,x.pitch),O=x._farZ-x._nearZ,F=u*x.height,U=((1-(G=P))*x.cameraToCenterDistance+G*(x._farZ+F))*N;var G;return{shouldRenderCutoff:P<1,uniformValues:{u_cutoff_params:[x._nearZ,x._farZ,(U-x._nearZ)/O,(U-F-x._nearZ)/O]}}},Ah=2048;class w_{constructor(u,x){this.aabb=u,this.lastCascade=x}}class Nle{add(u,x){const N=this.receivers[u.key];N!==void 0?(N.aabb.min[0]=Math.min(N.aabb.min[0],x.min[0]),N.aabb.min[1]=Math.min(N.aabb.min[1],x.min[1]),N.aabb.min[2]=Math.min(N.aabb.min[2],x.min[2]),N.aabb.max[0]=Math.max(N.aabb.max[0],x.max[0]),N.aabb.max[1]=Math.max(N.aabb.max[1],x.max[1]),N.aabb.max[2]=Math.max(N.aabb.max[2],x.max[2])):this.receivers[u.key]=new w_(x,null)}clear(){this.receivers={}}get(u){return this.receivers[u.key]}computeRequiredCascades(u,x,N){const P=i.d9.fromPoints(u.points);let O=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 G=U.aabb.getCorners();for(let J=0;J1||he[1]<-1||he[1]>1){te=!1;break}}if(U.lastCascade=J,O=Math.max(O,J),te)break}}return O+1}}class E0{constructor(u){this.painter=u,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new Nle,this._depthMode=new ks(u.context.gl.LEQUAL,ks.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 N=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=N.style.order.reduce((ke,be)=>{const Re=N.style._mergedLayers[be];return ke+(Re.hasShadowPass()&&!Re.isHidden(u.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const O=N.context,F=Ah,U=Ah;if(this._cascades.length===0||Ah!==this._cascades[0].texture.size[0]){this._cascades=[];for(let ke=0;ke<2;++ke){const be=N._shadowMapDebug,Re=O.gl,Oe=O.createFramebuffer(F,U,be?1:0,"texture"),Ge=new i.T(O,{width:F,height:U,data:null},Re.DEPTH_COMPONENT16);if(Oe.depthAttachment.set(Ge.texture),be){const at=new i.T(O,{width:F,height:U,data:null},Re.RGBA8);Oe.colorAttachment0.set(at.texture)}this._cascades.push({framebuffer:Oe,texture:Ge,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=k_(x);let G=0;if(u.elevation){const ke=u.elevation,be=[1e4,-1e4];ke.visibleDemTiles.filter(Re=>Re.dem).forEach(Re=>{const Oe=Re.dem.tree;be[0]=Math.min(be[0],Oe.minimums[0]),be[1]=Math.max(be[1],Oe.maximums[0])}),be[0]!==1e4&&(G=(be[1]-be[0])*ke.exaggeration())}const J=1.5*u.cameraToCenterDistance,te=3*J,me=new Float64Array(16);for(let ke=0;ke=0)return{};const O=function(G,J,te){const me=te/(1<0&&(i.d8(O[1],O[1],[P[0]*F,0,0]),i.d8(O[2],O[2],[P[0]*F,0,0])),P[1]<0?(i.d8(O[0],O[0],[0,P[1]*F,0]),i.d8(O[1],O[1],[0,P[1]*F,0])):P[1]>0&&(i.d8(O[2],O[2],[0,P[1]*F,0]),i.d8(O[3],O[3],[0,P[1]*F,0]));const U={};return U.vertices=O,U.planes=[j_(O[1],O[0],O[4]),j_(O[2],O[1],O[5]),j_(O[3],O[2],O[6]),j_(O[0],O[3],O[7])],U}addShadowReceiver(u,x,N){this._receivers.add(u,i.d9.fromTileIdAndHeight(u,x,N))}getMaxCascadeForTile(u){const x=this._receivers.get(u);return x&&x.lastCascade?x.lastCascade:0}}function j_(j,u,x){const N=i.av([],x,u),P=i.av([],j,u),O=i.bI([],N,P),F=i.ag(O);return F===0?[0,0,1,0]:(i.c5(O,O,1/F),[O[0],O[1],O[2],-i.bJ(O,u)])}function k_(j){const u=j.properties.get("direction"),x=i.d4(u.x,u.y,u.z);x[2]=i.aA(x[2],0,75);const N=i.d6([x[0],x[1],x[2]]);return i.d5(N.x,N.y,N.z)}function ap(j,u,x){const N=u.properties.get("color-use-theme")==="none",P=u.properties.get("color"),O=u.properties.get("intensity"),F=u.properties.get("direction"),U=[F.x,F.y,F.z],G=x.properties.get("color-use-theme")==="none",J=x.properties.get("color"),te=x.properties.get("intensity"),me=Math.max(i.bJ([0,0,1],U),0),he=[0,0,0];i.c5(he,J.toPremultipliedRenderColor(G?null:j.getLut(u.scope)).toArray01Linear().slice(0,3),te);const fe=[0,0,0];return i.c5(fe,P.toPremultipliedRenderColor(N?null:j.getLut(x.scope)).toArray01Linear().slice(0,3),me*O),i.db([he[0]>0?he[0]/(he[0]+fe[0]):0,he[1]>0?he[1]/(he[1]+fe[1]):0,he[2]>0?he[2]/(he[2]+fe[2]):0])}function kg(j,u,x,N,P,O){const F=j.zoom,U=j.scale,G=j.worldSize,J=1/G,te=j.aspect,me=Math.sqrt(1+te*te)*Math.tan(.5*j.fovX),he=me*me,fe=N-x,ke=N+x;let be,Re;he>fe/ke?(be=N,Re=N*me):(be=.5*ke*(1+he),Re=.5*Math.sqrt(fe*fe+2*(N*N+x*x)*he+ke*ke*he*he));const Oe=j.projection.pixelsPerMeter(j.center.lat,G),Ge=j._camera.getCameraToWorldMercator(),at=[0,0,-be*J];i.af(at,at,Ge);let Ke=Re*J;const Nt=j._edgeInsets;if(!(Nt.left===0&&Nt.top===0&&Nt.right===0&&Nt.bottom===0||Nt.left===Nt.right&&Nt.top===Nt.bottom)){const gr=j._camera.getWorldToCamera(j.worldSize,j.projection.zAxisUnit==="meters"?Oe:1),qr=j._camera.getCameraToClipPerspective(j._fov,j.width/j.height,x,N);qr[8]=2*-j.centerOffset.x/j.width,qr[9]=2*j.centerOffset.y/j.height;const rs=new Float64Array(16);i.cP(rs,qr,gr);const Or=new Float64Array(16);i.bl(Or,rs);const Tr=i.cB.fromInvProjectionMatrix(Or,G,F,!0);for(const vs of Tr.points){const ps=((xt=vs)[0]/=U,xt[1]/=U,xt[2]=i.cf(xt[2],j._center.lat),xt);Ke=Math.max(Ke,i.c6(i.da([],at,ps)))}}var xt;Ke*=P/(P-1);const bt=Math.acos(u[2]),gt=Math.atan2(-u[0],-u[1]),ht=new BN;ht.position=at,ht.setPitchBearing(bt,gt);const At=ht.getWorldToCamera(G,Oe),Bt=Ke*G,zt=Math.min(j._mercatorZfromZoom(17)*G*-2,-2*Bt),Jt=ht.getCameraToClipOrthographic(-Bt,Bt,-Bt,Bt,zt,(Bt+O*Oe)/u[2]),er=new Float64Array(16);i.aB(er,Jt,At);const ur=i.d5(Math.floor(1e6*at[0])/1e6*G,Math.floor(1e6*at[1])/1e6*G,0),Cr=.5*P,Kt=[0,0,0];i.af(Kt,ur,er),i.c5(Kt,Kt,Cr);const Lt=[Math.floor(Kt[0]),Math.floor(Kt[1]),Math.floor(Kt[2])],nr=[0,0,0];i.av(nr,Kt,Lt),i.c5(nr,nr,-1/Cr);const Xt=new Float64Array(16);return i.bA(Xt),i.br(Xt,Xt,nr),i.aB(er,Xt,er),[er,Bt]}class Sle 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(N=>{if(!N)return;const P=i.dd(N),O=new i.de(u,x,void 0,void 0,P);return O.computeBoundsAndApplyParent(),O}).catch(N=>{if(N&&N.status===404)return null;this.fire(new i.y(new Error(`Could not load model ${u} from ${x}: ${N.message}`)))})}load(u,x,N={forceReload:!1}){this.models[x]||(this.models[x]={});const P=Object.keys(u),O=[],F=[];for(const U of P){const G=u[U];this.hasURLBeenRequested(G)&&!N.forceReload||(this.modelByURL[G]={modelId:U,scope:x},O.push(this.loadModel(U,G)),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(O).then(U=>{for(let G=0;G{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,N={exactIdMatch:!1}){return!!(N.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,N){this.models[N]||(this.models[N]={}),this.modelUris[N]||(this.modelUris[N]={});const P=this.requestManager.normalizeModelURL(x);if((this.hasModel(u,N,{exactIdMatch:!0})||this.hasModelBeenAdded(u,N))&&this.modelUris[N][u]===P)this.models[N][u].numReferences++;else if(this.hasURLBeenRequested(P)){const{scope:O,modelId:F}=this.modelByURL[P];this.models[O][F].numReferences++}else this.modelUris[N][u]=P,this.load({[u]:this.modelUris[N][u]},N)}addModelURLs(u,x){this.models[x]||(this.models[x]={}),this.modelUris[x]||(this.modelUris[x]={});const N=this.modelUris[x];for(const P in u)N[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 N={};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)?N[P]=this.modelUris[x][P]:!this.hasURLBeenRequested(P)&&i.df(P,!1)&&(this.modelUris[x][P]=this.requestManager.normalizeModelURL(P),N[P]=this.modelUris[x][P]);this.load(N,x)}hasURLBeenRequested(u){return this.modelByURL[u]!==void 0}removeModel(u,x,N=!1,P=!1){if(this.models[x]&&this.models[x][u]&&(this.models[x][u].numReferences--,this.models[x][u].numReferences===0||P)){const O=this.modelUris[x][u];N||delete this.modelUris[x][u],delete this.modelByURL[O];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 N=this.models[u][x].model;delete this.models[u][x],N&&N.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 N in this.models[x])this.models[x][N].model&&this.models[x][N].model.upload(u.context)}}const fM=i.a6.colorTheme,Cle=new i.a9({data:new i.aa(fM.data)});function sL(j){if(!j.metadata||!j.metadata.content_area)return;const u=i.o.devicePixelRatio,{left:x,top:N,width:P,height:O}=j.metadata.content_area,F=x*u,U=N*u;return[F,U,F+P*u,U+O*u]}function nL(j){if(j)return j.map(([u,x])=>[u*i.o.devicePixelRatio,x*i.o.devicePixelRatio])}class pM{constructor(u,x,N){this.id=u,this.scope=x,this.sourceCache=N,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 N=this.sourceCache.getSource();if(!(N instanceof Ac))return u;const P=x.map(F=>this.sourceCache.getTile(F)),O=N.getImages(P,Array.from(this.pendingRequests));for(const[F,U]of O)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 Ng=(j,u)=>Xe(j,u&&u.filter(x=>x.identifier!=="source.canvas")),aL=i.aH(oa,["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"]),iL=i.aH(oa,["setCenter","setZoom","setBearing","setPitch"]),UN=new Set(["background","sky","slot","custom"]),Sg={version:8,layers:[],sources:{}},N_={duration:300,delay:0};class Eh 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({},N_),this._buildingIndex=new oM(this),this.crossTileSymbolIndex=new hm,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 je,this._hasDataDrivenEmissive=!1,this.dispatcher=x.dispatcher?x.dispatcher:new i.D(i.dh(),this),x.imageManager?this.imageManager=x.imageManager:(this.imageManager=new Se(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 Sle(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 N=this;this._rtlTextPluginCallback=Eh.registerForPluginStateChange(P=>{N.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:P.pluginStatus,pluginURL:P.pluginURL},(O,F)=>{if(i.dl(O),F&&F.every(U=>U))for(const U in N._sourceCaches){const G=N._sourceCaches[U],J=G.getSource().type;J!=="vector"&&J!=="geojson"||G.reload()}})}),this.on("data",P=>{if(P.dataType!=="source"||P.sourceDataType!=="metadata")return;const O=this.getOwnSource(P.sourceId);if(O&&O.vectorLayerIds)for(const F in this._layers){const U=this._layers[F];U.source===O.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,N){this.globalId=this._getGlobalId(u);const P=(O,F)=>{try{F(null,this.setState(O,N))}catch(U){F(U,!1)}};if(typeof u=="string"){const O=this.map._requestManager.normalizeStyleURL(u),F=this.map._requestManager.transformRequest(O,i.R.Style);i.m(F,(U,G)=>{U?this.fire(new i.y(U)):G&&P(G,x)})}else typeof u=="object"&&P(u,x)}loadURL(u,x={}){this.fire(new i.z("dataloading",{dataType:"style"}));const N=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,N);const O=this.map._requestManager.transformRequest(u,i.R.Style);this._request=i.m(O,(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,N)})}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(Sg,!1)}_loadImports(u,x,N){if(this.importDepth>=4)return i.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const P=[];for(const O of u){const F=this._createFragmentStyle(O),U=new Promise(te=>{F.once("style.import.load",te),F.once("error",te)}).then(()=>this.mergeAll());if(P.push(U),this.resolvedImports.has(O.url)){F.loadEmpty();continue}const G=O.data||this.importsCache.get(O.url);G?(F.loadJSON(G,{validate:x}),this._isInternalStyle(G)&&(F.globalId=null)):O.url?F.loadURL(O.url,{validate:x}):F.loadEmpty();const J={style:F,id:O.id,config:O.config};if(N){const te=this.fragments.findIndex(({id:me})=>me===N);this.fragments=this.fragments.slice(0,te).concat(J).concat(this.fragments.slice(te))}else this.fragments.push(J)}return Promise.allSettled(P)}getImportGlobalIds(u=this,x=new Set){for(const N of u.fragments)N.style.globalId&&x.add(N.style.globalId),this.getImportGlobalIds(N.style,x);return[...x.values()]}_createFragmentStyle(u){const x=this.scope?i.B(u.id,this.scope):u.id;let N;const P=this._initialConfig&&this._initialConfig[x];(u.config||P)&&(N=Object.assign({},u.config,P));const O=new Eh(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:N,configOptions:this.options,colorThemeOverride:u["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return O.setEventedParent(this.map,{style:O}),O}_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 O=Object.assign({},Sg,{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(O,x)}if(this.updateConfig(this._config,u.schema),x&&Ng(this,Yn(u)))return;this._loaded=!0,this.stylesheet=i.dp(u);const N=()=>{for(const G in u.sources)this.addSource(G,u.sources[G],{validate:!1,isInitialLoad:!0});if(u.iconsets)for(const G in u.iconsets)this.addIconset(G,u.iconsets[G]);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 O=zx(this.stylesheet.layers);if(this._order=O.map(G=>G.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 G=this.stylesheet.lights[0];this.light=new Dt(G.properties,G.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Dt(this.stylesheet.light)),this._layers={};for(const G of O){const J=i.du(G,this.scope,this._styleColorTheme.lut,this.options);J.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(J.fqid),J.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(J.fqid),this._hasAppearances=this._hasAppearances||J.getAppearances().length!==0,J.setEventedParent(this,{layer:{id:J.id}}),this._layers[J.id]=J;const te=this.getOwnLayerSourceCache(J),me=!!this.directionalLight&&this.directionalLight.shadowsEnabled();te&&J.canCastShadows()&&me&&(te.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(G=>{this.fire(new i.y(new Error("Failed to load imports",G))),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 O=this._evaluateColorThemeData(P);this._loadColorTheme(O).then(()=>{N()}).catch(F=>{i.w(`Couldn't load color theme from the stylesheet: ${F}`),N()})}else this._styleColorTheme.lut=null,N()}isRootStyle(){return this.importDepth===0}hasAppearances(){return this._hasAppearances||this.fragments.some(u=>u.style.hasAppearances())}mergeAll(){let u,x,N,P,O,F,U,G,J,te;const me={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(he=>{if(he.stylesheet){if(he.light!=null&&(u=he.light),he.stylesheet.lights)for(const fe of he.stylesheet.lights)fe.type==="ambient"&&he.ambientLight!=null&&(x=he.ambientLight),fe.type==="directional"&&he.directionalLight!=null&&(N=he.directionalLight);P=this._prioritizeTerrain(P,he.terrain,he.stylesheet.terrain),he.stylesheet.fog&&he.fog!=null&&(O=he.fog),he.stylesheet.snow&&he.snow!=null&&(F=he.snow),he.stylesheet.rain&&he.rain!=null&&(U=he.rain),he.stylesheet.camera!=null&&(te=he.stylesheet.camera),he.stylesheet.projection!=null&&(G=he.stylesheet.projection),he.stylesheet.transition!=null&&(J=he.stylesheet.transition),me[he.scope]=he._styleColorTheme}}),this.light=u,this.ambientLight=x,this.directionalLight=N,this.fog=O,this.snow=F,this.rain=U,this._styleColorThemeForScope=me,P===null?delete this.terrain:this.terrain=P,this.camera=te||{"camera-projection":"perspective"},this.projection=G||{name:"mercator"},this.transition=Object.assign({},N_,J),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(u){const x=N=>{for(const P of N.fragments)x(P.style);u(N)};x(this)}_prioritizeTerrain(u,x,N){const P=u&&u.drapeRenderMode===0;return N===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={},N={};this.forEachFragmentStyle(P=>{for(const O in P._sourceCaches){const F=i.B(O,P.scope);u[F]=P._sourceCaches[O]}for(const O in P._otherSourceCaches){const F=i.B(O,P.scope);x[F]=P._otherSourceCaches[O]}for(const O in P._symbolSourceCaches){const F=i.B(O,P.scope);N[F]=P._symbolSourceCaches[O]}}),this._mergedSourceCaches=u,this._mergedOtherSourceCaches=x,this._mergedSymbolSourceCaches=N}mergeIndoor(){this.forEachFragmentStyle(u=>{if(u.stylesheet&&u.stylesheet.indoor)for(const x of Object.values(u.stylesheet.indoor)){const N=x,P=i.B(N.sourceId,u.scope);this._mergedIndoor[P]=new Set(N.sourceLayers||[])}})}mergeLayers(){const u={},x=[],N={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(F=>{for(const U of F._order){const G=F._layers[U];if(G.type==="slot"){const J=i.dq(U);if(u[J])continue;u[J]=[]}G.slot&&u[G.slot]?u[G.slot].push(G):x.push(G)}}),this._mergedOrder=[];let P=-1;const O=(F=[])=>{for(const U of F)if(U.type==="slot"){const G=i.dq(U.id);u[G]&&O(u[G]),this._mergedSlots.push(G)}else{const G=i.B(U.id,U.scope);this._mergedOrder.push(G),N[G]=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(O(x),this._has3DLayers){const F={};for(let U=0;UF[U]-F[G])}this._mergedLayers=N,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,N,P,O){const F=Object.assign({},N);for(const G of Object.keys(fM))F[G]===void 0&&(F[G]=fM[G].default);const U=new i.a8(Cle,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((N,P)=>{const O="data:image/png;base64,";if(!u||u.length===0)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void N();let F=u;F.startsWith(O)||(F=O+F);const U=i.I.from("mapbox-reserved-lut"),G=new Image;G.src=F,G.onerror=()=>{this._styleColorTheme.lutLoading=!1,P(new Error("Failed to load image data"))},G.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==x)return void N();this._styleColorTheme.lutLoading=!1;const{width:J,height:te,data:me}=i.o.getImageData(G);if(te>32)return void P(new Error("The height of the image must be less than or equal to 32 pixels."));if(J!==te*te)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:J,height:te},me),pixelRatio:1,sdf:!1,usvg:!1,version:0});const he=this.imageManager.getImage(U,this.scope);he?(this._styleColorTheme.lut={image:he.data,data:u},N()):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,N,P){let O,F,U;const G=i.o.devicePixelRatio>1?"@2x":"";let J=i.m(N.transformRequest(N.normalizeSpriteURL(x,G,".json"),i.R.SpriteJSON),(he,fe)=>{J=null,U||(U=he,O=fe,me())}),te=i.n(N.transformRequest(N.normalizeSpriteURL(x,G,".png"),i.R.SpriteImage),(he,fe)=>{te=null,U||(U=he,F=fe,me())});function me(){if(U)P(U);else if(O&&F){const he=i.o.getImageData(F),fe={};for(const ke in O){const{width:be,height:Re,x:Oe,y:Ge,sdf:at,pixelRatio:Ke,stretchX:Nt,stretchY:xt,content:bt}=O[ke],gt=new i.q({width:be,height:Re});i.q.copy(he,gt,{x:Oe,y:Ge},{x:0,y:0},{width:be,height:Re},null),fe[ke]={data:gt,pixelRatio:Ke!==void 0?Ke:1,sdf:at!==void 0&&at,stretchX:Nt,stretchY:xt,content:bt,usvg:!1,version:0}}P(null,fe)}}return{cancel(){J&&(J.cancel(),J=null),te&&(te.cancel(),te=null)}}}(u,this.map._requestManager,(x,N)=>{if(this._spriteRequest=null,x)this.fire(new i.y(x));else if(N){const P=new Map;for(const O in N)P.set(i.I.from(O),N[O]);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 N=this.getOwnSourceCache(x.source);if(!N)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=N.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 O=new pM(u,this.scope,N);this.imageManager.addImageProvider(O,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 N,P;this._spriteRequest=(P=(O,F)=>{if(this._spriteRequest=null,O)x?this._loadSprite(u):this.fire(new i.y(O));else if(F){const U=new Map;for(const G in F)U.set(i.I.from(G),F[G]);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((N=this.map._requestManager).transformRequest(N.normalizeIconsetURL(u),i.R.Iconset),(O,F)=>{if(O)return void P(O);const U={},G=i.dg(new i.bt(F));for(const J of G.icons){const te={version:1,pixelRatio:i.o.devicePixelRatio,content:sL(J),stretchX:J.metadata?nL(J.metadata.stretch_x_areas):void 0,stretchY:J.metadata?nL(J.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:J};U[J.name]=te}P(null,U)}))}_validateLayer(u){const x=this.getOwnSource(u.source);if(!x)return;const N=u.sourceLayer;N&&(x.type==="geojson"||x.vectorLayerIds&&x.vectorLayerIds.indexOf(N)===-1)&&this.fire(new i.y(new Error(`Source layer "${N}" 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 N=this.fragments[x];return N&&N.style&&(u.data=N.style.serialize()),u})}_serializeSources(){const u={};for(const x in this._sourceCaches){const N=this._sourceCaches[x].getSource();u[N.id]||(u[N.id]=N.serialize())}return u}_serializeLayers(u){const x=[];for(const N of u){const P=this._layers[N];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 N=x._transitionablePaint._values["line-emissive-strength"];if(N&&N.value&&N.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 N=this.map.painter;if(N)for(let P=u.minzoom||0;P<(u.maxzoom||25.5);P++){const O=u.getProgramIds();if(O)for(const F of O){const U=u.getDefaultProgramParams(F,x.zoom,this._styleColorTheme.lut);U&&(N.style=this,this.fog&&(N._fogVisible=!0,U.overrideFog=!0,N.getOrCreateProgram(F,U)),N._fogVisible=!1,U.overrideFog=!1,N.getOrCreateProgram(F,U),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(U.overrideRtt=!0,N.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 N=this._changes.isDirty();let P=!1;if(this._changes.isDirty()){const U=this._changes.getLayerUpdatesByScope();for(const G in U){const{updatedIds:J,removedIds:te}=U[G];(J||te)&&(this._updateWorkerLayers(G,J,te),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 O={};for(const U in this._mergedSourceCaches){const G=this._mergedSourceCaches[U];O[U]=G.used,G.used=!1,G.tileCoverLift=0}for(const U of this._mergedOrder){const G=this._mergedLayers[U];if(G.visibility!=="none"&&G.recalculate(u,this._availableImages),!G.isHidden(u.zoom)){const J=this.getLayerSourceCache(G);J&&(J.used=!0,J.tileCoverLift=Math.max(J.tileCoverLift,G.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(G,u)}):this.precompilePrograms(G,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 O){const G=this._mergedSourceCaches[U];O[U]!==G.used&&G.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:G.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),N&&this.fire(new i.z("data",{dataType:"style"}))}updateImageProviders(){const u=this.imageManager.getPendingImageProviders();for(const x of u){const N=x.resolvePendingRequests(),P=this.getFragmentStyle(x.scope);P&&P.addImages(N)}}_updateTilesForChangedImages(){const u={};for(const x in this._mergedSourceCaches){const N=this._mergedSourceCaches[x].getSource().scope;u[N]=u[N]||this._changes.getUpdatedImages(N),u[N].length!==0&&this._mergedSourceCaches[x].reloadTilesForDependencies(["icons","patterns"],u[N])}for(const x in u)this._changes.resetUpdatedImages(x)}_updateWorkerLayers(u,x,N){const P=this.getFragmentStyle(u);P&&this.dispatcher.broadcast("updateLayers",{layers:x?P._serializeLayers(x):[],scope:u,removedIds:N||[],options:P.options})}setState(u,x){if(this._checkLoaded(),Ng(this,Yn(u)))return!1;(u=i.dp(u)).layers=zx(u.layers);const N=function(F,U){if(!F)return[{command:oa.setStyle,args:[U]}];let G=[];try{if(!i.by(F.version,U.version))return[{command:oa.setStyle,args:[U]}];if(i.by(F.center,U.center)||G.push({command:oa.setCenter,args:[U.center]}),i.by(F.zoom,U.zoom)||G.push({command:oa.setZoom,args:[U.zoom]}),i.by(F.bearing,U.bearing)||G.push({command:oa.setBearing,args:[U.bearing]}),i.by(F.pitch,U.pitch)||G.push({command:oa.setPitch,args:[U.pitch]}),i.by(F.sprite,U.sprite)||G.push({command:oa.setSprite,args:[U.sprite]}),i.by(F.glyphs,U.glyphs)||G.push({command:oa.setGlyphs,args:[U.glyphs]}),i.by(F.imports,U.imports)||function(fe=[],ke=[],be){ke=ke||[];const Re=(fe=fe||[]).map(bg),Oe=ke.map(bg),Ge=fe.reduce(Bx,{}),at=ke.reduce(Bx,{}),Ke=Re.slice();let Nt,xt,bt,gt;for(Nt=0,xt=0;Nt{fe.source&&J[fe.source]?G.push({command:oa.removeLayer,args:[fe.id]}):me.push(fe)});let he=F.terrain;he&&J[he.source]&&(G.push({command:oa.setTerrain,args:[void 0]}),he=void 0),G=G.concat(te),i.by(he,U.terrain)||G.push({command:oa.setTerrain,args:[U.terrain]}),function(fe,ke,be){ke=ke||[];const Re=(fe=fe||[]).map(bg),Oe=ke.map(bg),Ge=fe.reduce(Bx,{}),at=ke.reduce(Bx,{}),Ke=Re.slice(),Nt=Object.create(null);let xt,bt,gt,ht,At,Bt,zt;for(xt=0,bt=0;xt!(F.command in iL));if(N.length===0)return!1;const P=N.filter(F=>!(F.command in aL));if(P.length>0)throw new Error(`Unimplemented: ${P.map(F=>F.command).join(", ")}.`);const O=[];return N.forEach(F=>{O.push(this[F.command](...F.args))}),x&&Promise.all(O).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,N]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,N),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,N=!1){this.imageManager.updateImage(u,this.scope,x),N&&(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,N={}){return this._checkLoaded(),this._validate(ye,`models.${u}`,x,null,N)||(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,N={}){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(Pi,`sources.${u}`,x,null,N))return;this.map&&this.map._collectResourceTiming&&(x.collectResourceTiming=!0);const P=tl(u,x,this.dispatcher,this);P.scope=this.scope,P.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(P.id),source:P.serialize(),sourceId:P.id}));const O=F=>{const U=(F?"symbol:":"other:")+P.id,G=i.B(U,this.scope),J=this._sourceCaches[U]=new Ed(G,P,F);(F?this._symbolSourceCaches:this._otherSourceCaches)[P.id]=J,J.onAdd(this.map)};O(!1),x.type!=="vector"&&x.type!=="geojson"||O(!0),P.onAdd&&P.onAdd(this.map),N.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(([O,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 N=this.getOwnSourceCaches(u);for(const P of N){const O=i.dq(P.id);delete this._sourceCaches[O],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 N=this.getOwnSourceCache(x);N&&u.push(N.getSource())}return u}areTilesLoaded(){const u=this._mergedSourceCaches;for(const x in u){const N=u[x]._tiles;for(const P in N){const O=N[P];if(O.state!=="loaded"&&O.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 O of u){if(this._validate($a,"lights",O))return;switch(O.type){case"ambient":if(this.ambientLight){const F=this.ambientLight;F.set(O),F.updateTransitions(x)}else this.ambientLight=new da(O,Eo||(Eo=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(O),F.updateTransitions(x)}else this.directionalLight=new da(O,Ma||(Ma=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 N=Object.assign(x,{worldview:this.map.getWorldview()}),P=new i.ac(this.z||0,N);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 N=he=>.2126*(he[0]<=.03928?he[0]/12.92:Math.pow((he[0]+.055)/1.055,2.4))+.7152*(he[1]<=.03928?he[1]/12.92:Math.pow((he[1]+.055)/1.055,2.4))+.0722*(he[2]<=.03928?he[2]/12.92:Math.pow((he[2]+.055)/1.055,2.4)),P=u.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),O=u.properties.get("intensity"),F=u.properties.get("direction"),U=1-i.d4(F.x,F.y,F.z)[2]/90,G=N(P)*O*U,J=x.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),te=x.properties.get("intensity"),me=N(J)*te;return Number(((G+me)/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),N=this.fragments.find(({id:O})=>O===x);if(!N)return;const P=i.dq(u);return N.style.getFragmentStyle(P)}{const x=this.fragments.find(({id:N})=>N===u);return x?x.style:void 0}}setFeaturesetSelectors(u){if(!u)return;const x={},N=(P,O="")=>`${P}::${O}`;this._featuresetSelectors={};for(const P in u){const O=this._featuresetSelectors[P]=[];for(const F of u[P].selectors){if(F.featureNamespace){const G=this.getOwnLayer(F.layer);if(!G){i.w(`Layer is undefined for selector: ${F.layer}`);continue}const J=N(G.source,G.sourceLayer);if(J in x&&x[J]!==F.featureNamespace){i.w(`"featureNamespace ${F.featureNamespace} of featureset ${P}'s selector is not associated to the same source, skip this selector`);continue}x[J]=F.featureNamespace}let U;if(F.properties)for(const G in F.properties){const J=i.U(F.properties[G]);J.result==="success"&&(U=U||{},U[G]=J.value)}O.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 N=[];for(const P in x.stylesheet.featuresets)N.push({featuresetId:P,importId:x.scope?x.scope:void 0});return N}getFeaturesetLayers(u,x){const N=this.getFragmentStyle(x),P=N.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 O=[];for(const F of P[u].selectors){const U=N.getOwnLayer(F.layer);U&&O.push(U)}return O}getConfigProperty(u,x){const N=this.getFragmentStyle(u);if(!N)return null;const P=i.B(x,N.scope),O=N.options.get(P),F=O?O.value||O.default:null;return F?F.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(u,x){const N=i.B(u,x);return this._mergedIndoor[N]}setIndoorData(u,x){this.map.indoor.setIndoorData(x)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(u,x,N){const P=this.getFragmentStyle(u);if(!P)return;const O=P.stylesheet.schema;if(!O||!O[x])return;const F=i.U(N);if(F.result!=="success")return void Ng(this,F.value);const U=F.value.expression,G=i.B(x,P.scope),J=P.options.get(G);if(!J)return;let te;const{minValue:me,maxValue:he,stepValue:fe,type:ke,values:be}=O[x],Re=i.U(O[x].default);Re.result==="success"&&(te=Re.value.expression),te?(this.options.set(G,Object.assign({},J,{value:U,default:te,minValue:me,maxValue:he,stepValue:fe,type:ke,values:be})),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 N=x.stylesheet.schema;if(!N)return null;const P={};for(const O in N){const F=i.B(O,x.scope),U=x.options.get(F),G=U?U.value||U.default:null;P[O]=G?G.serialize():null}return P}setConfig(u,x){const N=this.getFragmentStyle(u);N&&(N.updateConfig(x,N.stylesheet.schema),this.updateConfigDependencies())}getSchema(u){const x=this.getFragmentStyle(u);return x?x.stylesheet.schema:null}setSchema(u,x){const N=this.getFragmentStyle(u);N&&(N.stylesheet.schema=x,N.updateConfig(N._config,x),this.updateConfigDependencies())}updateConfig(u,x){if(this._config=u,u||x)if(x)for(const N in x){let P,O;const F=i.U(x[N].default);if(F.result==="success"&&(P=F.value.expression),u&&u[N]!==void 0){const he=i.U(u[N]);he.result==="success"&&(O=he.value.expression)}const{minValue:U,maxValue:G,stepValue:J,type:te,values:me}=x[N];if(P){const he=i.B(N,this.scope);this.options.set(he,{default:P,value:O,minValue:U,maxValue:G,stepValue:J,type:te,values:me})}else this.fire(new i.y(new Error(`No schema defined for config option "${N}".`)))}else this.fire(new i.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(u,x=()=>!0){for(const N of u){const P=this.getLayer(N);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 N=x._styleColorTheme.colorThemeOverride?x._styleColorTheme.colorThemeOverride:x._styleColorTheme.colorTheme;if(N){const P=x._evaluateColorThemeData(N);(!x._styleColorTheme.lut&&P!==""||x._styleColorTheme.lut&&P!==x._styleColorTheme.lut.data)&&x.setColorTheme(N)}}),this._changes.setDirty()}addLayer(u,x,N={}){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 O;if(u.type==="custom"){if(Ng(this,i.dt(u)))return;O=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(Mc,`layers.${P}`,u,{arrayIndex:-1},N))return;O=i.du(u,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(O),O.setEventedParent(this,{layer:{id:P}})}const F=i.B(O.source,O.scope);O.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(F),O.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(F);let U=this._order.length;if(x){const me=this._order.indexOf(x);if(me===-1)return void this.fire(new i.y(new Error(`Layer with id "${x}" does not exist on this map.`)));O.slot===this._layers[x].slot?U=me: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]=O;const G=this.getOwnLayerSourceCache(O),J=!!this.directionalLight&&this.directionalLight.shadowsEnabled();G&&O.canCastShadows()&&J&&(G.castsShadows=!0);const te=this._changes.getRemovedLayer(O);if(te&&O.source&&G&&O.type!=="custom"){this._changes.discardLayerRemoval(O);const me=i.B(O.source,O.scope);te.type!==O.type?this._changes.updateSourceCache(me,"clear"):(this._changes.updateSourceCache(me,"reload"),G.pause())}this._updateLayer(O),O.onAdd&&O.onAdd(this.map),O.scope=this.scope,this.mergeLayers()}moveLayer(u,x){this._checkLoaded();const N=this._checkLayer(u);if(!N||u===x)return;const P=this._order.indexOf(u);this._order.splice(P,1);let O=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.`)));N.slot===this._layers[x].slot?O=F:i.w(`Layer with id "${x}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(O,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 N=this._order.indexOf(u);this._order.splice(N,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 O=!1;for(const F in this._layers)if(this._layers[F].source===x.source&&this._layers[F].canCastShadows()){O=!0;break}P.castsShadows=O}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,N){this._checkLoaded();const P=this._checkLayer(u);P&&(P.minzoom===x&&P.maxzoom===N||(x!=null&&(P.minzoom=x),N!=null&&(P.maxzoom=N),this._updateLayer(P)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(u,x){this._checkLoaded();const N=this._checkLayer(u);N&&N.slot!==x&&(N.slot=x,this._updateLayer(N))}setFilter(u,x,N={}){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(No,`layers.${P.id}.filter`,x,{layerType:P.type},N)||(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,N,P={}){this._checkLoaded();const O=this._checkLayer(u);if(O&&!i.by(O.getLayoutProperty(x),N)){if(N!=null&&(!P||P.validate!==!1)&&Ng(O,nt.call(Yn,{key:`layers.${u}.layout.${x}`,layerType:O.type,objectKey:x,value:N,styleSpec:i.a6,style:{glyphs:!0,sprite:!0}})))return;O.setLayoutProperty(x,N),O.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(O.fqid),O.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(O.fqid),this._updateLayer(O)}}setLayerProperty(u,x,N,P={}){this._checkLoaded();const O=this._checkLayer(u);O&&(x==="appearances"?(O.setAppearances(N),this._changes.setDirty()):O.isPaintProperty(x)?this.setPaintProperty(u,x,N,P):this.setLayoutProperty(u,x,N,P))}getLayoutProperty(u,x){const N=this._checkLayer(u);if(N)return N.getLayoutProperty(x)}setPaintProperty(u,x,N,P={}){this._checkLoaded();const O=this._checkLayer(u);if(!O||i.by(O.getPaintProperty(x),N)||N!=null&&(!P||P.validate!==!1)&&Ng(O,Tc.call(Yn,{key:`layers.${u}.paint.${x}`,layerType:O.type,objectKey:x,value:N,styleSpec:i.a6})))return;const F=O.setPaintProperty(x,N);O.expressionDependencies.configDependencies.size!==0&&this._configDependentLayers.add(O.fqid),O.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(O.fqid),F&&this._updateLayer(O),this._changes.updatePaintProperties(O)}getPaintProperty(u,x){const N=this._checkLayer(u);if(N)return N.getPaintProperty(x)}setFeatureState(u,x){if(this._checkLoaded(),"target"in u){if("featuresetId"in u.target){const{featuresetId:G,importId:J}=u.target,te=this.getFragmentStyle(J),me=te.getFeaturesetLayers(G);for(const{source:he,sourceLayer:fe}of me)te.setFeatureState({id:u.id,source:he,sourceLayer:fe},x)}else if("layerId"in u.target){const{layerId:G}=u.target,J=this.getLayer(G);this.setFeatureState({id:u.id,source:J.source,sourceLayer:J.sourceLayer},x)}return}const N=u.source,P=u.sourceLayer,O=this._checkSource(N);if(!O)return;const F=O.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(N);for(const G of U)G.setFeatureState(P,u.id,x)}removeFeatureState(u,x){if(this._checkLoaded(),"target"in u){if("featuresetId"in u.target){const{featuresetId:G,importId:J}=u.target,te=this.getFragmentStyle(J),me=te.getFeaturesetLayers(G);for(const{source:he,sourceLayer:fe}of me)te.removeFeatureState({id:u.id,source:he,sourceLayer:fe},x)}else if("layerId"in u.target){const{layerId:G}=u.target,J=this.getLayer(G);this.removeFeatureState({id:u.id,source:J.source,sourceLayer:J.sourceLayer},x)}return}const N=u.source,P=this._checkSource(N);if(!P)return;const O=P.type,F=O==="vector"?u.sourceLayer:void 0;if(O==="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(N);for(const G of U)G.removeFeatureState(F,u.id,x)}getFeatureState(u){if(this._checkLoaded(),"target"in u){let O;if("featuresetId"in u.target){const{featuresetId:F,importId:U}=u.target,G=this.getFragmentStyle(U),J=G.getFeaturesetLayers(F);for(const{source:te,sourceLayer:me}of J){const he=G.getFeatureState({id:u.id,source:te,sourceLayer:me});if(he&&!O)O=he;else if(!i.by(O,he))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);O=this.getFeatureState({id:u.id,source:U.source,sourceLayer:U.sourceLayer})}return O}const x=u.source,N=u.sourceLayer,P=this._checkSource(x);if(P){if(P.type!=="vector"||N)return u.id===void 0&&this.fire(new i.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(x)[0].getFeatureState(N,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)},N=>N!==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),N=i.B(u.source,u.scope),P=this._changes.getUpdatedSourceCaches();u.source&&!P[N]&&x&&x.getSource().type!=="raster"&&(this._changes.updateSourceCache(N,"reload"),x.pause()),u.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(u){const x=U=>this._mergedLayers[U].is3D(!!this.terrain),N=this.order,P={},O=[];for(let U=N.length-1;U>=0;U--){const G=N[U];if(x(G)){P[G]=U;for(const J of u){const te=J[G];if(te)for(const me of te)O.push(me)}}}O.sort((U,G)=>G.intersectionZ-U.intersectionZ);const F=[];for(let U=N.length-1;U>=0;U--){const G=N[U];if(x(G))for(let J=O.length-1;J>=0;J--){const te=O[J].feature;if(te.layer&&P[te.layer.id]{if(UN.has(te.type))return;const me=this.getOwnLayerSourceCache(te),he=O[me.id]=O[me.id]||{sourceCache:me,layers:{},has3DLayers:!1};te.is3D(!!this.terrain)&&(he.has3DLayers=!0),he.layers[te.fqid]=he.layers[te.fqid]||{styleLayer:te,targets:[]},he.layers[te.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 te of x.layers){const me=this._layers[te];if(!me)return this.fire(new i.y(new Error(`The layer '${te}' does not exist in the map's style and cannot be queried for features.`))),[];F(me)}}else for(const te in this._layers)F(this._layers[te]);const U=this._queryRenderedFeatures(u,O,N),G=this._flattenAndSortRenderedFeatures(U),J=[];for(const te of G)i.dw(te.layer.id)===this.scope&&J.push(te);return J}queryRenderedFeatureset(u,x,N){let P;x&&!Array.isArray(x)&&x.filter&&(this._validate(No,"queryRenderedFeatures.filter",x.filter,null,x),P=i.b6(x.filter));const O="mock",F=[];if(x&&x.target)F.push(Object.assign({},x,{targetId:O,filter:P}));else{const te=this.getFeaturesetDescriptors();for(const me of te)F.push({targetId:O,filter:P,target:me});for(const{style:me}of this.fragments){const he=me.getFeaturesetDescriptors();for(const fe of he)F.push({targetId:O,filter:P,target:fe})}}const U=this.queryRenderedTargets(u,F,N),G=[],J=new Set;for(const te of U)for(const me of te.variants[O])_g(me,te,J)||G.push(new i.dx(te,me));return G}queryRenderedTargets(u,x,N){const P={},O=(U,G,J,te)=>{const me=P[G.id]=P[G.id]||{sourceCache:G,layers:{},has3DLayers:!1};if(me.layers[U.fqid]=me.layers[U.fqid]||{styleLayer:U,targets:[]},U.is3D(!!this.terrain)&&(me.has3DLayers=!0),!te)return J.uniqueFeatureID=!1,void me.layers[U.fqid].targets.push(J);me.layers[U.fqid].targets.push(Object.assign({},J,{namespace:te.namespace,properties:te.properties,uniqueFeatureID:te.uniqueFeatureID}))};for(const U of x)if("featuresetId"in U.target){const{featuresetId:G,importId:J}=U.target,te=this.getFragmentStyle(J);if(!te||!te._featuresetSelectors)continue;const me=te._featuresetSelectors[G];if(!me){this.fire(new i.y(new Error(`The featureset '${G}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const he of me){const fe=te.getOwnLayer(he.layerId);fe&&!UN.has(fe.type)&&O(fe,te.getOwnLayerSourceCache(fe),U,he)}}else if("layerId"in U.target){const{layerId:G}=U.target,J=this.getLayer(G);if(!J||UN.has(J.type))continue;O(J,this.getLayerSourceCache(J),U)}const F=this._queryRenderedFeatures(u,P,N);return this._flattenAndSortRenderedFeatures(F)}_queryRenderedFeatures(u,x,N){const P=[],O=!!this.map._showQueryGeometry,F=Ui.createFromScreenPoints(u,N);for(const U in x){const G=w0(F,x[U],this._availableImages,N,O);Object.keys(G).length&&P.push(G)}if(this.placement)for(const U in x){if(!x[U].sourceCache._onlySymbols)continue;const G=j0(F.screenGeometry,x[U],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(G).length&&P.push(G)}return P}querySourceFeatures(u,x){const N=x&&x.filter;N&&this._validate(No,"querySourceFeatures.filter",N,null,x);let P=[];const O=this.getOwnSourceCaches(u);for(const F of O)P=P.concat(k0(F,x));return P}addSourceType(u,x,N){return Eh.getSourceType(u)?N(new Error(`A source type called "${u}" already exists.`)):(Eh.setSourceType(u,x),x.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:u,url:x.workerSourceURL},N):N(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(u,x,N={}){this._checkLoaded();const P=this.light.getLight();let O=!1;for(const U in u)if(!i.by(u[U],P[U])){O=!0;break}if(!O)return;const F=this._getTransitionParameters();this.light.setLight(u,x,N),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 N=u;const P=!("source"in u)||u.source==null;if(x===1){if(this.disableElevatedTerrain)return;if("source"in N&&typeof N.source=="object"){const U="terrain-dem-src";this.addSource(U,N.source),N=i.dp(N),N=Object.assign(N,{source:U})}const O=Object.assign({},N),F={};if(this.terrain&&P){O.source=this.terrain.get().source;const U=this.terrain?this.getFragmentStyle(this.terrain.scope):null;U&&(F.style=U.serialize())}if(this._validate(xo,"terrain",O,F))return}if(!this.terrain||this.terrain.scope!==this.scope&&!P||this.terrain&&x!==this.terrain.drapeRenderMode){if(!N)return;this._createTerrain(N,x),this.fire(new i.z("data",{dataType:"style"}))}else{const O=this.terrain,F=O.get();for(const U of Object.keys(i.a6.terrain))!N.hasOwnProperty(U)&&i.a6.terrain[U].default&&(N[U]=i.a6.terrain[U].default);for(const U in u)if(!i.by(u[U],F[U])){O.set(u,this.options),this.stylesheet.terrain=u;const G=this._getTransitionParameters({duration:0});O.updateTransitions(G),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(u){const x=this.fog=new hn(u,this.map.transform,this.scope,this.options);this.stylesheet.fog=x.get();const N=this._getTransitionParameters({duration:0});x.updateTransitions(N)}_createSnow(u){const x=this.snow=new Do(u,this.map.transform,this.scope,this.options);this.stylesheet.snow=x.get();const N=this._getTransitionParameters({duration:0});x.updateTransitions(N)}_createRain(u){const x=this.rain=new $i(u,this.map.transform,this.scope,this.options);this.stylesheet.rain=x.get();const N=this._getTransitionParameters({duration:0});x.updateTransitions(N)}_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 N=this._getTransitionParameters({duration:0});x.updateTransitions(N)}}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 N=this._getTransitionParameters({duration:0});x.updateTransitions(N)}}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 N=this._getTransitionParameters({duration:0});x.updateTransitions(N)}}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 N=this._evaluateColorThemeData(x);this._loadColorTheme(N).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 N=this.getFragmentStyle(u);N&&(N._styleColorTheme.colorThemeOverride=x,N._reloadColorTheme())}_getTransitionParameters(u){return{now:i.o.now(),transition:Object.assign(this.transition,u)}}updateDrapeFirstLayers(){if(!this.terrain)return;const u=[],x=[];for(const N of this._mergedOrder)this.isLayerDraped(this._mergedLayers[N])?u.push(N):x.push(N);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...u),this._drapedFirstOrder.push(...x)}_createTerrain(u,x){const N=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});N.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,N,P,O={}){if(O&&O.validate===!1)return!1;const F=Object.assign({},this.serialize());return Ng(this,u.call(Yn,Object.assign({key:x,style:F,value:N,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 N of x)N.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 N of x)N.resume(),N.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=k_(this.directionalLight));const N=new Set,P=new Set;for(const O in this._mergedLayers){const F=this._mergedLayers[O];F.type==="building"&&N.add(F.source),F.hasElevation()&&!P.has(F.source)&&P.add(F.source)}for(const O in this._mergedSourceCaches){const F=this._mergedSourceCaches[O],U=P.has(F._source.id);N.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,N,P,O,F,U=!1){let G=!1,J=!1;const te={},me={};for(const be of this._mergedOrder){const Re=this._mergedLayers[be];if(Re.type!=="symbol")continue;const Oe=i.B(Re.source,Re.scope);let Ge=te[Oe];if(!Ge){const Ke=this.getLayerSourceCache(Re);if(!Ke)continue;const Nt=Ke.getRenderableIds(!0).map(xt=>Ke.getTileByID(xt));me[Oe]=Nt.slice(),Ge=te[Oe]=Nt.sort((xt,bt)=>bt.tileID.overscaledZ-xt.tileID.overscaledZ||(xt.tileID.isLessThan(bt.tileID)?-1:1))}const at=this.crossTileSymbolIndex.addLayer(Re,Ge,x.center.lng,x.projection);G=G||at}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),U=U||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const he=!!(this.placement&&!x.equals(this.placement.transform)),fe=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!F||this.placement.lastReplacementSourceUpdateTime!==F.updateTime)),ke=(he||fe||G||this.placement&&this.placement.isStale())&&P===0;if((U||!this.pauseablePlacement||ke||P!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),x.zoom))&&(this.pauseablePlacement=new Ml(x,this._mergedOrder,U||P===0,N,P,O,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,te,me,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),J=!0),G&&this.pauseablePlacement.placement.setStale()),J||G){this._buildingIndex.onNewFrame(x.zoom);for(let be=0;beO===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 N.push(u),this._loadImports([u],!0);const P=N.findIndex(({id:O})=>O===x);return P===-1&&this.fire(new i.y(new Error(`Import with id "${x}" does not exist on this map.`))),this.stylesheet.imports=N.slice(0,P).concat(u).concat(N.slice(P)),this._loadImports([u],!0,x)}updateImport(u,x){this._checkLoaded();const N=this.stylesheet.imports||[],P=this.getImportIndex(u);return P===-1?this:typeof x=="string"?(this.setImportUrl(u,x),this):(x.url&&x.url!==N[P].url&&this.setImportUrl(u,x.url),i.by(x.config,N[P].config)||this.setImportConfig(u,x.config,x.data.schema),i.by(x.data,N[P].data)||this.setImportData(u,x.data),this)}moveImport(u,x){this._checkLoaded();let N=this.stylesheet.imports||[];const P=this.getImportIndex(u);if(P===-1)return this;const O=this.getImportIndex(x);if(O===-1)return this;const F=N[P],U=this.fragments[P];return N=N.filter(({id:G})=>G!==u),this.fragments=this.fragments.filter(({id:G})=>G!==u),this.stylesheet.imports=N.slice(0,O).concat(F).concat(N.slice(O)),this.fragments=this.fragments.slice(0,O).concat(U).concat(this.fragments.slice(O)),this.mergeLayers(),this}setImportUrl(u,x){this._checkLoaded();const N=this.stylesheet.imports||[],P=this.getImportIndex(u);if(P===-1)return this;N[P].url=x;const O=this.fragments[P];return O.style=this._createFragmentStyle(N[P]),O.style.on("style.import.load",()=>this.mergeAll()),O.style.loadURL(x),this}setImportData(u,x){this._checkLoaded();const N=this.getImportIndex(u),P=this.stylesheet.imports||[];return N===-1?this:x?(this.fragments[N].style.setState(x),this._reloadImports(),this):(delete P[N].data,this.setImportUrl(u,P[N].url))}setImportConfig(u,x,N){this._checkLoaded();const P=this.getImportIndex(u),O=this.stylesheet.imports||[];if(P===-1)return this;x?O[P].config=x:delete O[P].config;const F=this.fragments[P];N&&F.style.stylesheet&&(F.style.stylesheet.schema=N);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||[],N=this.getImportIndex(u);N!==-1&&(x.splice(N,1),this.fragments[N].style._remove(),this.fragments.splice(N,1),this._reloadImports())}getImportIndex(u){const x=(this.stylesheet.imports||[]).findIndex(N=>N.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 N=this._mergedOtherSourceCaches[x];N&&u.push(N.getSource())}return u}getSource(u,x){const N=this.getSourceCache(u,x);return N&&N.getSource()}getLayerSource(u){const x=this.getLayerSourceCache(u);return x&&x.getSource()}getSourceCache(u,x){const N=i.B(u,x);return this._mergedOtherSourceCaches[N]}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 N=u[x];N==="reload"?this.reloadSource(x):N==="clear"&&this.clearSource(x)}}updateLayers(u){const x=this._changes.getUpdatedPaintProperties();for(const N of x){const P=this.getLayer(N);P&&P.updateTransitions(u)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(u){this.stylesheet.glyphs=u,this.glyphManager.setURL(u)}getImages(u,x,N){this.imageManager.getImages(x.images,x.scope,N),this._updateTilesForChangedImages();const P=F=>{if(F){const U=x.images.map(G=>i.I.toString(G));F.setDependencies(x.tileID.key,x.type,U)}},O=i.B(x.source,x.scope);P(this._mergedOtherSourceCaches[O]),P(this._mergedSymbolSourceCaches[O]),x.images.some(F=>F.iconsetId)&&this.fire(new i.z("data",{dataType:"style"}))}rasterizeImages(u,x,N){this.imageManager.rasterizeImages(x,N)}getGlyphs(u,x,N){this.glyphManager.getGlyphs(x.stacks,N)}getResource(u,x,N){return i.dz(x,N)}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(N=>N.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 N=u.type==="fill-extrusion"&&(u.sourceLayer==="building"||u.sourceLayer==="procedural_buildings"),P=u.type==="building";if(u.is3D(!!this.terrain)){if(N||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)}}Eh.getSourceType=function(j){return Ch[j]},Eh.setSourceType=function(j,u){Ch[j]=u},Eh.registerForPluginStateChange=i.dA;class oL 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,N]of Object.entries(u.buildings))if(this._buildings[x])for(const P of N.floorIds)this._buildings[x].floors[P]||(this._buildings[x].floors[P]=N.floors[P]);else this._buildings[x]=N;for(const x of u.activeFloors)this._activeFloors.add(x);this._updateIndoorSelector()}getIndoorTileOptions(u,x){const N=this._style.getIndoorSourceLayers(u,x);return N&&this._indoorState?{sourceLayers:N,indoorState:this._indoorState}:null}_updateUI(u,x,N){const P=function(O,F,U,G){let J=null,te=Number.MAX_SAFE_INTEGER;if(G<16)return null;for(const[me,he]of Object.entries(O)){const fe=he.center;if(fe){const ke=F.distanceTo(i.aT.convert(fe));ke({id:F,name:N.floors[F].name,zIndex:N.floors[F].zIndex})).sort((F,U)=>U.zIndex-F.zIndex);this.fire(new i.z("selector-update",{selectedFloorId:P,activeFloorsVisible:this._activeFloorsVisible,floors:O}))}_updateActiveFloors(){const u=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:u,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var I0=` #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`,P0=` #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;}`,gM=` #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`,VN="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;}",Zu=` #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`,qN=`#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`,Br=`#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`,xM=`#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`,HN=`#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;}`,WN=`#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`,yM=`#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 S_=/#include\s+"([^"]+)"/g,rf=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,vM=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,Ux=new Set(["ifdef","ifndef","elif","if","defined"]),Vx=new Set;Mg(I0,Vx),Mg(gM,Vx),Mg(P0,Vx);const Cg={"_prelude_fog.vertex.glsl":qN,"_prelude_terrain.vertex.glsl":Zu,"_prelude_shadow.vertex.glsl":WN,"_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":Br,"_prelude_shadow.fragment.glsl":yM,"_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":xM,"_prelude_raster_particle.glsl":HN},GN={};fa("",Zu),fa(Br,qN),fa(yM,WN),fa(xM,""),fa(HN,"");const lL=fa(P0,gM),KN=I0,Mle=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",KN,lL.fragmentSource].join(` `),cL=["precision highp float;",KN,lL.vertexSource].join(` `);var _M={background:fa(`#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:fa(`#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:fa(`#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:fa(`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:fa(`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:fa(`#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:fa("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:fa(`#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:fa(`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:fa("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:fa("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:fa("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:fa(`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:fa(`#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:fa(`#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:fa(`#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:fa(`#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:fa(`#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:fa(`#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:fa(`#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:fa(`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:fa(`#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:fa(`#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:fa(`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:fa(`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:fa(`#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:fa(`#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:fa(`#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:fa(`#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:fa(`#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:fa("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:fa("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:fa(`#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:fa(`#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:fa(`#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:fa("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:fa(`#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 }`,VN),skyboxGradient:fa(`#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 }`,VN),skyboxCapture:fa(` 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:fa(`#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:fa(`#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:fa(`#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:fa(`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:fa(`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:fa("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:fa("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:fa("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:fa("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 Mg(j,u){const x=j.split(` `);for(let N of x){if(N=N.trimStart(),N[0]!=="#"||!N.includes("if")||N.startsWith("#endif"))continue;const P=N.match(vM);if(P)for(const O of P)Ux.has(O)||u.add(O)}}function fa(j,u){const x=new Set,N=[],P=[];j=j.replace(S_,(F,U)=>(P.push(U),"")),u=u.replace(S_,(F,U)=>(N.push(U),""));let O=new Set(Vx);Mg(j,O),Mg(u,O);for(const F of[...N,...P])GN[F]||(GN[F]=new Set,Mg(Cg[F],GN[F])),O=new Set([...O,...GN[F]]);return{fragmentSource:j=j.replace(rf,(F,U,G,J,te)=>(x.add(te),U==="define"?` #ifndef HAS_UNIFORM_u_${te} in ${G} ${J} ${te}; #else uniform ${G} ${J} u_${te}; #endif `:U==="initialize"?` #ifdef HAS_UNIFORM_u_${te} ${G} ${J} ${te} = u_${te}; #endif `:U==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${te} in ${G} ${J} ${te}; #endif `:U==="initialize-attribute"?"":void 0)),vertexSource:u=u.replace(rf,(F,U,G,J,te)=>{const me=`MATERIAL_ATTRIBUTE_OFFSET_${te}`,he=J==="float"?"vec2":J,fe=`GET_ATTRIBUTE_${he}(a_${te}, materialInfo, ${me})`,ke=te.match(/color/)?"color":he;return U==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${te} in ${G} ${J} a_${te}; #endif `:x.has(te)?U==="define"?` #ifndef HAS_UNIFORM_u_${te} uniform lowp float u_${te}_t; #if !defined(${me}) in ${G} ${he} a_${te}; #endif out ${G} ${J} ${te}; #else uniform ${G} ${J} u_${te}; #endif `:U==="initialize"?ke==="vec4"?` #ifndef HAS_UNIFORM_u_${te} ${te} = a_${te}; #else ${G} ${J} ${te} = u_${te}; #endif `:` #if !defined(HAS_UNIFORM_u_${te}) #ifdef ${me} ${te} = unpack_mix_${ke}(${fe}, u_${te}_t); #else ${te} = unpack_mix_${ke}(a_${te}, u_${te}_t); #endif #else ${G} ${J} ${te} = u_${te}; #endif `:U==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${te} in ${G} ${J} a_${te}; out ${G} ${J} ${te}; #endif `:U==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${te} ${te} = a_${te}; #endif `:void 0:U==="define"?` #ifndef HAS_UNIFORM_u_${te} uniform lowp float u_${te}_t; #if !defined(${me}) in ${G} ${he} a_${te}; #endif #else uniform ${G} ${J} u_${te}; #endif `:U==="define-instanced"?ke==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${te}0; in vec4 a_${te}1; in vec4 a_${te}2; in vec4 a_${te}3; #else uniform ${G} ${J} u_${te}; #endif `:` #ifdef INSTANCED_ARRAYS in ${G} ${he} a_${te}; #else uniform ${G} ${J} u_${te}; #endif `:U==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${te} ${G} ${J} ${te} = a_${te}; #endif `:ke==="vec4"?` #ifndef HAS_UNIFORM_u_${te} #ifdef ${me} ${G} ${J} ${te} = ${fe}; #else ${G} ${J} ${te} = a_${te}; #endif #else ${G} ${J} ${te} = u_${te}; #endif `:` #ifndef HAS_UNIFORM_u_${te} #ifdef ${me} ${G} ${J} ${te} = unpack_mix_${ke}(${fe}, u_${te}_t); #else ${G} ${J} ${te} = unpack_mix_${ke}(a_${te}, u_${te}_t); #endif #else ${G} ${J} ${te} = u_${te}; #endif `}),usedDefines:O,vertexIncludes:N,fragmentIncludes:P}}class Tle{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(u,x,N,P,O,F,U,G){this.context=u;let J=this.boundPaintVertexBuffers.length!==P.length;for(let me=0;!J&&me{const Nt=at.paint.get("hillshade-shadow-color"),xt=at.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",bt=at.paint.get("hillshade-highlight-color"),gt=at.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",ht=at.paint.get("hillshade-accent-color"),At=at.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Bt=at.paint.get("hillshade-emissive-strength");let zt=i.an(at.paint.get("hillshade-illumination-direction"));if(at.paint.get("hillshade-illumination-anchor")==="viewport")zt-=Oe.transform.angle;else if(Oe.style&&Oe.style.enable3dLights()&&Oe.style.directionalLight){const er=Oe.style.directionalLight.properties.get("direction"),ur=i.d4(er.x,er.y,er.z);zt=i.an(ur[1])}const Jt=!Oe.options.moving;return{u_matrix:Ke||Oe.transform.calculateProjMatrix(Ge.tileID.toUnwrapped(),Jt),u_image:0,u_latrange:Ale(0,Ge.tileID),u_light:[at.paint.get("hillshade-exaggeration"),zt],u_shadow:Nt.toPremultipliedRenderColor(xt?null:at.lut),u_highlight:bt.toPremultipliedRenderColor(gt?null:at.lut),u_emissive_strength:Bt,u_accent:ht.toPremultipliedRenderColor(At?null:at.lut)}})(j,x,N,j.terrain?u.projMatrix:null);j.uploadCommonUniforms(U,he,u.toUnwrapped());const{tileBoundsBuffer:ke,tileBoundsIndexBuffer:be,tileBoundsSegments:Re}=j.getTileBoundsBuffers(x);he.draw(j,G.TRIANGLES,P,O,F,Ys.disabled,fe,N.id,ke,be,Re)}function bM(j,u,x){if(!u.needsDEMTextureUpload)return;const N=j.context,P=N.gl;N.pixelStoreUnpackPremultiplyAlpha.set(!1),u.demTexture=u.demTexture||j.getTileTexture(x.stride);const O=x.getPixels();u.demTexture?u.demTexture.update(O,{premultiply:!1}):u.demTexture=new i.T(N,O,P.R32F,{premultiply:!1}),u.needsDEMTextureUpload=!1}function Ile(j,u,x){const N=j.context,P=N.gl;if(!u.dem)return;const O=u.dem;if(N.activeTexture.set(P.TEXTURE1),bM(j,u,O),!u.demTexture)return;u.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);const F=O.dim;N.activeTexture.set(P.TEXTURE0);let U=u.hillshadeFBO;if(!U){const he=new i.T(N,{width:F,height:F,data:null},P.RGBA8);he.bind(P.LINEAR,P.CLAMP_TO_EDGE),U=u.hillshadeFBO=N.createFramebuffer(F,F,1,"renderbuffer"),U.colorAttachment0.set(he.texture)}N.bindFramebuffer.set(U.framebuffer),N.viewport.set([0,0,F,F]);const{tileBoundsBuffer:G,tileBoundsIndexBuffer:J,tileBoundsSegments:te}=j.getMercatorTileBoundsBuffers(),me=[];j.linearFloatFilteringSupported()&&me.push("TERRAIN_DEM_FLOAT_FORMAT"),j.terrain&&j.terrain.renderingToTexture&&j.emissiveMode==="mrt-fallback"&&me.push("USE_MRT1"),j.getOrCreateProgram("hillshadePrepare",{defines:me}).draw(j,P.TRIANGLES,ks.disabled,Js.disabled,wn.unblended,Ys.disabled,((he,fe)=>{const ke=fe.stride,be=i.bC();return i.ce(be,0,i.al,-i.al,0,0,1),i.br(be,be,[0,-i.al,0]),{u_matrix:be,u_image:1,u_dimension:[ke,ke],u_zoom:he.overscaledZ}})(u.tileID,O),x.id,G,J,te),u.needsHillshadePrepare=!1}class qi{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 Ple extends qi{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 dL extends qi{getDefault(){return 1}set(u){(u!==this.current||this.dirty)&&(this.gl.clearDepth(u),this.current=u,this.dirty=!1)}}class wM extends qi{getDefault(){return 0}set(u){(u!==this.current||this.dirty)&&(this.gl.clearStencil(u),this.current=u,this.dirty=!1)}}class ZN extends qi{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 jM extends qi{getDefault(){return!0}set(u){(u!==this.current||this.dirty)&&(this.gl.depthMask(u),this.current=u,this.dirty=!1)}}class qx extends qi{getDefault(){return 255}set(u){(u!==this.current||this.dirty)&&(this.gl.stencilMask(u),this.current=u,this.dirty=!1)}}class L0 extends qi{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 C_ extends qi{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 D0 extends qi{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 uL extends qi{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 kM extends qi{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 hL extends qi{getDefault(){return this.gl.LESS}set(u){(u!==this.current||this.dirty)&&(this.gl.depthFunc(u),this.current=u,this.dirty=!1)}}class O0 extends qi{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 YN extends qi{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 XN extends qi{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 NM extends qi{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 QN extends qi{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 M_ extends qi{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 qi{getDefault(){return this.gl.CCW}set(u){(u!==this.current||this.dirty)&&(this.gl.frontFace(u),this.current=u,this.dirty=!1)}}let fL=class extends qi{getDefault(){return null}set(j){(j!==this.current||this.dirty)&&(this.gl.useProgram(j),this.current=j,this.dirty=!1)}};class pL extends qi{getDefault(){return this.gl.TEXTURE0}set(u){(u!==this.current||this.dirty)&&(this.gl.activeTexture(u),this.current=u,this.dirty=!1)}}class R0 extends qi{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 gL extends qi{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 Lle extends qi{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 Dle extends qi{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 Ole extends qi{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 SM extends qi{getDefault(){return null}set(u){const x=this.gl;x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,u),this.current=u,this.dirty=!1}}class CM extends qi{getDefault(){return null}set(u){this.gl&&(u!==this.current||this.dirty)&&(this.gl.bindVertexArray(u),this.current=u,this.dirty=!1)}}class MM extends qi{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 TM extends qi{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 xL extends qi{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 JN extends qi{constructor(u,x){super(u),this.context=u,this.parent=x}getDefault(){return null}}class eS extends JN{constructor(u,x,N=0){super(u,x),this.attachmentPoint=u.gl.COLOR_ATTACHMENT0+N}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 F0 extends JN{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 T_ extends JN{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 yL extends F0{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const Yu=(j,u,x,N)=>({u_matrix:j,u_image0:0,u_image1:1,u_skirt_height:u,u_ground_shadow_factor:x,u_emissive_texture_available:N}),tS=(j,u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re)=>({u_proj_matrix:Float32Array.from(j),u_globe_matrix:u,u_normalize_matrix:Float32Array.from(N),u_merc_matrix:x,u_zoom_transition:P,u_merc_center:O,u_image0:0,u_image1:1,u_frustum_tl:F,u_frustum_tr:U,u_frustum_br:G,u_frustum_bl:J,u_globe_pos:te,u_globe_radius:me,u_viewport:he,u_grid_matrix:Re?Float32Array.from(Re):new Float32Array(9),u_skirt_height:fe,u_far_z_cutoff:ke,u_emissive_texture_available:be});function A_(j,u){return j!=null&&u!=null&&!(!j.hasData()||!u.hasData())&&j.demTexture!=null&&u.demTexture!=null&&j.tileID.key!==u.tileID.key}const ip=new class{constructor(){this.operations={}}newMorphing(j,u,x,N,P){if(j in this.operations){const O=this.operations[j];O.to.tileID.key!==x.tileID.key&&(O.queued=x)}else this.operations[j]={startTime:N,phase:0,duration:P,from:u,to:x,queued:null}}getMorphValuesForProxy(j){if(!(j in this.operations))return null;const u=this.operations[j];return{from:u.from,to:u.to,phase:u.phase}}update(j){for(const u in this.operations){const x=this.operations[u];for(x.phase=(j-x.startTime)/x.duration;x.phase>=1||!this._validOp(x);)if(!this._nextOp(x,j)){delete this.operations[u];break}}}_nextOp(j,u){return!!j.queued&&(j.from=j.to,j.to=j.queued,j.queued=null,j.phase=0,j.startTime=u,!0)}_validOp(j){return j.from.hasData()&&j.to.hasData()}},rS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function sS(j,u,x){if(u===0)return 0;const N=u<1&&x===514?.25/u:1;return 6*Math.pow(1.5,22-j)*Math.max(u,1)*N}function AM(j,u){const x=1<({u_matrix:j});function I_(j,u,x,N,P){if(P>0){const O=i.o.now(),F=(O-j.timeAdded)/P,U=u?(O-u.timeAdded)/P:-1,G=x.getSource(),J=N.coveringZoomLevel({tileSize:G.tileSize,roundZoom:G.roundZoom}),te=!u||Math.abs(u.tileID.overscaledZ-J)>Math.abs(j.tileID.overscaledZ-J),me=te&&j.refreshedUponExpiration?1:i.aA(te?F:1-U,0,1);return u?{opacity:1,mix:1-me,isFading:F<1}:{opacity:me,mix:0,isFading:F<1}}return{opacity:1,mix:0,isFading:!1}}class nS extends Ed{constructor(u){const x=tl("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 EM extends Ed{constructor(u){const x=tl("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,N){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((O,F)=>{if(O[F.key]="",!this._tiles[F.key]){const U=new tp(F,this._source.tileSize*F.overscaleFactor(),u.tileZoom,void 0,void 0,this._source.worldview);U.state="loaded",this._tiles[F.key]=U}return O},{});for(const O in this._tiles)O in P||(this.freeFBO(O),this._tiles[O].unloadVectorData(),delete this._tiles[O])}freeFBO(u){const x=this.proxyCachedFBO[u];if(x!==void 0){const N=Object.values(x);this.renderCachePool.push(...N),delete this.proxyCachedFBO[u]}}deallocRenderCache(){this.renderCache.forEach(u=>u.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class IM extends i.aQ{constructor(u,x,N){super(u.overscaledZ,u.wrap,u.canonical.z,u.canonical.x,u.canonical.y),this.proxyTileKey=x,this.projMatrix=N}}class PM extends i.bV{constructor(u,x){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},this.painter=u,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[N,P,O]=function(G){const J=new i.bd,te=new i.b0,me=131;J.reserve(17161),te.reserve(33800);const he=i.al/128,fe=i.al+he/2,ke=fe+he;for(let Re=-he;Refe||Re<0||Re>fe?24575:0,at=i.aA(Math.round(Oe),0,i.al),Ke=i.aA(Math.round(Re),0,i.al);J.emplaceBack(at+Ge,Ke)}const be=(Re,Oe)=>{const Ge=Oe*me+Re;te.emplaceBack(Ge+1,Ge,Ge+me),te.emplaceBack(Ge+me,Ge+me+1,Ge+1)};for(let Re=1;Re<129;Re++)for(let Oe=1;Oe<129;Oe++)be(Oe,Re);return[0,129].forEach(Re=>{for(let Oe=0;Oe<130;Oe++)be(Oe,Re),be(Re,Oe)}),[J,te,32768]}(),F=u.context;this.gridBuffer=F.createVertexBuffer(N,i.bf.members),this.gridIndexBuffer=F.createIndexBuffer(P),this.gridSegments=i.bg.simpleSegment(0,0,N.length,P.length),this.gridNoSkirtSegments=i.bg.simpleSegment(0,0,N.length,O),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new EM(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 Js({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 nS(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,N){if(u&&u.terrain){this._style!==u&&(this.style=u,this._evaluationZoom=void 0);const P=u.terrain.properties,O=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,G=P.get("source"),J=O?this._mockSourceCache:u.getSourceCache(G,U);if(!J)return void i.w(`Couldn't find terrain source "${G}".`);if(this.sourceCache=J,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 te=()=>{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 me=this.getScaledDemTileSize();this.sourceCache.update(x,me,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,te(),this._initializing=!0),te(),x.updateElevation(!0,N),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,N=u.getFreeCameraOptions().position.z/u.pixelsPerMeter*u.worldSize;this._previousCameraAltitude=N;const P=x!=null?N-x:Number.MAX_VALUE;if(Math.abs(P)<2)return this._exaggeration;const O=u.zoom,F=this._style.terrain;if(!this._previousUpdateTimestamp)return F.getExaggeration(O);let U=O-this._previousZoom;const G=this._previousUpdateTimestamp;let J=O;this._evaluationZoom!=null&&(J=this._evaluationZoom,Math.abs(O-J)>.5&&(U=.5*(O-J+U)),U*P<0&&(J+=U)),this._evaluationZoom=J;const te=F.getExaggeration(J),me=te===F.getExaggeration(Math.max(0,J-.1));if(me&&Math.abs(te-this._exaggeration)<.01)return te;let he=Math.min(.1,.00375*(this._updateTimestamp-G));return(me||te<.1||Math.abs(U)<1e-4)&&(he=Math.min(.2,4*he)),i.ak(this._exaggeration,te,he)}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,N=this.painter.transform;this._initializing&&(this._initializing=N._centerAltitude===0&&this.getAtPointOrZero(i.ae.fromLngLat(N.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const P=this.proxyCoords=x.getIds().map(G=>{const J=x.getTileByID(G).tileID;return J.projMatrix=N.calculateProjMatrix(J.toUnwrapped()),J});(function(G,J){const te=J.transform.pointCoordinate(J.transform.getCameraPoint()),me=new i.P(te.x,te.y);G.sort((he,fe)=>{if(fe.overscaledZ-he.overscaledZ)return fe.overscaledZ-he.overscaledZ;const ke=new i.P(he.canonical.x+(1<{this.proxyToSource[G.key]={}}),this.terrainTileForTile={};const F=this._style._mergedSourceCaches;for(const G in F){const J=F[G];if(!J.used||(J!==this.sourceCache&&this.resetTileLookupCache(J.id),this._setupProxiedCoordsForOrtho(J,u[G],O),J.usedForTerrain))continue;const te=u[G];J.getSource().reparseOverscaled&&this._assignTerrainTiles(te)}this.proxiedCoords[x.id]=P.map(G=>new IM(G,G.key,this.orthoMatrix)),this._assignTerrainTiles(P),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(O),this.renderingToTexture=!1;const U={};this._visibleDemTiles=[];for(const G of this.proxyCoords){const J=this.terrainTileForTile[G.key];if(!J)continue;const te=J.tileID.key;te in U||(this._visibleDemTiles.push(J),U[te]=te)}}_assignTerrainTiles(u){this._initializing||u.forEach(x=>{if(this.terrainTileForTile[x.key])return;const N=this._findTileCoveringTileID(x,this.sourceCache);N&&(this.terrainTileForTile[x.key]=N)})}_prepareDEMTextures(){const u=this.painter.context,x=u.gl;for(const N in this.terrainTileForTile){const P=this.terrainTileForTile[N],O=P.dem;!O||P.demTexture&&!P.needsDEMTextureUpload||(u.activeTexture.set(x.TEXTURE1),bM(this.painter,P,O))}}_prepareDemTileUniforms(u,x,N,P){if(!x||x.demTexture==null)return!1;const O=u.tileID.canonical,F=Math.pow(2,x.tileID.canonical.z-O.z),U=P||"";return N[`u_dem_tl${U}`]=[O.x*F%1,O.y*F%1],N[`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((N,P)=>{if(!P.dem)return N;const O=P.dem.tree.minimums[0];return O>0&&u++,N+O},0);return u?x/u:0}_updateEmptyDEMTexture(){const u=this.painter.context,x=u.gl;u.activeTexture.set(x.TEXTURE2);const N=this._getLoadedAreaMinimum(),P=new i.dL({width:1,height:1},new Float32Array([N]));this._emptyDEMTextureDirty=!1;let O=this._emptyDEMTexture;return O?O.update(P,{premultiply:!1}):O=this._emptyDEMTexture=new i.T(u,P,x.R32F,{premultiply:!1}),O}setupElevationDraw(u,x,N){const P=this.painter.context,O=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,G=null,J=1;if(N&&N.morphing&&this._useVertexMorphing){const fe=N.morphing.srcDemTile,ke=N.morphing.dstDemTile;J=N.morphing.phase,fe&&ke&&(this._prepareDemTileUniforms(u,fe,F,"_prev")&&(G=fe),this._prepareDemTileUniforms(u,ke,F)&&(U=ke))}const te=fe=>fe&&fe.demTexture&&this.painter.linearFloatFilteringSupported()?O.LINEAR:O.NEAREST;let me=null;var he;if(this.enabled?G&&U?(me=U.demTexture,P.activeTexture.set(O.TEXTURE4),G.demTexture.bind(te(G),O.CLAMP_TO_EDGE),F.u_dem_lerp=J):(U=this.terrainTileForTile[u.tileID.key],me=this._prepareDemTileUniforms(u,U,F)?U.demTexture:this.emptyDEMTexture):me=this.emptyDEMTexture,P.activeTexture.set(O.TEXTURE2),me&&(F.u_dem_size=(he=me).size[0]===1?1:he.size[0]-2,me.bind(te(U),O.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(N&&N.useDepthForOcclusion,x,F),N&&N.useMeterToDem&&U){const fe=(1<{if(Oe===er)return;const ur=[rS[er],"PROJECTION_GLOBE_VIEW"];at&&ur.push("CUSTOM_ANTIALIASING");const Cr=J.isTileAffectedByFog(Jt);Re=J.getOrCreateProgram("globeRaster",{defines:ur,overrideFog:Cr}),Oe=er},Nt=J.colorModeForRenderPass(),xt=new ks(be.LEQUAL,ks.ReadWrite,J.depthRangeFor3D);ip.update(fe);const bt=i.dF(Ge),gt=[i.aF(Ge.center.lng),i.aJ(Ge.center.lat)],ht=J.globeSharedBuffers,At=[Ge.width*i.o.devicePixelRatio,Ge.height*i.o.devicePixelRatio],Bt=Float32Array.from(Ge.globeMatrix),zt={useDenormalizedUpVectorScale:!0};{const Jt=J.transform,er=sS(Jt.zoom,te.exaggeration(),te.sourceCache._source.tileSize);Oe=-1;const ur=be.TRIANGLES;for(const Cr of he){const Kt=me.getTile(Cr),Lt=Js.disabled,nr=te.prevTerrainTileForTile[Cr.key],Xt=te.terrainTileForTile[Cr.key];A_(nr,Xt)&&ip.newMorphing(Cr.key,nr,Xt,fe,250),z0(J,Kt.emissiveTexture),ke.activeTexture.set(be.TEXTURE0),Kt.texture&&Kt.texture.bind(be.LINEAR,be.CLAMP_TO_EDGE);const gr=ip.getMorphValuesForProxy(Cr.key),qr=gr?1:0;gr&&Object.assign(zt,{morphing:{srcDemTile:gr.from,dstDemTile:gr.to,phase:i.dD(gr.phase)}});const rs=i.dG(Cr.canonical),Or=i.dH(rs.getCenter().lat),Tr=i.dI(Cr.canonical,rs,Or,Jt.worldSize/Jt._pixelsPerMercatorPixel),vs=i.bk(i.dJ(Cr.canonical)),ps=J.emissiveMode==="mrt-fallback"?1:0,Qr=tS(Jt.expandedFarZProjMatrix,Bt,bt,vs,i.aj(Jt.zoom),gt,Jt.frustumCorners.TL,Jt.frustumCorners.TR,Jt.frustumCorners.BR,Jt.frustumCorners.BL,Jt.globeCenterInViewSpace,Jt.globeRadius,At,er,Jt._farZ,ps,Tr);if(Ke(Cr,qr),Re&&(te.setupElevationDraw(Kt,Re,zt),J.uploadCommonUniforms(ke,Re,Cr.toUnwrapped()),ht)){const[ns,Ps,mn]=ht.getGridBuffers(Or,er!==0);Re.draw(J,ur,xt,Lt,Nt,Ys.backCCW,Qr,"globe_raster",ns,Ps,mn)}}}if(ht&&(J.renderDefaultNorthPole||J.renderDefaultSouthPole)){const Jt=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];at&&Jt.push("CUSTOM_ANTIALIASING"),Re=J.getOrCreateProgram("globeRaster",{defines:Jt});for(const er of he){const{x:ur,y:Cr,z:Kt}=er.canonical,Lt=Cr===0,nr=Cr===(1<ns.draw(J,be.TRIANGLES,xt,Js.disabled,Nt,Ys.disabled,tS(Ge.expandedFarZProjMatrix,Tr,Tr,vs,0,gt,Ge.frustumCorners.TL,Ge.frustumCorners.TR,Ge.frustumCorners.BR,Ge.frustumCorners.BL,Ge.globeCenterInViewSpace,Ge.globeRadius,At,0,Ge._farZ,ps),"globe_pole_raster",Ps,qr,rs);te.setupElevationDraw(Or,Re,zt),J.uploadCommonUniforms(ke,Re,er.toUnwrapped()),Lt&&J.renderDefaultNorthPole&&Qr(Re,Xt),nr&&J.renderDefaultSouthPole&&(Tr=i.cS(i.bC(),Tr,[1,-1,1]),Qr(Re,gr))}}}})(P,O,F,U,G);else{const J=P.context,te=J.gl;let me,he;const fe=P.shadowRenderer,ke=jg(P,P.longestCutoffRange),be=Nt=>{if(he===Nt)return;const xt=[];xt.push(rS[Nt]),ke.shouldRenderCutoff&&xt.push("RENDER_CUTOFF"),fe&&(xt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),fe.useNormalOffset&&xt.push("NORMAL_OFFSET")),me=P.getOrCreateProgram("terrainRaster",{defines:xt}),he=Nt},Re=P.colorModeForRenderPass(),Oe=new ks(te.LEQUAL,ks.ReadWrite,P.depthRangeFor3D);ip.update(G);const Ge=P.transform,at=sS(Ge.zoom,O.exaggeration(),O.sourceCache._source.tileSize);let Ke=[0,0,0];if(fe){const Nt=P.style.directionalLight,xt=P.style.ambientLight;Nt&&xt&&(Ke=ap(P.style,Nt,xt))}{he=-1;const Nt=te.TRIANGLES,[xt,bt]=[O.gridIndexBuffer,O.gridSegments];for(const gt of U){const ht=F.getTile(gt),At=Js.disabled,Bt=O.prevTerrainTileForTile[gt.key],zt=O.terrainTileForTile[gt.key];A_(Bt,zt)&&ip.newMorphing(gt.key,Bt,zt,G,250),z0(P,ht.emissiveTexture),J.activeTexture.set(te.TEXTURE0),ht.texture&&ht.texture.bind(te.LINEAR,te.CLAMP_TO_EDGE);const Jt=ip.getMorphValuesForProxy(gt.key),er=Jt?1:0;let ur;Jt&&(ur={morphing:{srcDemTile:Jt.from,dstDemTile:Jt.to,phase:i.dD(Jt.phase)}});const Cr=P.emissiveMode==="mrt-fallback"?1:0,Kt=Yu(gt.projMatrix,AM(gt.canonical,Ge.renderWorldCopies)?at/10:at,Ke,Cr);if(be(er),!me)continue;O.setupElevationDraw(ht,me,ur);const Lt=gt.toUnwrapped();fe&&fe.setupShadows(Lt,me),P.uploadCommonUniforms(J,me,Lt,null,ke),me.draw(P,Nt,Oe,At,Re,Ys.backCCW,Kt,"terrain_raster",O.gridBuffer,xt,bt)}}}}(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,N=this.painter.context,P=this.proxySourceCache,O=this.proxiedCoords[P.id],F=this._drapedRenderBatches.shift(),U=x.style.order,G=[];this._updateFBOs(x.emissiveMode==="mrt-fallback");let J=0;for(const te of O){const me=P.getTileByID(te.proxyTileKey),he=P.proxyCachedFBO[te.key]?P.proxyCachedFBO[te.key][u]:void 0,fe=he!==void 0?P.renderCache[he]:this.pool[J++],ke=he!==void 0;if(me.texture=fe.tex,me.emissiveTexture=fe.emissiveTex,ke&&!fe.dirty){G.push(me.tileID);continue}N.bindFramebuffer.set(fe.fb.framebuffer);const be=N.gl;let Re;be.drawBuffers(x.emissiveMode==="mrt-fallback"?[be.COLOR_ATTACHMENT0,be.COLOR_ATTACHMENT1]:[be.COLOR_ATTACHMENT0]),this.renderedToTile=!1,fe.dirty&&(N.clear({color:i.ao.transparent,stencil:0}),fe.dirty=!1);for(let Oe=F.start;Oe<=F.end;++Oe){const Ge=x.style._mergedLayers[U[Oe]];if(Ge.isHidden(x.transform.zoom))continue;const at=x.style.getLayerSourceCache(Ge),Ke=at?this.proxyToSource[te.key][at.id]:[te];if(!Ke)continue;const Nt=Ke;N.viewport.set([0,0,fe.fb.width,fe.fb.height]),Re!==(at?at.id:null)&&(this._setupStencil(fe,Ke,Ge,at),Re=at?at.id:null),x.renderLayer(x,at,Ge,Nt)}if(be.drawBuffers([be.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Oe of this._pendingGroundEffectLayers){const Ge=x.style._mergedLayers[U[Oe]];if(Ge.isHidden(x.transform.zoom))continue;const at=x.style.getLayerSourceCache(Ge),Ke=at?this.proxyToSource[te.key][at.id]:[te];if(!Ke)continue;const Nt=Ke;N.viewport.set([0,0,fe.fb.width,fe.fb.height]),Re!==(at?at.id:null)&&(this._setupStencil(fe,Ke,Ge,at),Re=at?at.id:null),x.renderLayer(x,at,Ge,Nt)}this.renderedToTile?(fe.dirty=!0,G.push(me.tileID)):ke||--J,J===5&&(J=0,this.renderToBackBuffer(G))}return this.renderToBackBuffer(G),this.renderingToTexture=!1,N.bindFramebuffer.set(null),N.viewport.set([0,0,x.width,x.height]),F.end+1}postRender(){}isLayerOrderingCorrect(u){const x=u.order.length;let N=-1,P=x;for(let O=0;ON}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,N){if(!this._visibleDemTiles)return null;const P=this._visibleDemTiles.filter(O=>O.dem).map(O=>{const F=O.tileID,U=1<(O.t!==null?O.t:Number.MAX_VALUE)-(F.t!==null?F.t:Number.MAX_VALUE));for(const O of P){if(O.t==null)return null;const F=O.tile.dem.tree.raycast(O.minx,O.miny,O.maxx,O.maxy,u,x,N);if(F!=null)return F}return null}_createFBO(){const u=this.painter.context,x=u.gl,N=this.drapeBufferSize;u.activeTexture.set(x.TEXTURE0);const P=new i.T(u,{width:N[0],height:N[1],data:null},x.RGBA8);P.bind(x.LINEAR,x.CLAMP_TO_EDGE);const O=u.createFramebuffer(N[0],N[1],1,null);let F;return O.colorAttachment0.set(P.texture),this._emissiveTexture&&(F=new i.T(u,{width:N[0],height:N[1],data:null},x.R8),F.bind(x.LINEAR,x.CLAMP_TO_EDGE),O.createColorAttachment(u,1),O.colorAttachment1.set(F.texture)),O.depthAttachment=new yL(u,O.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=u.createRenderbuffer(u.gl.DEPTH_STENCIL,N[0],N[1]),this._stencilRef=0,O.depthAttachment.set(this._sharedDepthStencil),u.clear({stencil:0})):O.depthAttachment.set(this._sharedDepthStencil),u.extTextureFilterAnisotropic&&x.texParameterf(x.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax),{fb:O,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 N=u.fb,P=this.painter.context,O=P.gl,F=this.drapeBufferSize;if(x){const U=new i.T(P,{width:F[0],height:F[1],data:null},O.R8);U.bind(O.LINEAR,O.CLAMP_TO_EDGE),u.emissiveTex=U,N.createColorAttachment(P,1),N.colorAttachment1.set(U.texture)}else u.emissiveTex=void 0,N.removeColorAttachment(P,1);u.dirty=!0}_initFBOPool(){for(;this.pool.length{const x=this._style._mergedLayers[u],N=x.isHidden(this.painter.transform.zoom);return x.type==="hillshade"||x.type==="custom"?!N&&x.shouldRedrape():!N&&x.hasTransition()})}_clearLineLayersFromRenderCache(){let u=!1;for(const N of this._style.getSources())if(N instanceof Ym){u=!0;break}if(!u)return;const x={};for(let N=0;NG>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=N}_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=N[F];if(x.getTileByID(U.key),x.proxyCachedFBO[U.key]!==void 0){const G=u[U.key],J=this.proxyToSource[U.key];let te=0;for(const me in J){const he=J[me],fe=G[me];if(!fe||fe.length!==he.length||he.some((ke,be)=>ke!==fe[be]||P[me]&&P[me].hasOwnProperty(ke.key))){te=-1;break}++te}for(const me in x.proxyCachedFBO[U.key])x.renderCache[x.proxyCachedFBO[U.key][me]].dirty=te<0||te!==Object.values(G).length}}const O=[...this._drapedRenderBatches];O.sort((F,U)=>U.end-U.start-(F.end-F.start));for(const F of O)for(const U of N){if(x.proxyCachedFBO[U.key])continue;let G=x.renderCachePool.pop();G===void 0&&x.renderCache.length<50&&(G=x.renderCache.length,x.renderCache.push(this._createFBO())),G!==void 0&&(x.proxyCachedFBO[U.key]={},x.proxyCachedFBO[U.key][F.start]=G,x.renderCache[G].dirty=!0)}this._tilesDirty={}}_setupStencil(u,x,N,P){if(!P||!this._sourceTilesOverlap[P.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const O=this.painter.context,F=O.gl;if(x.length<=1)return void(this._overlapStencilType=!1);let U;if(N.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&&(O.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=U,this._overlapStencilMode.ref=this._stencilRef,N.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):Js.disabled}_renderTileClippingMasks(u,x){const N=this.painter,P=this.painter.context,O=P.gl;N._tileClippingMaskIDs={},P.setColorMode(wn.disabled),P.setDepthMode(ks.disabled);const F=N.getOrCreateProgram("clippingMask");for(const U of u){const G=N._tileClippingMaskIDs[U.key]=--x;F.draw(N,O.TRIANGLES,ks.disabled,new Js({func:O.ALWAYS,mask:0},G,255,O.KEEP,O.KEEP,O.REPLACE),wn.disabled,Ys.disabled,E_(U.projMatrix),"$clipping",N.tileExtentBuffer,N.quadTriangleIndexBuffer,N.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 N=[u.x,u.y,1,1];i.aC(N,N,x.pixelMatrixInverse),i.cK(N,N,1/N[3]),N[0]/=x.worldSize,N[1]/=x.worldSize;const P=x._camera.position,O=i.cf(1,x.center.lat),F=[P[0],P[1],P[2]/O,0],U=i.da([],N.slice(0,3),F);i.aw(U,U);const G=this.raycast(F,U,this._exaggeration);return G!==null&&G?(i.bH(F,F,U,G),F[3]=F[2],F[2]*=O,F):null}_setupProxiedCoordsForOrtho(u,x,N){if(u.getSource()instanceof i.aU)return this._setupProxiedCoordsForImageSource(u,x,N);this._findCoveringTileCache[u.id]=this._findCoveringTileCache[u.id]||{};const P=this.proxiedCoords[u.id]=[],O=this.proxyCoords;for(let G=0;Gte.overscaledZ-J.overscaledZ)}_setupProxiedCoordsForImageSource(u,x,N){if(!u.getSource().loaded())return;const P=this.proxiedCoords[u.id]=[],O=this.proxyCoords,F=u.getSource(),U=F.tileID;if(!U)return;const G=new i.P(U.x,U.y)._div(1<(me.min.x=Math.min(me.min.x,he.x-G.x),me.min.y=Math.min(me.min.y,he.y-G.y),me.max.x=Math.max(me.max.x,he.x-G.x),me.max.y=Math.max(me.max.y,he.y-G.y),me),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),te=(me,he)=>{const fe=me.wrap+me.canonical.x/(1<Re+J.max.x||ke+beOe+J.max.y};for(let me=0;meF.key===x.tileID.key);if(O)return O}if(x.tileID.key!==u.key){const O=u.canonical.z-x.tileID.canonical.z;let F,U,G;P=i.bC();const J=x.tileID.wrap-u.wrap<0?(F=i.al>>O,U=F*((x.tileID.canonical.x<=me){const he=u.canonical.z-me;x.getSource().reparseOverscaled?(U=Math.max(u.canonical.z+2,x.transform.tileZoom),F=new i.aQ(U,u.wrap,me,u.canonical.x>>he,u.canonical.y>>he)):he!==0&&(U=me,F=new i.aQ(U,u.wrap,me,u.canonical.x>>he,u.canonical.y>>he))}F.key!==u.key&&(J.push(F.key),N=x.getTile(F))}const te=me=>{J.forEach(he=>{P[he]=me}),J.length=0};for(U-=1;U>=G&&(!N||!N.hasData());U--){N&&te(N.tileID.key);const me=F.calculateScaledKey(U);if(N=x.getTileByID(me),N&&N.hasData())break;const he=P[me];if(he===null)break;he===void 0?J.push(me):N=x.getTileByID(he)}return te(N?N.tileID.key:null),N&&N.hasData()?N:null}findDEMTileFor(u){return this.enabled?this._findTileCoveringTileID(u,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(u,x){let N=this._tilesDirty[u];N||(N=this._tilesDirty[u]={}),N[x.key]=!0}}function B0(j,u,x){const N=function(U,G,J){const te=i.bJ(G,U),me=i.bJ(J,[.2126,.7152,.0722]),he=(ke,be,Re)=>(1-Re)*ke+Re*be,fe=he(1-.3*Math.min(me,1),1,Math.min(te+1,1));return he(.92,1,Math.asin(i.aA(G[2],-1,1))/Math.PI+.5)*fe}(j,[0,0,1],u),P=[0,0,0];i.c5(P,x.slice(0,3),N);const O=[0,0,0];i.c5(O,u.slice(0,3),j[2]);const F=[0,0,0];return i.d8(F,P,O),i.db(F)}const Rle=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Fle=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class vL{static cacheKey(u,x,N,P){const O=[x];P&&O.push(P.cacheKey);for(const F of N)u.usedDefines.has(F)&&O.push(F);return O.join("/")}constructor(u,x,N,P,O,F){const U=u.gl;this.program=U.createProgram(),this.configuration=P,this.name=x,this.fixedDefines=[...F];const G=`#version 300 es ${(P?P.defines():[]).concat(F.map(be=>`#define ${be}`)).join(` `)}`,J=[G,Mle];for(const be of N.fragmentIncludes)J.push(Cg[be]);J.push(N.fragmentSource);const te=J.join(` `),me=[G,cL];for(const be of N.vertexIncludes)me.push(Cg[be]);this.forceManualRenderingForInstanceIDShaders=u.forceManualRenderingForInstanceIDShaders&&N.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&me.push("uniform int u_instanceID;"),me.push(N.vertexSource);let he=me.join(` `);this.forceManualRenderingForInstanceIDShaders&&(he=he.replaceAll("gl_InstanceID","u_instanceID"));const fe=U.createShader(U.FRAGMENT_SHADER);if(U.isContextLost())return void(this.failedToCreate=!0);U.shaderSource(fe,te),U.compileShader(fe),U.attachShader(this.program,fe);const ke=U.createShader(U.VERTEX_SHADER);U.isContextLost()?this.failedToCreate=!0:(U.shaderSource(ke,he),U.compileShader(ke),U.attachShader(this.program,ke),this.attributes={},U.linkProgram(this.program),U.deleteShader(ke),U.deleteShader(fe),this.fixedUniforms=O(u),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=P?P.getUniforms(u):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(be=>({u_instanceID:new i.ch(be)}))(u)),(F.includes("TERRAIN")||x.includes("symbol")||x.includes("circle"))&&(this.terrainUniforms=(be=>({u_dem:new i.ch(be),u_dem_prev:new i.ch(be),u_dem_tl:new i.ck(be),u_dem_scale:new i.cj(be),u_dem_tl_prev:new i.ck(be),u_dem_scale_prev:new i.cj(be),u_dem_size:new i.cj(be),u_dem_lerp:new i.cj(be),u_exaggeration:new i.cj(be),u_depth:new i.ch(be),u_depth_size_inv:new i.ck(be),u_depth_range_unpack:new i.ck(be),u_occluder_half_size:new i.cj(be),u_occlusion_depth_offset:new i.cj(be),u_meter_to_dem:new i.cj(be),u_label_plane_matrix_inv:new i.cl(be)}))(u)),F.includes("GLOBE")&&(this.globeUniforms=(be=>({u_tile_tl_up:new i.ci(be),u_tile_tr_up:new i.ci(be),u_tile_br_up:new i.ci(be),u_tile_bl_up:new i.ci(be),u_tile_up_scale:new i.cj(be)}))(u)),F.includes("FOG")&&(this.fogUniforms=(be=>({u_fog_matrix:new i.cl(be),u_fog_range:new i.ck(be),u_fog_color:new i.d3(be),u_fog_horizon_blend:new i.cj(be),u_fog_vertical_limit:new i.ck(be),u_fog_temporal_offset:new i.cj(be),u_frustum_tl:new i.ci(be),u_frustum_tr:new i.ci(be),u_frustum_br:new i.ci(be),u_frustum_bl:new i.ci(be),u_globe_pos:new i.ci(be),u_globe_radius:new i.cj(be),u_globe_transition:new i.cj(be),u_is_globe:new i.ch(be),u_viewport:new i.ck(be)}))(u)),F.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(be=>({u_cutoff_params:new i.d3(be)}))(u)),F.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(be=>({u_lighting_ambient_color:new i.ci(be),u_lighting_directional_dir:new i.ci(be),u_lighting_directional_color:new i.ci(be),u_ground_radiance:new i.ci(be)}))(u)),F.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(be=>({u_light_matrix_0:new i.cl(be),u_light_matrix_1:new i.cl(be),u_fade_range:new i.ck(be),u_shadow_normal_offset:new i.ci(be),u_shadow_intensity:new i.cj(be),u_shadow_texel_size:new i.cj(be),u_shadow_map_resolution:new i.cj(be),u_shadow_direction:new i.ci(be),u_shadow_bias:new i.ci(be),u_shadowmap_0:new i.ch(be),u_shadowmap_1:new i.ch(be)}))(u)))}getAttributeLocation(u,x){let N=this.attributes[x];return N===void 0&&(N=this.attributes[x]=u.getAttribLocation(this.program,x)),N}setTerrainUniformValues(u,x){if(!this.terrainUniforms)return;const N=this.terrainUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)N[P]&&N[P].set(this.program,P,x[P])}}setGlobeUniformValues(u,x){if(!this.globeUniforms)return;const N=this.globeUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)N[P]&&N[P].set(this.program,P,x[P])}}setFogUniformValues(u,x){if(!this.fogUniforms)return;const N=this.fogUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)N[P].set(this.program,P,x[P])}}setCutoffUniformValues(u,x){if(!this.cutoffUniforms)return;const N=this.cutoffUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)N[P].set(this.program,P,x[P])}}setLightsUniformValues(u,x){if(!this.lightsUniforms)return;const N=this.lightsUniforms;if(!this.failedToCreate){u.program.set(this.program);for(const P in x)N[P].set(this.program,P,x[P])}}setShadowUniformValues(u,x){if(this.failedToCreate||!this.shadowUniforms)return;const N=this.shadowUniforms;u.program.set(this.program);for(const P in x)N[P].set(this.program,P,x[P])}_drawDebugWireframe(u,x,N,P,O,F,U,G,J,te){const me=u.options.wireframe;if(me.terrain===!1&&me.layers2D===!1&&me.layers3D===!1)return;const he=u.context;if(!(!(!me.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!me.layers2D||u._terrain&&u._terrain.renderingToTexture||!Rle.includes(this.name))||!(!me.layers3D||!Fle.includes(this.name))))return;const fe=he.gl,ke=u.wireframeDebugCache.getLinesFromTrianglesBuffer(u.frameCounter,O,he);if(!ke)return;const be=[...this.fixedDefines,"DEBUG_WIREFRAME"],Re=u.getOrCreateProgram(this.name,{config:this.configuration,defines:be});he.program.set(Re.program);const Oe=(Ke,Nt,xt)=>{if(Nt[Ke]&&xt[Ke])for(const bt in Nt[Ke])xt[Ke][bt]&&xt[Ke][bt].set(xt.program,bt,Nt[Ke][bt].current)};J&&J.setUniforms(Re.program,he,Re.binderUniforms,U,{zoom:G}),Oe("fixedUniforms",this,Re),Oe("terrainUniforms",this,Re),Oe("globeUniforms",this,Re),Oe("fogUniforms",this,Re),Oe("lightsUniforms",this,Re),Oe("shadowUniforms",this,Re),ke.bind(),he.setColorMode(new wn([fe.ONE,fe.ONE_MINUS_SRC_ALPHA,fe.ZERO,fe.ONE],i.ao.transparent,[!0,!0,!0,!1])),he.setDepthMode(new ks(x.func===fe.LESS?fe.LEQUAL:x.func,ks.ReadOnly,x.range)),he.setStencilMode(Js.disabled);const Ge=3*F.primitiveLength*2,at=3*F.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const Ke=te||1;for(let Nt=0;Nt1?fe.drawElementsInstanced(fe.LINES,Ge,fe.UNSIGNED_SHORT,at,te):fe.drawElements(fe.LINES,Ge,fe.UNSIGNED_SHORT,at);O.bind(),he.program.set(this.program),he.setDepthMode(x),he.setStencilMode(N),he.setColorMode(P)}checkUniforms(u,x,N){if(this.fixedDefines.includes(x)){for(const P of Object.keys(N))if(!N[P].initialized)throw new Error(`Program '${this.name}', from draw '${u}': uniform ${P} not set but required by ${x} being defined`)}}draw(u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re){const Oe=u.context,Ge=Oe.gl;if(this.failedToCreate)return;Oe.program.set(this.program),Oe.setDepthMode(N),Oe.setStencilMode(P),Oe.setColorMode(O),Oe.setCullFace(F);for(const[gt,ht]of this.fixedUniformsEntries)ht.set(this.program,gt,U[gt]);ke&&ke.setUniforms(this.program,Oe,this.binderUniforms,he,{zoom:fe});const at={[Ge.POINTS]:1,[Ge.LINES]:2,[Ge.TRIANGLES]:3,[Ge.LINE_STRIP]:1}[x];this.checkUniforms(G,"RENDER_SHADOWS",this.shadowUniforms);const Ke=be||[],Nt=ke?ke.getPaintVertexBuffers():[],xt=x===Ge.TRIANGLES&&te,bt=Re&&Re>0?1:void 0;for(const gt of me.get()){const ht=gt.vaos||(gt.vaos={});if((ht[G]||(ht[G]=new Tle)).bind(Oe,this,J,Nt,te,gt.vertexOffset,Ke,bt),this.forceManualRenderingForInstanceIDShaders){const At=Re||1;for(let Bt=0;Bt1?Ge.drawElementsInstanced(x,gt.primitiveLength*at,Ge.UNSIGNED_SHORT,gt.primitiveOffset*at*2,Re):te?Ge.drawElements(x,gt.primitiveLength*at,Ge.UNSIGNED_SHORT,gt.primitiveOffset*at*2):Ge.drawArrays(x,gt.vertexOffset,gt.vertexLength);xt&&this._drawDebugWireframe(u,N,P,O,te,gt,he,fe,ke,Re)}}}function _L(j,u,x=0){const N=Math.pow(2,u.tileID.overscaledZ),P=u.tileSize*Math.pow(2,j.transform.tileZoom)/N,O=P*(u.tileID.canonical.x+u.tileID.wrap*N),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,j.transform.tileZoom),u_pixel_coord_upper:[O>>16,F>>16],u_pixel_coord_lower:[65535&O,65535&F],u_pattern_transition:x}}const aS={terrain:0,flat:1},zle=i.bC(),iS=(j,u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re,Oe)=>{const Ge=u.style.light,at=Ge.properties.get("position"),Ke=[at.x,at.y,at.z],Nt=i.dO();Ge.properties.get("anchor")==="viewport"&&(i.dP(Nt,-u.transform.angle),i.dQ(Ke,Ke,Nt));const xt=Ge.properties.get("color").toPremultipliedRenderColor(null),bt=u.transform,gt={u_matrix:j,u_lightpos:Ke,u_lightintensity:Ge.properties.get("intensity"),u_lightcolor:[xt.r,xt.g,xt.b],u_vertical_gradient:+x,u_opacity:N,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:zle,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:aS[J],u_base_type:aS[te],u_ao:P,u_edge_radius:O,u_width_scale:F,u_flood_light_color:ke,u_vertical_scale:be,u_flood_light_intensity:Re,u_ground_shadow_factor:Oe};return bt.projection.name==="globe"&&(gt.u_tile_id=[U.canonical.x,U.canonical.y,1<({u_matrix:j,u_edge_radius:u,u_width_scale:x,u_vertical_scale:N,u_height_type:aS[P],u_base_type:aS[O]}),bL=(j,u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re,Oe)=>{const Ge=iS(j,u,x,N,P,O,F,U,J,te,me,he,fe,ke,be,Re,1,[0,0,0]),at={u_height_factor:-Math.pow(2,U.overscaledZ)/G.tileSize/8};return Object.assign(Ge,_L(u,G,Oe),at)},$0=(j,u,x,N,P,O,F,U,G,J,te)=>({u_matrix:u,u_opacity:x,u_ao_pass:N?1:0,u_meter_to_tile:P,u_ao:O,u_flood_light_intensity:F,u_flood_light_color:U,u_attenuation:G,u_edge_radius:J,u_fb:0,u_fb_size:te,u_dynamic_offset:1}),DM=(j,u,x)=>({u_matrix:j,u_emissive_strength:u,u_ground_shadow_factor:x}),OM=(j,u,x,N,P,O=0)=>Object.assign(DM(j,u,P),_L(x,N,O)),wL=(j,u,x,N)=>({u_matrix:j,u_world:x,u_emissive_strength:u,u_ground_shadow_factor:N}),RM=(j,u,x,N,P,O,F=0)=>Object.assign(OM(j,u,x,N,O,F),{u_world:P}),Tg=(j,u)=>({u_matrix:j,u_ground_shadow_factor:u}),Hx=(j,u,x,N,P)=>({u_matrix:j,u_camera_pos:[u[0],u[1],u[2]],u_depth_bias:x,u_height_scale:N,u_reset_depth:P}),oS=(j,u,x,N,P,O,F,U,G)=>({u_matrix:j,u_normal_matrix:u,u_opacity:x,u_faux_facade_ao_intensity:N,u_camera_pos:P,u_tile_to_meter:O,u_facade_emissive_chance:F,u_flood_light_color:U,u_flood_light_intensity:G}),jL=j=>({u_matrix:j}),Ag=j=>({u_matrix:j}),FM=(j,u,x,N,P,O,F,U)=>{const G=i.al/O.tileSize;return{u_matrix:j,u_inv_rot_matrix:u,u_camera_to_center_distance:x.getCameraToCenterDistance(U),u_extrude_scale:[x.pixelsToGLUnits[0]/G,x.pixelsToGLUnits[1]/G],u_zoom_transition:N,u_tile_id:F,u_merc_center:P}},P_=(j,u,x=1)=>({u_matrix:j,u_color:u,u_overlay:0,u_overlay_scale:x}),kL=i.bC(),NL=(j,u,x,N,P,O,F)=>{const U=j.transform,G=U.projection.name==="globe",J=G?i.dR(U.zoom,u.canonical)*U._pixelsPerMercatorPixel:i.ay(x,1,O),te={u_matrix:u.projMatrix,u_extrude_scale:J,u_intensity:F,u_inv_rot_matrix:kL,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(G){te.u_inv_rot_matrix=N,te.u_merc_center=P,te.u_tile_id=[u.canonical.x,u.canonical.y,1<({u_matrix:j,u_normalize_matrix:u,u_globe_matrix:x,u_merc_matrix:N,u_grid_matrix:P,u_tl_parent:O,u_scale_parent:J,u_fade_t:te.mix,u_opacity:te.opacity*me.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:me.paint.get("raster-brightness-min"),u_brightness_high:me.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(me.paint.get("raster-saturation")),u_contrast_factor:i.dS(me.paint.get("raster-contrast")),u_spin_weights:CL(me.paint.get("raster-hue-rotate")),u_perspective_transform:he,u_raster_elevation:fe,u_zoom_transition:F,u_merc_center:U,u_cutoff_params:G,u_colorization_mix:lS(i.dU,be,Oe),u_colorization_offset:cS(i.dU,Re,Oe),u_color_ramp:ke,u_texture_offset:[at/(Ge+2*at),Ge/(Ge+2*at)],u_texture_res:[Ge+2*at,Ge+2*at],u_emissive_strength:Ke});function CL(j){j*=Math.PI/180;const u=Math.sin(j),x=Math.cos(j);return[(2*x+1)/3,(-Math.sqrt(3)*u-x+1)/3,(Math.sqrt(3)*u-x+1)/3]}const sf=.05,Ble=(j,u,x,N,P,O,F,U,G,J,te,me)=>({u_matrix:j,u_normalize_matrix:u,u_globe_matrix:x,u_merc_matrix:N,u_grid_matrix:P,u_tl_parent:O,u_scale_parent:J,u_fade_t:te.mix,u_opacity:te.opacity,u_image0:0,u_image1:1,u_raster_elevation:me,u_zoom_transition:F,u_merc_center:U,u_cutoff_params:G}),$le=(j,u,x,N,P,O,F,U,G,J)=>({u_particle_texture:j,u_particle_texture_side_len:u,u_tile_offset:x,u_velocity:N,u_color_ramp:O,u_velocity_res:P,u_max_speed:F,u_uv_offset:U,u_data_scale:[255*G[0],255*G[1]],u_data_offset:J,u_particle_pos_scale:1.1,u_particle_pos_offset:[sf,sf]}),ML=(j,u,x,N,P,O,F,U,G,J)=>({u_particle_texture:j,u_particle_texture_side_len:u,u_velocity:x,u_velocity_res:N,u_max_speed:P,u_speed_factor:O,u_reset_rate:F,u_rand_seed:Math.random(),u_uv_offset:U,u_data_scale:[255*G[0],255*G[1]],u_data_offset:J,u_particle_pos_scale:1.1,u_particle_pos_offset:[sf,sf]}),TL=i.bC(),dS=(j,u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re,Oe,Ge,at,Ke,Nt,xt,bt)=>{const gt=P.transform,ht={u_is_size_zoom_constant:+(j==="constant"||j==="source"),u_is_size_feature_constant:+(j==="constant"||j==="camera"),u_size_t:u?u.uSizeT:0,u_size:u?u.uSize:0,u_camera_to_center_distance:gt.getCameraToCenterDistance(Ge),u_rotate_symbol:+x,u_aspect_ratio:gt.width/gt.height,u_fade_change:P.options.fadeDuration?P.symbolFadeChange:1,u_matrix:O,u_label_plane_matrix:F,u_coord_matrix:U,u_is_text:+J,u_elevation_from_sea:G?1:0,u_pitch_with_map:+N,u_texsize:te,u_texsize_icon:me,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:TL,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:TL,u_up_vector:[0,-1,0],u_color_adj_mat:Nt,u_icon_transition:xt||0,u_gamma_scale:N?P.transform.getCameraToCenterDistance(Ge)*Math.cos(P.terrain?0:P.transform._pitch):1,u_device_pixel_ratio:i.o.devicePixelRatio,u_is_halo:1,u_scale_factor:bt||1,u_ground_shadow_factor:at,u_inv_matrix:i.bl(i.bC(),F),u_normal_scale:Ke,u_lutTexture:Vl.LUT};return Ge.name==="globe"&&(ht.u_tile_id=[fe.canonical.x,fe.canonical.y,1<({u_matrix:j,u_emissive_strength:u,u_opacity:x,u_color:N}),Eg=(j,u,x,N,P,O,F,U,G)=>Object.assign(function(J,te,me,he,fe,ke){const{width:be,height:Re}=he.imageManager.getPixelSize(te),Oe=Math.pow(2,ke.tileID.overscaledZ),Ge=ke.tileSize*Math.pow(2,he.transform.tileZoom)/Oe,at=Ge*(ke.tileID.canonical.x+ke.tileID.wrap*Oe),Ke=Ge*ke.tileID.canonical.y;return{u_image:0,u_pattern_tl:me.tl,u_pattern_br:me.br,u_texsize:[be,Re],u_pattern_size:me.displaySize,u_pattern_units_to_pixels:fe?[he.transform.width,-1*he.transform.height]:[1/i.ay(ke,1,he.transform.tileZoom),1/i.ay(ke,1,he.transform.tileZoom)],u_pixel_coord_upper:[at>>16,Ke>>16],u_pixel_coord_lower:[65535&at,65535&Ke]}}(0,O,F,N,U,G),{u_matrix:j,u_emissive_strength:u,u_opacity:x}),U0=new Float32Array(i.bA([])),Wx=(j,u,x,N,P,O,F,U,G,J,te,me,he,fe=[0,0,0],ke,be,Re)=>{const Oe=P.style.light,Ge=Oe.properties.get("position"),at=[-Ge.x,-Ge.y,Ge.z],Ke=i.dO();Oe.properties.get("anchor")==="viewport"&&(i.dP(Ke,-P.transform.angle),i.dQ(at,at,Ke));const Nt=te.alphaMode==="MASK",xt=Oe.properties.get("color").toNonPremultipliedRenderColor(null),bt=he.paint.get("model-ambient-occlusion-intensity"),gt=he.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return gt.a=he.paint.get("model-color-mix-intensity").constantOr(0),Re&&(gt.r=Re[0],gt.g=Re[1],gt.b=Re[2],gt.a=Re[3]),be&&(gt.r=be.color.r,gt.g=be.color.g,gt.b=be.color.b,gt.a=be.colorMix,me=be.emissionStrength,O*=be.opacity),{u_matrix:j,u_lighting_matrix:u,u_normal_matrix:x,u_node_matrix:N||U0,u_lightpos:at,u_lightintensity:Oe.properties.get("intensity"),u_lightcolor:[xt.r,xt.g,xt.b],u_camera_pos:fe,u_opacity:O,u_baseTextureIsAlpha:0,u_alphaMask:+Nt,u_alphaCutoff:te.alphaCutoff,u_baseColorFactor:F.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:U.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:G,u_roughnessFactor:J,u_baseColorTexture:Vl.BaseColor,u_metallicRoughnessTexture:Vl.MetallicRoughness,u_normalTexture:Vl.Normal,u_occlusionTexture:Vl.Occlusion,u_emissionTexture:Vl.Emission,u_lutTexture:Vl.LUT,u_color_mix:gt.toArray01(),u_aoIntensity:bt,u_emissive_strength:me,u_occlusionTextureTransform:ke||[0,0,0,0]}},zM=(j,u=U0,x=U0)=>({u_matrix:j,u_instance:u,u_node_matrix:x}),uS={fillExtrusion:j=>({u_matrix:new i.cl(j),u_lightpos:new i.ci(j),u_lightintensity:new i.cj(j),u_lightcolor:new i.ci(j),u_vertical_gradient:new i.cj(j),u_opacity:new i.cj(j),u_edge_radius:new i.cj(j),u_width_scale:new i.cj(j),u_ao:new i.ck(j),u_height_type:new i.ch(j),u_base_type:new i.ch(j),u_tile_id:new i.ci(j),u_zoom_transition:new i.cj(j),u_inv_rot_matrix:new i.cl(j),u_merc_center:new i.ck(j),u_up_dir:new i.ci(j),u_height_lift:new i.cj(j),u_flood_light_color:new i.ci(j),u_vertical_scale:new i.cj(j),u_flood_light_intensity:new i.cj(j),u_ground_shadow_factor:new i.ci(j)}),fillExtrusionDepth:j=>({u_matrix:new i.cl(j),u_edge_radius:new i.cj(j),u_width_scale:new i.cj(j),u_vertical_scale:new i.cj(j),u_height_type:new i.ch(j),u_base_type:new i.ch(j)}),fillExtrusionPattern:j=>({u_matrix:new i.cl(j),u_lightpos:new i.ci(j),u_lightintensity:new i.cj(j),u_lightcolor:new i.ci(j),u_vertical_gradient:new i.cj(j),u_height_factor:new i.cj(j),u_edge_radius:new i.cj(j),u_width_scale:new i.cj(j),u_ao:new i.ck(j),u_height_type:new i.ch(j),u_base_type:new i.ch(j),u_tile_id:new i.ci(j),u_zoom_transition:new i.cj(j),u_inv_rot_matrix:new i.cl(j),u_merc_center:new i.ck(j),u_up_dir:new i.ci(j),u_height_lift:new i.cj(j),u_image:new i.ch(j),u_texsize:new i.ck(j),u_pixel_coord_upper:new i.ck(j),u_pixel_coord_lower:new i.ck(j),u_tile_units_to_pixels:new i.cj(j),u_opacity:new i.cj(j),u_pattern_transition:new i.cj(j)}),fillExtrusionGroundEffect:j=>({u_matrix:new i.cl(j),u_opacity:new i.cj(j),u_ao_pass:new i.cj(j),u_meter_to_tile:new i.cj(j),u_ao:new i.ck(j),u_flood_light_intensity:new i.cj(j),u_flood_light_color:new i.ci(j),u_attenuation:new i.cj(j),u_edge_radius:new i.cj(j),u_fb:new i.ch(j),u_fb_size:new i.cj(j),u_dynamic_offset:new i.cj(j)}),fill:j=>({u_matrix:new i.cl(j),u_emissive_strength:new i.cj(j),u_ground_shadow_factor:new i.ci(j)}),fillPattern:j=>({u_matrix:new i.cl(j),u_emissive_strength:new i.cj(j),u_image:new i.ch(j),u_texsize:new i.ck(j),u_pixel_coord_upper:new i.ck(j),u_pixel_coord_lower:new i.ck(j),u_tile_units_to_pixels:new i.cj(j),u_ground_shadow_factor:new i.ci(j),u_pattern_transition:new i.cj(j)}),fillOutline:j=>({u_matrix:new i.cl(j),u_emissive_strength:new i.cj(j),u_world:new i.ck(j),u_ground_shadow_factor:new i.ci(j)}),fillOutlinePattern:j=>({u_matrix:new i.cl(j),u_emissive_strength:new i.cj(j),u_world:new i.ck(j),u_image:new i.ch(j),u_texsize:new i.ck(j),u_pixel_coord_upper:new i.ck(j),u_pixel_coord_lower:new i.ck(j),u_tile_units_to_pixels:new i.cj(j),u_ground_shadow_factor:new i.ci(j),u_pattern_transition:new i.cj(j)}),building:j=>({u_matrix:new i.cl(j),u_normal_matrix:new i.cl(j),u_opacity:new i.cj(j),u_faux_facade_ao_intensity:new i.cj(j),u_camera_pos:new i.ci(j),u_tile_to_meter:new i.cj(j),u_facade_emissive_chance:new i.cj(j),u_flood_light_color:new i.ci(j),u_flood_light_intensity:new i.cj(j)}),buildingBloom:j=>({u_matrix:new i.cl(j)}),buildingDepth:j=>({u_matrix:new i.cl(j)}),elevatedStructuresDepth:j=>({u_matrix:new i.cl(j),u_depth_bias:new i.cj(j)}),elevatedStructures:j=>({u_matrix:new i.cl(j),u_ground_shadow_factor:new i.ci(j)}),elevatedStructuresDepthReconstruct:j=>({u_matrix:new i.cl(j),u_camera_pos:new i.ci(j),u_depth_bias:new i.cj(j),u_height_scale:new i.cj(j),u_reset_depth:new i.cj(j)}),circle:i.dY,collisionBox:j=>({u_matrix:new i.cl(j),u_inv_rot_matrix:new i.cl(j),u_camera_to_center_distance:new i.cj(j),u_extrude_scale:new i.ck(j),u_zoom_transition:new i.cj(j),u_merc_center:new i.ck(j),u_tile_id:new i.ci(j)}),collisionCircle:j=>({u_matrix:new i.cl(j),u_inv_matrix:new i.cl(j),u_camera_to_center_distance:new i.cj(j),u_viewport_size:new i.ck(j)}),debug:j=>({u_color:new i.dB(j),u_matrix:new i.cl(j),u_overlay:new i.ch(j),u_overlay_scale:new i.cj(j)}),clippingMask:j=>({u_matrix:new i.cl(j)}),heatmap:j=>({u_extrude_scale:new i.cj(j),u_intensity:new i.cj(j),u_matrix:new i.cl(j),u_inv_rot_matrix:new i.cl(j),u_merc_center:new i.ck(j),u_tile_id:new i.ci(j),u_zoom_transition:new i.cj(j),u_up_dir:new i.ci(j)}),heatmapTexture:j=>({u_image:new i.ch(j),u_color_ramp:new i.ch(j),u_opacity:new i.cj(j)}),hillshade:j=>({u_matrix:new i.cl(j),u_image:new i.ch(j),u_latrange:new i.ck(j),u_light:new i.ck(j),u_shadow:new i.dB(j),u_highlight:new i.dB(j),u_emissive_strength:new i.cj(j),u_accent:new i.dB(j)}),hillshadePrepare:j=>({u_matrix:new i.cl(j),u_image:new i.ch(j),u_dimension:new i.ck(j),u_zoom:new i.cj(j)}),line:i.dX,linePattern:i.dW,raster:j=>({u_matrix:new i.cl(j),u_normalize_matrix:new i.cl(j),u_globe_matrix:new i.cl(j),u_merc_matrix:new i.cl(j),u_grid_matrix:new i.dC(j),u_tl_parent:new i.ck(j),u_scale_parent:new i.cj(j),u_fade_t:new i.cj(j),u_opacity:new i.cj(j),u_image0:new i.ch(j),u_image1:new i.ch(j),u_brightness_low:new i.cj(j),u_brightness_high:new i.cj(j),u_saturation_factor:new i.cj(j),u_contrast_factor:new i.cj(j),u_spin_weights:new i.ci(j),u_perspective_transform:new i.ck(j),u_raster_elevation:new i.cj(j),u_zoom_transition:new i.cj(j),u_merc_center:new i.ck(j),u_cutoff_params:new i.d3(j),u_colorization_mix:new i.d3(j),u_colorization_offset:new i.cj(j),u_color_ramp:new i.ch(j),u_texture_offset:new i.ck(j),u_texture_res:new i.ck(j),u_emissive_strength:new i.cj(j)}),rasterParticle:j=>({u_matrix:new i.cl(j),u_normalize_matrix:new i.cl(j),u_globe_matrix:new i.cl(j),u_merc_matrix:new i.cl(j),u_grid_matrix:new i.dC(j),u_tl_parent:new i.ck(j),u_scale_parent:new i.cj(j),u_fade_t:new i.cj(j),u_opacity:new i.cj(j),u_image0:new i.ch(j),u_image1:new i.ch(j),u_raster_elevation:new i.cj(j),u_zoom_transition:new i.cj(j),u_merc_center:new i.ck(j),u_cutoff_params:new i.d3(j)}),rasterParticleTexture:j=>({u_texture:new i.ch(j),u_opacity:new i.cj(j)}),rasterParticleDraw:j=>({u_particle_texture:new i.ch(j),u_particle_texture_side_len:new i.cj(j),u_tile_offset:new i.ck(j),u_velocity:new i.ch(j),u_color_ramp:new i.ch(j),u_velocity_res:new i.ck(j),u_max_speed:new i.cj(j),u_uv_offset:new i.ck(j),u_data_scale:new i.ck(j),u_data_offset:new i.cj(j),u_particle_pos_scale:new i.cj(j),u_particle_pos_offset:new i.ck(j)}),rasterParticleUpdate:j=>({u_particle_texture:new i.ch(j),u_particle_texture_side_len:new i.cj(j),u_velocity:new i.ch(j),u_velocity_res:new i.ck(j),u_max_speed:new i.cj(j),u_speed_factor:new i.cj(j),u_reset_rate:new i.cj(j),u_rand_seed:new i.cj(j),u_uv_offset:new i.ck(j),u_data_scale:new i.ck(j),u_data_offset:new i.cj(j),u_particle_pos_scale:new i.cj(j),u_particle_pos_offset:new i.ck(j)}),symbol:j=>({u_is_size_zoom_constant:new i.ch(j),u_is_size_feature_constant:new i.ch(j),u_size_t:new i.cj(j),u_size:new i.cj(j),u_camera_to_center_distance:new i.cj(j),u_rotate_symbol:new i.ch(j),u_aspect_ratio:new i.cj(j),u_fade_change:new i.cj(j),u_matrix:new i.cl(j),u_label_plane_matrix:new i.cl(j),u_coord_matrix:new i.cl(j),u_is_text:new i.ch(j),u_elevation_from_sea:new i.ch(j),u_pitch_with_map:new i.ch(j),u_texsize:new i.ck(j),u_texsize_icon:new i.ck(j),u_texture:new i.ch(j),u_texture_icon:new i.ch(j),u_gamma_scale:new i.cj(j),u_device_pixel_ratio:new i.cj(j),u_tile_id:new i.ci(j),u_zoom_transition:new i.cj(j),u_inv_rot_matrix:new i.cl(j),u_merc_center:new i.ck(j),u_camera_forward:new i.ci(j),u_tile_matrix:new i.cl(j),u_up_vector:new i.ci(j),u_ecef_origin:new i.ci(j),u_is_halo:new i.ch(j),u_icon_transition:new i.cj(j),u_color_adj_mat:new i.cl(j),u_scale_factor:new i.cj(j),u_ground_shadow_factor:new i.ci(j),u_inv_matrix:new i.cl(j),u_normal_scale:new i.cj(j),u_lutTexture:new i.ch(j)}),background:j=>({u_matrix:new i.cl(j),u_emissive_strength:new i.cj(j),u_opacity:new i.cj(j),u_color:new i.dB(j)}),backgroundPattern:j=>({u_matrix:new i.cl(j),u_emissive_strength:new i.cj(j),u_opacity:new i.cj(j),u_image:new i.ch(j),u_pattern_tl:new i.ck(j),u_pattern_br:new i.ck(j),u_texsize:new i.ck(j),u_pattern_size:new i.ck(j),u_pixel_coord_upper:new i.ck(j),u_pixel_coord_lower:new i.ck(j),u_pattern_units_to_pixels:new i.ck(j)}),terrainRaster:j=>({u_matrix:new i.cl(j),u_image0:new i.ch(j),u_image1:new i.ch(j),u_skirt_height:new i.cj(j),u_ground_shadow_factor:new i.ci(j),u_emissive_texture_available:new i.cj(j)}),skybox:j=>({u_matrix:new i.cl(j),u_sun_direction:new i.ci(j),u_cubemap:new i.ch(j),u_opacity:new i.cj(j),u_temporal_offset:new i.cj(j)}),skyboxGradient:j=>({u_matrix:new i.cl(j),u_color_ramp:new i.ch(j),u_center_direction:new i.ci(j),u_radius:new i.cj(j),u_opacity:new i.cj(j),u_temporal_offset:new i.cj(j)}),skyboxCapture:j=>({u_matrix_3f:new i.dC(j),u_sun_direction:new i.ci(j),u_sun_intensity:new i.cj(j),u_color_tint_r:new i.d3(j),u_color_tint_m:new i.d3(j),u_luminance:new i.cj(j)}),globeRaster:j=>({u_proj_matrix:new i.cl(j),u_globe_matrix:new i.cl(j),u_normalize_matrix:new i.cl(j),u_merc_matrix:new i.cl(j),u_zoom_transition:new i.cj(j),u_merc_center:new i.ck(j),u_image0:new i.ch(j),u_image1:new i.ch(j),u_grid_matrix:new i.dC(j),u_skirt_height:new i.cj(j),u_far_z_cutoff:new i.cj(j),u_frustum_tl:new i.ci(j),u_frustum_tr:new i.ci(j),u_frustum_br:new i.ci(j),u_frustum_bl:new i.ci(j),u_globe_pos:new i.ci(j),u_globe_radius:new i.cj(j),u_viewport:new i.ck(j),u_emissive_texture_available:new i.cj(j)}),globeAtmosphere:j=>({u_frustum_tl:new i.ci(j),u_frustum_tr:new i.ci(j),u_frustum_br:new i.ci(j),u_frustum_bl:new i.ci(j),u_horizon:new i.cj(j),u_transition:new i.cj(j),u_fadeout_range:new i.cj(j),u_atmosphere_fog_color:new i.d3(j),u_high_color:new i.d3(j),u_space_color:new i.d3(j),u_temporal_offset:new i.cj(j),u_horizon_angle:new i.cj(j)}),model:j=>({u_matrix:new i.cl(j),u_lighting_matrix:new i.cl(j),u_normal_matrix:new i.cl(j),u_node_matrix:new i.cl(j),u_lightpos:new i.ci(j),u_lightintensity:new i.cj(j),u_lightcolor:new i.ci(j),u_camera_pos:new i.ci(j),u_opacity:new i.cj(j),u_baseColorFactor:new i.d3(j),u_emissiveFactor:new i.d3(j),u_metallicFactor:new i.cj(j),u_roughnessFactor:new i.cj(j),u_baseTextureIsAlpha:new i.ch(j),u_alphaMask:new i.ch(j),u_alphaCutoff:new i.cj(j),u_baseColorTexture:new i.ch(j),u_metallicRoughnessTexture:new i.ch(j),u_normalTexture:new i.ch(j),u_occlusionTexture:new i.ch(j),u_emissionTexture:new i.ch(j),u_lutTexture:new i.ch(j),u_color_mix:new i.d3(j),u_aoIntensity:new i.cj(j),u_emissive_strength:new i.cj(j),u_occlusionTextureTransform:new i.d3(j)}),modelDepth:j=>({u_matrix:new i.cl(j),u_instance:new i.cl(j),u_node_matrix:new i.cl(j)}),groundShadow:j=>({u_matrix:new i.cl(j),u_ground_shadow_factor:new i.ci(j)}),stars:j=>({u_matrix:new i.cl(j),u_up:new i.ci(j),u_right:new i.ci(j),u_intensity_multiplier:new i.cj(j)}),snowParticle:j=>({u_modelview:new i.cl(j),u_projection:new i.cl(j),u_time:new i.cj(j),u_cam_pos:new i.ci(j),u_velocityConeAperture:new i.cj(j),u_velocity:new i.cj(j),u_horizontalOscillationRadius:new i.cj(j),u_horizontalOscillationRate:new i.cj(j),u_boxSize:new i.cj(j),u_billboardSize:new i.cj(j),u_simpleShapeParameters:new i.ck(j),u_screenSize:new i.ck(j),u_thinningCenterPos:new i.ck(j),u_thinningShape:new i.ci(j),u_thinningAffectedRatio:new i.cj(j),u_thinningParticleOffset:new i.cj(j),u_particleColor:new i.d3(j),u_direction:new i.ci(j)}),rainParticle:j=>({u_modelview:new i.cl(j),u_projection:new i.cl(j),u_time:new i.cj(j),u_cam_pos:new i.ci(j),u_texScreen:new i.ch(j),u_velocityConeAperture:new i.cj(j),u_velocity:new i.cj(j),u_boxSize:new i.cj(j),u_rainDropletSize:new i.ck(j),u_distortionStrength:new i.cj(j),u_rainDirection:new i.ci(j),u_color:new i.d3(j),u_screenSize:new i.ck(j),u_thinningCenterPos:new i.ck(j),u_thinningShape:new i.ci(j),u_thinningAffectedRatio:new i.cj(j),u_thinningParticleOffset:new i.cj(j),u_shapeDirectionalPower:new i.cj(j),u_shapeNormalPower:new i.cj(j),u_mode:new i.cj(j)}),vignette:j=>({u_vignetteShape:new i.ci(j),u_vignetteColor:new i.d3(j)}),occlusion:j=>({u_matrix:new i.cl(j),u_anchorPos:new i.ci(j),u_screenSizePx:new i.ck(j),u_occluderSizePx:new i.ck(j),u_color:new i.d3(j)})};class fm{constructor(u,x,N,P){this.id=fm.uniqueIdxCounter,fm.uniqueIdxCounter++,this.context=u;const O=u.gl;this.buffer=O.createBuffer(),this.dynamicDraw=!!N,this.context.unbindVAO(),u.bindElementBuffer.set(this.buffer),O.bufferData(O.ELEMENT_ARRAY_BUFFER,x.arrayBuffer,this.dynamicDraw?O.DYNAMIC_DRAW:O.STATIC_DRAW),this.dynamicDraw||P||x.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(u){this.id=fm.uniqueIdxCounter,fm.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)}}fm.uniqueIdxCounter=0;const BM={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class AL{constructor(u,x,N,P,O,F){this.length=x.length,this.attributes=N,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||O||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 N=0;N0&&u.vertexAttribDivisor(O,N)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class EL{constructor(u,x,N,P,O){this.context=u,this.width=x,this.height=N;const F=this.framebuffer=u.gl.createFramebuffer();P>0&&(this.colorAttachment0=new eS(u,F,0)),P>1&&(this.colorAttachment1=new eS(u,F,1)),O&&(this.depthAttachmentType=O,this.depthAttachment=O==="renderbuffer"?new F0(u,F):new T_(u,F))}createColorAttachment(u,x){x===0?this.colorAttachment0=new eS(u,this.framebuffer,0):x===1&&(this.colorAttachment1=new eS(u,this.framebuffer,1))}removeColorAttachment(u,x){const N=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&&N.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 V0{constructor(u,x){this.gl=u,this.clearColor=new Ple(this),this.clearDepth=new dL(this),this.clearStencil=new wM(this),this.colorMask=new ZN(this),this.depthMask=new jM(this),this.stencilMask=new qx(this),this.stencilFunc=new L0(this),this.stencilOp=new C_(this),this.stencilTest=new D0(this),this.depthRange=new uL(this),this.depthTest=new kM(this),this.depthFunc=new hL(this),this.blend=new O0(this),this.blendFunc=new YN(this),this.blendColor=new XN(this),this.blendEquation=new NM(this),this.cullFace=new QN(this),this.cullFaceSide=new M_(this),this.frontFace=new mL(this),this.program=new fL(this),this.activeTexture=new pL(this),this.viewport=new R0(this),this.bindFramebuffer=new gL(this),this.bindRenderbuffer=new Lle(this),this.bindTexture=new Dle(this),this.bindVertexBuffer=new Ole(this),this.bindElementBuffer=new SM(this),this.bindVertexArrayOES=new CM(this),this.pixelStoreUnpack=new MM(this),this.pixelStoreUnpackPremultiplyAlpha=new TM(this),this.pixelStoreUnpackFlipY=new xL(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,N){return new fm(this,u,x,N)}createVertexBuffer(u,x,N,P,O){return new AL(this,u,x,N,P,O)}createRenderbuffer(u,x,N){const P=this.gl,O=P.createRenderbuffer();return this.bindRenderbuffer.set(O),P.renderbufferStorage(P.RENDERBUFFER,u,x,N),this.bindRenderbuffer.set(null),O}createFramebuffer(u,x,N,P){return new EL(this,u,x,N,P)}clear({color:u,depth:x,stencil:N,colorMask:P}){const O=this.gl;let F=0;u&&(F|=O.COLOR_BUFFER_BIT,this.clearColor.set(u.toNonPremultipliedRenderColor(null)),this.colorMask.set(P||[!0,!0,!0,!0])),x!==void 0&&(F|=O.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(x),this.depthMask.set(!0)),N!==void 0&&(F|=O.STENCIL_BUFFER_BIT,this.clearStencil.set(N),this.stencilMask.set(255)),O.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,wn.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 Gx;function ms(j,u,x,N,P,O,F){const U=j.context,G=U.gl,J=j.transform,te=[i.aF(J.center.lng),i.aJ(J.center.lat)],me=x.layout.get("symbol-placement"),he=x.layout.get("text-variable-anchor"),fe=x.layout.get("icon-rotation-alignment")==="map",ke=x.layout.get("text-rotation-alignment")==="map",be=me!=="point",Re=[];let Oe=0,Ge=0;for(let ht=0;ht0){const Qr=i.bC(),ns=Or;i.cP(Qr,zt.placementInvProjMatrix,J.glCoordMatrix),i.cP(Qr,Qr,zt.placementViewportMatrix),Re.push({circleArray:vs,circleOffset:Ge,transform:ns,invTransform:Qr,projection:zt.getProjection()}),Oe+=vs.length/4,Ge=Oe}if(!Tr)continue;j.terrain&&j.terrain.setupElevationDraw(Bt,rs);const ps=gr?[At.canonical.x,At.canonical.y,1<=0&&(fe[at.associatedIconIndex]={x:zt,y:Jt,z:er,angle:nr})}else um(xt,me)}if(J){he.clear();const Ge=j.icon.placedSymbolArray;for(let at=0;at{let pa=[0,0,0];if(Ra){const Nn=j.style.directionalLight,Si=j.style.ambientLight;Nn&&Si&&(pa=ap(j.style,Nn,Si))}return pa},ja=Ra=>{ht.depthOcclusionForSymbolsAndCircles&&(x.hasOcclusionOpacityProperties||j.terrain)&&(Ra.push("DEPTH_D24"),Ra.push("DEPTH_OCCLUSION"))},an=Ra=>{x.lut&&!xt&&(x.lut.texture||(x.lut.texture=new i.d$(j.context,x.lut.image,[x.lut.image.height,x.lut.image.height,x.lut.image.height],bt.gl.RGBA8)),bt.activeTexture.set(bt.gl.TEXTURE0+Vl.LUT),x.lut.texture&&x.lut.texture.bind(bt.gl.LINEAR,bt.gl.CLAMP_TO_EDGE),Ra.push("APPLY_LUT_ON_GPU"))},Oa=()=>{const Ra=At&&x.layout.get("symbol-placement")!=="point",pa=[];ja(pa),an(pa);const Nn=Ra||mn,Si=Tr.elevationType==="road",bo=j.shadowRenderer,ro=Si&&zt&&!!bo&&bo.enabled,oi=js(ro),Rd=Si&&zt&&!j.terrain?Kt:Cr,Ic=x.paint.get("icon-image-cross-fade");j.terrainRenderModeElevated()&&zt&&pa.push("PITCH_WITH_MAP_TERRAIN"),vs&&(pa.push("PROJECTION_GLOBE_VIEW"),Nn&&pa.push("PROJECTED_POS_ON_VIEWPORT")),Ic>0&&Tr.hasAnySecondaryIcon&&pa.push("ICON_TRANSITION"),!Tr.icon.zOffsetVertexBuffer||Si&&j.terrain||pa.push("Z_OFFSET"),Oe===0&&Ge===0&&at===0&&Ke===1||pa.push("COLOR_ADJUSTMENT"),Tr.sdfIcons&&pa.push("RENDER_SDF"),ro&&pa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Si&&zt&&!j.terrain&&Tr.icon.orientationVertexBuffer&&pa.push("ELEVATED_ROADS");const nl=Tr.icon.programConfigurations.get(x.id),Zc=j.getOrCreateProgram("symbol",{config:nl,defines:pa}),Yc=Or.imageAtlasTexture?Or.imageAtlasTexture.size:[0,0],nc=Tr.iconSizeData,Ju=i.bK(nc,ht.zoom),Dh=zt||!ht.isOrthographic,nu=Ta(Qr,Or.tileID.canonical,zt,At,ht,Tr.getProjection(),ns),fo=bu(Qr,Or.tileID.canonical,zt,At,ht,Tr.getProjection(),ns),So=j.translatePosMatrix(fo,Or,U,J,!0),li=j.translatePosMatrix(Qr,Or,U,J),Oo=Nn?D_:nu,oo=At&&!zt&&!Ra;let so=qr;!Xt&&!ht.mercatorFromTransition||At||(so=op(ht));const Oh=vs?so:qr,K_=x.getColorAdjustmentMatrix(Oe,Ge,at,Ke),xm=dS(nc.kind,Ju,oo,zt,j,li,Oo,So,Nt,!1,Yc,[0,0],0,rs,ps,Lt,sa,Oh,Tr.getProjection(),oi,Ea,K_,Ic,null),Z_=Or.imageAtlasTexture?Or.imageAtlasTexture:null,Q0=x.layout.get("icon-size").constantOr(0)!==1||Tr.iconsNeedLinear,cf=Tr.sdfIcons||j.options.rotating||j.options.zooming||Q0||Dh?gt.LINEAR:gt.NEAREST,gp=Tr.sdfIcons&&x.paint.get("icon-halo-width").constantOr(1)!==0,J0=j.terrain&&zt&&Ra?i.bl(i.bC(),nu):D_;if(Ra&&Tr.icon){const Rg=i.bV.getAtTileOffsetFunc(rs,ht.center.lat,ht.worldSize,Tr.getProjection()),xp=dm(Qr,Or.tileID.canonical,zt,At,ht,Tr.getProjection(),ns),ym=x.layout.get("icon-size-scale-range"),yp=i.aA(j.scaleFactor,ym[0],ym[1]);tL(Tr,Qr,j,!1,xp,fo,zt,be,Rg,rs,yp)}return{program:Zc,buffers:Tr.icon,uniformValues:xm,atlasTexture:Z_,atlasTextureIcon:null,atlasInterpolation:cf,atlasInterpolationIcon:null,isSDF:Tr.sdfIcons,hasHalo:gp,depthMode:Rd,tile:Or,renderWithShadows:ro,labelPlaneMatrixInv:J0}},Xa=()=>{const Ra=Bt&&x.layout.get("symbol-placement")!=="point",pa=[],Nn=Ra||nr||mn,Si=Tr.elevationType==="road",bo=j.shadowRenderer,ro=Si&&Jt&&!!bo&&bo.enabled,oi=js(ro),Rd=Si&&Jt&&!j.terrain?Kt:Cr;j.terrainRenderModeElevated()&&Jt&&pa.push("PITCH_WITH_MAP_TERRAIN"),vs&&(pa.push("PROJECTION_GLOBE_VIEW"),Nn&&pa.push("PROJECTED_POS_ON_VIEWPORT")),!Tr.text.zOffsetVertexBuffer||Si&&j.terrain||pa.push("Z_OFFSET"),Tr.iconsInText&&pa.push("RENDER_TEXT_AND_SYMBOL"),pa.push("RENDER_SDF"),ro&&pa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Si&&Jt&&!j.terrain&&Tr.text.orientationVertexBuffer&&pa.push("ELEVATED_ROADS"),ja(pa);const Ic=Tr.text.programConfigurations.get(x.id),nl=j.getOrCreateProgram("symbol",{config:Ic,defines:pa});let Zc,Yc=[0,0],nc=null;const Ju=Tr.textSizeData;Tr.iconsInText&&(Yc=Or.imageAtlasTexture?Or.imageAtlasTexture.size:[0,0],nc=Or.imageAtlasTexture?Or.imageAtlasTexture:null,Zc=Jt||!ht.isOrthographic||j.options.rotating||j.options.zooming||Ju.kind==="composite"||Ju.kind==="camera"?gt.LINEAR:gt.NEAREST);const Dh=Or.glyphAtlasTexture?Or.glyphAtlasTexture.size:[0,0],nu=x.layout.get("text-size-scale-range"),fo=i.aA(j.scaleFactor,nu[0],nu[1]),So=i.bK(Ju,ht.zoom,fo),li=Ta(Qr,Or.tileID.canonical,Jt,Bt,ht,Tr.getProjection(),ns),Oo=bu(Qr,Or.tileID.canonical,Jt,Bt,ht,Tr.getProjection(),ns),oo=j.translatePosMatrix(Oo,Or,G,te,!0),so=j.translatePosMatrix(Qr,Or,G,te),Oh=Nn?D_:li,K_=Bt&&!Jt&&!Ra;let xm=qr;!Xt&&!ht.mercatorFromTransition||Bt||(xm=op(ht));const Z_=dS(Ju.kind,So,K_,Jt,j,so,Oh,oo,Nt,!0,Dh,Yc,0,rs,ps,Lt,sa,vs?xm:qr,Tr.getProjection(),oi,Ea,null,null,fo),Q0=Or.glyphAtlasTexture?Or.glyphAtlasTexture:null,cf=gt.LINEAR,gp=x.paint.get("text-halo-width").constantOr(1)!==0,J0=j.terrain&&Jt&&Ra?i.bl(i.bC(),li):D_;if(Ra&&Tr.text){const Rg=i.bV.getAtTileOffsetFunc(rs,ht.center.lat,ht.worldSize,Tr.getProjection()),xp=dm(Qr,Or.tileID.canonical,Jt,Bt,ht,Tr.getProjection(),ns);tL(Tr,Qr,j,!0,xp,Oo,Jt,Re,Rg,rs,fo)}return{program:nl,buffers:Tr.text,uniformValues:Z_,atlasTexture:Q0,atlasTextureIcon:nc,atlasInterpolation:cf,atlasInterpolationIcon:Zc,isSDF:!0,hasHalo:gp,depthMode:Rd,tile:Or,renderWithShadows:ro,labelPlaneMatrixInv:J0}},qa=Tr.icon.segments.get().length,wa=Tr.text.segments.get().length,kn=qa&&!F.onlyText?Oa():null,Da=wa&&!F.onlyIcons?Xa():null,io=x.paint.get("icon-opacity").constantOr(1),Di=x.paint.get("text-opacity").constantOr(1);if(er&&Tr.canOverlap){ur=!0;const Ra=io&&!F.onlyText?Tr.icon.segments.get():[],pa=Di&&!F.onlyIcons?Tr.text.segments.get():[];for(const Nn of Ra)gr.push({segments:new i.bg([Nn]),sortKey:Nn.sortKey,state:kn});for(const Nn of pa)gr.push({segments:new i.bg([Nn]),sortKey:Nn.sortKey,state:Da})}else F.onlyText||gr.push({segments:io?Tr.icon.segments:new i.bg([]),sortKey:0,state:kn}),F.onlyIcons||gr.push({segments:Di?Tr.text.segments:new i.bg([]),sortKey:0,state:Da})}ur&&gr.sort((rs,Or)=>rs.sortKey-Or.sortKey);for(const rs of gr){const Or=rs.state;if(Or)if(j.terrain?j.terrain.setupElevationDraw(Or.tile,Or.program,{useDepthForOcclusion:ht.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:Or.labelPlaneMatrixInv}):j.setupDepthForOcclusion(ht.depthOcclusionForSymbolsAndCircles,Or.program),bt.activeTexture.set(gt.TEXTURE0),Or.atlasTexture&&Or.atlasTexture.bind(Or.atlasInterpolation,gt.CLAMP_TO_EDGE,!0),Or.atlasTextureIcon&&(bt.activeTexture.set(gt.TEXTURE1),Or.atlasTextureIcon&&Or.atlasTextureIcon.bind(Or.atlasInterpolationIcon,gt.CLAMP_TO_EDGE,!0)),Or.renderWithShadows&&j.shadowRenderer.setupShadows(Or.tile.tileID.toUnwrapped(),Or.program,"vector-tile"),j.uploadCommonLightUniforms(j.context,Or.program),Or.hasHalo){const Tr=Or.uniformValues;Tr.u_is_halo=1,$M(Or.buffers,rs.segments,x,j,Or.program,Or.depthMode,P,O,Tr,2),Tr.u_is_halo=0}else{if(Or.isSDF){const Tr=Or.uniformValues;Or.hasHalo&&(Tr.u_is_halo=1,$M(Or.buffers,rs.segments,x,j,Or.program,Or.depthMode,P,O,Tr,1)),Tr.u_is_halo=0}$M(Or.buffers,rs.segments,x,j,Or.program,Or.depthMode,P,O,Or.uniformValues,1)}}}function $M(j,u,x,N,P,O,F,U,G,J){const te=[j.dynamicLayoutVertexBuffer,j.opacityVertexBuffer,j.iconTransitioningVertexBuffer,j.globeExtVertexBuffer,j.zOffsetVertexBuffer,j.orientationVertexBuffer];P.draw(N,N.context.gl.TRIANGLES,O,F,U,Ys.disabled,G,x.id,j.layoutVertexBuffer,j.indexBuffer,u,x.paint,N.transform.zoom,j.programConfigurations.get(x.id),te,J)}function IL(j,u){const x=1<=mm?1:fe.pitch/mm))),2*ke}(j.transform),J=j.transform.getFreeCameraOptions().position,te="elevatedStructuresDepthReconstruct",me=j.getOrCreateProgram(te,{defines:["DEPTH_RECONSTRUCTION"]}),he=j.getOrCreateProgram(te);for(const fe of N){const ke=u.getTile(fe),be=ke.getBucket(x);if(!be)continue;const Re=be.elevatedStructures;if(!Re)continue;const Oe=be.elevationBufferData.heightRange,Ge=IL(fe.toUnwrapped(),J),at=j.translatePosMatrix(fe.projMatrix,ke,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor"));let Ke,Nt,xt,bt;if(P==="initialize"){if(!Oe||Oe.min>=1||Re.depthSegments.segments[0].primitiveLength===0)continue;Ke=Hx(at,Ge,G,1,0),Nt=F,xt=Re.depthSegments,bt=me}else if(P==="reset"){if(!Oe||Oe.min>=0||Re.maskSegments.segments[0].primitiveLength===0)continue;Ke=Hx(at,Ge,0,0,1),Nt=U,xt=Re.maskSegments,bt=me}else if(P==="geometry"){if(Re.depthSegments.segments[0].primitiveLength===0)continue;Ke=Hx(at,Ge,G,1,0),Nt=F,xt=Re.depthSegments,bt=he}bt.draw(j,O.TRIANGLES,Nt,Js.disabled,wn.disabled,Ys.disabled,Ke,x.id,Re.vertexBuffer,Re.indexBuffer,xt,x.paint,j.transform.zoom)}}function mS(j,u,x,N){const{painter:P,sourceCache:O,layer:F,coords:U,colorMode:G,elevationType:J,terrainEnabled:te,pass:me}=j,he=P.context.gl,fe=F.paint.get("fill-pattern"),ke=F.paint.get("fill-pattern-cross-fade"),be=fe.constantOr(null);let Re=J;J!=="road"||u&&!te||(Re="none");const Oe=Re==="road",Ge=j.painter.shadowRenderer,at=Oe&&!!Ge&&Ge.enabled,Ke=new ks(P.context.gl.LEQUAL,ks.ReadOnly,P.depthRangeFor3D);let Nt=[0,0,0];if(at){const ht=P.style.directionalLight,At=P.style.ambientLight;ht&&At&&(Nt=ap(P.style,ht,At))}const xt=fe&&fe.constantOr(1),bt=P.terrain&&P.terrain.renderingToTexture,gt=(ht,At)=>{let Bt,zt,Jt,er,ur;At?(Bt=xt&&!F.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",Jt=he.LINES):(Bt=xt?"fillPattern":"fill",Jt=he.TRIANGLES);for(const Cr of U){const Kt=O.getTile(Cr);if(xt&&!Kt.patternsLoaded())continue;const Lt=Kt.getBucket(F);if(!Lt)continue;const nr=u?Lt.elevationBufferData:Lt.bufferData;if(nr.isEmpty())continue;P.prepareDrawTile();const Xt=nr.programConfigurations.get(F.id),gr=P.isTileAffectedByFog(Cr),qr=[],rs=[];Oe&&(qr.push("ELEVATED_ROADS"),rs.push(nr.elevatedLayoutVertexBuffer)),at&&qr.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),bt&&x&&qr.push("USE_MRT1"),xt&&(P.context.activeTexture.set(he.TEXTURE0),Kt.imageAtlasTexture&&Kt.imageAtlasTexture.bind(he.LINEAR,he.CLAMP_TO_EDGE),Xt.updatePaintBuffers());let Or=!1;if(be&&Kt.imageAtlas){const ns=Kt.imageAtlas,Ps=i.e3.from(be),mn=Ps.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),sa=Ps.getSecondary(),Ea=ns.patternPositions.get(mn),js=sa?ns.patternPositions.get(sa.scaleSelf(i.o.devicePixelRatio).toString()):null;Or=!!Ea&&!!js,Ea&&Xt.setConstantPatternPositions(Ea,js)}ke>0&&(Or||Xt.getPatternTransitionVertexBuffer("fill-pattern"))&&qr.push("FILL_PATTERN_TRANSITION");const Tr=P.getOrCreateProgram(Bt,{config:Xt,overrideFog:gr,defines:qr}),vs=P.translatePosMatrix(Cr.projMatrix,Kt,F.paint.get("fill-translate"),F.paint.get("fill-translate-anchor"));at&&Ge.setupShadows(Kt.tileID.toUnwrapped(),Tr,"vector-tile");const ps=F.paint.get("fill-emissive-strength");if(At){er=nr.lineIndexBuffer,ur=nr.lineSegments;const ns=P.terrain&&P.terrain.renderingToTexture?P.terrain.drapeBufferSize:[he.drawingBufferWidth,he.drawingBufferHeight];zt=Bt==="fillOutlinePattern"&&xt?RM(vs,ps,P,Kt,ns,Nt,ke):wL(vs,ps,ns,Nt)}else er=nr.indexBuffer,ur=nr.triangleSegments,zt=xt?OM(vs,ps,P,Kt,Nt,ke):DM(vs,ps,Nt);P.uploadCommonUniforms(P.context,Tr,Cr.toUnwrapped());let Qr=ht;(J==="road"&&!te||J==="offset")&&(Qr=Ke),Tr.draw(P,Jt,Qr,N||P.stencilModeForClipping(Cr),G,Ys.disabled,zt,F.id,nr.layoutVertexBuffer,er,ur,F.paint,P.transform.zoom,Xt,rs)}};P.renderPass===me&>(P.depthModeForSublayer(1,P.renderPass==="opaque"?ks.ReadWrite:ks.ReadOnly),!1),Re==="none"&&P.renderPass==="translucent"&&F.paint.get("fill-antialias")&>(P.depthModeForSublayer(F.getPaintProperty("fill-outline-color")?2:0,ks.ReadOnly),!0)}function fS(j,u,x,N,P,O,F,U){x.resetLayerRenderingStats(j);const G=j.context,J=G.gl,te=j.transform,me=x.paint.get("fill-extrusion-pattern"),he=x.paint.get("fill-extrusion-pattern-cross-fade"),fe=me.constantOr(null),ke=me.constantOr(1),be=x.paint.get("fill-extrusion-opacity"),Re=j.style.enable3dLights(),Oe=x.paint.get(Re&&!ke?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),Ge=[x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Oe],at=x.layout.get("fill-extrusion-edge-radius"),Ke=at>0&&!x.paint.get("fill-extrusion-rounded-roof"),Nt=Ke?0:at,xt=te.projection.name==="globe"?i.eb():0,bt=te.projection.name==="globe",gt=bt?i.aj(te.zoom):0,ht=[i.aF(te.center.lng),i.aJ(te.center.lat)],At=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Bt=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(At?null:x.lut).toArray01().slice(0,3),zt=x.paint.get("fill-extrusion-flood-light-intensity"),Jt=x.paint.get("fill-extrusion-vertical-scale"),er=x.paint.get("fill-extrusion-line-width").constantOr(1)!==0,ur=x.paint.get("fill-extrusion-height-alignment"),Cr=x.paint.get("fill-extrusion-base-alignment"),Kt=jg(j,x.paint.get("fill-extrusion-cutoff-fade-range")),Lt=[];let nr;bt&&Lt.push("PROJECTION_GLOBE_VIEW"),Ge[0]>0&&Lt.push("FAUX_AO"),Ke&&Lt.push("ZERO_ROOF_RADIUS"),U&&Lt.push("HAS_CENTROID"),zt>0&&Lt.push("FLOOD_LIGHT"),Kt.shouldRenderCutoff&&Lt.push("RENDER_CUTOFF"),er&&Lt.push("RENDER_WALL_MODE");const Xt=j.renderPass==="shadow",gr=j.shadowRenderer,qr=Xt&&!!gr,rs=Xt?Ys.disabled:Ys.backCCW;j.shadowRenderer&&(j.shadowRenderer.useNormalOffset=!0);let Or=[0,0,0];if(gr){const ps=j.style.directionalLight,Qr=j.style.ambientLight;ps&&Qr&&(Or=ap(j.style,ps,Qr)),Xt||(Lt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),gr.useNormalOffset&&Lt.push("NORMAL_OFFSET")),nr=Lt.concat(["SHADOWS_SINGLE_CASCADE"])}const Tr=qr?"fillExtrusionDepth":ke?"fillExtrusionPattern":"fillExtrusion",vs=x.getLayerRenderingStats();for(const ps of N){const Qr=u.getTile(ps),ns=Qr.getBucket(x);if(!ns||ns.projection.name!==te.projection.name)continue;let Ps=!1;gr&&(Ps=gr.getMaxCascadeForTile(ps.toUnwrapped())===0);const mn=j.isTileAffectedByFog(ps),sa=ns.programConfigurations.get(x.id);let Ea=!1;if(fe&&Qr.imageAtlas){const wa=Qr.imageAtlas,kn=i.e3.from(fe),Da=kn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),io=kn.getSecondary(),Di=wa.patternPositions.get(Da),Ra=io?wa.patternPositions.get(io.scaleSelf(i.o.devicePixelRatio).toString()):null;Ea=!!Di&&!!Ra,Di&&sa.setConstantPatternPositions(Di,Ra)}he>0&&(Ea||sa.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Lt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const js=j.getOrCreateProgram(Tr,{config:sa,defines:Ps?nr:Lt,overrideFog:mn});if(j.terrain&&j.terrain.setupElevationDraw(Qr,js,{useMeterToDem:!0}),!ns.centroidVertexBuffer){const wa=js.getAttributeLocation(J,"a_centroid_pos");wa!==-1&&J.vertexAttrib2f(wa,0,0)}!Xt&&gr&&gr.setupShadows(Qr.tileID.toUnwrapped(),js,"vector-tile"),ke&&(j.context.activeTexture.set(J.TEXTURE0),Qr.imageAtlasTexture&&Qr.imageAtlasTexture.bind(J.LINEAR,J.CLAMP_TO_EDGE),sa.updatePaintBuffers());const ja=x.paint.get("fill-extrusion-vertical-gradient"),an=1/ns.tileToMeter;let Oa;if(Xt&&gr){if(cp(Qr.tileID,ns.maxHeight,j))continue;const wa=gr.calculateShadowPassMatrixFromTile(Qr.tileID.toUnwrapped());Oa=LM(wa,Nt,an,Jt,ur,Cr)}else{const wa=j.translatePosMatrix(ps.expandedProjMatrix,Qr,x.paint.get("fill-extrusion-translate"),x.paint.get("fill-extrusion-translate-anchor")),kn=te.projection.createInversionMatrix(te,ps.canonical);Oa=ke?bL(wa,j,ja,be,Ge,Nt,an,ps,Qr,xt,ur,Cr,gt,ht,kn,Bt,Jt,he):iS(wa,j,ja,be,Ge,Nt,an,ps,xt,ur,Cr,gt,ht,kn,Bt,Jt,zt,Or)}j.uploadCommonUniforms(G,js,ps.toUnwrapped(),null,Kt);let Xa=ns.segments;if(te.projection.name==="mercator"&&!Xt&&(Xa=ns.getVisibleSegments(Qr.tileID,j.terrain,j.transform.getFrustum(0)),!Xa.get().length))continue;if(vs)if(Xt)for(const wa of Xa.get())vs.numRenderedVerticesInShadowPass+=wa.primitiveLength;else for(const wa of Xa.get())vs.numRenderedVerticesInTransparentPass+=wa.primitiveLength;const qa=[];(j.terrain||U)&&qa.push(ns.centroidVertexBuffer),bt&&qa.push(ns.layoutVertexExtBuffer),er&&qa.push(ns.wallVertexBuffer),js.draw(j,G.gl.TRIANGLES,P,O,F,rs,Oa,x.id,ns.layoutVertexBuffer,ns.indexBuffer,Xa,x.paint,j.transform.zoom,sa,qa)}j.shadowRenderer&&(j.shadowRenderer.useNormalOffset=!1)}class UM{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function lp(j,u,x,N,P,O,F,U,G,J,te,me,he,fe,ke,be,Re,Oe,Ge,at){const Ke=u.context,Nt=Ke.gl,xt=u.transform,bt=u.transform.zoom,gt=[],ht=j.translate,At=j.translateAnchor,Bt=j.edgeRadius,zt=jg(u,j.cutoffFadeRange);te==="clear"?(gt.push("CLEAR_SUBPASS"),at&&(gt.push("CLEAR_FROM_TEXTURE"),Ke.activeTexture.set(Nt.TEXTURE0),at.bind(Nt.LINEAR,Nt.CLAMP_TO_EDGE))):te==="sdf"?gt.push("SDF_SUBPASS"):te==="emissive"&&(gt.push("USE_MRT1"),Ke.activeTexture.set(Nt.TEXTURE0),at.bind(Nt.LINEAR,Nt.CLAMP_TO_EDGE)),Oe&>.push("HAS_CENTROID"),zt.shouldRenderCutoff&>.push("RENDER_CUTOFF");const Jt=(er,ur,Cr,Kt,Lt)=>{let nr=gt;ur.groundRadiusBuffer!=null&&(nr=gt.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Xt=ur.programConfigurations.get(N.id),gr=u.isTileAffectedByFog(er),qr=u.getOrCreateProgram("fillExtrusionGroundEffect",{config:Xt,defines:nr,overrideFog:gr}),rs=$0(u,Kt,me,J,Lt,[he,fe*Lt],ke,be,Re,bt>=17?0:Bt*Lt,at?at.size[0]:0),Or=[];Oe&&Or.push(ur.hiddenByLandmarkVertexBuffer),ur.groundRadiusBuffer!=null&&Or.push(ur.groundRadiusBuffer),u.uploadCommonUniforms(Ke,qr,er.toUnwrapped(),null,zt),qr.draw(u,Ke.gl.TRIANGLES,O,F,U,G,rs,N.id,ur.vertexBuffer,ur.indexBuffer,Cr,N.paint,bt,Xt,Or)};for(const er of P){const ur=x.getTile(er),Cr=ur.getBucket(N);if(!Cr||Cr.projection.name!==xt.projection.name||!Cr.groundEffect||Cr.groundEffect&&!Cr.groundEffect.hasData())continue;const Kt=Cr.groundEffect,Lt=1/Cr.tileToMeter;{const nr=u.translatePosMatrix(er.projMatrix,ur,ht,At),Xt=Kt.getDefaultSegment();Jt(er,Kt,Xt,nr,Lt)}if(Ge)for(let nr=0;nr<4;nr++){const Xt=i.e9[nr](er),gr=x.getTile(Xt);if(!gr)continue;const qr=gr.getBucket(N);if(!qr||qr.projection.name!==xt.projection.name||!qr.groundEffect||qr.groundEffect&&!qr.groundEffect.hasData())continue;const rs=qr.groundEffect;let Or,Tr;nr===0?(Or=[-i.al,0,0],Tr=1):nr===1?(Or=[i.al,0,0],Tr=0):nr===2?(Or=[0,-i.al,0],Tr=3):(Or=[0,i.al,0],Tr=2);const vs=rs.regionSegments[Tr];if(!vs)continue;const ps=new Float32Array(16);i.br(ps,er.projMatrix,Or),Jt(er,rs,vs,u.translatePosMatrix(ps,ur,ht,At),Lt)}}}function Ule(j,u,x,N,P,O,F){N.centroidVertexArray.length===0&&N.createCentroidsBuffer();const U=O?O.findDEMTileFor(x):null;if(!(U&&U.dem||F))return;O&&U&&U.dem&&N.selfDEMTileTimestamp!==U.dem._timestamp&&(N.borderDoneWithNeighborZ=[-1,-1,-1,-1],N.selfDEMTileTimestamp=U.dem._timestamp);const G=Oe=>new i.P(Math.ceil((Oe+i.ed)*i.ee),0),J=Oe=>{const Ge=u.getSource().minzoom,at=Nt=>{const xt=u.getTileByID(Nt);if(xt&&xt.hasData())return xt.getBucket(P)},Ke=[0,-1,1];for(const Nt of Ke){if(Oe.overscaledZ+Nt(te[0]=Math.min(Oe.min.y,Ge.min.y),te[1]=Math.max(Oe.max.y,Ge.max.y),te[2]=i.al-Ge.min.x>Oe.max.x?Ge.min.x-i.al:Oe.max.x,te),he=(Oe,Ge)=>(te[0]=Math.min(Oe.min.x,Ge.min.x),te[1]=Math.max(Oe.max.x,Ge.max.x),te[2]=i.al-Ge.min.y>Oe.max.y?Ge.min.y-i.al:Oe.max.y,te),fe=[(Oe,Ge)=>me(Oe,Ge),(Oe,Ge)=>me(Ge,Oe),(Oe,Ge)=>he(Oe,Ge),(Oe,Ge)=>he(Ge,Oe)],ke=(Oe,Ge,at,Ke,Nt,xt,bt)=>{if(!O)return 0;const gt=[[xt?at:Oe,xt?Oe:at,0],[xt?at:Ge,xt?Ge:at,0]],ht=bt<0?i.al+bt:bt,At=[xt?ht:(Oe+Ge)/2,xt?(Oe+Ge)/2:ht,0];return at===0&&bt<0||at!==0&&bt>0?O.getForTilePoints(Nt,[At],!0,Ke):gt.push(At),O.getForTilePoints(x,gt,!0,U),Math.max(gt[0][2],gt[1][2],At[2])/O.exaggeration()};for(let Oe=0;Oe<4;Oe++){const Ge=N.borderFeatureIndices[Oe];if(Ge.length===0)continue;const at=i.e9[Oe](x),Ke=J(at);if(!(Ke&&Ke instanceof i.ea))continue;const Nt=O?O.findDEMTileFor(at):null;if(!(Nt&&Nt.dem||F)||(O&&Nt&&Nt.dem&&N.borderDEMTileTimestamp[Oe]!==Nt.dem._timestamp&&(N.borderDoneWithNeighborZ[Oe]=-1,N.borderDEMTileTimestamp[Oe]=Nt.dem._timestamp),N.borderDoneWithNeighborZ[Oe]===Ke.canonical.z))continue;Ke.centroidVertexArray.length===0&&Ke.createCentroidsBuffer();const xt=(Oe<2?1:5)-Oe,bt=Ke.borderDoneWithNeighborZ[xt]!==N.canonical.z,gt=Ke.borderFeatureIndices[xt];let ht=0;if(N.canonical.z!==Ke.canonical.z){for(const At of Ge)N.showCentroid(N.featuresOnBorder[At]);if(bt)for(const At of gt)Ke.showCentroid(Ke.featuresOnBorder[At]);N.borderDoneWithNeighborZ[Oe]=Ke.canonical.z,Ke.borderDoneWithNeighborZ[xt]=N.canonical.z}for(const At of Ge){const Bt=N.featuresOnBorder[At],zt=N.centroidData[Bt.centroidDataIndex],Jt=Bt.borders[Oe];let er;for(;htJt[0]+3||ur[0]>Jt[0]-3)break;Ke.showCentroid(er),ht++}if(er&&htJt[1]-3)&&(Cr++,++ht!==gt.length);)er=Ke.featuresOnBorder[gt[ht]];er=Ke.featuresOnBorder[gt[ur]];let Kt=!1;if(Cr>=1){const Xt=er.borders[xt];Math.abs(Jt[0]-Xt[0])<3&&Math.abs(Jt[1]-Xt[1])<3&&(Cr=1,Kt=!0,ht=ur+1)}else if(Cr===0){N.showCentroid(Bt);continue}const Lt=Ke.centroidData[er.centroidDataIndex];F&&Kt&&(((be=zt).flags|(Re=Lt).flags)&i.ec?(be.flags|=i.ec,Re.flags|=i.ec):(be.flags&=~i.ec,Re.flags&=~i.ec));const nr=Bt.intersectsCount()>1||er.intersectsCount()>1;if(Cr>1)ht=ur,zt.centroidXY=Lt.centroidXY=new i.P(0,0);else if(Nt&&Nt.dem&&!nr){const Xt=fe[Oe](zt,Lt),gr=Oe%2?i.al-1:0,qr=ke(Xt[0],Math.min(i.al-1,Xt[1]),gr,Nt,at,Oe<2,Xt[2]);zt.centroidXY=Lt.centroidXY=G(qr)}else nr?zt.centroidXY=Lt.centroidXY=new i.P(0,0):(zt.centroidXY=N.encodeBorderCentroid(Bt),Lt.centroidXY=Ke.encodeBorderCentroid(er));N.writeCentroidToBuffer(zt),Ke.writeCentroidToBuffer(Lt)}else N.showCentroid(Bt)}N.borderDoneWithNeighborZ[Oe]=Ke.canonical.z,Ke.borderDoneWithNeighborZ[xt]=N.canonical.z}var be,Re;(N.needsCentroidUpdate||!N.centroidVertexBuffer&&N.centroidVertexArray.length!==0)&&N.uploadCentroid(j)}const wu=[1,0,0],VM=[0,1,0],Dd=[0,0,1];function cp(j,u,x){const N=x.transform,P=x.shadowRenderer;if(!P)return!0;const O=j.toUnwrapped(),F=N.tileSize*P._cascades[x.currentShadowCascade].scale;let U=u;if(N.elevation){const be=N.elevation.getMinMaxForTile(j);be&&(U+=be.max)}const G=[...P.shadowDirection];G[2]=-G[2];const J=P.computeSimplifiedTileShadowVolume(O,U,F,G);if(!J)return!1;const te=[wu,VM,Dd,G,[G[0],0,G[2]],[0,G[1],G[2]]],me=N.projection.name==="globe",he=N.scaleZoom(F),fe=i.cB.fromInvProjectionMatrix(N.invProjMatrix,N.worldSize,he,!me),ke=P.getCurrentCascadeFrustum();return fe.intersectsPrecise(J.vertices,J.planes,te)===0||ke.intersectsPrecise(J.vertices,J.planes,te)===0}function R_(j){const{painter:u,source:x,layer:N,coords:P}=j;let O=j.defines;const F=u.context,U=u.renderPass==="shadow",G=u.renderPass==="light-beam",J=u.shadowRenderer,te=i.ef(u.transform.center.lat,u.transform.zoom),me=jg(u,N.paint.get("building-cutoff-fade-range"));me.shouldRenderCutoff&&(O=O.concat("RENDER_CUTOFF")),j.floodLightIntensity>0&&(O=O.concat("FLOOD_LIGHT"));for(const he of P){const fe=x.getTile(he),ke=fe.getBucket(N);if(!ke)continue;J&&J.getMaxCascadeForTile(he.toUnwrapped())===0&&(O=O.concat("SHADOWS_SINGLE_CASCADE"));const be=ke.programConfigurations.get(N.id);let Re,Oe,Ge,at=u.translatePosMatrix(he.expandedProjMatrix,fe,[0,0],"map");if(at=i.cS(i.bC(),at,[1,1,j.verticalScale]),U&&J){if(cp(fe.tileID,ke.maxHeight*te,u))continue;let Nt=J.calculateShadowPassMatrixFromTile(fe.tileID.toUnwrapped());Nt=i.cS(i.bC(),Nt,[1,1,j.verticalScale]),Ge=Ag(Nt),Re=Oe=u.getOrCreateProgram("buildingDepth",{config:be,defines:O,overrideFog:!1})}else if(G)Re=Oe=u.getOrCreateProgram("buildingBloom",{config:be,defines:O,overrideFog:!1}),Ge=jL(at);else{const Nt=u.transform.calculatePosMatrix(he.toUnwrapped(),u.transform.worldSize);i.cS(Nt,Nt,[1,1,j.verticalScale]);const xt=i.bC();i.cS(xt,Nt,[1,-1,1/te]),i.bl(xt,xt),i.eg(xt,xt);const bt=u.transform.getFreeCameraOptions().position,gt=1<{if(G){const bt=Nt.entranceBloom;xt.draw(u,F.gl.TRIANGLES,j.depthMode,Js.disabled,j.blendMode,Ys.disabled,Ge,N.id,bt.layoutVertexBuffer,bt.indexBuffer,bt.segmentsBucket,N.paint,u.transform.zoom,be,[bt.layoutAttenuationBuffer,bt.layoutColorBuffer])}else{const bt=Nt.segmentsBucket;let gt=[Nt.layoutNormalBuffer,Nt.layoutCentroidBuffer,Nt.layoutColorBuffer,Nt.layoutFloodLightDataBuffer];Nt.layoutFacadePaintBuffer&&(gt=gt.concat([Nt.layoutFacadeDataBuffer,Nt.layoutFacadeVerticalRangeBuffer,Nt.layoutFacadePaintBuffer])),xt.draw(u,F.gl.TRIANGLES,j.depthMode,Js.disabled,j.blendMode,U?Ys.disabled:Ys.backCW,Ge,N.id,Nt.layoutVertexBuffer,Nt.indexBuffer,bt,N.paint,u.transform.zoom,be,gt)}};u.uploadCommonUniforms(F,Oe,he.toUnwrapped(),null,me),ke.buildingWithoutFacade&&Ke(ke.buildingWithoutFacade,Oe),ke.buildingWithFacade&&(Re!==Oe&&u.uploadCommonUniforms(F,Re,he.toUnwrapped(),null,me),Ke(ke.buildingWithFacade,Re))}}function pS(j,u,x,N,P,O,F,U,G,J,te,me,he){const fe=j.context.gl,ke=j.depthModeForSublayer(1,ks.ReadOnly,fe.LEQUAL,!0),be=.1*(1-(Re=te))+3*Re;var Re;const Oe=j._showOverdrawInspector,Ge=me,at=new UM;Oe||lp(at,j,u,x,N,ke,new Js({func:fe.ALWAYS,mask:255},255,255,fe.KEEP,fe.KEEP,fe.REPLACE),new wn([fe.ONE,fe.ONE,fe.ONE,fe.ONE],i.ao.transparent,[!1,!1,!1,!0],fe.MIN),Ys.disabled,P,"sdf",O,F,U,G,J,be,Ge,!1);{const Ke=Oe?Js.disabled:new Js({func:fe.EQUAL,mask:255},255,255,fe.KEEP,fe.DECR,fe.DECR),Nt=Oe?j.colorModeForRenderPass():new wn([fe.ONE_MINUS_DST_ALPHA,fe.DST_ALPHA,fe.ONE,fe.ONE],i.ao.transparent,[!0,!0,!0,!0]);lp(at,j,u,x,N,ke,Ke,Nt,Ys.disabled,P,"color",O,F,U,G,J,be,Ge,!1)}}function gS(j){return[j[0]*i.eh,j[1]*i.eh,j[2]*i.eh,0]}function F_(j,u,x,N,P,O,F,U,G){const J=N.getSource(),te=x.globeSharedBuffers;if(!te)return;let me,he,fe;if(u&&(me=N.getTile(u)),J instanceof i.aU?(he=J.texture,fe=i.dK(0,0,x.transform)):me&&u&&(he=me.texture,fe=i.dK(u.canonical.z,u.canonical.x,x.transform)),!he||!fe)return;j||(fe=i.cS(i.bC(),fe,[1,-1,1]));const ke=x.context,be=ke.gl,Re=P.paint.get("raster-resampling")==="nearest"?be.NEAREST:be.LINEAR,Oe=x.colorModeForDrapableLayerRenderPass(O),Ge=F.defines;Ge.push("GLOBE_POLES");const at=new ks(be.LEQUAL,ks.ReadWrite,x.depthRangeFor3D),Ke=Float32Array.from(x.transform.expandedFarZProjMatrix),Nt=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));x.terrain&&x.terrain.prepareDrawTile(),ke.activeTexture.set(be.TEXTURE0),he.bind(Re,be.CLAMP_TO_EDGE),ke.activeTexture.set(be.TEXTURE1),he.bind(Re,be.CLAMP_TO_EDGE),"useMipmap"in he&&ke.extTextureFilterAnisotropic&&x.transform.pitch>20&&be.texParameterf(be.TEXTURE_2D,ke.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ke.extTextureFilterAnisotropicMax);const[xt,bt,gt,ht]=u?te.getPoleBuffers(u.canonical.z,!1):te.getPoleBuffers(0,!0),At=P.paint.get("raster-elevation");let Bt;j?(Bt=xt,x.renderDefaultNorthPole=At!==0):(Bt=bt,x.renderDefaultSouthPole=At!==0);const zt=gS(F.mix),Jt=((ur,Cr,Kt,Lt,nr,Xt,gr,qr,rs,Or,Tr,vs,ps)=>SL(ur,Cr,Kt,new Float32Array(16),new Float32Array(9),[0,0],Lt,[0,0],[0,0,0,0],1,{opacity:1,mix:0},Xt,[0,0],qr,2,Or,Tr,vs,1,0,ps))(Ke,Nt,fe,i.aj(x.transform.zoom),0,P,0,At,0,zt,F.offset,F.range,O),er=x.getOrCreateProgram("raster",{defines:Ge});x.uploadCommonUniforms(ke,er,null),er.draw(x,be.TRIANGLES,at,G,Oe,U,Jt,P.id,Bt,gt,ht)}function PL(j){const u=j._nearZ,x=j.projection.farthestPixelDistance(j),N=x-u,P=.2*j.height,O=u+P;return[u,x,(O-P-u)/N,(O-u)/N]}function dp(j,u,x,N){if(j)return u instanceof Ac&&j instanceof N0?u.getTextureDescriptor(j,x,!0):{texture:j.texture,mix:gS(N.mix),offset:N.offset,buffer:0,tileSize:1}}var bi=i.ei([{name:"a_index",type:"Int16",components:1}]);class xS{constructor(u,x,N,P){const O={width:N[0],height:N[1],data:null},F=u.gl;this.targetColorTexture=new i.T(u,O,F.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new i.T(u,O,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 N=this.context.gl,P=x.width*x.height;this.particleTexture0=new i.T(this.context,x,N.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new i.T(this.context,x,N.RGBA8,{premultiply:!1,useMipmap:!1});const O=new i.ej;O.reserve(P);for(let F=0;F0){const zt=i.bj(x.canonical,G),Jt=i.el(zt);he=i.aB(new Float32Array(16),G.globeMatrix,Jt),i.aB(he,G.projMatrix,he)}const fe=i.bC();fe[12]+=2*P/(i.o.devicePixelRatio*G.width),fe[13]+=2*O/(i.o.devicePixelRatio*G.height),i.aB(he,fe,he);const ke=j.getOrCreateProgram("debug",{defines:me}),be=u.getTileByID(x.key);j.terrain&&j.terrain.setupElevationDraw(be,ke);const Re=ks.disabled,Oe=Js.disabled,Ge=j.colorModeForRenderPass(),at="$debug";U.activeTexture.set(J.TEXTURE0),j.emptyTexture.bind(J.LINEAR,J.CLAMP_TO_EDGE),te?be._makeGlobeTileDebugBuffers(j.context,G):be._makeDebugTileBoundsBuffers(j.context,G.projection);const Ke=be._tileDebugBuffer||j.debugBuffer,Nt=be._tileDebugIndexBuffer||j.debugIndexBuffer,xt=be._tileDebugSegments||j.debugSegments;if(ke.draw(j,J.LINE_STRIP,Re,Oe,Ge,Ys.disabled,P_(he,N.toPremultipliedRenderColor(null)),at,Ke,Nt,xt,null,null,null,[be._globeTileDebugBorderBuffer]),F){const zt=be.latestRawTileData,Jt=Math.floor((zt&&zt.byteLength||0)/1024);let er=x.canonical.toString();x.overscaledZ!==x.canonical.z&&(er+=` => ${x.overscaledZ}`),er+=` ${be.state}`,er+=` ${Jt}kb`,function(ur,Cr){ur.initDebugOverlayCanvas();const Kt=ur.debugOverlayCanvas,Lt=ur.context.gl,nr=ur.debugOverlayCanvas.getContext("2d");nr.clearRect(0,0,Kt.width,Kt.height),nr.shadowColor="white",nr.shadowBlur=2,nr.lineWidth=1.5,nr.strokeStyle="white",nr.textBaseline="top",nr.font="bold 36px Open Sans, sans-serif",nr.fillText(Cr,5,5),nr.strokeText(Cr,5,5),ur.debugOverlayTexture.update(Kt),ur.debugOverlayTexture.bind(Lt.LINEAR,Lt.CLAMP_TO_EDGE)}(j,er)}const bt=u.getTile(x).tileSize,gt=512/Math.min(bt,512)*(x.overscaledZ/G.zoom)*.5,ht=be._tileDebugTextBuffer||j.debugBuffer,At=be._tileDebugTextIndexBuffer||j.quadTriangleIndexBuffer,Bt=be._tileDebugTextSegments||j.debugSegments;ke.draw(j,J.TRIANGLES,Re,Oe,wn.alphaBlended,Ys.disabled,P_(he,i.ao.transparent.toPremultipliedRenderColor(null),gt),at,ht,At,Bt,null,null,null,[be._globeTileDebugTextBuffer])}function Yx(j,u,x,N){qt(j,0,u+x/2,j.transform.width,x,N)}function mo(j,u,x,N){qt(j,u-x/2,0,x,j.transform.height,N)}function qt(j,u,x,N,P,O){const F=j.context,U=F.gl;U.enable(U.SCISSOR_TEST),U.scissor(u*i.o.devicePixelRatio,x*i.o.devicePixelRatio,N*i.o.devicePixelRatio,P*i.o.devicePixelRatio),F.clear({color:O}),U.disable(U.SCISSOR_TEST)}const FL=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:yS}=FL;function nf(j,u,x,N){j.emplaceBack(u,x,N)}class vS{constructor(u){this.vertexArray=new i.em,this.indices=new i.b0,nf(this.vertexArray,-1,-1,1),nf(this.vertexArray,1,-1,1),nf(this.vertexArray,-1,1,1),nf(this.vertexArray,1,1,1),nf(this.vertexArray,-1,-1,-1),nf(this.vertexArray,1,-1,-1),nf(this.vertexArray,-1,1,-1),nf(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,yS),this.indexBuffer=u.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function Xx(j,u,x,N,P,O){const F=j.context.gl,U=u.paint.get("sky-atmosphere-color"),G=u.paint.get("sky-atmosphere-halo-color"),J=u.paint.get("sky-atmosphere-sun-intensity"),te=((me,he,fe,ke,be)=>({u_matrix_3f:me,u_sun_direction:he,u_sun_intensity:fe,u_color_tint_r:[ke.r,ke.g,ke.b,ke.a],u_color_tint_m:[be.r,be.g,be.b,be.a],u_luminance:5e-5}))(i.eo(i.dO(),N),P,J,U.toPremultipliedRenderColor(null),G.toPremultipliedRenderColor(null));F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+O,u.skyboxTexture,0),x.draw(j,F.TRIANGLES,ks.disabled,Js.disabled,wn.unblended,Ys.frontCW,te,"skyboxCapture",u.skyboxGeometry.vertexBuffer,u.skyboxGeometry.indexBuffer,u.skyboxGeometry.segment)}const zL=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 N=new i.b0;N.emplaceBack(0,1,2),N.emplaceBack(2,3,0),this.vertexBuffer=u.createVertexBuffer(x,zL.members),this.indexBuffer=u.createIndexBuffer(N),this.segments=i.bg.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Vle=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 qle{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class BL{constructor(u){this.colorModeAlphaBlendedWriteRGB=new wn([1,ef,1,ef],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new wn([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new qle,this.updateNeeded=!0}update(u){const x=u.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new q0(x);const N=this.params.sizeRange,P=this.params.intensityRange,O=function(te){const me=i.eq(30),he=[];for(let fe=0;fe{const gt=O.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];bt&>.push("ALPHA_PASS");const ht=u.getOrCreateProgram("globeAtmosphere",{defines:gt}),At=((zt,Jt,er,ur,Cr,Kt,Lt,nr,Xt,gr,qr,rs)=>({u_frustum_tl:zt,u_frustum_tr:Jt,u_frustum_br:er,u_frustum_bl:ur,u_horizon:Cr,u_transition:Kt,u_fadeout_range:Lt,u_atmosphere_fog_color:nr.toArray01(),u_high_color:Xt.toArray01(),u_space_color:gr.toArray01(),u_temporal_offset:qr,u_horizon_angle:rs}))(O.frustumCorners.TL,O.frustumCorners.TR,O.frustumCorners.BR,O.frustumCorners.BL,O.frustumCorners.horizon,U,Re,te,he,ke,Ge,Nt);u.uploadCommonUniforms(N,ht);const Bt=this.atmosphereBuffer;Bt&&ht.draw(u,P.TRIANGLES,F,Js.disabled,bt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Ys.backCW,At,bt?"atmosphere_glow_alpha":"atmosphere_glow",Bt.vertexBuffer,Bt.indexBuffer,Bt.segments)};xt(!1),xt(!0)}drawStars(u,x){const N=i.aA(x.properties.get("star-intensity"),0,1);if(N===0)return;const P=u.context,O=P.gl,F=u.transform,U=u.getOrCreateProgram("stars"),G=i.c7([]);i.c9(G,G,-F._pitch),i.c8(G,G,-F.angle),i.c9(G,G,i.an(F._center.lat)),i.et(G,G,-i.an(F._center.lng));const J=i.cc(new Float32Array(16),G),te=i.aB([],F.starsProjMatrix,J),me=i.eo([],J),he=i.eu([],me),fe=[0,1,0];i.dQ(fe,fe,he),i.c5(fe,fe,this.params.sizeMultiplier);const ke=[1,0,0];i.dQ(ke,ke,he),i.c5(ke,ke,this.params.sizeMultiplier);const be=(Re=fe,Oe=ke,Ge=N,{u_matrix:Float32Array.from(te),u_up:Re,u_right:Oe,u_intensity_multiplier:Ge});var Re,Oe,Ge;u.uploadCommonUniforms(P,U),this.starsVx&&this.starsIdx&&U.draw(u,O.TRIANGLES,ks.disabled,Js.disabled,this.colorModeAlphaBlendedWriteRGB,Ys.disabled,be,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class _S{constructor(){this.visibleTiles=[]}updateBorders(u,x){const N=[],P=[],O=u._getRenderableCoordinates(!1,!0);for(const G of O){const J=u.getTile(G);if(!J.hasData())continue;const te=J.getBucket(x);te&&(te.isEmpty()||(N.push(G.key),P.push({bucket:te,tileID:G.canonical})))}let F=N.length!==this.visibleTiles.length;if(!F){N.sort();for(let G=0;GG.tileID.z-J.tileID.z||G.tileID.x-J.tileID.x||G.tileID.y-J.tileID.y);for(const G of P){const J=new Array,te=new Array,me=G.bucket;for(const he of me.featuresOnBorder)U.has(he.featureId)?te.push(he.footprintIndex):(U.add(he.featureId),J.push(he.footprintIndex));me.updateFootprintHiddenFlags(J,i.ev,!1),me.updateFootprintHiddenFlags(te,i.ev,!0)}}}function bS(j,u){const x=[...j],N=u.cameraWorldSizeForFog/u.worldSize,P=i.bA([]);return i.cS(P,P,[N,N,1]),i.aB(x,P,x),i.aB(x,u.worldToFogMatrix,x),x}function wS(j,u,x,N,P){const O=x.material,F=N.context,{baseColorTexture:U,metallicRoughnessTexture:G}=O.pbrMetallicRoughness,{normalTexture:J,occlusionTexture:te,emissionTexture:me}=O;function he(ke,be,Re){if(ke&&(j.push(be),F.activeTexture.set(F.gl.TEXTURE0+Re),ke.gfxTexture)){const{minFilter:Oe,magFilter:Ge,wrapS:at,wrapT:Ke}=ke.sampler;ke.gfxTexture.bindExtraParam(Oe,Ge,at,Ke)}}he(U,"HAS_TEXTURE_u_baseColorTexture",Vl.BaseColor),he(G,"HAS_TEXTURE_u_metallicRoughnessTexture",Vl.MetallicRoughness),he(J,"HAS_TEXTURE_u_normalTexture",Vl.Normal),he(te,"HAS_TEXTURE_u_occlusionTexture",Vl.Occlusion),he(me,"HAS_TEXTURE_u_emissionTexture",Vl.Emission),P&&(P.texture||(P.texture=new i.d$(N.context,P.image,[P.image.height,P.image.height,P.image.height],F.gl.RGBA8)),F.activeTexture.set(F.gl.TEXTURE0+Vl.LUT),P.texture&&P.texture.bind(F.gl.LINEAR,F.gl.CLAMP_TO_EDGE),j.push("APPLY_LUT_ON_GPU")),x.texcoordBuffer&&(j.push("HAS_ATTRIBUTE_a_uv_2f"),u.push(x.texcoordBuffer)),x.colorBuffer&&(j.push(x.colorBuffer.itemSize===12?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),u.push(x.colorBuffer)),x.normalBuffer&&(j.push("HAS_ATTRIBUTE_a_normal_3f"),u.push(x.normalBuffer)),x.pbrBuffer&&(j.push("HAS_ATTRIBUTE_a_pbr"),j.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),u.push(x.pbrBuffer)),O.alphaMode!=="OPAQUE"&&O.alphaMode!=="MASK"||j.push("UNPREMULT_TEXTURE_IN_SHADER"),O.defined||j.push("DIFFUSE_SHADED");const fe=N.shadowRenderer;fe&&(j.push("RENDER_SHADOWS","DEPTH_TEXTURE"),fe.useNormalOffset&&j.push("NORMAL_OFFSET"))}function jS(j,u,x,N,P,O){const F=j.modelOpacity,U=u.context,G=new ks(u.context.gl.LEQUAL,j.isLightMesh?ks.ReadOnly:ks.ReadWrite,u.depthRangeFor3D),J=u.transform,te=j.mesh,me=te.material,he=me.pbrMetallicRoughness,fe=u.style.fog;let ke;ke=u.transform.projection.zAxisUnit==="pixels"?[...j.nodeModelMatrix]:i.aB([],N.zScaleMatrix,j.nodeModelMatrix),i.aB(ke,N.negCameraPosMatrix,ke);const be=i.bl([],ke);i.eg(be,be);const Re=x.paint.get("model-color-use-theme").constantOr("default")==="none",Oe=x.paint.get("model-emissive-strength").constantOr(0),Ge=Wx(new Float32Array(j.worldViewProjection),new Float32Array(ke),new Float32Array(be),null,u,F,he.baseColorFactor,me.emissiveFactor,he.metallicFactor,he.roughnessFactor,me,Oe,x,void 0,void 0,j.materialOverride,j.modelColor),at={defines:[]},Ke=[],Nt=u.shadowRenderer;Nt&&(Nt.useNormalOffset=!1),wS(at.defines,Ke,te,u,Re?null:x.lut);let xt=null;if(fe){const ht=bS(j.nodeModelMatrix,u.transform);if(xt=new Float32Array(ht),J.projection.name!=="globe"){const At=te.aabb.min,Bt=te.aabb.max,[zt,Jt]=fe.getOpacityForBounds(ht,At[0],At[1],Bt[0],Bt[1]);at.overrideFog=zt>=hr||Jt>=hr}}const bt=jg(u,x.paint.get("model-cutoff-fade-range"));bt.shouldRenderCutoff&&at.defines.push("RENDER_CUTOFF");const gt=u.getOrCreateProgram("model",at);u.uploadCommonUniforms(U,gt,null,xt,bt),u.renderPass!=="shadow"&&Nt&&Nt.setupShadowsFromMatrix(j.nodeModelMatrix,gt),gt.draw(u,U.gl.TRIANGLES,G,P,O,te.material.doubleSided?Ys.disabled:Ys.backCCW,Ge,x.id,te.vertexBuffer,te.indexBuffer,te.segments,x.paint,u.transform.zoom,void 0,Ke)}function z_(j,u){return j.style._importedAsBasemap?"basemap":u.scope}function Qx(j,u,x,N,P,O,F,U,G,J){const te=j.transform,me=!!u.isGeometryBloom&&u.isGeometryBloom;if(me&&j.renderPass==="shadow")return;const he=te.projection.name==="globe"?i.eD(x,te):[...x];i.aB(he,he,u.globalMatrix);const fe=i.aB([],N,he);if(u.meshes)for(const ke of u.meshes){const be=U.get(ke.material.name);if(be&&be.opacity<=0)continue;if(ke.material.alphaMode!=="BLEND"){F.push({mesh:ke,depth:0,modelIndex:P,worldViewProjection:fe,nodeModelMatrix:he,isLightMesh:me,materialOverride:be,modelOpacity:G,modelColor:J});continue}const Re=i.af([],ke.centroid,fe);!te.isOrthographic&&Re[2]<=0||O.push({mesh:ke,depth:Re[2],modelIndex:P,worldViewProjection:fe,nodeModelMatrix:he,isLightMesh:me,materialOverride:be,modelOpacity:G,modelColor:J})}if(u.children)for(const ke of u.children)Qx(j,ke,x,N,P,O,F,U,G,J)}function pm(j,u,x,N){const P=x.shadowRenderer;if(!P)return;const O=P.getShadowPassDepthMode(),F=P.getShadowPassColorMode(),U=P.calculateShadowPassMatrixFromMatrix(u),G=zM(U);x.getOrCreateProgram("modelDepth",{defines:x._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(x,x.context.gl.TRIANGLES,O,Js.disabled,F,Ys.disabled,G,N.id,j.vertexBuffer,j.indexBuffer,j.segments,N.paint,x.transform.zoom,void 0,void 0)}function $L(j,u,x,N,P,O){for(const F of P){const U=Object.assign({},N);U.part=F;const G={type:"Unknown",id:u,properties:U},J={orientation:j.paint.get("model-rotation").evaluate(G,x)};O.set(F,J)}}function UL(j,u,x,N,P,O){for(const F of P){const U=Object.assign({},N);U.part=F;const G={type:"Unknown",id:u,properties:U},J={color:j.paint.get("model-color").evaluate(G,x),colorMix:j.paint.get("model-color-mix-intensity").evaluate(G,x),opacity:j.paint.get("model-opacity").evaluate(G,x),emissionStrength:j.paint.get("model-emissive-strength").evaluate(G,x)};O.set(F,J)}}function VL(j,u,x,N,P){let O=!1;for(const U of N)U.modelOpacity!==1&&(jS(U,j,u,P[U.modelIndex],Js.disabled,wn.disabled),O=!0);for(const U of N)jS(U,j,u,P[U.modelIndex],U.modelOpacity!==1?j.stencilModeFor3D():Js.disabled,j.colorModeForRenderPass());O&&j.resetStencilClippingMasks();const F=wn.additive;for(const U of x)jS(U,j,u,P[U.modelIndex],Js.disabled,U.isLightMesh?F:j.colorModeForRenderPass())}function qL(j,u,x){const N=u.updateZoomBasedPaintProperties(),P=function(O,F,U){let G,J,te,me=O.terrain?O.terrain.exaggeration():0;if(O.terrain&&me>0){const he=O.terrain,fe=he.findDEMTileFor(U);fe&&fe.dem?G=i.eF.create(he,U,fe):me=0}if(me===0&&(F.terrainElevationMin=0,F.terrainElevationMax=0),me===F.validForExaggeration&&(me===0||G&&G._demTile&&G._demTile.tileID===F.validForDEMTile.id&&G._dem._timestamp===F.validForDEMTile.timestamp))return!1;for(const he in F.instancesPerModel){const fe=F.instancesPerModel[he];for(let ke=0;keJ&&(J=fe.max)}const te=i.aA(N.x,O,F)-N.x,me=i.aA(N.y,U,G)-N.y,he=i.cf(J,u.center.lat)-N.z;return u._zoomFromMercatorZ(Math.sqrt(te*te+me*me+he*he))}function HL(j,u,x,N,P,O,F){const U=j.context,G=j.renderPass==="shadow",J=j.shadowRenderer,te=G&&J?J.getShadowPassDepthMode():new ks(U.gl.LEQUAL,ks.ReadWrite,j.depthRangeFor3D),me=j.isTileAffectedByFog(O),he=j.transform.projection.name==="globe";if(x.meshes)for(const fe of x.meshes){const ke=he?[]:["MODEL_POSITION_ON_GPU"],be=[];let Re,Oe,Ge;const at=!he&&N.instancedDataArray.length>20;at&&ke.push("INSTANCED_ARRAYS");const Ke=jg(j,u.paint.get("model-cutoff-fade-range"));if(Ke.shouldRenderCutoff&&ke.push("RENDER_CUTOFF"),G&&J)Re=j.getOrCreateProgram("modelDepth",{defines:ke}),Oe=zM(F.shadowTileMatrix,F.shadowTileMatrix,Float32Array.from(x.globalMatrix)),Ge=J.getShadowPassColorMode();else{wS(ke,be,fe,j,u.paint.get("model-color-use-theme").constantOr("default")==="none"?null:u.lut),Re=j.getOrCreateProgram("model",{defines:ke,overrideFog:me});const xt=fe.material,bt=xt.pbrMetallicRoughness,gt=u.paint.get("model-opacity").constantOr(1),ht=u.paint.get("model-emissive-strength").constantOr(0);Oe=Wx(O.expandedProjMatrix,Float32Array.from(x.globalMatrix),new Float32Array(16),null,j,gt,bt.baseColorFactor,xt.emissiveFactor,bt.metallicFactor,bt.roughnessFactor,xt,ht,u,P),J&&(F.shadowUniformsInitialized?Re.setShadowUniformValues(U,J.getShadowUniformValues()):(J.setupShadows(O.toUnwrapped(),Re,"model-tile"),F.shadowUniformsInitialized=!0)),Ge=Ke.shouldRenderCutoff||gt<1||xt.alphaMode!=="OPAQUE"?wn.alphaBlended:wn.unblended}j.uploadCommonUniforms(U,Re,O.toUnwrapped(),null,Ke);const Nt=fe.material.doubleSided?Ys.disabled:Ys.backCCW;if(at)be.push(N.instancedDataBuffer),Re.draw(j,U.gl.TRIANGLES,te,Js.disabled,Ge,Nt,Oe,u.id,fe.vertexBuffer,fe.indexBuffer,fe.segments,u.paint,j.transform.zoom,void 0,be,N.instancedDataArray.length);else{const xt=G?"u_instance":"u_normal_matrix";for(let bt=0;btG[1]?F:G,O[0]=x.max[0],F=i.aC(i.eG(),O,P),U=F[1]G[1]?F:G,O[1]=x.min[1],F=i.aC(i.eG(),O,P),U=F[1]G[1]?F:G;const J=i.aA(N[0],0,1),te=100*u.pixelsPerMeter*i.aA(N[1],0,1),me=i.aA(N[2],0,1),he=i.eH(i.eG(),U,G,J),fe=Math.tan(.5*u.fovX),ke=-he[2]*fe;if(te===0)return he[1]<-Math.abs(ke)?me:1;const be=(-Math.abs(ke)-he[1])/te,Re=(Ge,at,Ke)=>(1-Ke)*Ge+Ke*at,Oe=i.aA(Re(1,me,be),me,1);return Re(1,Oe,i.aA((u.pitch-20)/20,0,1))}class WL{}class Pg{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(u,x,N){{const me=this._storage.get(x.id);if(me)return me.lastUsedFrameIdx=u,me.buf}const P=N.gl,O=P.getBufferParameter(P.ELEMENT_ARRAY_BUFFER,P.BUFFER_SIZE),F=new ArrayBuffer(O),U=new Int16Array(F);P.getBufferSubData(P.ELEMENT_ARRAY_BUFFER,0,new Int16Array(F));const G=new i.eJ;for(let me=0;me30&&(N.buf.destroy(),this._storage.delete(x))}destroy(){for(const[u,x]of this._storage)x.buf.destroy(),this._storage.delete(u)}}class H0{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const W0=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 up{constructor(u){this.revealStart=11,this.revealRange=2}}const HM=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class WM{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(u,x){const N=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,HM.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,N);const F={u_vignetteShape:(O={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:O.vignetteColor};N.draw(u,u.context.gl.TRIANGLES,ks.disabled,Js.disabled,wn.alphaBlended,Ys.disabled,F,"vignette",this.vignetteVx,this.vignetteIdx,P)}var O}}class GM{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(u,x){const N=u.getFreeCameraOptions().position,P=N.toAltitude(),O=N.toLngLat(),F=i.an(O.lng),U=i.an(O.lat),G=u.pixelsPerMeter/x,J=F*i.eM,te=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 me=-this._offsetYPrev+te,he=-this._elevationPrev+P;this._accumulatedOffsetX+=(-this._offsetXPrev+J)*G,this._accumulatedOffsetY+=me*G,this._accumulatedElevation+=he*G,this._offsetXPrev=J,this._offsetYPrev=te,this._elevationPrev=P}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function kS(j,u){return[-(j[0]-Math.floor(j[0]/u)*u),-(j[1]-Math.floor(j[1]/u)*u),-(j[2]-Math.floor(j[2]/u)*u)]}function Xu(j){const u=i.eq(1323123451230),x=[];for(let N=0;N 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 N=Xu(this.particlesCount),P=new i.eN,O=new i.b0;let F=0;const U=i.eq(1323123451230);for(let G=0;GN)return;const P=ru(0,1,x.revealStart,x.revealStart+x.revealRange,N);if(!this.particlesVx||!this.particlesIdx)return;const O=structuredClone(this._params);let F=[-O.direction.x,O.direction.y,-100];i.aw(F,F);const U=structuredClone(this._vignetteParams);U.strength*=P,O.overrideStyleParameters||(O.intensity=u.style.rain.state.density,O.timeFactor=u.style.rain.state.intensity,O.color=structuredClone(u.style.rain.state.color),F=structuredClone(u.style.rain.state.direction),O.screenThinning.intensity=u.style.rain.state.centerThinning,O.dropletSizeX=u.style.rain.state.dropletSize[0],O.dropletSizeYScale=u.style.rain.state.dropletSize[1]/u.style.rain.state.dropletSize[0],O.distortionStrength=100*u.style.rain.state.distortionStrength,U.strength=1,U.color=structuredClone(u.style.rain.state.vignetteColor));const G=this.updateOnRender(u,O.timeFactor),J=u.context,te=J.gl,me=u.transform;this.screenTexture&&this.screenTexture.size[0]===u.width&&this.screenTexture.size[1]===u.height||(this.screenTexture=new i.T(J,{width:u.width,height:u.height,data:null},te.RGBA8)),O.distortionStrength>0&&(J.activeTexture.set(te.TEXTURE0),this.screenTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE),te.copyTexSubImage2D(te.TEXTURE_2D,0,0,0,0,0,u.width,u.height));const he=u.getOrCreateProgram("rainParticle");u.uploadCommonUniforms(J,he),J.activeTexture.set(te.TEXTURE0),this.screenTexture.bind(te.LINEAR,te.CLAMP_TO_EDGE);const fe=[O.color.r,O.color.g,O.color.b,O.color.a],ke=(be,Re)=>{const Oe=kS(this._movement.getPosition(),be),Ge=O.dropletSizeX,at=O.dropletSizeX*O.dropletSizeYScale,Ke=u.width/2,Nt=u.height/2,xt=ru(0,O.screenThinning.start,0,1,O.screenThinning.intensity),bt=ru(.001,O.screenThinning.range,0,1,O.screenThinning.intensity),gt=ru(0,O.screenThinning.particleOffset,0,1,O.screenThinning.intensity),ht=(At={modelview:G.modelviewMatrix,projection:G.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Oe,velocityConeAperture:O.velocityConeAperture,velocity:O.velocity,boxSize:be,rainDropletSize:[Ge,at],distortionStrength:O.distortionStrength,rainDirection:F,color:fe,screenSize:[me.width,me.height],thinningCenterPos:[Ke,Nt],thinningShape:[xt,bt,Math.pow(10,O.screenThinning.fadePower)],thinningAffectedRatio:O.screenThinning.affectedRatio,thinningParticleOffset:gt,shapeDirectionalPower:O.shapeDirPower,shapeNormalPower:O.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 Bt=Math.round(O.intensity*this.particlesCount),zt=i.bg.simpleSegment(0,0,4*Bt,2*Bt);he.draw(u,te.TRIANGLES,ks.disabled,Js.disabled,wn.alphaBlended,Ys.disabled,ht,"rain_particles",this.particlesVx,this.particlesIdx,zt)};O.distortionStrength>0&&ke(O.boxSize,!0),ke(O.boxSize,!1),this._vignette.draw(u,U)}}const KM=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 ZM extends Jx{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 up("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 N=Xu(this.particlesCount),P=new i.eO,O=new i.b0;let F=0;const U=i.eq(1323123451230);for(let G=0;GF)return;const U=ru(0,1,O.revealStart,O.revealStart+O.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),N=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 G=this.updateOnRender(u,x.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const J=u.context,te=J.gl,me=u.transform,he=u.getOrCreateProgram("snowParticle");u.uploadCommonUniforms(J,he),((fe,ke,be)=>{const Re=kS(this._movement.getPosition(),fe),Oe=me.width/2,Ge=me.height/2,at=ru(0,be.screenThinning.start,0,1,be.screenThinning.intensity),Ke=ru(.001,be.screenThinning.range,0,1,be.screenThinning.intensity),Nt=ru(0,be.screenThinning.particleOffset,0,1,be.screenThinning.intensity),xt=(bt={modelview:G.modelviewMatrix,projection:G.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Re,velocityConeAperture:be.velocityConeAperture,velocity:be.velocity,horizontalOscillationRadius:be.horizontalOscillationRadius,horizontalOscillationRate:be.horizontalOscillationRate,boxSize:fe,billboardSize:1*be.billboardSize,simpleShapeParameters:[be.shapeFadeStart,be.shapeFadePower],screenSize:[me.width,me.height],thinningCenterPos:[Oe,Ge],thinningShape:[at,Ke,Math.pow(10,be.screenThinning.fadePower)],thinningAffectedRatio:be.screenThinning.affectedRatio,thinningParticleOffset:Nt,color:[be.color.r,be.color.g,be.color.b,be.color.a],direction:N},{u_modelview:Float32Array.from(bt.modelview),u_projection:Float32Array.from(bt.projection),u_time:bt.time,u_cam_pos:bt.camPos,u_velocityConeAperture:bt.velocityConeAperture,u_velocity:bt.velocity,u_horizontalOscillationRadius:bt.horizontalOscillationRadius,u_horizontalOscillationRate:bt.horizontalOscillationRate,u_boxSize:bt.boxSize,u_billboardSize:bt.billboardSize,u_simpleShapeParameters:bt.simpleShapeParameters,u_screenSize:bt.screenSize,u_thinningCenterPos:bt.thinningCenterPos,u_thinningShape:bt.thinningShape,u_thinningAffectedRatio:bt.thinningAffectedRatio,u_thinningParticleOffset:bt.thinningParticleOffset,u_particleColor:bt.color,u_direction:bt.direction});var bt;const gt=Math.round(be.intensity*this.particlesCount),ht=i.bg.simpleSegment(0,0,4*gt,2*gt);this.particlesVx&&this.particlesIdx&&he.draw(u,te.TRIANGLES,ks.disabled,Js.disabled,wn.alphaBlended,Ys.disabled,xt,"snow_particles",this.particlesVx,this.particlesIdx,ht)})(x.boxSize,0,x),this._vignette.draw(u,P)}}const Lg={symbol:function(j,u,x,N,P){if(j.renderPass!=="translucent")return;const O=Js.disabled,F=j.colorModeForRenderPass(),U=x.layout.get("text-variable-anchor"),G=x.layout.get("text-size-scale-range"),J=i.aA(j.scaleFactor,G[0],G[1]);U&&function(he,fe,ke,be,Re,Oe,Ge,at){const Ke=fe.transform,Nt=Re==="map",xt=Oe==="map";for(const bt of he){const gt=be.getTile(bt),ht=gt.getBucket(ke);if(!ht||!ht.text||!ht.text.segments.get().length)continue;const At=i.bK(ht.textSizeData,Ke.zoom,at),Bt=Hr(bt,ht.getProjection(),Ke),zt=Ke.calculatePixelsToTileUnitsMatrix(gt),Jt=Ta(Bt,gt.tileID.canonical,xt,Nt,Ke,ht.getProjection(),zt),er=ht.hasIconTextFit()&&ht.hasIconData();At&&Rs(ht,Nt,xt,Ge,Ke,Jt,bt,Math.pow(2,Ke.zoom-gt.tileID.overscaledZ),At,er)}}(N,j,x,u,x.layout.get("text-rotation-alignment"),x.layout.get("text-pitch-alignment"),P,J);const te=x.paint.get("icon-opacity").constantOr(1)!==0,me=x.paint.get("text-opacity").constantOr(1)!==0;x.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(te||me)?O_(j,u,x,N,O,F):(te&&O_(j,u,x,N,O,F,{onlyIcons:!0}),me&&O_(j,u,x,N,O,F,{onlyText:!0})),u.map.showCollisionBoxes&&(ms(j,u,x,N,x.paint.get("text-translate"),x.paint.get("text-translate-anchor"),!0),ms(j,u,x,N,x.paint.get("icon-translate"),x.paint.get("icon-translate-anchor"),!1))},circle:function(j,u,x,N){if(j.renderPass!=="translucent")return;const P=x.paint.get("circle-opacity"),O=x.paint.get("circle-stroke-width"),F=x.paint.get("circle-stroke-opacity"),U=x.layout.get("circle-sort-key").constantOr(1)!==void 0,G=x.paint.get("circle-emissive-strength");if(P.constantOr(1)===0&&(O.constantOr(1)===0||F.constantOr(1)===0))return;const J=j.context,te=J.gl,me=j.transform,he=!(!j.terrain||!j.terrain.enabled),fe=x.layout.get("circle-elevation-reference"),ke=j.depthModeForSublayer(0,ks.ReadOnly),be=new ks(j.context.gl.LEQUAL,ks.ReadOnly,j.depthRangeFor3D),Re=fe==="none"||he?ke:be,Oe=Js.disabled,Ge=j.colorModeForDrapableLayerRenderPass(G),at=me.projection.name==="globe",Ke=[i.aF(me.center.lng),i.aJ(me.center.lat)],Nt=[];for(let bt=0;btbt.sortKey-gt.sortKey);const xt={useDepthForOcclusion:me.depthOcclusionForSymbolsAndCircles};for(const bt of Nt){const{programConfiguration:gt,program:ht,layoutVertexBuffer:At,dynamicBuffers:Bt,indexBuffer:zt,uniformValues:Jt,tile:er}=bt.state,ur=bt.segments;j.terrain&&j.terrain.setupElevationDraw(er,ht,xt),j.uploadCommonUniforms(J,ht,er.tileID.toUnwrapped()),ht.draw(j,te.TRIANGLES,Re,Oe,Ge,Ys.disabled,Jt,x.id,At,zt,ur,x.paint,me.zoom,gt,Bt)}},heatmap:function(j,u,x,N){if(x.paint.get("heatmap-opacity")!==0)if(j.renderPass==="offscreen"){const P=j.context,O=P.gl,F=Js.disabled,U=new wn([O.ONE,O.ONE,O.ONE,O.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(fe,ke,be,Re){const Oe=fe.gl,Ge=ke.width*Re,at=ke.height*Re;fe.activeTexture.set(Oe.TEXTURE1),fe.viewport.set([0,0,Ge,at]);let Ke=be.heatmapFbo;if(!Ke||Ke&&(Ke.width!==Ge||Ke.height!==at)){Ke&&Ke.destroy();const Nt=Oe.createTexture();Oe.bindTexture(Oe.TEXTURE_2D,Nt),Oe.texParameteri(Oe.TEXTURE_2D,Oe.TEXTURE_WRAP_S,Oe.CLAMP_TO_EDGE),Oe.texParameteri(Oe.TEXTURE_2D,Oe.TEXTURE_WRAP_T,Oe.CLAMP_TO_EDGE),Oe.texParameteri(Oe.TEXTURE_2D,Oe.TEXTURE_MIN_FILTER,Oe.LINEAR),Oe.texParameteri(Oe.TEXTURE_2D,Oe.TEXTURE_MAG_FILTER,Oe.LINEAR),Ke=be.heatmapFbo=fe.createFramebuffer(Ge,at,1,null),function(xt,bt,gt,ht,At,Bt){const zt=xt.gl;zt.texImage2D(zt.TEXTURE_2D,0,xt.extRenderToTextureHalfFloat?zt.RGBA16F:zt.RGBA,At,Bt,0,zt.RGBA,xt.extRenderToTextureHalfFloat?zt.HALF_FLOAT:zt.UNSIGNED_BYTE,null),ht.colorAttachment0.set(gt)}(fe,0,Nt,Ke,Ge,at)}else Oe.bindTexture(Oe.TEXTURE_2D,Ke.colorAttachment0.get()),fe.bindFramebuffer.set(Ke.framebuffer)})(P,j,x,j.transform.projection.name==="globe"?.5:.25),P.clear({color:i.ao.transparent});const G=j.transform,J=G.projection.name==="globe",te=J?["PROJECTION_GLOBE_VIEW"]:[],me=J?Ys.frontCCW:Ys.disabled,he=[i.aF(G.center.lng),i.aJ(G.center.lat)];for(let fe=0;fe({u_image:0,u_color_ramp:1,u_opacity:me.paint.get("heatmap-opacity")}))(0,O),O.id,P.viewportBuffer,P.quadTriangleIndexBuffer,P.viewportSegments,O.paint,P.transform.zoom)}(j,x))},line:function(j,u,x,N){if(j.renderPass!=="translucent")return;const P=x.paint.get("line-opacity"),O=x.paint.get("line-width");if(P.constantOr(1)===0||O.constantOr(1)===0)return;const F=x.paint.get("line-emissive-strength").isConstant(),U=x.paint.get("line-emissive-strength").constantOr(0),G=x.paint.get("line-occlusion-opacity"),J=x.layout.get("line-elevation-reference"),te=x.layout.get("line-width-unit")==="meters",me=J==="sea",he=!(!j.terrain||!j.terrain.enabled),fe=j.context,ke=fe.gl;if(x.hasElevatedBuckets&&j.transform.projection.name==="globe")return;const be=x.layout.get("line-cross-slope"),Re=be!==void 0,Oe=be<1,Ge=j.colorModeForDrapableLayerRenderPass(F?U:null),at=j.terrain&&j.terrain.renderingToTexture,Ke=at?1:i.o.devicePixelRatio,Nt=x.paint.get("line-dasharray"),xt=Nt.constantOr(1),bt=x.layout.get("line-cap"),gt=Nt.constantOr(null),ht=bt.constantOr(null),At=x.paint.get("line-pattern"),Bt=At.constantOr(1),zt=x.paint.get("line-pattern-cross-fade"),Jt=At.constantOr(null),er=x.paint.get("line-opacity").constantOr(1);let ur=!Bt&&er!==1||j.depthOcclusion&&G>0&&G<1;const Cr=x.paint.get("line-gradient"),Kt=Bt?"linePattern":"line",Lt=i.e2(x);let nr;if(at&&j.terrain&&j.terrain.clipOrMaskOverlapStencilType()&&(ur=!1),G!==0&&j.depthOcclusion){const rs=x.paint._values["line-opacity"];rs&&rs.value&&rs.value.kind==="constant"?nr=rs.value:i.w(`Occlusion opacity for layer ${x.id} is supported only when line-opacity isn't data-driven.`)}O.value.kind!=="constant"&&O.value.isLineProgressConstant===!1&&Lt.push("VARIABLE_LINE_WIDTH"),at&&(j.emissiveMode!=="dual-source-blending"||F?j.emissiveMode==="mrt-fallback"&&Lt.push("USE_MRT1"):Lt.push("DUAL_SOURCE_BLENDING"));const Xt=(rs,Or,Tr,vs,ps,Qr)=>{for(const ns of rs){const Ps=u.getTile(ns);if(Bt&&!Ps.patternsLoaded())continue;const mn=Ps.getBucket(x);if(!mn||mn.elevationType!=="none"&&!ps||mn.elevationType==="none"&&ps)continue;j.prepareDrawTile();const sa=[...Or],Ea=j.shadowRenderer,js=mn.elevationType==="road"&&!!Ea&&Ea.enabled;let ja=[0,0,0];if(js){const Nn=j.style.directionalLight,Si=j.style.ambientLight;Nn&&Si&&(ja=ap(j.style,Nn,Si)),sa.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const an=mn.programConfigurations.get(x.id);let Oa=!1;if(Jt&&Ps.imageAtlas){const Nn=i.e3.from(Jt),Si=Nn.getPrimary().scaleSelf(Ke).toString(),bo=Ps.imageAtlas.patternPositions.get(Si),ro=Nn.getSecondary(),oi=ro?Ps.imageAtlas.patternPositions.get(ro.scaleSelf(Ke).toString()):null;Oa=!!bo&&!!oi,bo&&an.setConstantPatternPositions(bo,oi)}zt>0&&(Oa||an.getPatternTransitionVertexBuffer("line-pattern"))&&sa.push("LINE_PATTERN_TRANSITION");const Xa=j.isTileAffectedByFog(ns),qa=j.getOrCreateProgram(Kt,{config:an,defines:sa,overrideFog:Xa});if(!Bt&>&&ht&&Ps.lineAtlas){const Nn=Ps.lineAtlas.getDash(gt,ht);Nn&&an.setConstantPatternPositions(Nn)}js&&Ea.setupShadows(Ps.tileID.toUnwrapped(),qa,"vector-tile");let[wa,kn]=x.paint.get("line-trim-offset");(ht==="round"||ht==="square")&&wa!==kn&&(wa===0&&(wa-=1),kn===1&&(kn+=1));const Da=at?ns.projMatrix:null,io=te?1/mn.tileToMeter/i.ay(Ps,1,j.transform.zoom):1,Di=te?1/mn.tileToMeter/i.ay(Ps,1,Math.floor(j.transform.zoom)):1,Ra=Bt?i.e4(j,Ps,x,Da,Ke,io,Di,[wa,kn],ja,zt):i.e5(j,Ps,x,Da,mn.lineClipsArray.length,Ke,io,Di,[wa,kn],ja);if(Cr){const Nn=mn.gradients[x.id];let Si=Nn.texture;if(x.gradientVersion!==Nn.version){let bo=256;if(x.stepInterpolant){const ro=u.getSource().maxzoom,oi=ns.canonical.z===ro?Math.ceil(1<{nr!=null&&(nr.value=er*G),qa.draw(j,ke.TRIANGLES,Tr,Nn,Ge,Ys.disabled,Ra,x.id,mn.layoutVertexBuffer,mn.indexBuffer,mn.segments,x.paint,j.transform.zoom,an,[mn.layoutVertexBuffer2,mn.patternVertexBuffer,mn.zOffsetVertexBuffer]),nr!=null&&(nr.value=er)};if(ur&&!ps){const Nn=j.stencilModeForClipping(ns).ref;Nn===0&&at&&fe.clear({stencil:0});const Si={func:ke.EQUAL,mask:255};Ra.u_alpha_discard_threshold=.8,pa(new Js(Si,Nn,255,ke.KEEP,ke.KEEP,ke.INVERT)),Ra.u_alpha_discard_threshold=0,pa(new Js(Si,Nn,255,ke.KEEP,ke.KEEP,ke.KEEP))}else Ra.u_alpha_discard_threshold=ur&&ps&&Qr?.8:0,pa(ps?vs:j.stencilModeForClipping(ns))}};let gr=j.depthModeForSublayer(0,ks.ReadOnly);const qr=new ks(j.depthOcclusion?ke.GREATER:ke.LEQUAL,ks.ReadOnly,j.depthRangeFor3D);if(x.hasNonElevatedBuckets){const rs=!at&&j.terrain;G!==0&&rs?i.w(`Occlusion opacity for layer ${x.id} is supported on terrain only if the layer has line-z-offset enabled.`):rs?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${x.id}.`):Xt(N,Lt,gr,Js.disabled,!1,!0)}if(x.hasElevatedBuckets){J==="hd-road-markup"?he||(gr=qr,Lt.push("ELEVATED_ROADS")):(Lt.push("ELEVATED"),gr=qr,Re&&Lt.push(Oe?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),me&&Lt.push("ELEVATION_REFERENCE_SEA"));const rs=ur?j.stencilModeFor3D():Js.disabled;j.forceTerrainMode=!0,Xt(N,Lt,gr,rs,!0,!0),ur&&Xt(N,Lt,gr,rs,!0,!1),j.forceTerrainMode=!1}ur&&(j.resetStencilClippingMasks(),at&&fe.clear({stencil:0})),G===0||j.depthOcclusion||at||j.layersWithOcclusionOpacity.push(j.currentLayer)},fill:function(j,u,x,N){const P=x.paint.get("fill-color"),O=x.paint.get("fill-opacity");if(O.constantOr(1)===0)return;const F=x.paint.get("fill-emissive-strength"),U=j.colorModeForDrapableLayerRenderPass(F),G=x.paint.get("fill-pattern"),J=j.opaquePassEnabledForLayer()&&!G.constantOr(1)&&P.constantOr(i.ao.transparent).a===1&&O.constantOr(0)===1?"opaque":"translucent";let te="none";x.layout.get("fill-elevation-reference")!=="none"?te="road":x.paint.get("fill-z-offset").constantOr(1)!==0&&(te="offset");const me=!(!j.terrain||!j.terrain.enabled),he={painter:j,sourceCache:u,layer:x,coords:N,colorMode:U,elevationType:te,terrainEnabled:me,pass:J};if(j.renderPass==="shadow")return void(j.shadowRenderer&&te==="road"&&!me&&function(ke){const{painter:be,sourceCache:Re,layer:Oe,coords:Ge}=ke,at=be.context.gl,Ke=ke.painter.shadowRenderer;for(const Nt of Ge){const xt=Re.getTile(Nt),bt=xt.getBucket(Oe);if(!bt)continue;const gt=bt.elevatedStructures;if(!gt||!gt.shadowCasterSegments||gt.shadowCasterSegments.segments[0].primitiveLength===0)continue;be.prepareDrawTile();const ht=bt.bufferData.programConfigurations.get(Oe.id),At=be.isTileAffectedByFog(Nt),Bt=be.getOrCreateProgram("elevatedStructuresDepth",{config:ht,overrideFog:At}),zt=Ke.calculateShadowPassMatrixFromTile(xt.tileID.toUnwrapped());be.uploadCommonUniforms(be.context,Bt,Nt.toUnwrapped());const Jt={u_matrix:zt,u_depth_bias:0};Bt.draw(be,at.TRIANGLES,Ke.getShadowPassDepthMode(),Js.disabled,Ke.getShadowPassColorMode(),Ys.disabled,Jt,Oe.id,gt.vertexBuffer,gt.indexBuffer,gt.shadowCasterSegments,Oe.paint,be.transform.zoom,ht)}}(he));const fe=j.emissiveMode==="mrt-fallback";if(te!=="offset"){if(mS(he,!1,fe),te==="road"){const ke=!me&&j.renderPass==="translucent";ke&&hS(j,u,x,N,"geometry"),mS(he,!0,fe,Js.disabled),ke&&function(be){const{painter:Re,sourceCache:Oe,layer:Ge,coords:at,colorMode:Ke}=be,Nt=Re.context.gl,xt=be.painter.shadowRenderer,bt=!!xt&&xt.enabled,gt=new ks(Re.context.gl.LEQUAL,ks.ReadOnly,Re.depthRangeFor3D);let ht=[0,0,0];if(bt){const Bt=Re.style.directionalLight,zt=Re.style.ambientLight;Bt&&zt&&(ht=ap(Re.style,Bt,zt))}const At=Bt=>{for(const zt of at){const Jt=Oe.getTile(zt),er=Jt.getBucket(Ge);if(!er)continue;const ur=er.elevatedStructures;if(!ur)continue;let Cr,Kt;if(Bt?(Cr=ur.renderableBridgeSegments,Kt=ur.bridgeProgramConfigurations.get(Ge.id)):(Cr=ur.renderableTunnelSegments,Kt=ur.tunnelProgramConfigurations.get(Ge.id)),!Cr||Cr.segments[0].primitiveLength===0)continue;Kt.updatePaintBuffers(),Re.prepareDrawTile();const Lt=Re.isTileAffectedByFog(zt),nr=[];bt&&nr.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Xt=Re.getOrCreateProgram("elevatedStructures",{config:Kt,overrideFog:Lt,defines:nr}),gr=Re.translatePosMatrix(zt.projMatrix,Jt,Ge.paint.get("fill-translate"),Ge.paint.get("fill-translate-anchor"));bt&&xt.setupShadows(Jt.tileID.toUnwrapped(),Xt,"vector-tile");const qr=Tg(gr,ht);Re.uploadCommonUniforms(Re.context,Xt,zt.toUnwrapped()),Xt.draw(Re,Nt.TRIANGLES,gt,Js.disabled,Ke,Ys.backCCW,qr,Ge.id,ur.vertexBuffer,ur.indexBuffer,Cr,Ge.paint,Re.transform.zoom,Kt,[ur.vertexBufferNormal])}};At(!0),At(!1)}(he)}}else mS(he,!1,fe,j.stencilModeFor3D())},"fill-extrusion":function(j,u,x,N){const P=x.paint.get("fill-extrusion-opacity"),O=j.context,F=O.gl,U=j.terrain,G=U&&U.renderingToTexture;if(P===0)return;const J=j.emissiveMode==="mrt-fallback",te=j.conflationActive&&j.style.isLayerClipped(x,u.getSource()),me=j.style.order.indexOf(x.fqid);if(te&&function(he,fe,ke,be,Re){for(const Oe of be){const Ge=fe.getTile(Oe).getBucket(ke);Ge&&(Ge.updateReplacement(Oe,he.replacementSource,Re),Ge.uploadCentroid(he.context))}}(j,u,x,N,me),U||te)for(const he of N){const fe=u.getTile(he).getBucket(x);fe&&Ule(j.context,u,he,fe,x,U,te)}if(j.renderPass==="shadow"&&j.shadowRenderer){const he=j.shadowRenderer;if(U&&P<.65&&x._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const fe=he.getShadowPassDepthMode(),ke=he.getShadowPassColorMode();fS(j,u,x,N,fe,Js.disabled,ke,te)}else if(j.renderPass==="translucent"){const he=!x.paint.get("fill-extrusion-pattern").constantOr(1),fe=x.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!G&&fe.a!==0){const ke=new ks(j.context.gl.LEQUAL,ks.ReadWrite,j.depthRangeFor3D);P===1&&he?fS(j,u,x,N,ke,Js.disabled,wn.unblended,te):(fS(j,u,x,N,ke,Js.disabled,wn.disabled,te),fS(j,u,x,N,ke,j.stencilModeFor3D(),j.colorModeForRenderPass(),te),j.resetStencilClippingMasks())}if(j.style.enable3dLights()&&he&&(!U&&j.transform.projection.name!=="globe"||G)){const ke=x.paint.get("fill-extrusion-opacity"),be=x.paint.get("fill-extrusion-ambient-occlusion-intensity"),Re=x.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Oe=x.paint.get("fill-extrusion-flood-light-intensity"),Ge=x.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",at=x.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(Ge?null:x.lut).toArray01().slice(0,3),Ke=be>0&&Re>0,Nt=Oe>0,xt=(ht,At,Bt)=>(1-Bt)*ht+Bt*At,bt=new UM;bt.translate=x.paint.get("fill-extrusion-translate"),bt.translateAnchor=x.paint.get("fill-extrusion-translate-anchor"),bt.edgeRadius=x.layout.get("fill-extrusion-edge-radius"),bt.cutoffFadeRange=x.paint.get("fill-extrusion-cutoff-fade-range");const gt=ht=>{const At=j.depthModeForSublayer(1,ks.ReadOnly,F.LEQUAL,!0),Bt=x.paint.get(ht?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),zt=xt(.1,3,Bt),Jt=j._showOverdrawInspector;if(!Jt){const er=new Js({func:F.ALWAYS,mask:255},255,255,F.KEEP,F.KEEP,F.REPLACE),ur=new wn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!1,!1,!1,!0],F.MIN);lp(bt,j,u,x,N,At,er,ur,Ys.disabled,ht,"sdf",ke,be,Re,Oe,at,zt,te,!1)}{const er=Jt?Js.disabled:new Js({func:F.EQUAL,mask:255},255,255,F.KEEP,F.DECR,F.DECR),ur=Jt?j.colorModeForRenderPass():new wn([F.ONE_MINUS_DST_ALPHA,F.DST_ALPHA,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);lp(bt,j,u,x,N,At,er,ur,Ys.disabled,ht,"color",ke,be,Re,Oe,at,zt,te,!1)}};if(G){const ht=()=>{const Bt=U.drapeBufferSize[0],zt=U.drapeBufferSize[1];let Jt=U.framebufferCopyTexture;return Jt&&(!Jt||Jt.size[0]===Bt&&Jt.size[1]===zt)||(Jt&&Jt.destroy(),Jt=U.framebufferCopyTexture=new i.T(O,new i.q({width:Bt,height:zt}),F.RGBA8)),Jt.bind(F.LINEAR,F.CLAMP_TO_EDGE),F.copyTexSubImage2D(F.TEXTURE_2D,0,0,0,0,0,Bt,zt),Jt},At=(Bt,zt,Jt)=>{const er=j.depthModeForSublayer(1,ks.ReadOnly,F.LEQUAL,!1),ur=x.paint.get(Bt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Cr=xt(.1,3,ur);{const Kt=new wn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!1,!1,!1,!0]);lp(bt,j,u,x,N,er,Js.disabled,Kt,Ys.disabled,Bt,"clear",ke,be,Re,Oe,at,Cr,te,zt)}{const Kt=new Js({func:F.ALWAYS,mask:255},255,255,F.KEEP,F.KEEP,F.REPLACE),Lt=new wn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!1,!1,!1,!0],F.MIN);lp(bt,j,u,x,N,er,Kt,Lt,Ys.disabled,Bt,"sdf",ke,be,Re,Oe,at,Cr,te,zt)}J&&!Bt&&(Jt=ht());{const Kt=Bt?F.ZERO:F.ONE_MINUS_DST_ALPHA,Lt=new Js({func:F.EQUAL,mask:255},255,255,F.KEEP,F.DECR,F.DECR),nr=new wn([Kt,F.DST_ALPHA,F.ONE_MINUS_DST_ALPHA,F.ZERO],i.ao.transparent,[!0,!0,!0,!0]);lp(bt,j,u,x,N,er,Lt,nr,Ys.disabled,Bt,"color",ke,be,Re,Oe,at,Cr,te,zt)}if(!J||Bt){const Kt=new wn([F.ONE,F.ONE,F.ONE,Bt?F.ZERO:F.ONE],i.ao.transparent,[!1,!1,!1,!0],Bt?F.FUNC_ADD:F.MAX);lp(bt,j,u,x,N,er,Js.disabled,Kt,Ys.disabled,Bt,"clear",ke,be,Re,Oe,at,Cr,te,zt,Jt)}else{F.drawBuffers([F.NONE,F.COLOR_ATTACHMENT1]);const Kt=new Js({func:F.EQUAL,mask:255},254,255,F.KEEP,F.DECR,F.DECR),Lt=new wn([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!1,!1,!1],F.MAX);lp(bt,j,u,x,N,er,Kt,Lt,Ys.disabled,Bt,"emissive",ke,be,Re,Oe,at,Cr,te,zt,Jt),F.drawBuffers([F.COLOR_ATTACHMENT0])}};if(Ke||Nt){let Bt;j.prepareDrawTile(),J&&!Ke||(Bt=ht()),Ke&&At(!0,!1,Bt),Nt&&At(!1,!0,Bt)}}else Ke&>(!0),Nt&>(!1),(Ke||Nt)&&j.resetStencilClippingMasks()}}},building:function(j,u,x,N){j.currentLayer0&&O>0,J=!0;const te=x.paint.get("building-vertical-scale");if(te<=0)return;j.shadowRenderer||(J=!1);const me=j.conflationActive&&j.style.isLayerClipped(x,u.getSource()),he=j.style.order.indexOf(x.fqid);if(function(fe,ke,be,Re,Oe,Ge){for(const at of Ge){const Ke=ke.getTile(at).getBucket(be);Ke&&(Oe&&Ke.updateReplacement(at,fe.replacementSource,Re),Ke.uploadUpdatedIndexBuffer(fe.context))}}(j,u,x,he,me,N),function(fe,ke,be,Re){for(const Oe of Re){const Ge=ke.getTile(Oe).getBucket(be);Ge&&Ge.needsEvaluation()&&Ge.uploadUpdatedColorBuffer(fe.context)}}(j,u,x,N),x.resetLayerRenderingStats(j),j.shadowRenderer&&(j.shadowRenderer.useNormalOffset=!0),j.renderPass==="shadow"&&j.shadowRenderer){const fe=j.shadowRenderer,ke=[],be=fe.getShadowPassDepthMode();R_({painter:j,source:u,layer:x,coords:N,defines:ke,blendMode:fe.getShadowPassColorMode(),depthMode:be,opacity:U,verticalScale:te,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(j.renderPass==="translucent"){let fe=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];J&&(fe=fe.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),j.shadowRenderer&&j.shadowRenderer.useNormalOffset&&(fe=fe.concat("NORMAL_OFFSET"));const ke=x.paint.get("building-facade-emissive-chance"),be=x.paint.get("building-ambient-occlusion-intensity"),Re=x.paint.get("building-flood-light-intensity"),Oe=x.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",Ge=x.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Oe?null:x.lut).toArray01().slice(0,3),at=x.paint.get("building-flood-light-ground-attenuation"),Ke=Re>0,Nt=new ks(j.context.gl.LEQUAL,ks.ReadWrite,j.depthRangeFor3D);U<1&&R_({painter:j,source:u,layer:x,coords:N,defines:fe,blendMode:wn.disabled,depthMode:Nt,opacity:U,verticalScale:te,facadeEmissiveChance:ke,facadeAOIntensity:be,floodLightIntensity:Re,floodLightColor:Ge,depthOnly:!0});const xt=j.colorModeForRenderPass();R_({painter:j,source:u,layer:x,coords:N,defines:fe,blendMode:xt,depthMode:Nt,opacity:U,verticalScale:te,facadeEmissiveChance:ke,facadeAOIntensity:be,floodLightIntensity:Re,floodLightColor:Ge}),G&&pS(j,u,x,N,!0,U,P,O,Re,Ge,F,me),Ke&&pS(j,u,x,N,!1,U,P,O,Re,Ge,at,me)}else if(j.renderPass==="light-beam"){const fe=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],ke=new ks(j.context.gl.LEQUAL,ks.ReadOnly,j.depthRangeFor3D);R_({painter:j,source:u,layer:x,coords:N,defines:fe,blendMode:wn.alphaBlended,depthMode:ke,opacity:U,verticalScale:te,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}j.shadowRenderer&&(j.shadowRenderer.useNormalOffset=!1),j.resetStencilClippingMasks()},hillshade:function(j,u,x,N){if(j.renderPass!=="offscreen"&&j.renderPass!=="translucent"||j.style.disableElevatedTerrain)return;const P=j.context,O=j.terrain&&j.terrain.renderingToTexture,[F,U]=j.renderPass!=="translucent"||O?[{},N]:j.stencilConfigForOverlap(N);for(const G of U){const J=u.getTile(G);if(J.needsHillshadePrepare&&j.renderPass==="offscreen")Ile(j,J,x);else if(j.renderPass==="translucent"){const te=j.depthModeForSublayer(0,ks.ReadOnly),me=x.paint.get("hillshade-emissive-strength"),he=j.colorModeForDrapableLayerRenderPass(me),fe=O&&j.terrain?j.terrain.stencilModeForRTTOverlap(G):F[G.overscaledZ];Ele(j,G,J,x,te,fe,he)}}P.viewport.set([0,0,j.width,j.height]),j.resetStencilClippingMasks()},raster:function(j,u,x,N,P,O){if(j.renderPass!=="translucent"||x.paint.get("raster-opacity")===0)return;const F=j.transform.projection.name==="globe",U=x.paint.get("raster-elevation")!==0,G=U&&F;if(j.renderElevatedRasterBackface&&!G)return;const J=j.context,te=J.gl,me=u.getSource(),he=function(xt,bt,gt,ht,At){const Bt=bt.paint.get("raster-color"),zt=xt.type==="raster-array",Jt=[],er=bt.paint.get("raster-resampling"),ur=bt.paint.get("raster-color-mix");let Cr=bt.paint.get("raster-color-range");const Kt=[ur[0],ur[1],ur[2],0],Lt=ur[3];let nr=er==="nearest"?ht.NEAREST:ht.LINEAR;if(zt&&(Jt.push("RASTER_ARRAY"),Bt||Jt.push("RASTER_COLOR"),er==="linear"&&Jt.push("RASTER_ARRAY_LINEAR"),nr=ht.NEAREST,!Cr&&xt.rasterLayers)){const Xt=xt.rasterLayers.find(({id:gr})=>gr===bt.sourceLayer);Xt&&Xt.fields&&Xt.fields.range&&(Cr=Xt.fields.range)}if(Cr=Cr||[0,1],Bt){Jt.push("RASTER_COLOR"),gt.activeTexture.set(ht.TEXTURE2),bt.updateColorRamp(Cr);let Xt=bt.colorRampTexture;Xt||(Xt=bt.colorRampTexture=new i.T(gt,bt.colorRamp,ht.RGBA8)),Xt.bind(ht.LINEAR,ht.CLAMP_TO_EDGE)}return At&&Jt.push("USE_MRT1"),{mix:Kt,range:Cr,offset:Lt,defines:Jt,resampling:nr}}(me,x,J,te,j.terrain&&j.terrain.renderingToTexture&&j.emissiveMode==="mrt-fallback");if(me instanceof i.aU&&!N.length&&!F)return;const fe=x.paint.get("raster-emissive-strength"),ke=j.colorModeForDrapableLayerRenderPass(fe),be=j.terrain&&j.terrain.renderingToTexture,Re=!j.options.moving,Oe=x.paint.get("raster-resampling")==="nearest"?te.NEAREST:te.LINEAR;if(me instanceof i.aU&&!N.length&&(me.onNorthPole||me.onSouthPole)){const xt=U?j.stencilModeFor3D():Js.disabled;return void F_(!!me.onNorthPole,null,j,u,x,fe,he,Ys.disabled,xt)}if(!N.length)return;const[Ge,at]=me instanceof i.aU||be?[{},N]:j.stencilConfigForOverlap(N),Ke=at[at.length-1].overscaledZ;G&&he.defines.push("PROJECTION_GLOBE_VIEW"),U&&he.defines.push("RENDER_CUTOFF");const Nt=(xt,bt,gt)=>{for(const ht of xt){const At=ht.toUnwrapped(),Bt=u.getTile(ht);if(be&&(!Bt||!Bt.hasData()))continue;J.activeTexture.set(te.TEXTURE0);const zt=dp(Bt,me,x,he);if(!zt||!zt.texture)continue;const{texture:Jt,mix:er,offset:ur,tileSize:Cr,buffer:Kt}=zt;let Lt,nr;be?(Lt=ks.disabled,nr=ht.projMatrix):U?(Lt=new ks(te.LEQUAL,ks.ReadWrite,j.depthRangeFor3D),nr=F?Float32Array.from(j.transform.expandedFarZProjMatrix):j.transform.calculateProjMatrix(At,Re)):(Lt=j.depthModeForSublayer(ht.overscaledZ-Ke,x.paint.get("raster-opacity")===1?ks.ReadWrite:ks.ReadOnly,te.LESS),nr=j.transform.calculateProjMatrix(At,Re));const Xt=j.terrain&&be?j.terrain.stencilModeForRTTOverlap(ht):Ge[ht.overscaledZ],gr=O?0:x.paint.get("raster-fade-duration");Bt.registerFadeDuration(gr);const qr=u.findLoadedParent(ht,0),rs=I_(Bt,qr,u,j.transform,gr);let Or,Tr;!rs.isFading&&Bt.refreshedUponExpiration&&(Bt.refreshedUponExpiration=!1),j.terrain&&j.terrain.prepareDrawTile(),J.activeTexture.set(te.TEXTURE0),Jt.bind(Oe,te.CLAMP_TO_EDGE),J.activeTexture.set(te.TEXTURE1),qr?(qr.texture&&qr.texture.bind(Oe,te.CLAMP_TO_EDGE),Or=Math.pow(2,qr.tileID.overscaledZ-Bt.tileID.overscaledZ),Tr=[Bt.tileID.canonical.x*Or%1,Bt.tileID.canonical.y*Or%1]):Jt.bind(Oe,te.CLAMP_TO_EDGE),"useMipmap"in Jt&&J.extTextureFilterAnisotropic&&j.transform.pitch>20&&te.texParameterf(te.TEXTURE_2D,J.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,J.extTextureFilterAnisotropicMax);const vs=j.transform;let ps;const Qr=U?PL(vs):[0,0,0,0];let ns,Ps,mn,sa,Ea,js=0;if(G&&me instanceof i.aU&&me.coordinates.length>3)ns=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Ps=Float32Array.from(vs.globeMatrix),mn=Float32Array.from(i.dF(vs)),sa=[i.aF(vs.center.lng),i.aJ(vs.center.lat)],ps=me.elevatedGlobePerspectiveTransform,Ea=me.elevatedGlobeGridMatrix||new Float32Array(9);else if(G){const Xa=i.dG(ht.canonical);js=i.dH(Xa.getCenter().lat),ns=Float32Array.from(i.bk(i.dJ(ht.canonical))),Ps=Float32Array.from(vs.globeMatrix),mn=Float32Array.from(i.dF(vs)),sa=[i.aF(vs.center.lng),i.aJ(vs.center.lat)],ps=[0,0],Ea=Float32Array.from(i.dI(ht.canonical,Xa,js,vs.worldSize/vs._pixelsPerMercatorPixel))}else ps=me instanceof i.aU?me.perspectiveTransform:[0,0],ns=new Float32Array(16),Ps=new Float32Array(9),mn=new Float32Array(16),sa=[0,0],Ea=new Float32Array(9);const ja=SL(nr,ns,Ps,mn,Ea,Tr||[0,0],i.aj(j.transform.zoom),sa,Qr,Or||1,rs,x,ps,U?x.paint.get("raster-elevation"):0,2,er,ur,he.range,Cr,Kt,fe),an=j.isTileAffectedByFog(ht),Oa=j.getOrCreateProgram("raster",{defines:he.defines,overrideFog:an});if(j.uploadCommonUniforms(J,Oa,At),me instanceof i.aU){const Xa=me.elevatedGlobeVertexBuffer,qa=me.elevatedGlobeIndexBuffer;if(be||!F)me.boundsBuffer&&me.boundsSegments&&Oa.draw(j,te.TRIANGLES,Lt,Js.disabled,ke,Ys.disabled,ja,x.id,me.boundsBuffer,j.quadTriangleIndexBuffer,me.boundsSegments);else if(Xa&&qa){const wa=vs.zoom<=i.c_?me.elevatedGlobeSegments:me.getSegmentsForLongitude(vs.center.lng);wa&&Oa.draw(j,te.TRIANGLES,Lt,Js.disabled,ke,bt,ja,x.id,Xa,qa,wa)}}else if(G){Lt=new ks(te.LEQUAL,ks.ReadOnly,j.depthRangeFor3D);const Xa=j.globeSharedBuffers;if(Xa){const[qa,wa,kn]=Xa.getGridBuffers(js,!1);Oa.draw(j,te.TRIANGLES,Lt,gt||Xt,j.colorModeForRenderPass(),bt,ja,x.id,qa,wa,kn)}}else{const{tileBoundsBuffer:Xa,tileBoundsIndexBuffer:qa,tileBoundsSegments:wa}=j.getTileBoundsBuffers(Bt);Oa.draw(j,te.TRIANGLES,Lt,Xt,ke,Ys.disabled,ja,x.id,Xa,qa,wa)}}if(!(me instanceof i.aU)&&G)for(const ht of xt){const At=ht.canonical.y===(1<>>16,2654435769),((ht=Math.imul(ht^ht>>>16,2654435769))>>>0)/4294967296},gt=1/1.1;for(let ht=0;hti.e9[Xt](Jt));Kt.push(Jt);const Lt=Jt.canonical.x,nr=Jt.canonical.y;for(const Xt of Kt){const gr=Ke.getTile(At?Xt.wrapped():Xt);if(!gr)continue;const qr=gr.rasterParticleState;if(!qr)continue;const rs=Xt.canonical.x+(1<bt.tileID)),fe&&(J.activeTexture.set(te.TEXTURE0),j.imageManager.bind(j.context,x.scope));const xt=[];if(j.terrain&&j.terrain.renderingToTexture&&j.emissiveMode==="mrt-fallback"&&xt.push("USE_MRT1"),G){const bt=j.getOrCreateProgram(at,{overrideFog:!1,overrideRtt:!0,defines:xt}),gt=new Float32Array(i.bA([])),ht=new i.aQ(0,0,0,0,0),At=fe?Eg(gt,U,F,j,0,x.scope,ke,G,{tileID:ht,tileSize:he}):L_(gt,U,F,P.toPremultipliedRenderColor(O?null:x.lut));bt.draw(j,te.TRIANGLES,Oe,Re,Ge,Ys.disabled,At,x.id,j.viewportBuffer,j.quadTriangleIndexBuffer,j.viewportSegments)}else for(const bt of Nt){const gt=j.isTileAffectedByFog(bt),ht=j.getOrCreateProgram(at,{overrideFog:gt,defines:xt}),At=bt.toUnwrapped(),Bt=N?bt.projMatrix:j.transform.calculateProjMatrix(At);j.prepareDrawTile();const zt=u?u.getTile(bt):Ke?Ke[bt.key]:new tp(bt,he,me.zoom,j),Jt=fe?Eg(Bt,U,F,j,0,x.scope,ke,G,{tileID:bt,tileSize:he}):L_(Bt,U,F,P.toPremultipliedRenderColor(O?null:x.lut));j.uploadCommonUniforms(J,ht,At);const{tileBoundsBuffer:er,tileBoundsIndexBuffer:ur,tileBoundsSegments:Cr}=j.getTileBoundsBuffers(zt);ht.draw(j,te.TRIANGLES,Oe,Re,Ge,Ys.disabled,Jt,x.id,er,ur,Cr)}},sky:function(j,u,x){const N=j._atmosphere?i.aj(j.transform.zoom):1,P=x.paint.get("sky-opacity")*N;if(P===0)return;const O=j.context,F=x.paint.get("sky-type"),U=new ks(O.gl.LEQUAL,ks.ReadOnly,[0,1]),G=j.frameCounter/1e3%1;F==="atmosphere"?j.renderPass==="offscreen"?x.needsSkyboxCapture(j)&&(function(J,te,me,he){const fe=J.context,ke=fe.gl;let be=te.skyboxFbo;if(!be){be=te.skyboxFbo=fe.createFramebuffer(32,32,1,null),te.skyboxGeometry=new vS(fe),te.skyboxTexture=fe.gl.createTexture(),ke.bindTexture(ke.TEXTURE_CUBE_MAP,te.skyboxTexture),ke.texParameteri(ke.TEXTURE_CUBE_MAP,ke.TEXTURE_WRAP_S,ke.CLAMP_TO_EDGE),ke.texParameteri(ke.TEXTURE_CUBE_MAP,ke.TEXTURE_WRAP_T,ke.CLAMP_TO_EDGE),ke.texParameteri(ke.TEXTURE_CUBE_MAP,ke.TEXTURE_MIN_FILTER,ke.LINEAR),ke.texParameteri(ke.TEXTURE_CUBE_MAP,ke.TEXTURE_MAG_FILTER,ke.LINEAR);for(let at=0;at<6;++at)ke.texImage2D(ke.TEXTURE_CUBE_MAP_POSITIVE_X+at,0,ke.RGBA,32,32,0,ke.RGBA,ke.UNSIGNED_BYTE,null)}fe.bindFramebuffer.set(be.framebuffer),fe.viewport.set([0,0,32,32]);const Re=te.getCenter(J,!0),Oe=J.getOrCreateProgram("skyboxCapture"),Ge=new Float64Array(16);i.bA(Ge),i.en(Ge,Ge,.5*-Math.PI),Xx(J,te,Oe,Ge,Re,0),i.bA(Ge),i.en(Ge,Ge,.5*Math.PI),Xx(J,te,Oe,Ge,Re,1),i.bA(Ge),i.cU(Ge,Ge,.5*-Math.PI),Xx(J,te,Oe,Ge,Re,2),i.bA(Ge),i.cU(Ge,Ge,.5*Math.PI),Xx(J,te,Oe,Ge,Re,3),i.bA(Ge),Xx(J,te,Oe,Ge,Re,4),i.bA(Ge),i.en(Ge,Ge,Math.PI),Xx(J,te,Oe,Ge,Re,5),fe.viewport.set([0,0,J.width,J.height])}(j,x),x.markSkyboxValid(j)):j.renderPass==="sky"&&function(J,te,me,he,fe){const ke=J.context,be=ke.gl,Re=J.transform,Oe=J.getOrCreateProgram("skybox");ke.activeTexture.set(be.TEXTURE0),be.bindTexture(be.TEXTURE_CUBE_MAP,te.skyboxTexture);const Ge=((at,Ke,Nt,xt,bt)=>({u_matrix:at,u_sun_direction:Ke,u_cubemap:0,u_opacity:xt,u_temporal_offset:bt}))(Re.skyboxMatrix,te.getCenter(J,!1),0,he,fe);J.uploadCommonUniforms(ke,Oe),Oe.draw(J,be.TRIANGLES,me,Js.disabled,J.colorModeForRenderPass(),Ys.backCW,Ge,"skybox",te.skyboxGeometry.vertexBuffer,te.skyboxGeometry.indexBuffer,te.skyboxGeometry.segment)}(j,x,U,P,G):F==="gradient"&&j.renderPass==="sky"&&function(J,te,me,he,fe){const ke=J.context,be=ke.gl,Re=J.transform,Oe=J.getOrCreateProgram("skyboxGradient");te.skyboxGeometry||(te.skyboxGeometry=new vS(ke)),ke.activeTexture.set(be.TEXTURE0);let Ge=te.colorRampTexture;Ge||(Ge=te.colorRampTexture=new i.T(ke,te.colorRamp,be.RGBA8)),Ge.bind(be.LINEAR,be.CLAMP_TO_EDGE);const at=((Ke,Nt,xt,bt,gt)=>({u_matrix:Ke,u_color_ramp:0,u_center_direction:Nt,u_radius:i.an(xt),u_opacity:bt,u_temporal_offset:gt}))(Re.skyboxMatrix,te.getCenter(J,!1),te.paint.get("sky-gradient-radius"),he,fe);J.uploadCommonUniforms(ke,Oe),Oe.draw(J,be.TRIANGLES,me,Js.disabled,J.colorModeForRenderPass(),Ys.backCW,at,"skyboxGradient",te.skyboxGeometry.vertexBuffer,te.skyboxGeometry.indexBuffer,te.skyboxGeometry.segment)}(j,x,U,P,G)},custom:function(j,u,x,N){const P=j.context,O=x.implementation;if(!j.transform.projection.unsupportedLayers||!j.transform.projection.unsupportedLayers.includes("custom")||j.terrain&&(j.terrain.renderingToTexture||j.renderPass==="offscreen")&&x.isDraped(u)){if(j.renderPass==="offscreen"){const F=O.prerender;if(F){if(j.setCustomLayerDefaults(),P.setColorMode(j.colorModeForRenderPass()),j.transform.projection.name==="globe"){const U=j.transform.pointMerc;F.call(O,P.gl,j.transform.customLayerMatrix(),j.transform.getProjection(),j.transform.globeToMercatorMatrix(),i.aj(j.transform.zoom),[U.x,U.y],j.transform.pixelsPerMeterRatio)}else F.call(O,P.gl,j.transform.customLayerMatrix());P.setDirty(),j.setBaseState()}}else if(j.renderPass==="translucent"){if(j.terrain&&j.terrain.renderingToTexture){const U=O.renderToTile;if(U){const G=N[0].canonical,J={x:G.x+N[0].wrap*(O.wrapTileId?0:1<{J&&(J.useNormalOffset=!0,te||(J.enabled=!0))},he=u.getSource();if(j.renderPass==="light-beam"&&he.type!=="batched-model")return;if(he.type==="vector"||he.type==="geojson")return function(Ke,Nt,xt,bt,gt){const ht=Ke.transform,At=ht.projection.name==="globe",Bt=ht.getFreeCameraOptions().position;if(!Ke.modelManager)return;const zt=Ke.modelManager;xt.modelManager=zt;const Jt=Ke.shadowRenderer;if(!xt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const er=xt._unevaluatedLayout._values["model-id"],ur=Object.assign({},xt.layout.get("model-id").parameters),Cr=Ke.style.order.indexOf(xt.fqid),Kt=xt.paint.get("model-opacity").constantOr(1);for(const Lt of bt){const nr=Nt.getTile(Lt).getBucket(xt);if(!nr||nr.projection.name!==ht.projection.name)continue;const Xt=nr.getModelUris();if(Xt&&!nr.modelsRequested&&(zt.addModelsFromBucket(Xt,gt),nr.modelsRequested=!0),At)ur.zoom=Lt.overscaledZ;else{const Qr=Od(Lt,ht);ur.zoom=Qr}const gr=er.possiblyEvaluate(ur);if(qL(Ke,nr,Lt),af.shadowUniformsInitialized=!1,af.useSingleShadowCascade=!!Jt&&Jt.getMaxCascadeForTile(Lt.toUnwrapped())===0,Ke.renderPass==="shadow"&&Jt){if(Ke.currentShadowCascade===1&&nr.isInsideFirstShadowMapFrustum)continue;const Qr=ht.calculatePosMatrix(Lt.toUnwrapped(),ht.worldSize);if(af.tileMatrix.set(Qr),af.shadowTileMatrix=Float32Array.from(Jt.calculateShadowPassMatrixFromMatrix(Qr)),af.aabb.min=[0,0,0],af.aabb.max[0]=af.aabb.max[1]=i.al,af.aabb.max[2]=0,Hle(nr,af,Ke,xt.scope))continue}const qr=1<0&&Ke.style.isLayerClipped(xt,Nt.getSource())&&nr.updateReplacement(Lt,Ke.replacementSource,Cr,xt.scope)&&(nr.uploaded=!1,nr.upload(Ke.context));let Or=0;const Tr=new Array,vs=new Array,ps=new Array;for(let Qr in nr.instancesPerModel){const ns=nr.instancesPerModel[Qr];ns.features.length>0&&!At&&(Qr=gr.evaluate(ns.features[0].feature,{}));const Ps=zt.getModel(Qr,gt);if(Ps||zt.hasURLBeenRequested(Qr)||nr.modelUris.includes(Qr)||(nr.modelUris.push(Qr),nr.modelsRequested=!1),Ps&&Ps.uploaded)if(At){const mn=i.c5([],[Bt.x,Bt.y,Bt.z],Ke.transform.worldSize);i.ew(mn,mn);for(let sa=0;sa0&&ja.elevationUpdate(Qr.terrain,sa,js,Ps.source),ja.needsReEvaluation(Qr,Ea,Ps)&&ja.evaluate(Ps))}})(Ke,Nt,xt,bt),function(){let Qr,ns,Ps;Tr?(Qr=bt.length-1,ns=-1,Ps=-1):(Qr=0,ns=bt.length,Ps=1);const mn=new Float64Array(16),sa=i.cA(),Ea=new i.P(0,0);for(let js=Qr;js!==ns;js+=Ps){const ja=bt[js],an=Nt.getTile(ja).getBucket(xt);if(!an||!an.uploaded)continue;let Oa=!1;Bt&&(Oa=Bt.getMaxCascadeForTile(ja.toUnwrapped())===0);const Xa=ht.calculatePosMatrix(ja.toUnwrapped(),ht.worldSize),qa=an.modelTraits;!qr&&Tr&&(i.bl(mn,Xa),i.af(sa,Jt,mn),Ea.x=sa[0],Ea.y=sa[1]);const wa=[];an.setFilter(xt.filter);for(const kn of an.getNodesInfo()){if(kn.hiddenByReplacement||!kn.node.meshes)continue;const Da=kn.node;let io=0;Ke.terrain&&Da.elevation&&(io=Da.elevation*Ke.terrain.exaggeration());const Di=(()=>{const Zc=kn.aabb;return gr.min=[...Zc.min],gr.max=[...Zc.max],gr.min[2]+=io,gr.max[2]+=io,i.af(gr.min,gr.min,Xa),i.af(gr.max,gr.max,Xa),gr})(),Ra=kn.evaluatedScale;if(Ra[0]<=1&&Ra[1]<=1&&Ra[2]<=1&&Di.intersects(rs)===0)continue;if(!qr&&Tr){const Zc=.16666666666666666;kn.cameraCollisionOpacity=Jt[0]>Di.min[0]&&Jt[0]Di.min[1]&&Jt[1]!Tr||kn.opacity===1&&Da.opacity===1?kn.depthDa.depth?-1:1);for(const kn of wa){const Da=kn.nodeInfo,io=Da.node;let Di=i.aB([],Kt,kn.tileModelMatrix);i.aB(Di,ur,Di);const Ra=i.bl([],Di);i.eg(Ra,Ra),i.cS(Ra,Ra,B_),Di=i.aB(Di,Di,io.globalMatrix);const pa=Ke.renderPass==="light-beam",Nn=xt.paint.get("model-color-use-theme").constantOr("default")==="none",Si=qa&i.eI.HasMapboxMeshFeatures,bo=Si?0:Da.evaluatedRMEA[0][2];for(let ro=0;ro=hr||so>=hr}}const nc=oi.material;let Ju;nc.occlusionTexture&&nc.occlusionTexture.offsetScale&&(Ju=nc.occlusionTexture.offsetScale,nl.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const Dh=Ke.getOrCreateProgram("model",nl);!qr&&Bt&&Bt.setupShadowsFromMatrix(kn.tileModelMatrix,Dh,Bt.useNormalOffset),Ke.uploadCommonUniforms(gt,Dh,null,Yc);const nu=nc.pbrMetallicRoughness;nu.metallicFactor=.9,nu.roughnessFactor=.5;const fo=Wx(new Float32Array(Ic),new Float32Array(Di),new Float32Array(Ra),new Float32Array(io.globalMatrix),Ke,kn.opacity,nu.baseColorFactor,nc.emissiveFactor,nu.metallicFactor,nu.roughnessFactor,nc,bo,xt,[0,0,0],Ju);!Rd&&(Da.hasTranslucentParts||kn.opacity<1)&&Dh.draw(Ke,gt.gl.TRIANGLES,nr,Js.disabled,wn.disabled,Ys.backCCW,fo,xt.id,oi.vertexBuffer,oi.indexBuffer,oi.segments,xt.paint,Ke.transform.zoom,void 0,Zc),Dh.draw(Ke,gt.gl.TRIANGLES,Rd?Xt:nr,Js.disabled,Rd||kn.opacity<1||Da.hasTranslucentParts?wn.alphaBlended:wn.unblended,Ys.backCCW,fo,xt.id,oi.vertexBuffer,oi.indexBuffer,oi.segments,xt.paint,Ke.transform.zoom,void 0,Zc)}}}}()}(j,u,x,N),void me();if(he.type!=="model")return;const fe=he.getModels(),ke=[],be=j.transform.getFreeCameraOptions().position,Re=i.c5([],[be.x,be.y,be.z],j.transform.worldSize);i.ew(Re,Re);const Oe=[],Ge=[];let at=0;for(const Ke of fe){const Nt=u.getFeatureState("",Ke.id),xt={type:"Unknown",id:Ke.id,properties:Ke.featureProperties},bt=x.paint.get("model-rotation").evaluate(xt,Nt),gt=x.paint.get("model-scale").evaluate(xt,Nt),ht=x.paint.get("model-translation").evaluate(xt,Nt),At=x.paint.get("model-opacity").evaluate(xt,Nt);$L(x,Ke.id,Nt,Ke.featureProperties,Ke.nodeOverrideNames,Ke.nodeOverrides),UL(x,Ke.id,Nt,Ke.featureProperties,Ke.materialOverrideNames,Ke.materialOverrides),Ke.nodeOverrides.size>0&&Ke.computeBoundsAndApplyParent(),Ke.computeModelMatrix(j,bt,gt,ht,U,F,!1);const Bt=i.bA([]),zt=i.ef(Ke.position.lat,j.transform.zoom),Jt=i.bq([],[1,1,1/zt]);i.br(Bt,Bt,Re),ke.push({zScaleMatrix:Jt,negCameraPosMatrix:Bt});for(const er of Ke.nodes)Qx(j,er,Ke.matrix,j.transform.expandedFarZProjMatrix,at,Oe,Ge,Ke.materialOverrides,At);at++}if(Oe.sort((Ke,Nt)=>Nt.depth-Ke.depth),j.renderPass!=="shadow")VL(j,x,Oe,Ge,ke),me();else{for(const Ke of Ge)pm(Ke.mesh,Ke.nodeModelMatrix,j,x);for(const Ke of Oe)pm(Ke.mesh,Ke.nodeModelMatrix,j,x);me()}}},SS={line:function(j,u,x){if(j.hasElevatedBuckets=!1,j.hasNonElevatedBuckets=!1,j._unevaluatedLayout.getValue("line-elevation-reference")!==void 0||j._unevaluatedLayout.getValue("line-z-offset")!==void 0){if(u){const N=u.getVisibleCoordinates();for(const P of N){const O=u.getTile(P).getBucket(j);if(O&&(O.elevationType!=="none"?j.hasElevatedBuckets=!0:j.hasNonElevatedBuckets=!0,j.hasElevatedBuckets&&j.hasNonElevatedBuckets))break}}}else j.hasNonElevatedBuckets=!0},model:function(j,u,x){const N=u.getSource();if(!N.loaded())return;if(N.type==="vector"||N.type==="geojson")return void(x.modelManager&&x.modelManager.upload(x,z_(x,j)));if(N.type==="batched-model"||N.type!=="model")return;const P=N.getModels();for(const O of P)O.upload(x.context)},raster:function(j,u,x){const N=u.getSource();if(!(N instanceof Ac&&N.loaded()))return;const P=j.sourceLayer||N.rasterLayerIds&&N.rasterLayerIds[0];if(!P)return;const O=j.paint.get("raster-array-band")||N.getInitialBand(P);if(O==null)return;const F=u.getIds().map(U=>u.getTileByID(U));for(const U of F)U.updateNeeded(j.id,O)&&N.prepareTile(U,P,j.id,O)},"raster-particle":function(j,u,x){const N=u.getSource();if(!(N instanceof Ac&&N.loaded()))return;const P=j.sourceLayer||N.rasterLayerIds&&N.rasterLayerIds[0];if(!P)return;const O=j.paint.get("raster-particle-array-band")||N.getInitialBand(P);if(O==null)return;const F=u.getIds().map(U=>u.getTileByID(U));for(const U of F)U.updateNeeded(j.id,O)&&N.prepareTile(U,P,j.id,O)}},Qu={fill:hS},CS={fill:function(j,u,x,N){if(!x.layout||x.layout.get("fill-elevation-reference")==="none"||x.paint.get("fill-opacity").constantOr(1)===0)return;const P=j.context.gl,O=new ks(P.LEQUAL,ks.ReadOnly,j.depthRangeFor3D),F=new Js({func:P.ALWAYS,mask:255},255,255,P.KEEP,P.KEEP,P.REPLACE),U=j.transform.getFreeCameraOptions().position,G=j.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const J of N){const te=u.getTile(J),me=te.getBucket(x);if(!me)continue;const he=me.elevatedStructures;if(!he||he.depthSegments.segments[0].primitiveLength===0)continue;const fe=IL(J.toUnwrapped(),U),ke=j.translatePosMatrix(J.projMatrix,te,x.paint.get("fill-translate"),x.paint.get("fill-translate-anchor")),be=Hx(ke,fe,0,1,0);G.draw(j,P.TRIANGLES,O,F,wn.disabled,Ys.disabled,be,x.id,he.vertexBuffer,he.indexBuffer,he.depthSegments,x.paint,j.transform.zoom)}}};class MS{constructor(u,x,N,P,O){this.context=new V0(u,x),this.transform=N,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 G of F)this._debugParams.enabledLayers[G]=!0;for(const G of F);this.occlusionParams=new H0,this.setup(),this.numSublayers=Ed.maxUnderzooming+Ed.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 E0(this),this._wireframeDebugCache=new Pg,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=O,this._forceEmissiveMode=!1,this.emissiveMode="constant"}updateTerrain(u,x){const N=!!u&&!!u.terrain&&this.transform.projection.supportsTerrain;if(!(N||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new PM(this,u));const P=this._terrain;this.transform.elevation=N?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[N,P]=x.getFovAdjustedRange(this.transform._fov);if(N>P)return void(this.transform.fogCullDistSq=null);const O=N+.78*(P-N);this.transform.fogCullDistSq=O*O}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 PM(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 N of this.style.order)this.style._mergedLayers[N].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 N=new i.bd;N.emplaceBack(0,0),N.emplaceBack(i.al,0),N.emplaceBack(0,i.al),N.emplaceBack(i.al,i.al),this.debugBuffer=u.createVertexBuffer(N,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 O=new i.b1;O.emplaceBack(0,0,0,0),O.emplaceBack(i.al,0,i.al,0),O.emplaceBack(0,i.al,0,i.al),O.emplaceBack(i.al,i.al,i.al,i.al),this.mercatorBoundsBuffer=u.createVertexBuffer(O,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 J of[0,1,3,2,0])U.emplaceBack(J);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 G=this.context.gl;this.stencilClearMode=new Js({func:G.ALWAYS,mask:0},0,255,G.ZERO,G.ZERO,G.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,ks.disabled,this.stencilClearMode,wn.disabled,Ys.disabled,E_(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(u,x,N){if(!x||this.currentStencilSource===x.id||!u.isTileClipped()||!N||N.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let U=!1;for(const G of N)if(this._tileClippingMaskIDs[G.key]===void 0){U=!0;break}if(!U)return}this.currentStencilSource=x.id;const P=this.context,O=P.gl;this.nextStencilID+N.length>256&&this.clearStencil(),P.setColorMode(wn.disabled),P.setDepthMode(ks.disabled);const F=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const U of N){const G=x.getTile(U),J=this._tileClippingMaskIDs[U.key]=this.nextStencilID++,{tileBoundsBuffer:te,tileBoundsIndexBuffer:me,tileBoundsSegments:he}=this.getTileBoundsBuffers(G);F.draw(this,O.TRIANGLES,ks.disabled,new Js({func:O.ALWAYS,mask:0},J,255,O.KEEP,O.KEEP,O.REPLACE),wn.disabled,Ys.disabled,E_(U.projMatrix),"$clipping",te,me,he)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const u=this.nextStencilID++,x=this.context.gl;return new Js({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 Js({func:x.EQUAL,mask:255},this._tileClippingMaskIDs[u.key],0,x.KEEP,x.KEEP,x.REPLACE)}stencilConfigForOverlap(u){const x=this.context.gl,N=u.sort((F,U)=>U.overscaledZ-F.overscaledZ),P=N[N.length-1].overscaledZ,O=N[0].overscaledZ-P+1;if(O>1){this.currentStencilSource=void 0,this.nextStencilID+O>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 N=i.o.now();this._dt=N-this._timeStamp,this._timeStamp=N,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=u.map.repaint,this.style=u,this.options=x;const P=this.style._mergedLayers,O=!(!this.terrain||!this.terrain.enabled),F=()=>this.style._getOrder(O).filter(Kt=>{const Lt=P[Kt];return!(Lt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Lt.type]});let U=F(),G=!1,J=!1,te=null,me=0,he=!1;for(const Kt of U){const Lt=P[Kt];Lt.visibility!=="none"&&(Lt.type==="circle"?G=!0:Lt.type==="building"?(te=Lt,++me):Lt.type==="symbol"&&(Lt.hasOcclusionOpacityProperties?J=!0:G=!0))}this.updateEmissiveMode();let fe=U.map(Kt=>P[Kt]);const ke=this.style._mergedSourceCaches;this.imageManager=u.imageManager,this.modelManager=u.modelManager,this.symbolFadeChange=u.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Kt in ke){const Lt=ke[Kt];Lt.used&&(Lt.prepare(this.context),Lt.getSource().usedInConflation&&++me)}let be=!1;for(const Kt of fe)Kt.isHidden(this.transform.zoom)||(Kt.type==="clip"&&(be=!0),this.prepareLayer(Kt));const Re={},Oe={},Ge={},at={},Ke={};for(const Kt in ke){const Lt=ke[Kt];Re[Kt]=Lt.getVisibleCoordinates(),Oe[Kt]=Re[Kt].slice().reverse(),Ge[Kt]=Lt.getVisibleCoordinates(!0).reverse(),at[Kt]=Lt.getShadowCasterCoordinates(),Ke[Kt]=Lt.sortCoordinatesByDistance(Re[Kt])}const Nt=Kt=>{const Lt=this.style.getLayerSourceCache(Kt);return Lt&&Lt.used?Lt.getSource():null};if(me||be||this._clippingActiveLastFrame){const Kt=[],Lt=[];let nr=0;for(const Xt of fe)this.isSourceForClippingOrConflation(Xt,Nt(Xt))&&(Kt.push(Xt),Lt.push(nr)),nr++;if(Kt&&(be||Kt.length>1)||this._clippingActiveLastFrame){be=!1;const Xt=[];for(let gr=0;gr0){const Xt=Nt(Lt);Xt&&(this.minCutoffZoom=Math.max(Xt.minzoom,this.minCutoffZoom)),Lt.minzoom&&(this.minCutoffZoom=Math.max(Lt.minzoom,this.minCutoffZoom))}Lt.is3D(O)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=Kt),this._lastOcclusionLayer=Kt)}const xt=this.style&&this.style.fog;xt?(this._fogVisible=xt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=xt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(Ge),this.opaquePassCutoff=0,U=F(),fe=U.map(Kt=>P[Kt]));const bt=this._shadowRenderer;if(bt){bt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Kt in ke)for(const Lt of Re[Kt]){let nr={min:0,max:0};this.terrain&&(nr=this.terrain.getMinMaxForTile(Lt)||nr),bt.addShadowReceiver(Lt.toUnwrapped(),nr.min,nr.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 BL(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const gt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),ht=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(gt&&!this._snow&&(this._snow=new ZM(this)),!gt&&this._snow&&(this._snow.destroy(),delete this._snow),ht&&!this._rain&&(this._rain=new NS(this)),!ht&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),te){this.buildingTileBorderManager||(this.buildingTileBorderManager=new _S);const Kt=this.style.getLayerSourceCache(te);this.buildingTileBorderManager.updateBorders(Kt,te)}if(!tt.has(this.context.gl))return;this.renderPass="offscreen";for(const Kt of fe){const Lt=u.getLayerSourceCache(Kt);if(!Kt.hasOffscreenPass()||Kt.isHidden(this.transform.zoom))continue;const nr=Lt?Oe[Lt.id]:void 0;(Kt.type==="custom"||Kt.type==="raster"||Kt.type==="raster-particle"||Kt.isSky()||nr&&nr.length)&&this.renderLayer(this,Lt,Kt,nr)}this.depthRangeFor3D=[0,1-(fe.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,at)),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(),Bt=(()=>{if(x.showOverdrawInspector)return i.ao.black;const Kt=this.style.fog;if(Kt&&this.transform.projection.supportsFog){const Lt=this.style.getLut(Kt.scope);if(!At){const nr=Kt.properties.get("color-use-theme")==="none",Xt=Kt.properties.get("color").toNonPremultipliedRenderColor(nr?null:Lt).toArray01();return new i.ao(...Xt)}if(At){const nr=Kt.properties.get("space-color-use-theme")==="none",Xt=Kt.properties.get("space-color").toNonPremultipliedRenderColor(nr?null:Lt).toArray01();return new i.ao(...Xt)}}return i.ao.transparent})();if(this.context.clear({color:Bt,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 Kt=fe[this.currentLayer],Lt=u.getLayerSourceCache(Kt);if(Kt.isSky())continue;const nr=Lt?(Kt.is3D(O)?Ke:Oe)[Lt.id]:void 0;this._renderTileClippingMasks(Kt,Lt,nr),this.renderLayer(this,Lt,Kt,nr)}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&&Kt.hasShadowPass()&&--Jt==0){{this.clearStencil(),this.resetStencilClippingMasks();const nr=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const nr=this.currentLayer;this.depthOcclusion=!0;for(const Xt of this.layersWithOcclusionOpacity){this.currentLayer=Xt;const gr=fe[this.currentLayer],qr=u.getLayerSourceCache(gr),rs=qr?Oe[qr.id]:void 0;this.terrain||this._renderTileClippingMasks(gr,qr,qr?Re[qr.id]:void 0),this.renderLayer(this,qr,gr,rs)}this.depthOcclusion=!1,this.currentLayer=nr,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 Kt=null;fe.forEach(Lt=>{const nr=u.getLayerSourceCache(Lt);nr&&!Lt.isHidden(this.transform.zoom)&&nr.getVisibleCoordinates().length&&(!Kt||Kt.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,N){const P=N===void 0?this.terrain&&this.terrain.renderingToTexture:N,O=[];return this.style&&this.style.enable3dLights()&&(u==="globeRaster"||u==="terrainRaster"?(O.push("LIGHTING_3D_MODE"),O.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):P||O.push("LIGHTING_3D_MODE")),this.renderPass==="shadow"&&(this._shadowMapDebug||O.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(O.push("TERRAIN"),this.linearFloatFilteringSupported()&&O.push("TERRAIN_DEM_FLOAT_FORMAT")),this.transform.projection.name==="globe"&&O.push("GLOBE"),!this._fogVisible||P||x!==void 0&&!x||O.push("FOG","FOG_DITHERING"),P&&O.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&O.push("OVERDRAW_INSPECTOR"),O}getOrCreateProgram(u,x){this.cache=this.cache||{};const N=x&&x.defines||[],P=x&&x.config,O=this.currentGlobalDefines(u,x&&x.overrideFog,x&&x.overrideRtt).concat(N),F=vL.cacheKey(_M[u],u,O,P);return this.cache[F]||(this.cache[F]=new vL(this.context,u,_M[u],P,uS[u],O)),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 N=this.style.directionalLight,P=this.style.ambientLight;if(N&&P){const O=((F,U,G)=>{const J=F.properties.get("direction"),te=F.properties.get("color-use-theme")==="none",me=F.properties.get("color").toNonPremultipliedRenderColor(te?null:G.getLut(F.scope)).toArray01(),he=F.properties.get("intensity"),fe=U.properties.get("color-use-theme")==="none",ke=U.properties.get("color").toNonPremultipliedRenderColor(fe?null:G.getLut(U.scope)).toArray01(),be=U.properties.get("intensity"),Re=[J.x,J.y,J.z],Oe=i.dN(ke,be),Ge=i.dN(me,he);return{u_lighting_ambient_color:Oe,u_lighting_directional_dir:Re,u_lighting_directional_color:Ge,u_ground_radiance:B0(Re,Ge,Oe)}})(N,P,this.style);x.setLightsUniformValues(u,O)}}}uploadCommonUniforms(u,x,N,P,O){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),G=((J,te,me,he,fe,ke,be,Re,Oe,Ge,at,Ke)=>{const Nt=J.transform,xt=te.properties.get("color-use-theme")==="none",bt=te.properties.get("color").toNonPremultipliedRenderColor(xt?null:J.style.getLut(te.scope)).toArray01();bt[3]=he;const gt=J.frameCounter/1e3%1,[ht,At]=te.properties.get("vertical-range");return{u_fog_matrix:me?Nt.calculateFogTileMatrix(me):Ke||J.identityMat,u_fog_range:te.getFovAdjustedRange(Nt._fov),u_fog_color:bt,u_fog_horizon_blend:te.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(ht,At),At],u_fog_temporal_offset:gt,u_frustum_tl:fe,u_frustum_tr:ke,u_frustum_br:be,u_frustum_bl:Re,u_globe_pos:Oe,u_globe_radius:Ge,u_viewport:at,u_globe_transition:i.aj(Nt.zoom),u_is_globe:+(Nt.projection.name==="globe")}})(this,F,N,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,G)}O&&x.setCutoffUniformValues(u,O.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={},N=this.transform.coveringTiles({tileSize:512});for(const P of N)x[P.key]=u[P.key]||new tp(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]>=hr||x[1]>=hr}setupDepthForOcclusion(u,x,N){const P=this.context,O=P.gl,F=!!N;var U;N||(N={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(O.TEXTURE3),u&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(O.NEAREST,O.CLAMP_TO_EDGE),N.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],N.u_depth_range_unpack=[2/((U=this.depthRangeFor3D)[1]-U[0]),-1-2*U[0]/(U[1]-U[0])],N.u_occluder_half_size=.5*this.occlusionParams.occluderSize,N.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(O.NEAREST,O.CLAMP_TO_EDGE),P.activeTexture.set(O.TEXTURE0),F||x.setTerrainUniformValues(P,N)}updateEmissiveMode(){if(this._forceEmissiveMode)return;const u=this.style.hasDataDrivenEmissiveStrength();this.emissiveMode=u?this.context.extBlendFuncExtended?"dual-source-blending":"mrt-fallback":"constant"}}function TS(j,u){let x=!1,N=null;const P=()=>{N=null,x&&(j(),N=setTimeout(P,u),x=!1)};return()=>(x=!0,N||P(),N)}class YM{constructor(u){this._hashName=u&&encodeURIComponent(u),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=TS(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=rl(u);if(this._hashName){const N=this._hashName;let P=!1;const O=location.hash.slice(1).split("&").map(F=>{const U=F.split("=")[0];return U===N?(P=!0,`${U}=${x}`):F}).filter(F=>F);return P||O.push(`${N}=${x}`),`#${O.join("&")}`}return`#${x}`}_getCurrentHash(){const u=location.hash.replace("#","");if(this._hashName){let x;return u.split("&").map(N=>N.split("=")).forEach(N=>{N[0]===this._hashName&&(x=N)}),(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(N=>isNaN(Number(N)))){const N=u.dragRotate.isEnabled()&&u.touchZoomRotate.isEnabled()?+(x[3]||0):u.getBearing();return u.jumpTo({center:[+x[2],+x[1]],zoom:+x[0],bearing:N,pitch:+(x[4]||0)}),!0}return!1}_updateHashUnthrottled(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function rl(j,u){const x=j.getCenter(),N=Math.round(100*j.getZoom())/100,P=Math.ceil((N*Math.LN2+Math.log(512/360/.5))/Math.LN10),O=Math.pow(10,P),F=Math.round(x.lng*O)/O,U=Math.round(x.lat*O)/O,G=j.getBearing(),J=j.getPitch();let te=u?`/${F}/${U}/${N}`:`${N}/${U}/${F}`;return(G||J)&&(te+="/"+Math.round(10*G)/10),J&&(te+=`/${Math.round(J)}`),te}const G0={linearity:.3,easing:i.eT(0,0,.3,1)},XM=Object.assign({deceleration:2500,maxSpeed:1400},G0),QM=Object.assign({deceleration:20,maxSpeed:1400},G0),ey=Object.assign({deceleration:1e3,maxSpeed:360},G0),JM=Object.assign({deceleration:1e3,maxSpeed:90},G0);class eT{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:O}of this._inertiaBuffer)x.zoom+=O.zoomDelta||0,x.bearing+=O.bearingDelta||0,x.pitch+=O.pitchDelta||0,O.panDelta&&x.pan._add(O.panDelta),O.around&&(x.around=O.around),O.pinchAround&&(x.pinchAround=O.pinchAround);const N=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,P={};if(x.pan.mag()){const O=of(x.pan.mag(),N,Object.assign({},XM,u||{}));P.offset=x.pan.mult(O.amount/x.pan.mag()),P.center=this._map.transform.center,K0(P,O)}if(x.zoom){const O=of(x.zoom,N,QM);P.zoom=this._map.transform.zoom+O.amount,K0(P,O)}if(x.bearing){const O=of(x.bearing,N,ey);P.bearing=this._map.transform.bearing+i.aA(O.amount,-179,179),K0(P,O)}if(x.pitch){const O=of(x.pitch,N,JM);P.pitch=this._map.transform.pitch+O.amount,K0(P,O)}if(P.zoom||P.bearing){const O=x.pinchAround===void 0?x.around:x.pinchAround;P.around=O?this._map.unproject(O):this._map.getCenter()}return this.clear(),P.noMoveStart=!0,P}}function K0(j,u){(!j.duration||j.durationx.unproject(G)),U=O.reduce((G,J,te,me)=>G.add(J.div(me.length)),new i.P(0,0));super(u,{points:O,point:U,lngLats:F,lngLat:x.unproject(U),originalEvent:N}),this._defaultPrevented=!1}}class tT extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(u,x){super("wheel",{originalEvent:x}),this._defaultPrevented=!1}}class AS{constructor(u,x){this._map=u,this._clickTolerance=x.clickTolerance}reset(){this._mousedownPos=void 0}wheel(u){return this._firePreventable(new tT(this._map,u))}mousedown(u,x){return this._mousedownPos=x,this._firePreventable(new su(u.type,this._map,u))}mouseup(u){this._map.fire(new su(u.type,this._map,u))}preclick(u){const x=new MouseEvent("preclick",u);this._map.fire(new su(x.type,this._map,x))}click(u,x){this._mousedownPos&&this._mousedownPos.dist(x)>=this._clickTolerance||(this.preclick(u),this._map.fire(new su(u.type,this._map,u)))}dblclick(u){return this._firePreventable(new su(u.type,this._map,u))}mouseover(u){this._map.fire(new su(u.type,this._map,u))}mouseout(u){this._map.fire(new su(u.type,this._map,u))}touchstart(u){return this._firePreventable(new Dg(u.type,this._map,u))}touchmove(u){this._map.fire(new Dg(u.type,this._map,u))}touchend(u){this._map.fire(new Dg(u.type,this._map,u))}touchcancel(u){this._map.fire(new Dg(u.type,this._map,u))}_firePreventable(u){if(this._map.fire(u),u.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class rT{constructor(u){this._map=u}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(u){this._map.fire(new su(u.type,this._map,u))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new su("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(u){this._delayContextMenu?this._contextMenuEvent=u:this._map.fire(new su(u.type,this._map,u)),this._map.listens("contextmenu")&&u.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ES{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&&(R(),this._startPos=this._lastPos=x,this._active=!0)}mousemoveWindow(u,x){if(!this._active)return;const N=x,P=this._startPos,O=this._lastPos;if(!P||!O||O.equals(N)||!this._box&&N.dist(P){this._box&&(this._box.style.transform=`translate(${F}px,${G}px)`,this._box.style.width=U-F+"px",this._box.style.height=J-G+"px")})}mouseupWindow(u,x){if(!this._active)return;const N=this._startPos,P=x;if(N&&u.button===0){if(this.reset(),$(),N.x!==P.x||N.y!==P.y)return this._map.fire(new i.z("boxzoomend",{originalEvent:u})),{cameraAnimation:O=>O.fitScreenCoordinates(N,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),D(),delete this._startPos,delete this._lastPos}_fireEvent(u,x){return this._map.fire(new i.z(u,{originalEvent:x}))}}function IS(j,u){const x={};for(let N=0;Nthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=u.timeStamp),N.length===this.numTouches&&(this.centroid=function(P){const O=new i.P(0,0);for(const F of P)O._add(F);return O.div(P.length)}(x),this.touches=IS(N,x)))}touchmove(u,x,N){if(this.aborted||!this.centroid)return;const P=IS(N,x);for(const O in this.touches){const F=P[O];(!F||F.dist(this.touches[O])>30)&&(this.aborted=!0)}}touchend(u,x,N){if((!this.centroid||u.timeStamp-this.startTime>500)&&(this.aborted=!0),N.length===0){const P=!this.aborted&&this.centroid;if(this.reset(),P)return P}}}class PS{constructor(u){this.singleTap=new GL(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,N){this.singleTap.touchstart(u,x,N)}touchmove(u,x,N){this.singleTap.touchmove(u,x,N)}touchend(u,x,N){const P=this.singleTap.touchend(u,x,N);if(P){const O=u.timeStamp-this.lastTime<500,F=!this.lastTap||this.lastTap.dist(P)<30;if(O&&F||this.reset(),this.count++,this.lastTime=u.timeStamp,this.lastTap=P,this.count===this.numTaps)return this.reset(),P}}}class KL{constructor(){this._zoomIn=new PS({numTouches:1,numTaps:2}),this._zoomOut=new PS({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(u,x,N){this._zoomIn.touchstart(u,x,N),this._zoomOut.touchstart(u,x,N)}touchmove(u,x,N){this._zoomIn.touchmove(u,x,N),this._zoomOut.touchmove(u,x,N)}touchend(u,x,N){const P=this._zoomIn.touchend(u,x,N),O=this._zoomOut.touchend(u,x,N);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})}):O?(this._active=!0,u.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:F=>F.easeTo({duration:300,zoom:F.getZoom()-1,around:F.unproject(O)},{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 ZL={0:1,2:2},sT={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class LS{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 N=K(u);this._correctButton(u,N)&&(this._lastPoint=x,this._eventButton=N)}mousemoveWindow(u,x){const N=this._lastPoint;if(N){if(u.preventDefault(),this._eventButton!=null&&function(P,O){const F=ZL[O];return P.buttons===void 0||(P.buttons&F)!==F}(u,this._eventButton))this.reset();else if(this._moved||!(x.dist(N)0&&(this._active=!0);const P=IS(N,x),O=new i.P(0,0),F=new i.P(0,0);let U=0;for(const J in P){const te=P[J],me=this._touches[J];me&&(O._add(te),F._add(te.sub(me)),U++,P[J]=te)}if(this._touches=P,U{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class DS{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(u){}_move(u,x,N){return{}}touchstart(u,x,N){this._firstTwoTouches||N.length<2||(this._firstTwoTouches=[N[0].identifier,N[1].identifier],this._start([x[0],x[1]]))}touchmove(u,x,N){const P=this._firstTwoTouches;if(!P)return;u.preventDefault();const[O,F]=P,U=$_(N,x,O),G=$_(N,x,F);if(!U||!G)return;const J=this._aroundCenter?null:U.add(G).div(2);return this._move([U,G],J,u)}touchend(u,x,N){if(!this._firstTwoTouches)return;const[P,O]=this._firstTwoTouches,F=$_(N,x,P),U=$_(N,x,O);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 $_(j,u,x){for(let N=0;NMath.abs(j.x)}class Gle extends DS{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,OS(u[0].sub(u[1]))&&(this._valid=!1)}_move(u,x,N){const P=this._lastPoints;if(!P)return;const O=u[0].sub(P[0]),F=u[1].sub(P[1]);return this._map._cooperativeGestures&&!i.eU()&&N.touches.length<3||(this._valid=this.gestureBeginsVertically(O,F,N.timeStamp),!this._valid)?void 0:(this._lastPoints=u,this._active=!0,{pitchDelta:(O.y+F.y)/2*-.5})}gestureBeginsVertically(u,x,N){if(this._valid!==void 0)return this._valid;const P=u.mag()>=2,O=x.mag()>=2;if(!P&&!O)return;if(!P||!O)return this._firstMove==null&&(this._firstMove=N),N-this._firstMove<100&&void 0;const F=u.y>0==x.y>0;return OS(u)&&OS(x)&&F}}const Kle={panStep:100,bearingStep:15,pitchStep:10};class Zle{constructor(){const u=Kle;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,N=0,P=0,O=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?N=-1:(u.preventDefault(),O=-1);break;case 39:u.shiftKey?N=1:(u.preventDefault(),O=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&&(N=0,P=0),{cameraAnimation:U=>{const G=U.getZoom();U.easeTo({duration:300,easeId:"keyboardHandler",easing:U_,zoom:x?Math.round(G)+x*(u.shiftKey?2:1):G,bearing:U.getBearing()+N*this._bearingStep,pitch:U.getPitch()+P*this._pitchStep,offset:[-O*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 U_(j){return j*(2-j)}const iT=4.000244140625,oT=1/450;class RS{constructor(u,x){this._map=u,this._el=u.getCanvasContainer(),this._handler=x,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=oT,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 N=i.o.now(),P=N-(this._lastWheelEventTime||0);this._lastWheelEventTime=N,x!==0&&x%iT==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=q(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 J=this._type==="wheel"&&Math.abs(this._delta)>iT?this._wheelZoomRate:this._defaultZoomRate;let te=2/(1+Math.exp(-Math.abs(this._delta*J)));this._delta<0&&te!==0&&(te=1/te);const me=x(),he=Math.pow(2,me),fe=typeof this._targetZoom=="number"?u.zoomScale(this._targetZoom):he;this._targetZoom=Math.min(u.maxZoom,Math.max(u.minZoom,u.scaleZoom(fe*te))),this._type==="wheel"&&(this._startZoom=me,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const N=typeof this._targetZoom=="number"?this._targetZoom:x(),P=this._startZoom,O=this._easing;let F,U=!1;if(this._type==="wheel"&&P&&O){const J=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),te=O(J);F=i.ak(P,N,te),J<1?this._frameId||(this._frameId=!0):U=!0}else F=N,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 G=F-x();return G*this._lastDelta<0&&(G=0),{noInertia:!0,needsRenderFrame:!U,zoomDelta:G,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(u){let x=i.eV;if(this._prevEase){const N=this._prevEase,P=(i.o.now()-N.start)/N.duration,O=N.easing(P+.01)-N.easing(P),F=.27/Math.sqrt(O*O+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 hp{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 FS{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(u,x){return u.preventDefault(),{cameraAnimation:N=>{N.easeTo({duration:300,zoom:N.getZoom()+(u.shiftKey?-1:1),around:N.unproject(x)},{originalEvent:u})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sl{constructor(){this._tap=new PS({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,N){this._swipePoint||(this._tapTime&&u.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?N.length>0&&(this._swipePoint=x[0],this._swipeTouch=N[0].identifier):this._tap.touchstart(u,x,N))}touchmove(u,x,N){if(this._tapTime){if(this._swipePoint){if(N[0].identifier!==this._swipeTouch)return;const P=x[0],O=P.y-this._swipePoint.y;return this._swipePoint=P,u.preventDefault(),this._active=!0,{zoomDelta:O/128}}}else this._tap.touchmove(u,x,N)}touchend(u,x,N){this._tapTime?this._swipePoint&&N.length===0&&this.reset():this._tap.touchend(u,x,N)&&(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 lf{constructor(u,x,N){this._el=u,this._mousePan=x,this._touchPan=N}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 V_{constructor(u,x,N){this._pitchWithRotate=u.pitchWithRotate,this._mouseRotate=x,this._mousePitch=N}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 zS{constructor(u,x,N,P){this._el=u,this._touchZoom=x,this._touchRotate=N,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 q_=j=>j.zoom||j.drag||j.pitch||j.rotate;class Yle extends i.z{}class H_{constructor(){this.constants=[1,1,.01],this.radius=0}setup(u,x){const N=i.av([],x,u);this.radius=i.ag(N[2]<0?i.eX([],N,this.constants):[N[0],N[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 N=i.c5([],[0,0,1],i.bJ(x,[0,0,1])),P=i.c5([],i.aw([],[x[0],x[1],0]),this.radius),O=i.d8([],x,i.c5([],i.av([],i.d8([],P,N),x),2));x[0]=O[0],x[1]=O[1]}return x}}function BS(j){return j.panDelta&&j.panDelta.mag()||j.zoomDelta||j.bearingDelta||j.pitchDelta}class Xle{constructor(u,x){this._map=u,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new eT(u),this._bearingSnap=x.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new H_,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(x),i.aY(["handleEvent","handleWindowEvent"],this);const N=this._el;this._listeners=[[N,"touchstart",{passive:!0}],[N,"touchmove",{passive:!1}],[N,"touchend",void 0],[N,"touchcancel",void 0],[N,"mousedown",void 0],[N,"mousemove",void 0],[N,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[N,"mouseover",void 0],[N,"mouseout",void 0],[N,"dblclick",void 0],[N,"click",void 0],[N,"keydown",{capture:!1}],[N,"keyup",void 0],[N,"wheel",{passive:!1}],[N,"contextmenu",void 0],[window,"blur",void 0]];for(const[P,O,F]of this._listeners){const U=P===document?this.handleWindowEvent:this.handleEvent;P.addEventListener(O,U,F)}}destroy(){for(const[u,x,N]of this._listeners){const P=u===document?this.handleWindowEvent:this.handleEvent;u.removeEventListener(x,P,N)}}_addDefaultHandlers(u){const x=this._map,N=x.getCanvasContainer();this._add("mapEvent",new AS(x,u));const P=x.boxZoom=new ES(x,u);this._add("boxZoom",P);const O=new KL,F=new FS;x.doubleClickZoom=new hp(F,O),this._add("tapZoom",O),this._add("clickZoom",F);const U=new sl;this._add("tapDragZoom",U);const G=x.touchPitch=new Gle(x);this._add("touchPitch",G);const J=new nT(u),te=new aT(u);x.dragRotate=new V_(u,J,te),this._add("mouseRotate",J,["mousePitch"]),this._add("mousePitch",te,["mouseRotate"]);const me=new YL(u),he=new XL(x,u);x.dragPan=new lf(N,me,he),this._add("mousePan",me),this._add("touchPan",he,["touchZoom","touchRotate"]);const fe=new to,ke=new Wle;x.touchZoomRotate=new zS(N,ke,fe,U),this._add("touchRotate",fe,["touchPan","touchZoom"]),this._add("touchZoom",ke,["touchPan","touchRotate"]),this._add("blockableMapEvent",new rT(x));const be=x.scrollZoom=new RS(x,this);this._add("scrollZoom",be,["mousePan"]);const Re=x.keyboard=new Zle;this._add("keyboard",Re);for(const Oe of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])u.interactive&&u[Oe]&&x[Oe].enable(u[Oe])}_add(u,x,N){this._handlers.push({handlerName:u,handler:x,allowed:N}),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!!q_(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(u,x,N){for(const P in u)if(P!==N&&(!x||x.indexOf(P)<0))return!0;return!1}handleWindowEvent(u){this.handleEvent(u,`${u.type}Window`)}_getMapTouches(u){const x=[];for(const N of u)this._el.contains(N.target)&&x.push(N);return x}handleEvent(u,x){this._updatingCamera=!0;const N=u.type==="renderFrame",P=N?void 0:u,O={needsRenderFrame:!1},F={},U={},G=u.touches?this._getMapTouches(u.touches):void 0,J=G?W(this._el,G):N?void 0:q(this._el,u);for(const{handlerName:he,handler:fe,allowed:ke}of this._handlers){if(!fe.isEnabled())continue;let be;this._blockedByActive(U,ke,he)?fe.reset():fe[x||u.type]&&(be=fe[x||u.type](u,J,G),this.mergeHandlerResult(O,F,be,he,P),be&&be.needsRenderFrame&&this._triggerRenderFrame()),(be||fe.isActive())&&(U[he]=fe)}const te={};for(const he in this._previousActiveHandlers)U[he]||(te[he]=P);this._previousActiveHandlers=U,(Object.keys(te).length||BS(O))&&(this._changes.push([O,F,te]),this._triggerRenderFrame()),(Object.keys(U).length||BS(O))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:me}=O;me&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],me(this._map))}mergeHandlerResult(u,x,N,P,O){if(!N)return;Object.assign(u,N);const F={handlerName:P,originalEvent:N.originalEvent||O};N.zoomDelta!==void 0&&(x.zoom=F),N.panDelta!==void 0&&(x.drag=F),N.pitchDelta!==void 0&&(x.pitch=F),N.bearingDelta!==void 0&&(x.rotate=F)}_applyChanges(){const u={},x={},N={};for(const[P,O,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,O),Object.assign(N,F);this._updateMapTransform(u,x,N),this._changes=[]}_updateMapTransform(u,x,N){const P=this._map,O=P.transform,F=Ge=>[Ge.x,Ge.y,Ge.z];if((Ge=>{const at=this._eventsInProgress.drag;return at&&!this._handlersById[at.handlerName].isActive()})()&&!BS(u)){const Ge=O.zoom;O.cameraElevationReference="sea",this._originalZoom!=null&&O._orthographicProjectionAtLowPitch&&O.projection.name!=="globe"&&O.pitch===0?(O.cameraElevationReference="ground",O.zoom=this._originalZoom):(O.recenterOnTerrain(),O.cameraElevationReference="ground"),Ge!==O.zoom&&this._map._update(!0)}if(O._isCameraConstrained&&P._stop(!0),!BS(u))return void this._fireEvents(x,N,!0);let{panDelta:U,zoomDelta:G,bearingDelta:J,pitchDelta:te,around:me,aroundCoord:he,pinchAround:fe}=u;O._isCameraConstrained&&(G>0&&(G=0),O._isCameraConstrained=!1),fe!==void 0&&(me=fe),(G||(Ge=>x[Ge]&&!this._eventsInProgress[Ge])("drag"))&&me&&(this._dragOrigin=F(O.pointCoordinate3D(me)),this._originalZoom=O.zoom,this._trackingEllipsoid.setup(O._camera.position,this._dragOrigin)),O.cameraElevationReference="sea",P._stop(!0),me=me||P.transform.centerPoint,J&&(O.bearing+=J),te&&(O.pitch+=te),O._updateCameraState();const ke=[0,0,0];if(U)if(O.projection.name==="mercator"){const Ge=this._trackingEllipsoid.projectRay(O.screenPointToMercatorRay(me).dir),at=this._trackingEllipsoid.projectRay(O.screenPointToMercatorRay(me.sub(U)).dir);ke[0]=at[0]-Ge[0],ke[1]=at[1]-Ge[1]}else{const Ge=O.pointCoordinate(me);if(O.projection.name==="globe"){U=U.rotate(-O.angle);const at=O._pixelsPerMercatorPixel/O.worldSize;ke[0]=-U.x*i.eW(i.a$(Ge.y))*at,ke[1]=-U.y*i.eW(O.center.lat)*at}else{const at=O.pointCoordinate(me.sub(U));Ge&&at&&(ke[0]=at.x-Ge.x,ke[1]=at.y-Ge.y)}}const be=O.zoom,Re=[0,0,0];if(G){const Ge=F(he||O.pointCoordinate3D(me)),at={dir:i.aw([],i.av([],Ge,O._camera.position))};if(at.dir[2]<0){const Ke=O.zoomDeltaToMovement(Ge,G);i.c5(Re,at.dir,Ke)}}const Oe=i.d8(ke,ke,Re);O._translateCameraConstrained(Oe),G&&Math.abs(O.zoom-be)>1e-4&&O.recenterOnTerrain(),O.cameraElevationReference="ground",this._map._update(),u.noInertia||this._inertia.record(u),this._fireEvents(x,N,!0)}_fireEvents(u,x,N){const P=q_(this._eventsInProgress),O=q_(u),F={};for(const te in u){const{originalEvent:me}=u[te];this._eventsInProgress[te]||(F[`${te}start`]=me),this._eventsInProgress[te]=u[te]}!P&&O&&this._fireEvent("movestart",O.originalEvent);for(const te in F)this._fireEvent(te,F[te]);O&&this._fireEvent("move",O.originalEvent);for(const te in u){const{originalEvent:me}=u[te];this._fireEvent(te,me)}const U={};let G;for(const te in this._eventsInProgress){const{handlerName:me,originalEvent:he}=this._eventsInProgress[te];this._handlersById[me].isActive()||(delete this._eventsInProgress[te],G=x[me]||he,U[`${te}end`]=G)}for(const te in U)this._fireEvent(te,U[te]);const J=q_(this._eventsInProgress);if(N&&(P||O)&&!J){this._updatingCamera=!0;const te=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),me=he=>he!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Yle("renderFrame",{timeStamp:u})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const $S="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class lT 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,N){return u=i.P.convert(u).mult(-1),this.panTo(this.transform.center,Object.assign({offset:u},x),N)}panTo(u,x,N){return this.easeTo(Object.assign({center:u},x),N)}getZoom(){return this.transform.zoom}setZoom(u,x){return this.jumpTo({zoom:u},x),this}zoomTo(u,x,N){return this.easeTo(Object.assign({zoom:u},x),N)}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,N){return this.easeTo(Object.assign({bearing:u},x),N)}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?N/(2*Math.tan(.5*u.fovX)*u.aspect):P/(2*Math.tan(.5*u.fovY)*u.aspect)}_cameraForBoundsOnGlobe(u,x,N,P,O,F){const U=u.clone(),G=this._extendCameraOptions(F);U.bearing=P,U.pitch=O;const J=i.aT.convert(x),te=i.aT.convert(N),me=.5*(J.lat+te.lat),he=.5*(J.lng+te.lng),fe=i.eZ(me,he),ke=i.aw([],fe),be=i.aw([],i.bI([],ke,[0,1,0])),Re=i.bI([],be,ke),Oe=[be[0],be[1],be[2],0,Re[0],Re[1],Re[2],0,ke[0],ke[1],ke[2],0,0,0,0,1],Ge=[fe,i.eZ(J.lat,J.lng),i.eZ(te.lat,J.lng),i.eZ(te.lat,te.lng),i.eZ(J.lat,te.lng),i.eZ(me,J.lng),i.eZ(me,te.lng),i.eZ(J.lat,he),i.eZ(te.lat,he)];let at=i.d9.fromPoints(Ge.map(Xt=>[i.bJ(be,Xt),i.bJ(Re,Xt),i.bJ(ke,Xt)]));const Ke=i.af([],at.center,Oe);i.e_(Ke)===0&&i.e$(Ke,0,0,1),i.aw(Ke,Ke),i.c5(Ke,Ke,i.aD),U.center=i.f0(Ke);const Nt=U.getWorldToCameraMatrix(),xt=i.bl(new Float64Array(16),Nt);at=i.d9.applyTransform(at,i.aB([],Nt,Oe));const bt=this._extendAABB(at,U,G,P);if(!bt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");at=bt,i.af(Ke,Ke,Nt);const gt=.5*(at.max[2]-at.min[2]),ht=this._minimumAABBFrustumDistance(U,at),At=i.c5([],[0,0,1],gt),Bt=i.d8(At,Ke,At),zt=ht+(U.pitch===0?0:i.bG(Ke,Bt)),Jt=U.globeCenterInViewSpace,er=i.av([],Ke,[Jt[0],Jt[1],Jt[2]]);i.aw(er,er),i.c5(er,er,zt);const ur=i.d8([],Ke,er);i.af(ur,ur,xt);const Cr=i.eM/i.aD,Kt=i.ag(ur),Lt=i.cf(Math.max(Kt*Cr-i.eM,Number.EPSILON),0),nr=Math.min(U.zoomFromMercatorZAdjusted(Lt),G.maxZoom);return nr>.5*(i.c_+i.cL)?(U.setProjection({name:"mercator"}),U.zoom=nr,this._cameraForBounds(U,x,N,P,O,F)):{center:U.center,zoom:nr,bearing:P,pitch:O}}_extendAABB(u,x,N,P){const O=.5*((N.padding.left||0)+(N.padding.right||0)),F=.5*((N.padding.top||0)+(N.padding.bottom||0)),U=F,G=O,J=O,te=F,me=x.width-(G+J),he=x.height-(U+te),fe=i.av([],u.max,u.min),ke=Math.min(me/fe[0],he/fe[1]),be=Math.min(x.scaleZoom(x.scale*ke),N.maxZoom);if(isNaN(be))return null;const Re=x.scale/x.zoomScale(be),Oe=new i.d9([u.min[0]-G*Re,u.min[1]-te*Re,u.min[2]],[u.max[0]+J*Re,u.max[1]+U*Re,u.max[2]]),Ge=(typeof N.offset.x=="number"&&typeof N.offset.y=="number"?new i.P(N.offset.x,N.offset.y):i.P.convert(N.offset)).rotate(-i.an(P));return Oe.center[0]-=Ge.x*Re,Oe.center[1]+=Ge.y*Re,Oe}queryTerrainElevation(u,x){const N=this.transform.elevation;return N?(x=Object.assign({},{exaggerated:!0},x),N.getAtPoint(i.ae.fromLngLat(u),null,x.exaggerated)):null}_cameraForBounds(u,x,N,P,O,F){if(u.projection.name==="globe")return this._cameraForBoundsOnGlobe(u,x,N,P,O,F);const U=u.clone(),G=this._extendCameraOptions(F);U.bearing=P,U.pitch=O;const J=i.aT.convert(x),te=i.aT.convert(N),me=new i.aT(J.lng,te.lat),he=new i.aT(te.lng,J.lat),fe=U.project(J),ke=U.project(te),be=this.queryTerrainElevation(J),Re=this.queryTerrainElevation(te),Oe=this.queryTerrainElevation(me),Ge=this.queryTerrainElevation(he),at=[[fe.x,fe.y,Math.min(be||0,Re||0,Oe||0,Ge||0)],[ke.x,ke.y,Math.max(be||0,Re||0,Oe||0,Ge||0)]];let Ke=i.d9.fromPoints(at);const Nt=U.getWorldToCameraMatrix(),xt=i.bl(new Float64Array(16),Nt);Ke=i.d9.applyTransform(Ke,Nt);const bt=this._extendAABB(Ke,U,G,P);if(!bt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");Ke=bt;const gt=.5*i.av([],Ke.max,Ke.min)[2],ht=this._minimumAABBFrustumDistance(U,Ke),At=[0,0,1,0];i.aC(At,At,Nt),i.f1(At,At);const Bt=i.c5([],At,ht+gt),zt=i.d8([],Ke.center,Bt);i.af(Ke.center,Ke.center,xt),i.af(zt,zt,xt);const Jt=U.unproject(new i.P(Ke.center[0],Ke.center[1])),er=i.f2(U.projection,Jt),ur=Math.pow(2,er),Cr=Math.min(U._zoomFromMercatorZ(zt[2]*U.pixelsPerMeter*ur/U.worldSize),G.maxZoom);return U.mercatorFromTransition&&Cr<.5*(i.c_+i.cL)?(U.setProjection({name:"globe"}),U.zoom=Cr,this._cameraForBounds(U,x,N,P,O,F)):{center:Jt,zoom:Cr,bearing:P,pitch:O}}fitBounds(u,x,N){const P=this.cameraForBounds(u,x);return this._fitInternal(P,x,N)}fitScreenCoordinates(u,x,N,P,O){const F=i.P.convert(u),U=i.P.convert(x),G=new i.P(Math.min(F.x,U.x),Math.min(F.y,U.y)),J=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 te=this.transform.pointLocation3D(G),me=this.transform.pointLocation3D(J),he=this.transform.pointLocation3D(new i.P(G.x,J.y)),fe=this.transform.pointLocation3D(new i.P(J.x,G.y)),ke=[Math.min(te.lng,me.lng,he.lng,fe.lng),Math.min(te.lat,me.lat,he.lat,fe.lat)],be=[Math.max(te.lng,me.lng,he.lng,fe.lng),Math.max(te.lat,me.lat,he.lat,fe.lat)],Re=P&&P.pitch?P.pitch:this.getPitch(),Oe=this._cameraForBounds(this.transform,ke,be,N,Re,P);return this._fitInternal(Oe,P,O)}_fitInternal(u,x,N){return u?(x=Object.assign(u,x)).linear?this.easeTo(x,N):this.flyTo(x,N):this}jumpTo(u,x){this.stop();const N=u.preloadOnly?this.transform.clone():this.transform;let P=!1,O=!1,F=!1;"zoom"in u&&N.zoom!==+u.zoom&&(P=!0,N.zoom=+u.zoom),u.center!==void 0&&(N.center=i.aT.convert(u.center)),"bearing"in u&&N.bearing!==+u.bearing&&(O=!0,N.bearing=+u.bearing),"pitch"in u&&N.pitch!==+u.pitch&&(F=!0,N.pitch=+u.pitch);const U=typeof u.padding=="number"?this._extendPadding(u.padding):u.padding;if(u.padding!=null&&!N.isPaddingEqual(U))if(u.retainPadding===!1){const G=N.clone();G.padding=U,N.setLocationAtPoint(N.center,G.centerPoint)}else N.padding=U;return u.preloadOnly?(this._preloadTiles(N),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)),O&&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($S),this.transform.getFreeCameraOptions()}setFreeCameraOptions(u,x){const N=this.transform;if(!N.projection.supportsFreeCamera)return i.w($S),this;this.stop();const P=N.zoom,O=N.pitch,F=N.bearing;N.setFreeCameraOptions(u);const U=P!==N.zoom,G=O!==N.pitch,J=F!==N.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)),J&&this.fire(new i.z("rotatestart",x)).fire(new i.z("rotate",x)).fire(new i.z("rotateend",x)),G&&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 N=this.transform,P=this.getZoom(),O=this.getBearing(),F=this.getPitch(),U=this.getPadding(),G="zoom"in u?+u.zoom:P,J="bearing"in u?this._normalizeBearing(u.bearing,O):O,te="pitch"in u?+u.pitch:F,me=this._extendPadding(u.padding),he=i.P.convert(u.offset);let fe,ke,be;if(N.projection.name==="globe"){const At=i.ae.fromLngLat(N.center),Bt=he.rotate(-N.angle);At.x+=Bt.x/N.worldSize,At.y+=Bt.y/N.worldSize;const zt=At.toLngLat(),Jt=i.aT.convert(u.center||zt);this._normalizeCenter(Jt),fe=N.centerPoint.add(Bt),ke=new i.P(At.x,At.y).mult(N.worldSize),be=new i.P(i.aF(Jt.lng),i.aJ(Jt.lat)).mult(N.worldSize).sub(ke)}else{fe=N.centerPoint.add(he);const At=N.pointLocation(fe),Bt=i.aT.convert(u.center||At);this._normalizeCenter(Bt),ke=N.project(At),be=N.project(Bt).sub(ke)}const Re=N.zoomScale(G-P);let Oe,Ge;u.around&&(Oe=i.aT.convert(u.around),Ge=N.locationPoint(Oe));const at=this._zooming||G!==P,Ke=this._rotating||O!==J,Nt=this._pitching||te!==F,xt=!N.isPaddingEqual(me),bt=u.retainPadding===!1?N.clone():N,gt=At=>Bt=>{if(at&&(At.zoom=i.ak(P,G,Bt)),Ke&&(At.bearing=i.ak(O,J,Bt)),Nt&&(At.pitch=i.ak(F,te,Bt)),xt&&(bt.interpolatePadding(U,me,Bt),fe=bt.centerPoint.add(he)),Oe)At.setLocationAtPoint(Oe,Ge);else{const zt=At.zoomScale(At.zoom-P),Jt=G>P?Math.min(2,Re):Math.max(.5,Re),er=Math.pow(Jt,1-Bt),ur=At.unproject(ke.add(be.mult(Bt*er)).mult(zt));At.setLocationAtPoint(At.renderWorldCopies?ur.wrap():ur,fe)}return u.preloadOnly||this._fireMoveEvents(x),At};if(u.preloadOnly){const At=this._emulate(gt,u.duration,N);return this._preloadTiles(At),this}const ht={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=at,this._rotating=Ke,this._pitching=Nt,this._padding=xt,this._easeId=u.easeId,this._prepareEase(x,u.noMoveStart,ht),this._ease(gt(N),At=>{N.cameraElevationReference==="sea"&&N.recenterOnTerrain(),this._afterEase(x,At)},u),this}_prepareEase(u,x,N={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&this.transform.pitch===0&&this.transform.projection.name!=="globe"&&(this.transform.cameraElevationReference="ground"),x||N.moving||this.fire(new i.z("movestart",u)),this._zooming&&!N.zooming&&this.fire(new i.z("zoomstart",u)),this._rotating&&!N.rotating&&this.fire(new i.z("rotatestart",u)),this._pitching&&!N.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 N=this._zooming,P=this._rotating,O=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,N&&this.fire(new i.z("zoomend",u)),P&&this.fire(new i.z("rotateend",u)),O&&this.fire(new i.z("pitchend",u)),this.fire(new i.z("moveend",u))}flyTo(u,x){if(this._prefersReducedMotion(u)){const Xt=i.aH(u,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(Xt,x)}this.stop(),u=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:i.eV},u);const N=this.transform,P=this.getZoom(),O=this.getBearing(),F=this.getPitch(),U=this.getPadding(),G="zoom"in u?i.aA(+u.zoom,N.minZoom,N.maxZoom):P,J="bearing"in u?this._normalizeBearing(u.bearing,O):O,te="pitch"in u?+u.pitch:F,me=this._extendPadding(u.padding),he=N.zoomScale(G-P),fe=i.P.convert(u.offset);let ke=N.centerPoint.add(fe);const be=N.pointLocation(ke),Re=i.aT.convert(u.center||be);this._normalizeCenter(Re);const Oe=N.project(be),Ge=N.project(Re).sub(Oe);let at=u.curve;const Ke=Math.max(N.width,N.height),Nt=Ke/he,xt=Ge.mag();if("minZoom"in u){const Xt=i.aA(Math.min(u.minZoom,P,G),N.minZoom,N.maxZoom),gr=Ke/N.zoomScale(Xt-P);at=Math.sqrt(gr/xt*2)}const bt=at*at;function gt(Xt){const gr=(Nt*Nt-Ke*Ke+(Xt?-1:1)*bt*bt*xt*xt)/(2*(Xt?Nt:Ke)*bt*xt);return Math.log(Math.sqrt(gr*gr+1)-gr)}function ht(Xt){return(Math.exp(Xt)-Math.exp(-Xt))/2}function At(Xt){return(Math.exp(Xt)+Math.exp(-Xt))/2}const Bt=gt(0);let zt=function(Xt){return At(Bt)/At(Bt+at*Xt)},Jt=function(Xt){return Ke*((At(Bt)*(ht(gr=Bt+at*Xt)/At(gr))-ht(Bt))/bt)/xt;var gr},er=(gt(1)-Bt)/at;if(Math.abs(xt)<1e-6||!isFinite(er)){if(Math.abs(Ke-Nt)<1e-6)return this.easeTo(u,x);const Xt=Ntu.maxDuration&&(u.duration=0);const ur=O!==J,Cr=te!==F,Kt=!N.isPaddingEqual(me),Lt=u.retainPadding===!1?N.clone():N,nr=Xt=>gr=>{const qr=gr*er,rs=1/zt(qr);Xt.zoom=gr===1?G:P+Xt.scaleZoom(rs),ur&&(Xt.bearing=i.ak(O,J,gr)),Cr&&(Xt.pitch=i.ak(F,te,gr)),Kt&&(Lt.interpolatePadding(U,me,gr),ke=Lt.centerPoint.add(fe));const Or=gr===1?Re:Xt.unproject(Oe.add(Ge.mult(Jt(qr))).mult(rs));return Xt.setLocationAtPoint(Xt.renderWorldCopies?Or.wrap():Or,ke),Xt._updateCameraOnTerrain(),u.preloadOnly||this._fireMoveEvents(x),Xt};if(u.preloadOnly){const Xt=this._emulate(nr,u.duration,N);return this._preloadTiles(Xt),this}return this._zooming=!0,this._rotating=ur,this._pitching=Cr,this._padding=Kt,this._prepareEase(x,!1),this._ease(nr(N),()=>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 N=this._onEaseEnd;this._onEaseEnd=void 0,N.call(this,x)}if(!u){const N=this.handlers;N&&N.stop(!1)}return this}_ease(u,x,N){N.animate===!1||N.duration===0?(u(1),x()):(this._easeStart=i.o.now(),this._easeOptions=N,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 N=Math.abs(u-x);return Math.abs(u-360-x)180?-360:N<-180?360:0}_prefersReducedMotion(u){return this._respectPrefersReducedMotion&&i.o.prefersReducedMotion&&!(u&&u.essential)}_emulate(u,x,N){const P=Math.ceil(15*x/1e3),O=[],F=u(N.clone());for(let U=0;U<=P;U++){const G=F(U/P);O.push(G.clone())}return O}_preloadTiles(u,x){}}class W_{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,N=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",N);const P=w("span","mapboxgl-ctrl-icon",this._compactButton);return P.setAttribute("aria-hidden","true"),P.setAttribute("title",N),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 N=x.reduce((P,O,F)=>(O.value&&(P+=`${O.key}=${O.value}${FP.length-O.length),u=u.filter((P,O)=>{for(let F=O+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 N=u.map(P=>function(O){const F=new DOMParser().parseFromString(O,"text/html");return Array.from(F.body.querySelectorAll("*")).forEach(U=>{const G=U.textContent||"";if(U.tagName!=="A")return void U.replaceWith(F.createTextNode(G));const J=U.getAttribute("href");if(!J||!/^(https?:|mailto:)/i.test(J))return void U.replaceWith(F.createTextNode(G));const te=F.createElement("a");te.href=J,te.textContent=G,te.rel="noopener nofollow";const me=U.getAttribute("class");me&&(te.className=me),U.replaceWith(te)}),F.body.innerHTML}(P)).join(" | ");N!==this._attribHTML&&(this._attribHTML=N,u.length?(this._innerContainer.innerHTML=N,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 G_{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 N=u[x].getSource();if(N.hasOwnProperty("mapbox_logo")&&!N.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 Z0{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 N=w("button",u,this._container);return N.type="button",N.addEventListener("click",x),N}_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(N=>N.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 N=0;N{this._map._selectIndoorFloor(P.id)});this._setButtonTitle(O,P.zIndex.toString()),this._model&&P.id===this._model.selectedFloorId&&x&&O.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(O),N=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,N){this._start=this.getValue(x),this._end=u,this._startTime=x,this._endTime=x+N}}const pp={"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 Og extends i.z{constructor(u,x,N,P){const{point:O,lngLat:F,originalEvent:U,target:G}=u;super(u.type,{point:O,lngLat:F,originalEvent:U,target:G}),this.preventDefault=()=>{u.preventDefault()},this.id=x,this.interaction=N,this.feature=P}}class gm{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 N=x.filter;let P=x.type;N&&this.filters.set(u,i.b6(N)),P==="mouseover"&&(P="mouseenter"),P==="mouseout"&&(P="mouseleave");const O=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)):O.size===0&&this.map.on(P,this.handleType),O.size===0&&this.interactionsByType.set(P,O),O.set(u,x),this.typeById.set(u,P)}get(u){const x=this.typeById.get(u);if(!x)return;const N=this.interactionsByType.get(x);return N?N.get(u):void 0}remove(u){const x=this.typeById.get(u);if(!x)return;this.typeById.delete(u),this.filters.delete(u);const N=this.interactionsByType.get(x);N&&(N.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))):N.size===0&&this.map.off(x,this.handleType))}queryTargets(u,x){const N=[];for(const[P,O]of x)O.target&&N.push({targetId:P,target:O.target,filter:this.filters.get(P)});return this.map.style.queryRenderedTargets(u,N,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 N=new Map;for(const[P,{feature:O}]of this.prevHoveredFeatures)this.hoveredFeatures.has(P)||N.set(O.id,O);N.size&&(u.type="mouseleave",this.handleType(u,Array.from(N.values())))}handleOut(u){const x=Array.from(this.hoveredFeatures.values()).map(({feature:N})=>N);x.length&&(u.type="mouseleave",this.handleType(u,x)),this.hoveredFeatures.clear()}handleType(u,x){const N=u.type==="mouseenter";if(N&&!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(),O=!!x;x=x||this.queryTargets(u.point,P);let F=!1;const U=new Set;for(const G of x){for(const[J,te]of P){if(!te.target)continue;const me=G.variants?G.variants[J]:null;if(me){for(const he of me){if(_g(he,G,U,J))continue;const fe=new i.dx(G,he),ke=ep(he,G,J);O&&fe.id!==void 0&&(fe.state=this.map.getFeatureState(fe));const be=N?this.prevHoveredFeatures.get(ke):null,Re=new Og(u,J,te,fe),Oe=be?be.stop:te.handler(Re);if(N&&this.hoveredFeatures.set(ke,{feature:G,stop:Oe}),Oe!==!1){F=!0;break}}if(F)break}}if(F)break}if(!F)for(const[G,J]of P){const{handler:te,target:me}=J;if(!me&&te(new Og(u,G,J,null))!==!1)break}}}function Qle(j,u){if(Array.isArray(j)&&Array.isArray(u)){const x=new Set(j),N=new Set(u);return x.size===N.size&&j.every(P=>N.has(P))}return i.by(j,u)}const Jle={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"},ece={showCompass:!0,showZoom:!0,visualizePitch:!1};class tce{constructor(u,x,N=!1){this._clickTolerance=10,this.element=x,this.mouseRotate=new nT({clickTolerance:u.dragRotate._mouseRotate._clickTolerance}),this.map=u,N&&(this.mousePitch=new aT({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),R()}move(u,x){const N=this.map,P=this.mouseRotate.mousemoveWindow(u,x),O=P&&P.bearingDelta;if(O&&N.setBearing(N.getBearing()+O),this.mousePitch){const F=this.mousePitch.mousemoveWindow(u,x),U=F&&F.pitchDelta;U&&N.setPitch(N.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(){D(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(u){this.down(Object.assign({},u,{ctrlKey:!0,preventDefault:()=>u.preventDefault()}),q(this.element,u)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(u){this.move(u,q(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(N).distSqr(u)180;){const N=x.locationPoint3D(j);if(N.x>=0&&N.y>=0&&N.x<=x.width&&N.y<=x.height)break;j.lng>x.center.lng?j.lng-=360:j.lng+=360}return j}const Kc={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%)"},Ih={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class US 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:N="center",color:P="#3FB1CE",scale:O=1,draggable:F=!1,clickTolerance:U=0,rotation:G=Ih.rotation,rotationAlignment:J=Ih.rotationAlignment,pitchAlignment:te=Ih.pitchAlignment,occludedOpacity:me=Ih.occludedOpacity,altitude:he=Ih.altitude}=u||{};this._anchor=N,this._color=P,this._scale=O,this._draggable=F,this._clickTolerance=U,this._rotation=G,this._rotationAlignment=J,this._pitchAlignment=te,this._occludedOpacity=me,this._altitude=he,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",be=>{be.preventDefault()}),this._element.addEventListener("mousedown",be=>{be.preventDefault()});const fe=this._element.classList;for(const be in Kc)fe.remove(`mapboxgl-marker-anchor-${be}`);fe.add(`mapboxgl-marker-anchor-${this._anchor}`);const ke=u&&u.className?u.className.trim().split(/\s+/):[];fe.add(...ke),this._popup=null}_createDefaultMarker(){const u=w("div"),x=S("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},u);if(this._altitude===0){const N=S("radialGradient",{id:"shadowGradient"},S("defs",{},x));S("stop",{offset:"10%","stop-opacity":.4},N),S("stop",{offset:"100%","stop-opacity":.05},N),S("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},x)}return S("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),S("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),S("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||Ih.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,N=u.charCode||u.keyCode;x!=="Space"&&x!=="Enter"&&N!==32&&N!==13||this.togglePopup()}_onMapClick(u){const x=u.originalEvent.target,N=this._element;this._popup&&(x===N||N.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 N=u.unproject(x,this._altitude),P=u.getFreeCameraOptions();if(!P.position)return!1;const O=P.position.toLngLat();return O.distanceTo(N)<.9*O.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 N=u.unproject(x,this._altitude);let P;u._showingGlobe()&&i.f5(u.transform,this._lngLat)?P=0:(P=1-u._queryFogOpacity(N),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) ${Kc[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${x.x}px,${x.y}px) `}_calculateXYTransform(){const u=this._pos,x=this._map,N=this.getPitchAlignment();if(!x||!u||N!=="map")return"";if(!x._showingGlobe()){const G=x.getPitch();return G?`rotateX(${G}deg)`:""}const P=i.cX(i.f6(x.transform,this._lngLat)),O=u.sub(i.f7(x.transform)),F=Math.abs(O.x)+Math.abs(O.y);if(F===0)return"";const U=P/F;return`rotateX(${-O.y*U}deg) rotateY(${O.x*U}deg)`}_calculateZTransform(){const u=this._pos,x=this._map;if(!x||!u)return"";let N=0;const P=this.getRotationAlignment();if(P==="map")if(x._showingGlobe()){const O=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(O);N=i.cX(Math.atan2(F.y,F.x))-90}else N=-x.getBearing();else if(P==="horizon"){const O=i.ah(4,6,x.getZoom()),F=i.f7(x.transform);F.y+=O*x.transform.height;const U=u.sub(F),G=i.cX(Math.atan2(U.y,U.x));N=(G>90?G-270:G+90)*(1-O)}return N+=this._rotation,N?`rotateZ(${N}deg)`:""}_update(u){cancelAnimationFrame(this._updateFrameId);const x=this._map;x&&(x.transform.renderWorldCopies&&(this._lngLat=cT(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 N=this._pointerdownPos,P=this._positionDelta;if(N&&P){if(!this._isDragging){const O=this._clickTolerance||x._clickTolerance;if(u.point.dist(N)j.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(j.minPitch!=null&&j.maxPitch!=null&&j.minPitch>j.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(j.minPitch!=null&&j.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(j.maxPitch!=null&&j.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(j.antialias&&i.f3(window)&&(j.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 mM(j.minZoom,j.maxZoom,j.minPitch,j.maxPitch,j.renderWorldCopies,null,null),j),this._repaint=!!j.repaint,this._interactive=j.interactive,this._minTileCacheSize=j.minTileCacheSize,this._maxTileCacheSize=j.maxTileCacheSize,this._failIfMajorPerformanceCaveat=j.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=j.preserveDrawingBuffer,this._antialias=j.antialias,this._trackResize=j.trackResize,this._bearingSnap=j.bearingSnap,this._refreshExpiredTiles=j.refreshExpiredTiles,this._fadeDuration=j.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=j.crossSourceCollisions,this._collectResourceTiming=j.collectResourceTiming,this._language=this._parseLanguage(j.language),this._worldview=j.worldview,this._renderTaskQueue=new mp,this._domRenderTaskQueue=new mp,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},pp,j.locale),this._clickTolerance=j.clickTolerance,this._cooperativeGestures=j.cooperativeGestures,this._performanceMetricsCollection=j.performanceMetricsCollection,this._tessellationStep=j.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=j.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new fp(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=j.scaleFactor,this._requestManager=new se(j.transformRequest,j.accessToken,j.testMode),this._silenceAuthErrors=!!j.testMode,this._contextCreateOptions=j.contextCreateOptions?Object.assign({},j.contextCreateOptions):{},typeof j.container=="string"){const x=document.getElementById(j.container);if(!x)throw new Error(`Container '${j.container.toString()}' not found.`);this._container=x}else{if(!(j.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=j.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."),j.maxBounds&&this.setMaxBounds(j.maxBounds),this._spriteFormat=j.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 Xle(this,j),this._localFontFamily=j.localFontFamily,this._localIdeographFontFamily=j.localIdeographFontFamily,(j.style||!j.testMode)&&this.setStyle(j.style||i.e.DEFAULT_STYLE,{config:j.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),j.projection&&this.setProjection(j.projection),j.hash&&(this._hash=new YM(typeof j.hash=="string"&&j.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){u.center==null&&u.zoom==null||(this.transform._unmodified=!1),this.jumpTo({center:j.center,zoom:j.zoom,bearing:j.bearing,pitch:j.pitch});const x=j.bounds;x&&(this.resize(),this.fitBounds(x,Object.assign({},j.fitBoundsOptions,{duration:0})))}this.resize(),j.attributionControl&&this.addControl(new W_({customAttribution:j.customAttribution})),this._logoControl=new G_,this.addControl(this._logoControl,j.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",x=>{this._update(x.dataType==="style"),this.fire(new i.z(`${x.dataType}data`,x))}),this.on("dataloading",x=>{this.fire(new i.z(`${x.dataType}dataloading`,x))}),this._interactions=new gm(this)}_getMapId(){return this._mapId}addControl(j,u){if(u===void 0&&(u=j.getDefaultPosition?j.getDefaultPosition():"top-right"),!j||!j.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=j.onAdd(this);this._controls.push(j);const N=this._controlPositions[u];return u.indexOf("bottom")!==-1?N.insertBefore(x,N.firstChild):N.appendChild(x),this}removeControl(j){if(!j||!j.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(j);return u>-1&&this._controls.splice(u,1),j.onRemove(this),this}hasControl(j){return this._controls.indexOf(j)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(j){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",j)).fire(new i.z("move",j)),this.fire(new i.z("resize",j)),u&&this.fire(new i.z("moveend",j)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(j){return this.transform.setMaxBounds(i.aI.convert(j)),this._update()}setMinZoom(j){if((j=j??-2)>=-2&&j<=this.transform.maxZoom)return this.transform.minZoom=j,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=j,this._update(),this.getZoom()>j?this.setZoom(j):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(j){if((j=j??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(j>=0&&j<=this.transform.maxPitch)return this.transform.minPitch=j,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(j>=this.transform.minPitch)return this.transform.maxPitch=j,this._update(),this.getPitch()>j?this.setPitch(j):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(j){return this._scaleFactor=j,this.painter.scaleFactor=j,this._scaleFactorChanged=!0,this.style._updateFilteredLayers(u=>u.type==="symbol"),this._update(!0),this}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(j){return this.transform.renderWorldCopies=j,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(j){return j==="auto"?navigator.language:Array.isArray(j)?j.length===0?void 0:j.map(u=>u==="auto"?navigator.language:u):j}setLanguage(j){const u=this._parseLanguage(j);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(j){return this.style&&j!==this._worldview?(this._worldview=j,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(j){return this._lazyInitEmptyStyle(),j?typeof j=="string"&&(j={name:j}):j=null,this._useExplicitProjection=!!j,this._prioritizeAndUpdateProjection(j,this.style.projection)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const j=this.transform,u=j.projection.name;let x;u==="globe"&&j.zoom>=i.cL?(j.setMercatorFromTransition(),x=!0):u==="mercator"&&j.zoom=i.cL?this.transform.setMercatorFromTransition():this.transform.setProjection(j),this.style.applyProjectionUpdate();const N=this.transform.getProjection().name==="mercator"&&x!==this.transform.mercatorFromTransition;return(u||N)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(j,u){return this.transform.locationPoint3D(i.aT.convert(j),u)}unproject(j,u){return this.transform.pointLocation3D(i.P.convert(j),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(j,u,x){const N=P=>{let O=[];if(Array.isArray(u)){const F=u.filter(U=>this.getLayer(U));O=F.length?this.queryRenderedFeatures(P,{layers:F}):[]}else O=this.queryRenderedFeatures(P,{target:u});return O};if(j==="mouseenter"||j==="mouseover"){let P=!1;return{listener:x,targets:u,delegates:{mousemove:F=>{const U=N(F.point);U.length?P||(P=!0,x.call(this,new su(j,this,F.originalEvent,{features:U}))):P=!1},mouseout:()=>{P=!1}}}}if(j==="mouseleave"||j==="mouseout"){let P=!1;return{listener:x,targets:u,delegates:{mousemove:U=>{N(U.point).length?P=!0:P&&(P=!1,x.call(this,new su(j,this,U.originalEvent)))},mouseout:U=>{P&&(P=!1,x.call(this,new su(j,this,U.originalEvent)))}}}}{const P=O=>{const F=N(O.point);F.length&&(O.features=F,x.call(this,O),delete O.features)};return{listener:x,targets:u,delegates:{[j]:P}}}}on(j,u,x){if(typeof u=="function"||x===void 0)return super.on(j,u);if(typeof u=="string"&&(u=[u]),!this._areTargetsValid(u))return this;const N=this._createDelegatedListener(j,u,x);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[j]=this._delegatedListeners[j]||[],this._delegatedListeners[j].push(N);for(const P in N.delegates)this.on(P,N.delegates[P]);return this}once(j,u,x){if(typeof u=="function"||x===void 0)return super.once(j,u);if(typeof u=="string"&&(u=[u]),!this._areTargetsValid(u))return this;const N=this._createDelegatedListener(j,u,x);for(const P in N.delegates)this.once(P,N.delegates[P]);return this}off(j,u,x){if(typeof u=="function"||x===void 0)return super.off(j,u);if(typeof u=="string"&&(u=[u]),!this._areTargetsValid(u))return this;const N=this._delegatedListeners?this._delegatedListeners[j]:void 0;return N&&(P=>{for(let O=0;O{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(j,u)}else N&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=u.localIdeographFontFamily,this._localFontFamily=u.localFontFamily,this._updateStyle(j,u))}_getUIString(j){const u=this._locale[j];if(u==null)throw new Error(`Missing UI string '${j}'`);return u}_updateStyle(j,u){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),j){const x=Object.assign({},u);u&&u.config&&(x.initialConfig=u.config,delete x.config),this.style=new Eh(this,x).load(j),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Eh(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(j){return j==null?(this.fire(new i.y(new Error("IDs can't be empty."))),!1):!i.dr(j)||(this.fire(new i.y(new Error(`IDs can't contain special symbols: "${j}".`))),!1)}_isTargetValid(j){return"featuresetId"in j?this._isValidId("importId"in j?j.importId:j.featuresetId):"layerId"in j&&this._isValidId(j.layerId)}_areTargetsValid(j){if(Array.isArray(j)){for(const u of j)if(!this._isValidId(u))return!1;return!0}return this._isTargetValid(j)}addSource(j,u){return this._isValidId(j)?(this._lazyInitEmptyStyle(),this.style.addSource(j,u),this._update(!0)):this}isSourceLoaded(j){return!!this._isValidId(j)&&!!this.style&&this.style._isSourceCacheLoaded(j)}areTilesLoaded(){return this.style.areTilesLoaded()}addSourceType(j,u,x){this._lazyInitEmptyStyle(),this.style.addSourceType(j,u,x)}removeSource(j){return this._isValidId(j)?(this.style.removeSource(j),this._updateTerrain(),this._update(!0)):this}getSource(j){return this._isValidId(j)?this.style.getOwnSource(j):null}addImage(j,u,{pixelRatio:x=1,sdf:N=!1,stretchX:P,stretchY:O,content:F}={}){this._lazyInitEmptyStyle();const U=i.I.from(j);if(u instanceof HTMLImageElement||ImageBitmap&&u instanceof ImageBitmap){const{width:G,height:J,data:te}=i.o.getImageData(u);this.style.addImage(U,{data:new i.q({width:G,height:J},te),pixelRatio:x,stretchX:P,stretchY:O,content:F,sdf:N,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:G,height:J}=u,te=u;this.style.addImage(U,{data:new i.q({width:G,height:J},new Uint8Array(te.data)),pixelRatio:x,stretchX:P,stretchY:O,content:F,sdf:N,usvg:!1,version:0,userImage:te}),te.onAdd&&te.onAdd(this,j)}}updateImage(j,u){this._lazyInitEmptyStyle();const x=i.I.from(j),N=this.style.getImage(x);if(!N)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:O,height:F,data:U}=P;if(O===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(O!==(N.usvg?N.icon.usvg_tree.width:N.data.width)||F!==(N.usvg?N.icon.usvg_tree.height:N.data.height))return void this.fire(new i.y(new Error(`The width and height of the updated image (${O}, ${F}) must be that same as the previous version of the image (${N.data.width}, ${N.data.height})`)));const G=!(u instanceof HTMLImageElement||ImageBitmap&&u instanceof ImageBitmap);let J=!1;N.usvg?(N.data=new i.q({width:O,height:F},new Uint8Array(U)),N.usvg=!1,N.icon=void 0,J=!0):N.data.replace(U,G),this.style.updateImage(x,N,J)}hasImage(j){return j?!!this.style&&!!this.style.getImage(i.I.from(j)):(this.fire(new i.y(new Error("Missing required image id"))),!1)}removeImage(j){this.style.removeImage(i.I.from(j))}loadImage(j,u){i.n(this._requestManager.transformRequest(j,i.R.Image),(x,N)=>{u(x,N instanceof HTMLImageElement?i.o.getImageData(N):N)})}listImages(){return this.style.listImages().map(j=>j.name)}addModel(j,u){this._lazyInitEmptyStyle(),this.style.addModel(j,u)}hasModel(j){return j?this.style.hasModel(j):(this.fire(new i.y(new Error("Missing required model id"))),!1)}removeModel(j){this.style.removeModel(j)}listModels(){return this.style.listModels()}addLayer(j,u){return this._isValidId(j.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(j,u),this._update(!0)):this}getSlot(j){const u=this.getLayer(j);return u&&u.slot||null}setSlot(j,u){return this.style.setSlot(j,u),this.style.mergeLayers(),this._update(!0)}addImport(j,u){return this.style.addImport(j,u).catch(x=>this.fire(new i.y(new Error("Failed to add import",x)))),this}updateImport(j,u){return typeof u!="string"&&u.id!==j?(this.removeImport(j),this.addImport(u)):(this.style.updateImport(j,u),this._update(!0))}removeImport(j){return this.style.removeImport(j),this}moveImport(j,u){return this.style.moveImport(j,u),this._update(!0)}moveLayer(j,u){return this._isValidId(j)?(this.style.moveLayer(j,u),this._update(!0)):this}removeLayer(j){return this._isValidId(j)?(this.style.removeLayer(j),this._update(!0)):this}getLayer(j){if(!this._isValidId(j))return null;const u=this.style.getOwnLayer(j);return u?u.type==="custom"?u.implementation:u.serialize():void 0}getSlots(){return this.style.getSlots()}setLayerZoomRange(j,u,x){return this._isValidId(j)?(this.style.setLayerZoomRange(j,u,x),this._update(!0)):this}setFilter(j,u,x={}){return this._isValidId(j)?(this.style.setFilter(j,u,x),this._update(!0)):this}getFilter(j){return this._isValidId(j)?this.style.getFilter(j):null}setPaintProperty(j,u,x,N={}){return this._isValidId(j)?(this.style.setPaintProperty(j,u,x,N),this._update(!0)):this}getPaintProperty(j,u){return this._isValidId(j)?this.style.getPaintProperty(j,u):null}setLayoutProperty(j,u,x,N={}){return this._isValidId(j)?(this.style.setLayoutProperty(j,u,x,N),this._update(!0)):this}getLayoutProperty(j,u){return this._isValidId(j)?this.style.getLayoutProperty(j,u):null}setLayerProperty(j,u,x,N={}){return this._isValidId(j)?(u==="appearances"&&this._postAddingAppearancesToStyleEvent(),this.style.setLayerProperty(j,u,x,N),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(j){return this.style.setGlyphsUrl(j),this._update(!0)}getSchema(j){return this.style.getSchema(j)}setSchema(j,u){return this.style.setSchema(j,u),this._update(!0)}getConfig(j){return this.style.getConfig(j)}setConfig(j,u){return this.style.setConfig(j,u),this._update(!0)}getConfigProperty(j,u){return this.style.getConfigProperty(j,u)}setConfigProperty(j,u,x){return this.style.setConfigProperty(j,u,x),this._update(!0)}getFeaturesetDescriptors(j){return this.style.getFeaturesetDescriptors(j)}setLights(j){if(this._lazyInitEmptyStyle(),j&&j.length===1&&j[0].type==="flat"){const u=j[0];u.properties?this.style.setFlatLight(u.properties,u.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(j),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const j=this.style.getLights()||[];return j.length===0&&j.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),j}setLight(j,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:j}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(j){return this._lazyInitEmptyStyle(),!j&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(j),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(j){return this._lazyInitEmptyStyle(),this.style.setFog(j),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setSnow(j){return this._lazyInitEmptyStyle(),this.style.setSnow(j),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(j){return this._lazyInitEmptyStyle(),this.style.setRain(j),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(j){return this._lazyInitEmptyStyle(),this.style.setColorTheme(j),this._update(!0)}setImportColorTheme(j,u){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(j,u),this._update(!0)}setCamera(j){return this.style.setCamera(j),this._triggerCameraUpdate(j)}_triggerCameraUpdate(j){return this._update(this.transform.setOrthographicProjectionAtLowPitch(j["camera-projection"]==="orthographic"))}getCamera(){return this.style.camera}_queryFogOpacity(j){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.aT.convert(j),this.transform):0}setFeatureState(j,u){return j.source&&!this._isValidId(j.source)?this:(this.style.setFeatureState(j,u),this._update())}removeFeatureState(j,u){return j.source&&!this._isValidId(j.source)?this:(this.style.removeFeatureState(j,u),this._update())}getFeatureState(j){return j.source&&!this._isValidId(j.source)?null:this.style.getFeatureState(j)}_selectIndoorFloor(j){this.indoor.selectFloor(j)}_setIndoorActiveFloorsVisibility(j){this.indoor.setActiveFloorsVisibility(j)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new Z0),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const j=this._container.getBoundingClientRect().width||400,u=this._container.getBoundingClientRect().height||300;let x,N,P,O=this._container;for(;O&&(!N||!P);){const F=window.getComputedStyle(O).transform;F&&F!=="none"&&(x=F.match(/matrix.*\((.+)\)/)[1].split(", "),x[0]&&x[0]!=="0"&&x[0]!=="1"&&(N=x[0]),x[3]&&x[3]!=="0"&&x[3]!=="1"&&(P=x[3])),O=O.parentElement}this._containerWidth=N?Math.abs(j/N):j,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 oL(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 j=this._container;j.classList.add("mapboxgl-map"),(this._missingCSSCanary=w("div","mapboxgl-canary",j)).style.visibility="hidden",this._detectMissingCSS();const u=this._canvasContainer=w("div","mapboxgl-canvas-container",j);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",j),N=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(P=>{N[P]=w("div",`mapboxgl-ctrl-${P}`,x)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(j,u){const x=i.o.devicePixelRatio||1;this._canvas.width=x*Math.ceil(j),this._canvas.height=x*Math.ceil(u),this._canvas.style.width=`${j}px`,this._canvas.style.height=`${u}px`}_addMarker(j){this._markers.push(j)}_removeMarker(j){const u=this._markers.indexOf(j);u!==-1&&this._markers.splice(u,1)}_addPopup(j){this._popups.push(j)}_removePopup(j){const u=this._popups.indexOf(j);u!==-1&&this._popups.splice(u,1)}_setupPainter(){const j=Object.assign({},k.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),u=this._canvas.getContext("webgl2",j);u?(rt(u,!0),this.painter=new MS(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(j){j.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.z("webglcontextlost",{originalEvent:j}))}_contextRestored(j){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:j}))}_onMapScroll(j){if(j.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(j){return this.style?(this._styleDirty=this._styleDirty||j,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(j){return this._update(),this._renderTaskQueue.add(j)}_cancelRenderFrame(j){this._renderTaskQueue.remove(j)}_requestDomTask(j){!this.loaded()||this.loaded()&&!this.isMoving()?j():this._domRenderTaskQueue.add(j)}_render(j){let u;this.fire(new i.z("renderstart")),++this._frameId;const x=this.painter.context.extTimerQuery,N=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(j),this._domRenderTaskQueue.run(j),this._removed)return;this._updateProjectionTransition();const O=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const J=this.transform.zoom,te=this.transform.pitch,me=i.o.now(),he=new i.ac(J,{now:me,fadeDuration:O,pitch:te,transition:this.style.transition,worldview:this._worldview});this.style.update(he)}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(N),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):F=this._updateAverageElevation(N);const U=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,O,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:O,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.mark(m.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 J=i.o.now()-N;P.endQuery(x.TIME_ELAPSED_EXT),setTimeout(()=>{const te=P.getQueryParameter(u,P.QUERY_RESULT)/1e6;P.deleteQuery(u),this.fire(new i.z("gpu-timing-frame",{cpuTime:J,gpuTime:te}))},50)}if(this.listens("gpu-timing-layer")){const J=this.painter.collectGpuTimers();setTimeout(()=>{const te=this.painter.queryGpuTimers(J);this.fire(new i.z("gpu-timing-layer",{layerTimes:te}))},50)}if(this.listens("gpu-timing-deferred-render")){const J=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const te=this.painter.queryGpuTimeDeferredRender(J);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:te}))},50)}const G=this._sourcesDirty||this._styleDirty||this._placementDirty||F;if(G||this._repaint)this.triggerRepaint();else{const J=this.idle();if(J&&(F=this._updateAverageElevation(N,!0)),F)this.triggerRepaint();else if(this._triggerFrame(!1),J&&(this.fire(new i.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const te=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:te})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||G||(this._fullyLoaded=!0,p.mark(m.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(j){for(const u of this._markers)j&&!this.getRenderWorldCopies()&&(u._lngLat=u._lngLat.wrap()),u._update();for(const u of this._popups)!j||this.getRenderWorldCopies()||u._trackPointer||(u._lngLat=u._lngLat.wrap()),u._update()}_updateAverageElevation(j,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 N=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(N||(u||j-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(j)){const P=this.transform.averageElevation;let O=this.transform.sampleAverageElevation();this.transform.elevation!=null&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(O)?O=0:this._averageElevationLastSampledAt=j;const F=Math.abs(P-O);if(F>1){if(this._isInitialLoad||N)return this._averageElevation.jumpTo(O),x(O);this._averageElevation.easeTo(O,j,300)}else if(F>1e-4)return this._averageElevation.jumpTo(O),x(O)}return!!this._averageElevation.isEasing(j)&&x(this._averageElevation.getValue(j))}_authenticate(){$e(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,j=>{if(j&&(j.message===oe||j.status===401)){const u=this.painter.context.gl;rt(u,!1),this._logoControl instanceof G_&&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&&Ue(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Ie(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){wt(this._requestManager._customAccessToken)}_updateTerrain(){const j=this._isDragging();this.painter.updateTerrain(this.style,j)}_calculateSpeedIndex(){const j=this.painter.canvasCopy(),u=this.painter.getCanvasCopiesAndTimestamps();u.timeStamps.push(performance.now());const x=this.painter.context.gl,N=x.createFramebuffer();function P(O){x.framebufferTexture2D(x.FRAMEBUFFER,x.COLOR_ATTACHMENT0,x.TEXTURE_2D,O,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,N),this._canvasPixelComparison(P(j),u.canvasCopies.map(P),u.timeStamps)}_canvasPixelComparison(j,u,x){let N=x[1]-x[0];const P=j.length/4;for(let O=0;O{const x=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,x&&this._render(u)}))}_preloadTiles(j){const u=this.style?this.style.getSourceCaches():[];return i.bw(u,(x,N)=>x._preloadTiles(j,N),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(j){this._trackResize&&this.resize({originalEvent:j})._update()}_onVisibilityChange(){document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(j){this._showTileBoundaries!==j&&(this._showTileBoundaries=j,this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(j){this._showParseStatus!==j&&(this._showParseStatus=j,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(j){this._showTerrainWireframe!==j&&(this._showTerrainWireframe=j,this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(j){this._showLayers2DWireframe!==j&&(this._showLayers2DWireframe=j,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(j){this._showLayers3DWireframe!==j&&(this._showLayers3DWireframe=j,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(j){this._speedIndexTiming!==j&&(this._speedIndexTiming=j,this._update())}get showPadding(){return!!this._showPadding}set showPadding(j){this._showPadding!==j&&(this._showPadding=j,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(j){this._showCollisionBoxes!==j&&(this._showCollisionBoxes=j,this.style&&j?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(j){this._showOverdrawInspector!==j&&(this._showOverdrawInspector=j,this._update())}get repaint(){return!!this._repaint}set repaint(j){this._repaint!==j&&(this._repaint=j,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(j){this._vertices=j,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(j){this._showTileAABBs!==j&&(this._showTileAABBs=j,j&&this._update())}_setCacheLimits(j,u){i.f4(j,u)}get version(){return d}},NavigationControl:class{constructor(j={}){this.options=Object.assign({},ece,j),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 j=this._map;if(!j)return;const u=j.getZoom(),x=u===j.getMaxZoom(),N=u===j.getMinZoom();this._zoomInButton.disabled=x,this._zoomOutButton.disabled=N,this._zoomInButton.setAttribute("aria-disabled",x.toString()),this._zoomOutButton.setAttribute("aria-disabled",N.toString())}_rotateCompassArrow(){const j=this._map;if(!j)return;const u=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(j.transform.pitch*(Math.PI/180)),.5)}) rotateX(${j.transform.pitch}deg) rotateZ(${j.transform.angle*(180/Math.PI)}deg)`:`rotate(${j.transform.angle*(180/Math.PI)}deg)`;j._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=u)})}onAdd(j){return this._map=j,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),j.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&j.on("pitch",this._rotateCompassArrow),j.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new tce(j,this._compass,this.options.visualizePitch)),this._container}onRemove(){const j=this._map;j&&(this._container.remove(),this.options.showZoom&&j.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&j.off("pitch",this._rotateCompassArrow),j.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(j,u){const x=w("button",j,this._container);return x.type="button",x.addEventListener("click",u),x}_setButtonTitle(j,u){if(!this._map)return;const x=this._map._getUIString(`NavigationControl.${u}`);j.setAttribute("aria-label",x),j.firstElementChild&&j.firstElementChild.setAttribute("title",x)}},GeolocateControl:class extends i.E{constructor(j={}){super();const u=navigator.geolocation;this.options=Object.assign({geolocation:u},rce,j),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=TS(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(j){return this._map=j,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(j){const u=(x=!!this.options.geolocation)=>{this._supportsGeolocation=x,j(x)};this._supportsGeolocation!==void 0?j(this._supportsGeolocation):navigator.permissions!==void 0?navigator.permissions.query({name:"geolocation"}).then(x=>u(x.state!=="denied")).catch(()=>u()):u()}_isOutOfMapMaxBounds(j){const u=this._map.getMaxBounds(),x=j.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(j){if(this._map){if(this._isOutOfMapMaxBounds(j))return this._setErrorState(),this.fire(new i.z("outofmaxbounds",j)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=j,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(j),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(j),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new i.z("geolocate",Object.assign({coords:j.coords,timestamp:j.timestamp},j.toJSON?{toJSON:j.toJSON.bind(j)}:{}))),this._finish()}}_updateCamera(j){const u=new i.aT(j.coords.longitude,j.coords.latitude),x=j.coords.accuracy,N=this._map.getBearing(),P=Object.assign({bearing:N},this.options.fitBoundsOptions);this._map.fitBounds(u.toBounds(x),P,{geolocateSource:!0})}_updateMarker(j){if(j){const u=new i.aT(j.coords.longitude,j.coords.latitude);this._accuracyCircleMarker.setLngLat(u).addTo(this._map),this._userLocationDotMarker.setLngLat(u).addTo(this._map),this._accuracy=j.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const j=this._map.transform,u=i.cf(1,j._center.lat)*j.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(j){if(this._map){if(this.options.trackUserLocation)if(j.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(j.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",j)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(j){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",j===!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 US({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=w("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new US({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(j){this._userLocationDotMarker&&(j.webkitCompassHeading?this._heading=j.webkitCompassHeading:j.absolute===!0&&(this._heading=-1*j.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 j;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(j={maximumAge:6e5,timeout:0},this._noTimeout=!0):(j=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,j),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 j=()=>{"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"&&j()}).catch(console.error):j()}_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:W_,ScaleControl:class{constructor(j={}){this.options=Object.assign({},Y0,j),i.aY(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const j=this.options.maxWidth||100,u=this._map,x=u._containerHeight/2,N=u._containerWidth/2-j/2,P=u.unproject([N,x]),O=u.unproject([N+j,x]),F=P.distanceTo(O);if(this.options.unit==="imperial"){const U=3.2808*F;U>5280?this._setScale(j,U/5280,"mile"):this._setScale(j,U,"foot")}else this.options.unit==="nautical"?this._setScale(j,F/1852,"nautical-mile"):F>=1e3?this._setScale(j,F/1e3,"kilometer"):this._setScale(j,F,"meter")}_setScale(j,u,x){this._map._requestDomTask(()=>{const N=function(O){const F=Math.pow(10,`${Math.floor(O)}`.length-1);let U=O/F;return U=U>=10?10:U>=5?5:U>=3?3:U>=2?2:U>=1?1:function(G){const J=Math.pow(10,Math.ceil(-Math.log(G)/Math.LN10));return Math.round(G*J)/J}(U),F*U}(u),P=N/u;this._container.innerHTML=x!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:x}).format(N):`${N} ${dT[x]}`,this._container.style.width=j*P+"px"})}onAdd(j){return this._map=j,this._language=j.getLanguage(),this._container=w("div","mapboxgl-ctrl mapboxgl-ctrl-scale",j.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(j){this._language=j,this._update()}setUnit(j){this.options.unit=j,this._update()}},FullscreenControl:class{constructor(j={}){this._fullscreen=!1,j&&j.container&&(j.container instanceof HTMLElement?this._container=j.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(j){return this._map=j,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 j=this._fullscreenButton=w("button","mapboxgl-ctrl-fullscreen",this._controlContainer);w("span","mapboxgl-ctrl-icon",j).setAttribute("aria-hidden","true"),j.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const j=this._getTitle();this._fullscreenButton.setAttribute("aria-label",j),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",j)}_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:Z0,Popup:class extends i.E{constructor(j){super(),this.options=Object.assign(Object.create(Ph),j),this._altitude=this.options.altitude,i.aY(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(j&&j.className?j.className.trim().split(/\s+/):[])}addTo(j){return this._map&&this.remove(),this._map=j,this.options.closeOnClick&&j.on("preclick",this._onClose),this.options.closeOnMove&&j.on("move",this._onClose),j.on("remove",this.remove),this._update(),j._addPopup(this),this._focusFirstElement(),this._trackPointer?(j.on("mousemove",this._onMouseEvent),j.on("mouseup",this._onMouseEvent),j._canvasContainer.classList.add("mapboxgl-track-pointer")):j.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 j=this._map;return j&&(j.off("move",this._update),j.off("move",this._onClose),j.off("preclick",this._onClose),j.off("click",this._onClose),j.off("remove",this.remove),j.off("mousemove",this._onMouseEvent),j.off("mouseup",this._onMouseEvent),j.off("drag",this._onMouseEvent),j._canvasContainer&&j._canvasContainer.classList.remove("mapboxgl-track-pointer"),j._removePopup(this),this._map=void 0),this.fire(new i.z("close")),this}getLngLat(){return this._lngLat}setLngLat(j){this._lngLat=i.aT.convert(j),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(j){return this._altitude=j,this._update(),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const j=this._map;return j&&(j.off("move",this._update),j.on("mousemove",this._onMouseEvent),j.on("drag",this._onMouseEvent),j._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(j){return this.setDOMContent(document.createTextNode(j))}setHTML(j){const u=document.createDocumentFragment(),x=document.createElement("body");let N;for(x.innerHTML=j;N=x.firstChild,N;)u.appendChild(N);return this.setDOMContent(u)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(j){return this.options.maxWidth=j,this._update(),this}setDOMContent(j){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(j),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(j){return this._classList.add(j),this._updateClassList(),this}removeClassName(j){return this._classList.delete(j),this._updateClassList(),this}setOffset(j){return this.options.offset=j,this._update(),this}toggleClassName(j){let u;return this._classList.delete(j)?u=!1:(this._classList.add(j),u=!0),this._updateClassList(),u}_onMouseEvent(j){this._update(j.point)}_getAnchor(j){if(this.options.anchor)return this.options.anchor;const u=this._map,x=this._container,N=this._pos;if(!u||!x||!N)return"bottom";const P=x.offsetWidth,O=x.offsetHeight,F=N.x

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

`;const C=new fc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${k!=null&&k.photo_url?``:""}
${ypt(v.price)}
${v.property_address||""}
${v.city}, ${v.state}
${s4e[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 →
`),I=new fc.Marker(T).setLngLat([v.longitude,v.latitude]).setPopup(C).addTo(a.current);o.current.push(I)}),g.length>1){const v=new fc.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})},[e,l]),A.useEffect(()=>(window.__navigateToPublicListing__=g=>{s(g)},()=>{delete window.__navigateToPublicListing__}),[s]),d||t?r.jsx(pr,{className:"w-full h-[500px] rounded-lg"}):!l||e.filter(g=>g.latitude!=null&&g.longitude!=null).length===0?null:r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:Object.entries(r4e).map(([g,v])=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:v}}),r.jsx("span",{className:"text-xs text-gray-600",children:s4e[g]})]},g))}),r.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function YI(e,[t,s]){return Math.min(s,Math.max(t,e))}function C6(e){const t=A.useRef({value:e,previous:e});return A.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var _pt=[" ","Enter","ArrowUp","ArrowDown"],bpt=[" ","Enter"],Qk="Select",[pie,gie,wpt]=h6(Qk),[L3]=Sc(Qk,[wpt,Ix]),xie=Ix(),[jpt,s_]=L3(Qk),[kpt,Npt]=L3(Qk),xze=e=>{const{__scopeSelect:t,children:s,open:n,defaultOpen:a,onOpenChange:o,value:l,defaultValue:i,onValueChange:d,dir:m,name:p,autoComplete:g,disabled:v,required:_,form:k}=e,w=xie(t),[S,T]=A.useState(null),[C,I]=A.useState(null),[R,D]=A.useState(!1),B=vN(m),[$,q]=bh({prop:n,defaultProp:a??!1,onChange:o,caller:Qk}),[W,K]=bh({prop:l,defaultProp:i,onChange:d,caller:Qk}),re=A.useRef(null),ae=S?k||!!S.closest("form"):!0,[oe,se]=A.useState(new Set),pe=Array.from(oe).map(ie=>ie.props.value).join(";");return r.jsx(g6,{...w,children:r.jsxs(jpt,{required:_,scope:t,trigger:S,onTriggerChange:T,valueNode:C,onValueNodeChange:I,valueNodeHasChildren:R,onValueNodeHasChildrenChange:D,contentId:Md(),value:W,onValueChange:K,open:$,onOpenChange:q,dir:B,triggerPointerDownPosRef:re,disabled:v,children:[r.jsx(pie.Provider,{scope:t,children:r.jsx(kpt,{scope:e.__scopeSelect,onNativeOptionAdd:A.useCallback(ie=>{se(de=>new Set(de).add(ie))},[]),onNativeOptionRemove:A.useCallback(ie=>{se(de=>{const ce=new Set(de);return ce.delete(ie),ce})},[]),children:s})}),ae?r.jsxs($ze,{"aria-hidden":!0,required:_,tabIndex:-1,name:p,autoComplete:g,value:W,onChange:ie=>K(ie.target.value),disabled:v,form:k,children:[W===void 0?r.jsx("option",{value:""}):null,Array.from(oe)]},pe):null]})})};xze.displayName=Qk;var yze="SelectTrigger",vze=A.forwardRef((e,t)=>{const{__scopeSelect:s,disabled:n=!1,...a}=e,o=xie(s),l=s_(yze,s),i=l.disabled||n,d=va(t,l.onTriggerChange),m=gie(s),p=A.useRef("touch"),[g,v,_]=Vze(w=>{const S=m().filter(I=>!I.disabled),T=S.find(I=>I.value===l.value),C=qze(S,w,T);C!==void 0&&l.onValueChange(C.value)}),k=w=>{i||(l.onOpenChange(!0),_()),w&&(l.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return r.jsx(k3,{asChild:!0,...o,children:r.jsx(Hs.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":Uze(l.value)?"":void 0,...a,ref:d,onClick:bs(a.onClick,w=>{w.currentTarget.focus(),p.current!=="mouse"&&k(w)}),onPointerDown:bs(a.onPointerDown,w=>{p.current=w.pointerType;const S=w.target;S.hasPointerCapture(w.pointerId)&&S.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(k(w),w.preventDefault())}),onKeyDown:bs(a.onKeyDown,w=>{const S=g.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&v(w.key),!(S&&w.key===" ")&&_pt.includes(w.key)&&(k(),w.preventDefault())})})})});vze.displayName=yze;var _ze="SelectValue",bze=A.forwardRef((e,t)=>{const{__scopeSelect:s,className:n,style:a,children:o,placeholder:l="",...i}=e,d=s_(_ze,s),{onValueNodeHasChildrenChange:m}=d,p=o!==void 0,g=va(t,d.onValueNodeChange);return kc(()=>{m(p)},[m,p]),r.jsx(Hs.span,{...i,ref:g,style:{pointerEvents:"none"},children:Uze(d.value)?r.jsx(r.Fragment,{children:l}):o})});bze.displayName=_ze;var Spt="SelectIcon",wze=A.forwardRef((e,t)=>{const{__scopeSelect:s,children:n,...a}=e;return r.jsx(Hs.span,{"aria-hidden":!0,...a,ref:t,children:n||"▼"})});wze.displayName=Spt;var Cpt="SelectPortal",jze=e=>r.jsx(v3,{asChild:!0,...e});jze.displayName=Cpt;var Jk="SelectContent",kze=A.forwardRef((e,t)=>{const s=s_(Jk,e.__scopeSelect),[n,a]=A.useState();if(kc(()=>{a(new DocumentFragment)},[]),!s.open){const o=n;return o?Hh.createPortal(r.jsx(Nze,{scope:e.__scopeSelect,children:r.jsx(pie.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),o):null}return r.jsx(Sze,{...e,ref:t})});kze.displayName=Jk;var Pp=10,[Nze,n_]=L3(Jk),Mpt="SelectContentImpl",Tpt=$1("SelectContent.RemoveScroll"),Sze=A.forwardRef((e,t)=>{const{__scopeSelect:s,position:n="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:l,side:i,sideOffset:d,align:m,alignOffset:p,arrowPadding:g,collisionBoundary:v,collisionPadding:_,sticky:k,hideWhenDetached:w,avoidCollisions:S,...T}=e,C=s_(Jk,s),[I,R]=A.useState(null),[D,B]=A.useState(null),$=va(t,Ue=>R(Ue)),[q,W]=A.useState(null),[K,re]=A.useState(null),ae=gie(s),[oe,se]=A.useState(!1),pe=A.useRef(!1);A.useEffect(()=>{if(I)return iie(I)},[I]),aie();const ie=A.useCallback(Ue=>{const[Ve,...Ie]=ae().map(Pe=>Pe.ref.current),[We]=Ie.slice(-1),wt=document.activeElement;for(const Pe of Ue)if(Pe===wt||(Pe==null||Pe.scrollIntoView({block:"nearest"}),Pe===Ve&&D&&(D.scrollTop=0),Pe===We&&D&&(D.scrollTop=D.scrollHeight),Pe==null||Pe.focus(),document.activeElement!==wt))return},[ae,D]),de=A.useCallback(()=>ie([q,I]),[ie,q,I]);A.useEffect(()=>{oe&&de()},[oe,de]);const{onOpenChange:ce,triggerPointerDownPosRef:ge}=C;A.useEffect(()=>{if(I){let Ue={x:0,y:0};const Ve=We=>{var wt,Pe;Ue={x:Math.abs(Math.round(We.pageX)-(((wt=ge.current)==null?void 0:wt.x)??0)),y:Math.abs(Math.round(We.pageY)-(((Pe=ge.current)==null?void 0:Pe.y)??0))}},Ie=We=>{Ue.x<=10&&Ue.y<=10?We.preventDefault():I.contains(We.target)||ce(!1),document.removeEventListener("pointermove",Ve),ge.current=null};return ge.current!==null&&(document.addEventListener("pointermove",Ve),document.addEventListener("pointerup",Ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Ve),document.removeEventListener("pointerup",Ie,{capture:!0})}}},[I,ce,ge]),A.useEffect(()=>{const Ue=()=>ce(!1);return window.addEventListener("blur",Ue),window.addEventListener("resize",Ue),()=>{window.removeEventListener("blur",Ue),window.removeEventListener("resize",Ue)}},[ce]);const[Te,_e]=Vze(Ue=>{const Ve=ae().filter(wt=>!wt.disabled),Ie=Ve.find(wt=>wt.ref.current===document.activeElement),We=qze(Ve,Ue,Ie);We&&setTimeout(()=>We.ref.current.focus())}),ve=A.useCallback((Ue,Ve,Ie)=>{const We=!pe.current&&!Ie;(C.value!==void 0&&C.value===Ve||We)&&(W(Ue),We&&(pe.current=!0))},[C.value]),Me=A.useCallback(()=>I==null?void 0:I.focus(),[I]),Ze=A.useCallback((Ue,Ve,Ie)=>{const We=!pe.current&&!Ie;(C.value!==void 0&&C.value===Ve||We)&&re(Ue)},[C.value]),Ae=n==="popper"?dpe:Cze,Le=Ae===dpe?{side:i,sideOffset:d,align:m,alignOffset:p,arrowPadding:g,collisionBoundary:v,collisionPadding:_,sticky:k,hideWhenDetached:w,avoidCollisions:S}:{};return r.jsx(Nze,{scope:s,content:I,viewport:D,onViewportChange:B,itemRefCallback:ve,selectedItem:q,onItemLeave:Me,itemTextRefCallback:Ze,focusSelectedItem:de,selectedItemText:K,position:n,isPositioned:oe,searchRef:Te,children:r.jsx(w6,{as:Tpt,allowPinchZoom:!0,children:r.jsx(_6,{asChild:!0,trapped:C.open,onMountAutoFocus:Ue=>{Ue.preventDefault()},onUnmountAutoFocus:bs(a,Ue=>{var Ve;(Ve=C.trigger)==null||Ve.focus({preventScroll:!0}),Ue.preventDefault()}),children:r.jsx(J1,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Ue=>Ue.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:r.jsx(Ae,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:Ue=>Ue.preventDefault(),...T,...Le,onPlaced:()=>se(!0),ref:$,style:{display:"flex",flexDirection:"column",outline:"none",...T.style},onKeyDown:bs(T.onKeyDown,Ue=>{const Ve=Ue.ctrlKey||Ue.altKey||Ue.metaKey;if(Ue.key==="Tab"&&Ue.preventDefault(),!Ve&&Ue.key.length===1&&_e(Ue.key),["ArrowUp","ArrowDown","Home","End"].includes(Ue.key)){let We=ae().filter(wt=>!wt.disabled).map(wt=>wt.ref.current);if(["ArrowUp","End"].includes(Ue.key)&&(We=We.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ue.key)){const wt=Ue.target,Pe=We.indexOf(wt);We=We.slice(Pe+1)}setTimeout(()=>ie(We)),Ue.preventDefault()}})})})})})})});Sze.displayName=Mpt;var Apt="SelectItemAlignedPosition",Cze=A.forwardRef((e,t)=>{const{__scopeSelect:s,onPlaced:n,...a}=e,o=s_(Jk,s),l=n_(Jk,s),[i,d]=A.useState(null),[m,p]=A.useState(null),g=va(t,$=>p($)),v=gie(s),_=A.useRef(!1),k=A.useRef(!0),{viewport:w,selectedItem:S,selectedItemText:T,focusSelectedItem:C}=l,I=A.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&m&&w&&S&&T){const $=o.trigger.getBoundingClientRect(),q=m.getBoundingClientRect(),W=o.valueNode.getBoundingClientRect(),K=T.getBoundingClientRect();if(o.dir!=="rtl"){const wt=K.left-q.left,Pe=W.left-wt,st=$.left-Pe,ue=$.width+st,$e=Math.max(ue,q.width),tt=window.innerWidth-Pp,rt=YI(Pe,[Pp,Math.max(Pp,tt-$e)]);i.style.minWidth=ue+"px",i.style.left=rt+"px"}else{const wt=q.right-K.right,Pe=window.innerWidth-W.right-wt,st=window.innerWidth-$.right-Pe,ue=$.width+st,$e=Math.max(ue,q.width),tt=window.innerWidth-Pp,rt=YI(Pe,[Pp,Math.max(Pp,tt-$e)]);i.style.minWidth=ue+"px",i.style.right=rt+"px"}const re=v(),ae=window.innerHeight-Pp*2,oe=w.scrollHeight,se=window.getComputedStyle(m),pe=parseInt(se.borderTopWidth,10),ie=parseInt(se.paddingTop,10),de=parseInt(se.borderBottomWidth,10),ce=parseInt(se.paddingBottom,10),ge=pe+ie+oe+ce+de,Te=Math.min(S.offsetHeight*5,ge),_e=window.getComputedStyle(w),ve=parseInt(_e.paddingTop,10),Me=parseInt(_e.paddingBottom,10),Ze=$.top+$.height/2-Pp,Ae=ae-Ze,Le=S.offsetHeight/2,Ue=S.offsetTop+Le,Ve=pe+ie+Ue,Ie=ge-Ve;if(Ve<=Ze){const wt=re.length>0&&S===re[re.length-1].ref.current;i.style.bottom="0px";const Pe=m.clientHeight-w.offsetTop-w.offsetHeight,st=Math.max(Ae,Le+(wt?Me:0)+Pe+de),ue=Ve+st;i.style.height=ue+"px"}else{const wt=re.length>0&&S===re[0].ref.current;i.style.top="0px";const st=Math.max(Ze,pe+w.offsetTop+(wt?ve:0)+Le)+Ie;i.style.height=st+"px",w.scrollTop=Ve-Ze+w.offsetTop}i.style.margin=`${Pp}px 0`,i.style.minHeight=Te+"px",i.style.maxHeight=ae+"px",n==null||n(),requestAnimationFrame(()=>_.current=!0)}},[v,o.trigger,o.valueNode,i,m,w,S,T,o.dir,n]);kc(()=>I(),[I]);const[R,D]=A.useState();kc(()=>{m&&D(window.getComputedStyle(m).zIndex)},[m]);const B=A.useCallback($=>{$&&k.current===!0&&(I(),C==null||C(),k.current=!1)},[I,C]);return r.jsx(Ipt,{scope:s,contentWrapper:i,shouldExpandOnScrollRef:_,onScrollButtonChange:B,children:r.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:R},children:r.jsx(Hs.div,{...a,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});Cze.displayName=Apt;var Ept="SelectPopperPosition",dpe=A.forwardRef((e,t)=>{const{__scopeSelect:s,align:n="start",collisionPadding:a=Pp,...o}=e,l=xie(s);return r.jsx(x6,{...l,...o,ref:t,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)"}})});dpe.displayName=Ept;var[Ipt,Nve]=L3(Jk,{}),upe="SelectViewport",Mze=A.forwardRef((e,t)=>{const{__scopeSelect:s,nonce:n,...a}=e,o=n_(upe,s),l=Nve(upe,s),i=va(t,o.onViewportChange),d=A.useRef(0);return r.jsxs(r.Fragment,{children:[r.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}),r.jsx(pie.Slot,{scope:s,children:r.jsx(Hs.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:bs(a.onScroll,m=>{const p=m.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:v}=l;if(v!=null&&v.current&&g){const _=Math.abs(d.current-p.scrollTop);if(_>0){const k=window.innerHeight-Pp*2,w=parseFloat(g.style.minHeight),S=parseFloat(g.style.height),T=Math.max(w,S);if(T0?R:0,g.style.justifyContent="flex-end")}}}d.current=p.scrollTop})})})]})});Mze.displayName=upe;var Tze="SelectGroup",[Ppt,Lpt]=L3(Tze),Dpt=A.forwardRef((e,t)=>{const{__scopeSelect:s,...n}=e,a=Md();return r.jsx(Ppt,{scope:s,id:a,children:r.jsx(Hs.div,{role:"group","aria-labelledby":a,...n,ref:t})})});Dpt.displayName=Tze;var Aze="SelectLabel",Eze=A.forwardRef((e,t)=>{const{__scopeSelect:s,...n}=e,a=Lpt(Aze,s);return r.jsx(Hs.div,{id:a.id,...n,ref:t})});Eze.displayName=Aze;var cse="SelectItem",[Opt,Ize]=L3(cse),Pze=A.forwardRef((e,t)=>{const{__scopeSelect:s,value:n,disabled:a=!1,textValue:o,...l}=e,i=s_(cse,s),d=n_(cse,s),m=i.value===n,[p,g]=A.useState(o??""),[v,_]=A.useState(!1),k=va(t,C=>{var I;return(I=d.itemRefCallback)==null?void 0:I.call(d,C,n,a)}),w=Md(),S=A.useRef("touch"),T=()=>{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 r.jsx(Opt,{scope:s,value:n,disabled:a,textId:w,isSelected:m,onItemTextChange:A.useCallback(C=>{g(I=>I||((C==null?void 0:C.textContent)??"").trim())},[]),children:r.jsx(pie.ItemSlot,{scope:s,value:n,disabled:a,textValue:p,children:r.jsx(Hs.div,{role:"option","aria-labelledby":w,"data-highlighted":v?"":void 0,"aria-selected":m&&v,"data-state":m?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...l,ref:k,onFocus:bs(l.onFocus,()=>_(!0)),onBlur:bs(l.onBlur,()=>_(!1)),onClick:bs(l.onClick,()=>{S.current!=="mouse"&&T()}),onPointerUp:bs(l.onPointerUp,()=>{S.current==="mouse"&&T()}),onPointerDown:bs(l.onPointerDown,C=>{S.current=C.pointerType}),onPointerMove:bs(l.onPointerMove,C=>{var I;S.current=C.pointerType,a?(I=d.onItemLeave)==null||I.call(d):S.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:bs(l.onPointerLeave,C=>{var I;C.currentTarget===document.activeElement&&((I=d.onItemLeave)==null||I.call(d))}),onKeyDown:bs(l.onKeyDown,C=>{var R;((R=d.searchRef)==null?void 0:R.current)!==""&&C.key===" "||(bpt.includes(C.key)&&T(),C.key===" "&&C.preventDefault())})})})})});Pze.displayName=cse;var qA="SelectItemText",Lze=A.forwardRef((e,t)=>{const{__scopeSelect:s,className:n,style:a,...o}=e,l=s_(qA,s),i=n_(qA,s),d=Ize(qA,s),m=Npt(qA,s),[p,g]=A.useState(null),v=va(t,T=>g(T),d.onItemTextChange,T=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,T,d.value,d.disabled)}),_=p==null?void 0:p.textContent,k=A.useMemo(()=>r.jsx("option",{value:d.value,disabled:d.disabled,children:_},d.value),[d.disabled,d.value,_]),{onNativeOptionAdd:w,onNativeOptionRemove:S}=m;return kc(()=>(w(k),()=>S(k)),[w,S,k]),r.jsxs(r.Fragment,{children:[r.jsx(Hs.span,{id:d.textId,...o,ref:v}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Hh.createPortal(o.children,l.valueNode):null]})});Lze.displayName=qA;var Dze="SelectItemIndicator",Oze=A.forwardRef((e,t)=>{const{__scopeSelect:s,...n}=e;return Ize(Dze,s).isSelected?r.jsx(Hs.span,{"aria-hidden":!0,...n,ref:t}):null});Oze.displayName=Dze;var hpe="SelectScrollUpButton",Rze=A.forwardRef((e,t)=>{const s=n_(hpe,e.__scopeSelect),n=Nve(hpe,e.__scopeSelect),[a,o]=A.useState(!1),l=va(t,n.onScrollButtonChange);return kc(()=>{if(s.viewport&&s.isPositioned){let i=function(){const m=d.scrollTop>0;o(m)};const d=s.viewport;return i(),d.addEventListener("scroll",i),()=>d.removeEventListener("scroll",i)}},[s.viewport,s.isPositioned]),a?r.jsx(zze,{...e,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=s;i&&d&&(i.scrollTop=i.scrollTop-d.offsetHeight)}}):null});Rze.displayName=hpe;var mpe="SelectScrollDownButton",Fze=A.forwardRef((e,t)=>{const s=n_(mpe,e.__scopeSelect),n=Nve(mpe,e.__scopeSelect),[a,o]=A.useState(!1),l=va(t,n.onScrollButtonChange);return kc(()=>{if(s.viewport&&s.isPositioned){let i=function(){const m=d.scrollHeight-d.clientHeight,p=Math.ceil(d.scrollTop)d.removeEventListener("scroll",i)}},[s.viewport,s.isPositioned]),a?r.jsx(zze,{...e,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:d}=s;i&&d&&(i.scrollTop=i.scrollTop+d.offsetHeight)}}):null});Fze.displayName=mpe;var zze=A.forwardRef((e,t)=>{const{__scopeSelect:s,onAutoScroll:n,...a}=e,o=n_("SelectScrollButton",s),l=A.useRef(null),i=gie(s),d=A.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return A.useEffect(()=>()=>d(),[d]),kc(()=>{var p;const m=i().find(g=>g.ref.current===document.activeElement);(p=m==null?void 0:m.ref.current)==null||p.scrollIntoView({block:"nearest"})},[i]),r.jsx(Hs.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:bs(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:bs(a.onPointerMove,()=>{var m;(m=o.onItemLeave)==null||m.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:bs(a.onPointerLeave,()=>{d()})})}),Rpt="SelectSeparator",Bze=A.forwardRef((e,t)=>{const{__scopeSelect:s,...n}=e;return r.jsx(Hs.div,{"aria-hidden":!0,...n,ref:t})});Bze.displayName=Rpt;var fpe="SelectArrow",Fpt=A.forwardRef((e,t)=>{const{__scopeSelect:s,...n}=e,a=xie(s),o=s_(fpe,s),l=n_(fpe,s);return o.open&&l.position==="popper"?r.jsx(y6,{...a,...n,ref:t}):null});Fpt.displayName=fpe;var zpt="SelectBubbleInput",$ze=A.forwardRef(({__scopeSelect:e,value:t,...s},n)=>{const a=A.useRef(null),o=va(n,a),l=C6(t);return A.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&p){const g=new Event("change",{bubbles:!0});p.call(i,t),i.dispatchEvent(g)}},[l,t]),r.jsx(Hs.select,{...s,style:{...RDe,...s.style},ref:o,defaultValue:t})});$ze.displayName=zpt;function Uze(e){return e===""||e===void 0}function Vze(e){const t=gc(e),s=A.useRef(""),n=A.useRef(0),a=A.useCallback(l=>{const i=s.current+l;t(i),function d(m){s.current=m,window.clearTimeout(n.current),m!==""&&(n.current=window.setTimeout(()=>d(""),1e3))}(i)},[t]),o=A.useCallback(()=>{s.current="",window.clearTimeout(n.current)},[]);return A.useEffect(()=>()=>window.clearTimeout(n.current),[]),[s,a,o]}function qze(e,t,s){const a=t.length>1&&Array.from(t).every(m=>m===t[0])?t[0]:t,o=s?e.indexOf(s):-1;let l=Bpt(e,Math.max(o,0));a.length===1&&(l=l.filter(m=>m!==s));const d=l.find(m=>m.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==s?d:void 0}function Bpt(e,t){return e.map((s,n)=>e[(t+n)%e.length])}var $pt=xze,Hze=vze,Upt=bze,Vpt=wze,qpt=jze,Wze=kze,Hpt=Mze,Gze=Eze,Kze=Pze,Wpt=Lze,Gpt=Oze,Zze=Rze,Yze=Fze,Xze=Bze;const ds=$pt,us=Upt,ls=A.forwardRef(({className:e,children:t,...s},n)=>r.jsxs(Hze,{ref:n,className:Vt("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",e),...s,children:[t,r.jsx(Vpt,{asChild:!0,children:r.jsx(ad,{className:"h-4 w-4 opacity-50"})})]}));ls.displayName=Hze.displayName;const Qze=A.forwardRef(({className:e,...t},s)=>r.jsx(Zze,{ref:s,className:Vt("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(cx,{className:"h-4 w-4"})}));Qze.displayName=Zze.displayName;const Jze=A.forwardRef(({className:e,...t},s)=>r.jsx(Yze,{ref:s,className:Vt("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(ad,{className:"h-4 w-4"})}));Jze.displayName=Yze.displayName;const cs=A.forwardRef(({className:e,children:t,position:s="popper",...n},a)=>r.jsx(qpt,{children:r.jsxs(Wze,{ref:a,className:Vt("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",s==="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",e),position:s,...n,children:[r.jsx(Qze,{}),r.jsx(Hpt,{className:Vt("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(Jze,{})]})}));cs.displayName=Wze.displayName;const Kpt=A.forwardRef(({className:e,...t},s)=>r.jsx(Gze,{ref:s,className:Vt("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Kpt.displayName=Gze.displayName;const Ut=A.forwardRef(({className:e,children:t,...s},n)=>r.jsxs(Kze,{ref:n,className:Vt("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",e),...s,children:[r.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(Gpt,{children:r.jsx(mi,{className:"h-4 w-4"})})}),r.jsx(Wpt,{children:t})]}));Ut.displayName=Kze.displayName;const Zpt=A.forwardRef(({className:e,...t},s)=>r.jsx(Xze,{ref:s,className:Vt("-mx-1 my-1 h-px bg-muted",e),...t}));Zpt.displayName=Xze.displayName;const Ypt=e=>Ht({queryKey:["public-listings",e],queryFn:async()=>{let t=Y.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});e!=null&&e.status&&(t=t.eq("status",e.status)),e!=null&&e.propertyType&&(t=t.eq("property_type",e.propertyType)),e!=null&&e.city&&(t=t.ilike("city",`%${e.city}%`)),e!=null&&e.minPrice&&(t=t.gte("price",e.minPrice)),e!=null&&e.maxPrice&&(t=t.lte("price",e.maxPrice));const{data:s,error:n}=await t;if(n)throw n;return s}}),e7e=e=>Ht({queryKey:["public-listing",e],queryFn:async()=>{const t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e);let s=Y.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);t?s=s.eq("id",e):s=s.eq("slug",e);const{data:n,error:a}=await s.single();if(a)throw a;return n},enabled:!!e}),t7e=()=>Qt({mutationFn:async({listingId:e,agentId:t,firstName:s,lastName:n,email:a,phone:o,shareToken:l})=>{let i=null,d=null;if(l){const{data:v}=await Y.from("listing_shares").select("id, sharing_agent_id").eq("share_token",l).eq("listing_id",e).maybeSingle();v&&(i=v.id,d=v.sharing_agent_id)}const{data:m,error:p}=await Y.from("listing_leads").insert({listing_id:e,agent_id:d||t,first_name:s,last_name:n,email:a,phone:o,share_id:i,referred_by_agent_id:d}).select().single();if(p)throw p;const{error:g}=await Y.functions.invoke("process-listing-lead",{body:{leadId:m.id}});return g&&console.error("Error processing lead:",g),m}}),Xpt=()=>Qt({mutationFn:async e=>{const{error:t}=await Y.rpc("increment_listing_share_click",{p_share_token:e});if(t)throw t}}),Qpt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},n4e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},Jpt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function r7e(){const[e,t]=A.useState(""),[s,n]=A.useState(!1),[a,o]=A.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=Ypt({city:e||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),m=()=>{o({status:"",propertyType:"",minPrice:"",maxPrice:""}),t("")},p=e||a.status||a.propertyType||a.minPrice||a.maxPrice;return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsx("title",{children:"LevelUp Listings - Find Your Dream Home | Real Estate for Sale"}),r.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."}),r.jsx("link",{rel:"canonical",href:"https://listings.relevelup.com"}),r.jsx("meta",{property:"og:title",content:"LevelUp Listings - Find Your Dream Home"}),r.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."}),r.jsx("meta",{property:"og:type",content:"website"}),r.jsx("meta",{property:"og:url",content:"https://listings.relevelup.com"}),r.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),r.jsx("meta",{property:"og:locale",content:"en_US"}),r.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),r.jsx("meta",{name:"twitter:title",content:"LevelUp Listings - Find Your Dream Home"}),r.jsx("meta",{name:"twitter:description",content:"Browse exclusive property listings from LevelUp real estate agents."}),r.jsx("meta",{name:"robots",content:"index, follow"}),r.jsx("meta",{name:"keywords",content:"homes for sale, real estate, property listings, houses, condos, townhouses, luxury homes, LevelUp"}),r.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"}})}),r.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"})})]}),r.jsxs("div",{className:"min-h-screen bg-gray-50",children:[r.jsx("header",{className:"bg-white border-b border-gray-200 sticky top-0 z-50",children:r.jsx("div",{className:"max-w-7xl mx-auto px-4 py-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(vo,{to:"/public/listings",className:"flex items-center",children:r.jsx("img",{src:fze,alt:"LevelUp",className:"h-8"})}),r.jsx("nav",{className:"hidden md:flex items-center gap-6",children:r.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"})})]})})}),r.jsxs("section",{className:"relative bg-cover bg-center py-20 md:py-32",style:{backgroundImage:`url(${gpt})`},children:[r.jsx("div",{className:"absolute inset-0 bg-black/40"}),r.jsxs("div",{className:"relative max-w-7xl mx-auto px-4",children:[r.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"}),r.jsx("p",{className:"text-white/90 text-center mb-10 text-lg md:text-xl drop-shadow",children:"Exclusive listings from LevelUp agents"}),r.jsxs("div",{className:"max-w-3xl mx-auto",children:[r.jsxs("div",{className:"flex gap-0 shadow-2xl rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"relative flex-1 bg-white",children:[r.jsx(qn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400"}),r.jsx(Ye,{placeholder:"Enter an address, neighborhood, city, or ZIP code",value:e,onChange:g=>t(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"})]}),r.jsx(X,{className:"h-14 md:h-16 px-6 md:px-8 rounded-none bg-blue-600 hover:bg-blue-700",children:r.jsx(qn,{className:"h-5 w-5 md:h-6 md:w-6"})})]}),r.jsx("div",{className:"flex justify-center mt-6",children:r.jsxs(X,{variant:"secondary",size:"sm",onClick:()=>n(!s),className:"gap-2 bg-white/90 hover:bg-white text-gray-700 shadow-lg",children:[r.jsx(OE,{className:"h-4 w-4"}),s?"Hide Filters":"More Filters"]})}),s&&r.jsxs("div",{className:"mt-4 p-6 bg-white rounded-lg shadow-xl",children:[r.jsxs("div",{className:"grid sm:grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Status"}),r.jsxs(ds,{value:a.status||"all",onValueChange:g=>o({...a,status:g==="all"?"":g}),children:[r.jsx(ls,{className:"bg-white",children:r.jsx(us,{placeholder:"Any status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"Any status"}),Object.entries(n4e).map(([g,v])=>r.jsx(Ut,{value:g,children:v},g))]})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Property Type"}),r.jsxs(ds,{value:a.propertyType||"all",onValueChange:g=>o({...a,propertyType:g==="all"?"":g}),children:[r.jsx(ls,{className:"bg-white",children:r.jsx(us,{placeholder:"Any type"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"Any type"}),Object.entries(Jpt).map(([g,v])=>r.jsx(Ut,{value:g,children:v},g))]})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Min Price"}),r.jsx(Ye,{type:"number",placeholder:"No min",value:a.minPrice,onChange:g=>o({...a,minPrice:g.target.value}),className:"bg-white"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-gray-700 mb-1.5 block",children:"Max Price"}),r.jsx(Ye,{type:"number",placeholder:"No max",value:a.maxPrice,onChange:g=>o({...a,maxPrice:g.target.value}),className:"bg-white"})]})]}),p&&r.jsx("div",{className:"flex justify-end mt-4",children:r.jsxs(X,{variant:"ghost",size:"sm",onClick:m,className:"gap-1 text-gray-500",children:[r.jsx(Xs,{className:"h-4 w-4"}),"Clear all"]})})]})]})]})]}),l&&l.length>0&&r.jsx("section",{className:"py-8 bg-white border-b border-gray-200",children:r.jsxs("div",{className:"max-w-7xl mx-auto px-4",children:[r.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-4",children:"Explore on Map"}),r.jsx(vpt,{listings:l,isLoading:i})]})}),r.jsx("section",{className:"py-8",children:r.jsx("div",{className:"max-w-7xl mx-auto px-4",children:i?r.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:[...Array(8)].map((g,v)=>r.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm",children:[r.jsx(pr,{className:"aspect-[4/3]"}),r.jsxs("div",{className:"p-4 space-y-3",children:[r.jsx(pr,{className:"h-7 w-28"}),r.jsx(pr,{className:"h-4 w-full"}),r.jsx(pr,{className:"h-4 w-3/4"})]})]},v))}):l&&l.length>0?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex items-center justify-between mb-6",children:r.jsxs("h2",{className:"text-xl font-semibold text-gray-900",children:[l.length," ",l.length===1?"Home":"Homes"," Available"]})}),r.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5",children:l.map(g=>{var w,S,T;const v=((w=g.photos)==null?void 0:w.find(C=>C.is_primary))||((S=g.photos)==null?void 0:S[0]),k=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.id}`;return r.jsx(vo,{to:k,children:r.jsxs("div",{className:"bg-white rounded-lg overflow-hidden shadow-sm hover:shadow-lg transition-shadow cursor-pointer group border border-gray-100",children:[r.jsxs("div",{className:"aspect-[4/3] relative overflow-hidden bg-gray-100",children:[v?r.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"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(Vn,{className:"h-12 w-12 text-gray-300"})}),r.jsx(_t,{className:`absolute top-2 left-2 ${Qpt[g.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:n4e[g.status]}),r.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:C=>C.preventDefault(),children:r.jsx(Ai,{className:"h-5 w-5 text-gray-600"})})]}),r.jsxs("div",{className:"p-4",children:[r.jsx("p",{className:"text-xl font-bold text-gray-900 mb-1",children:d(g.price)}),r.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-700 mb-2",children:[g.bedrooms&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-semibold",children:g.bedrooms}),r.jsx("span",{className:"text-gray-500",children:"bds"}),r.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),g.bathrooms&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-semibold",children:g.bathrooms}),r.jsx("span",{className:"text-gray-500",children:"ba"}),r.jsx("span",{className:"text-gray-300 mx-1",children:"|"})]}),g.square_footage&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"font-semibold",children:g.square_footage.toLocaleString()}),r.jsx("span",{className:"text-gray-500",children:"sqft"})]})]}),g.property_address&&r.jsx("p",{className:"text-sm text-gray-700 truncate",children:g.property_address}),r.jsxs("p",{className:"text-sm text-gray-500 truncate",children:[g.city,", ",g.state]}),g.agent&&r.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[r.jsx("p",{className:"text-xs text-gray-500 truncate",children:g.agent.name}),((T=g.agent.brokerage)==null?void 0:T.name)&&r.jsx("p",{className:"text-xs text-gray-400 truncate",children:g.agent.brokerage.name})]})]})]})},g.id)})})]}):r.jsxs("div",{className:"text-center py-16",children:[r.jsx("div",{className:"w-20 h-20 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center",children:r.jsx(Vn,{className:"h-10 w-10 text-gray-400"})}),r.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No listings found"}),r.jsx("p",{className:"text-gray-500 mb-6",children:p?"Try adjusting your search or filters":"Check back soon for new listings"}),p&&r.jsx(X,{variant:"outline",onClick:m,children:"Clear filters"})]})})}),r.jsx("footer",{className:"bg-gray-900 text-white py-10 mt-auto",children:r.jsx("div",{className:"max-w-7xl mx-auto px-4",children:r.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("img",{src:kve,alt:"LevelUp",className:"h-6"})}),r.jsxs("p",{className:"text-gray-400 text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),r.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 ze=A.forwardRef(({className:e,...t},s)=>r.jsx("div",{ref:s,className:Vt("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ze.displayName="Card";const Wt=A.forwardRef(({className:e,...t},s)=>r.jsx("div",{ref:s,className:Vt("flex flex-col space-y-1.5 p-6",e),...t}));Wt.displayName="CardHeader";const Zt=A.forwardRef(({className:e,...t},s)=>r.jsx("h3",{ref:s,className:Vt("text-2xl font-semibold leading-none tracking-tight",e),...t}));Zt.displayName="CardTitle";const Cs=A.forwardRef(({className:e,...t},s)=>r.jsx("p",{ref:s,className:Vt("text-sm text-muted-foreground",e),...t}));Cs.displayName="CardDescription";const qe=A.forwardRef(({className:e,...t},s)=>r.jsx("div",{ref:s,className:Vt("p-6 pt-0",e),...t}));qe.displayName="CardContent";const GE=A.forwardRef(({className:e,...t},s)=>r.jsx("div",{ref:s,className:Vt("flex items-center p-6 pt-0",e),...t}));GE.displayName="CardFooter";var egt="Label",s7e=A.forwardRef((e,t)=>r.jsx(Hs.label,{...e,ref:t,onMouseDown:s=>{var a;s.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,s),!s.defaultPrevented&&s.detail>1&&s.preventDefault())}}));s7e.displayName=egt;var n7e=s7e;const tgt=_3("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Ee=A.forwardRef(({className:e,...t},s)=>r.jsx(n7e,{ref:s,className:Vt(tgt(),e),...t}));Ee.displayName=n7e.displayName;const dse="/assets/levelup-logo-color-D3mY9gCJ.png";function rgt(){const e=sm(),t=window.location.hostname;if(!(t==="listings.relevelup.com"||t.startsWith("listings.")))return null;const n=e.pathname.slice(1);return!n||n===""?r.jsx(r7e,{}):n.startsWith("public/")?null:r.jsx(sgt,{slug:n})}function sgt({slug:e}){return r.jsx(igt,{slug:e})}const ngt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},agt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},a4e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function igt({slug:e}){var W,K;const{data:t,isLoading:s}=e7e(e),n=t7e(),[a,o]=A.useState(""),[l,i]=A.useState(""),[d,m]=A.useState(""),[p,g]=A.useState(""),[v,_]=A.useState(!1),[k,w]=A.useState(!1),[S,T]=A.useState(null),C=re=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(re),I=async re=>{if(re.preventDefault(),!(!a.trim()||!d.trim()||!t)){_(!0);try{await n.mutateAsync({listingId:t.id,agentId:t.agent_id,firstName:a.trim(),lastName:l.trim(),email:d.trim(),phone:p.trim()}),w(!0),we.success("Thanks! The agent will be in touch soon.")}catch(ae){console.error("Lead submission error:",ae),we.error(`Failed to submit: ${ae.message||"Please try again"}`)}finally{_(!1)}}},R=(t==null?void 0:t.photos)||[],D=R.find(re=>re.is_primary)||R[0],B=()=>{S!==null&&T(S===0?R.length-1:S-1)},$=()=>{S!==null&&T(S===R.length-1?0:S+1)};if(s)return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"border-b bg-card",children:r.jsx("div",{className:"container mx-auto px-4 py-4",children:r.jsx(pr,{className:"h-8 w-32"})})}),r.jsxs("div",{className:"container mx-auto px-4 py-8",children:[r.jsx(pr,{className:"h-10 w-48 mb-6"}),r.jsx(pr,{className:"aspect-video mb-6"}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsx(pr,{className:"h-12 w-48"}),r.jsx(pr,{className:"h-6 w-full"}),r.jsx(pr,{className:"h-6 w-3/4"})]}),r.jsx(pr,{className:"h-64"})]})]})]});if(!t)return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"border-b bg-card",children:r.jsx("div",{className:"container mx-auto px-4 py-4",children:r.jsx("a",{href:"/",className:"flex items-center gap-2",children:r.jsx("img",{src:dse,alt:"LevelUp",className:"h-8"})})})}),r.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[r.jsx(Vn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),r.jsx(X,{asChild:!0,children:r.jsx("a",{href:"/",children:"Browse All Listings"})})]})]});const q=t.property_address?`${t.property_address} - ${t.city}, ${t.state}`:`${t.city}, ${t.state} Home for Sale`;return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsxs("title",{children:[q," | LevelUp Listings"]}),r.jsx("meta",{name:"description",content:`${C(t.price)} - ${t.bedrooms||""}BD ${t.bathrooms||""}BA ${t.square_footage?t.square_footage.toLocaleString()+" sqft":""} ${a4e[t.property_type]} in ${t.city}, ${t.state}. ${((W=t.description)==null?void 0:W.slice(0,150))||""}`}),r.jsx("meta",{property:"og:title",content:q}),r.jsx("meta",{property:"og:description",content:`${C(t.price)} - ${t.bedrooms||""}BD ${t.bathrooms||""}BA in ${t.city}, ${t.state}`}),r.jsx("meta",{property:"og:type",content:"website"}),D&&r.jsx("meta",{property:"og:image",content:D.photo_url})]}),r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:r.jsx("div",{className:"container mx-auto px-4 py-4",children:r.jsx("div",{className:"flex items-center justify-between",children:r.jsx("a",{href:"/",className:"flex items-center gap-2",children:r.jsx("img",{src:dse,alt:"LevelUp",className:"h-8"})})})})}),r.jsxs("div",{className:"container mx-auto px-4 py-6",children:[r.jsxs("a",{href:"/",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),R.length>0&&r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>T(0),children:r.jsx("img",{src:D==null?void 0:D.photo_url,alt:"Primary",className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),r.jsx("div",{className:"grid grid-cols-2 gap-2",children:R.slice(1,5).map((re,ae)=>r.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>T(ae+1),children:[r.jsx("img",{src:re.photo_url,alt:`Photo ${ae+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),ae===3&&R.length>5&&r.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",R.length-5," more"]})]},re.id))})]}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[r.jsxs("div",{className:"md:col-span-2 space-y-6",children:[r.jsxs("div",{children:[r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsx(_t,{className:`${ngt[t.status]} text-white border-0`,children:agt[t.status]})}),r.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:C(t.price)}),t.property_address&&r.jsx("p",{className:"text-xl font-medium",children:t.property_address}),r.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[r.jsx(Yi,{className:"h-4 w-4"}),t.city,", ",t.state,t.neighborhood&&` • ${t.neighborhood}`]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[t.bedrooms&&r.jsxs("div",{className:"text-center",children:[r.jsx(x1,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:t.bedrooms}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),t.bathrooms&&r.jsxs("div",{className:"text-center",children:[r.jsx(g1,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:t.bathrooms}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),t.square_footage&&r.jsxs("div",{className:"text-center",children:[r.jsx(fx,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:t.square_footage.toLocaleString()}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),t.year_built&&r.jsxs("div",{className:"text-center",children:[r.jsx(An,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:t.year_built}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(_t,{variant:"secondary",children:[r.jsx(Ni,{className:"h-3 w-3 mr-1"}),a4e[t.property_type]]}),t.lot_size&&r.jsxs(_t,{variant:"secondary",children:["Lot: ",t.lot_size]}),t.has_hoa&&r.jsx(_t,{variant:"secondary",children:"HOA"})]}),t.description&&r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.description})]}),t.agent_notes&&t.agent_notes_public&&r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:t.agent_notes})]}),t.mls_link&&r.jsx(X,{variant:"outline",asChild:!0,children:r.jsxs("a",{href:t.mls_link,target:"_blank",rel:"noopener noreferrer",children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),r.jsxs("div",{className:"space-y-6",children:[t.agent&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:[r.jsx(Fl,{className:"h-5 w-5"}),"Listing Agent"]})}),r.jsxs(qe,{children:[r.jsx("p",{className:"font-semibold text-lg",children:t.agent.name}),((K=t.agent.brokerage)==null?void 0:K.name)&&r.jsx("p",{className:"text-sm text-muted-foreground",children:t.agent.brokerage.name})]})]}),r.jsxs(ze,{className:"border-primary",children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Interested in this property?"})}),r.jsx(qe,{children:k?r.jsxs("div",{className:"text-center py-4",children:[r.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:r.jsx(Vs,{className:"h-6 w-6 text-primary"})}),r.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):r.jsxs("form",{onSubmit:I,className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"firstName",children:"First Name *"}),r.jsx(Ye,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:re=>o(re.target.value),required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"lastName",children:"Last Name"}),r.jsx(Ye,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:re=>i(re.target.value)})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"email",children:"Email *"}),r.jsx(Ye,{id:"email",type:"email",placeholder:"you@example.com",value:d,onChange:re=>m(re.target.value),required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"phone",children:"Phone"}),r.jsx(Ye,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:re=>g(re.target.value)})]}),r.jsx(X,{type:"submit",className:"w-full",disabled:v,children:v?"Submitting...":"Get More Info"}),r.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),r.jsx(Ir,{open:S!==null,onOpenChange:()=>T(null),children:r.jsxs(Er,{className:"max-w-5xl p-0 bg-black/95",children:[r.jsx(zr,{className:"sr-only",children:r.jsx(Fr,{children:"Photo Gallery"})}),r.jsx("button",{onClick:()=>T(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:r.jsx(Xs,{className:"h-5 w-5"})}),S!==null&&R[S]&&r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:R[S].photo_url,alt:`Photo ${S+1}`,className:"w-full max-h-[80vh] object-contain"}),R.length>1&&r.jsxs(r.Fragment,{children:[r.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:r.jsx(jc,{className:"h-6 w-6"})}),r.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:r.jsx(Zi,{className:"h-6 w-6"})}),r.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:[S+1," / ",R.length]})]})]})]})}),r.jsx("footer",{className:"border-t py-8 mt-16",children:r.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[r.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),r.jsx("p",{className:"mt-2",children:r.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function yie({card:e,variant:t}){const s=e.brokerage_display_name||e.brokerage_logo_url,n=e.team_name||e.team_logo_url;if(!s&&!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]"}}[t];return r.jsx("div",{className:`rounded-2xl p-4 mb-6 ${a.container}`,children:r.jsxs("div",{className:`flex flex-col items-center gap-3 ${s&&n?"divide-y divide-current/10":""}`,children:[s&&r.jsxs("div",{className:"flex flex-col items-center gap-1.5 w-full",children:[e.brokerage_logo_url&&r.jsx("img",{src:e.brokerage_logo_url,alt:e.brokerage_display_name||"Brokerage",style:{height:`${e.brokerage_logo_size||56}px`},className:"max-w-[280px] object-contain"}),e.brokerage_display_name&&!e.brokerage_logo_url&&r.jsx("p",{className:`text-sm font-medium ${a.text}`,children:e.brokerage_display_name})]}),n&&r.jsxs("div",{className:`flex flex-col items-center gap-1.5 w-full ${s?"pt-3":""}`,children:[e.team_logo_url&&r.jsx("img",{src:e.team_logo_url,alt:e.team_name||"Team",style:{height:`${e.team_logo_size||56}px`},className:"max-w-[280px] object-contain"}),e.team_name&&!e.team_logo_url&&r.jsx("p",{className:`text-sm font-medium ${a.text}`,children:e.team_name})]})]})})}const a7e=e=>Ht({queryKey:["agent-card-public",e],queryFn:async()=>{if(!e)throw new Error("No slug provided");const{data:t,error:s}=await Y.from("agent_cards").select("*").eq("slug",e).eq("is_published",!0).single();if(s)throw s;const{data:n}=await Y.from("profiles").select("name, email, phone, brokerage_id").eq("id",t.user_id).single();let a=null;if(n!=null&&n.brokerage_id){const{data:i}=await Y.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 Y.from("profiles").select("avatar_url").eq("id",t.user_id).single();if(i!=null&&i.avatar_url)o=i.avatar_url;else{const{data:d}=await Y.storage.from("avatars").list(`${t.user_id}`);if(d&&d.length>0){const{data:m}=Y.storage.from("avatars").getPublicUrl(`${t.user_id}/${d[0].name}`);o=`${m.publicUrl}?t=${Date.now()}`}}}catch{}const l={...n||{name:null,email:null,phone:null,brokerage_id:null},email:t.display_email||(n==null?void 0:n.email)||null};return{...t,social_links:t.social_links||[],profile:l,brokerage_name:t.brokerage_display_name||a,avatar_url:o}},enabled:!!e}),ogt=()=>Ht({queryKey:["agent-cards-admin"],queryFn:async()=>{const{data:e,error:t}=await Y.from("agent_cards").select("*").order("created_at",{ascending:!1});if(t)throw t;return e}}),lgt=e=>Ht({queryKey:["agent-card",e],queryFn:async()=>{if(!e)return null;const{data:t,error:s}=await Y.from("agent_cards").select("*").eq("user_id",e).maybeSingle();if(s)throw s;return t},enabled:!!e}),i7e=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("agent_cards").insert(t).select().single();if(n)throw n;return s},onSuccess:()=>{e.invalidateQueries({queryKey:["agent-cards-admin"]}),e.invalidateQueries({queryKey:["agent-card"]}),we.success("Agent card created")},onError:t=>we.error(t.message)})},o7e=()=>{const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("agent_cards").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["agent-cards-admin"]}),e.invalidateQueries({queryKey:["agent-card"]}),we.success("Agent card updated")},onError:t=>we.error(t.message)})},Gi=async(e,t,s,n)=>{const a=new URLSearchParams(window.location.search);await Y.from("agent_card_interactions").insert({card_id:e,interaction_type:t,interaction_detail:s||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:{}})},cgt=async(e,t)=>{const{error:s}=await Y.from("agent_card_leads").insert({card_id:e,...t});if(s)throw s},l7e=e=>Ht({queryKey:["agent-card-analytics",e],queryFn:async()=>{if(!e)return null;const{data:t,error:s}=await Y.from("agent_card_interactions").select("interaction_type, interaction_detail, created_at").eq("card_id",e).order("created_at",{ascending:!1}).limit(500);if(s)throw s;const{data:n,error:a}=await Y.from("agent_card_leads").select("*").eq("card_id",e).order("created_at",{ascending:!1});if(a)throw a;const o=(t==null?void 0:t.filter(d=>d.interaction_type==="card_view").length)||0,l=(t==null?void 0:t.filter(d=>d.interaction_type==="button_click").length)||0,i=(t==null?void 0:t.filter(d=>d.interaction_type==="contact_saved").length)||0;return{views:o,clicks:l,saves:i,leads:n||[],interactions:t||[]}},enabled:!!e});function vie({open:e,onOpenChange:t,cardId:s,type:n,agentName:a}){const[o,l]=A.useState(""),[i,d]=A.useState(""),[m,p]=A.useState(""),[g,v]=A.useState(""),[_,k]=A.useState(""),[w,S]=A.useState(!1),T=async C=>{if(C.preventDefault(),!o.trim()){we.error("Please enter your name");return}S(!0);try{await cgt(s,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:m.trim()||void 0,message:_.trim()||void 0,intent:g||void 0}),Gi(s,"lead_submitted",n),Y.functions.invoke("card-lead-notify",{body:{cardId:s,leadType:n,name:o.trim(),email:i.trim()||void 0,phone:m.trim()||void 0,message:_.trim()||void 0,intent:g||void 0}}).catch(I=>console.error("Card lead notify failed:",I)),we.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."),t(!1),l(""),d(""),p(""),v(""),k("")}catch{we.error("Something went wrong. Please try again.")}finally{S(!1)}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-md rounded-2xl",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:n==="booking"?"Book a Call":n==="connect"?"Connect with Me":"Refer a Friend"}),r.jsx(Zs,{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?`})]}),r.jsxs("form",{onSubmit:T,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"lead-name",children:"Name *"}),r.jsx(Ye,{id:"lead-name",value:o,onChange:C=>l(C.target.value),placeholder:"Your name",required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"lead-phone",children:"Phone"}),r.jsx(Ye,{id:"lead-phone",type:"tel",value:m,onChange:C=>p(C.target.value),placeholder:"(555) 123-4567"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"lead-email",children:"Email"}),r.jsx(Ye,{id:"lead-email",type:"email",value:i,onChange:C=>d(C.target.value),placeholder:"you@example.com"})]}),n==="booking"&&r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"lead-intent",children:"I'm looking to..."}),r.jsxs(ds,{value:g,onValueChange:v,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select one"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"buy",children:"Buy a home"}),r.jsx(Ut,{value:"sell",children:"Sell my home"}),r.jsx(Ut,{value:"both",children:"Buy & Sell"}),r.jsx(Ut,{value:"other",children:"Something else"})]})]})]}),n!=="connect"&&r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),r.jsx(Ye,{id:"lead-message",value:_,onChange:C=>k(C.target.value),placeholder:n==="referral"?"Their name, phone, situation...":"Anything you'd like us to know"})]}),r.jsx(X,{type:"submit",className:"w-full rounded-2xl",disabled:w,children:w?"Sending...":"Submit"})]})]})})}const dgt=e=>Ht({queryKey:["card-blocks",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("card_blocks").select("*").eq("card_id",e).eq("is_visible",!0).order("sort_order",{ascending:!0});if(s)throw s;return t||[]},enabled:!!e}),ugt=e=>Ht({queryKey:["card-blocks-all",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("card_blocks").select("*").eq("card_id",e).order("sort_order",{ascending:!0});if(s)throw s;return t||[]},enabled:!!e}),hgt=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("card_blocks").insert(t).select().single();if(n)throw n;return s},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["card-blocks",s.card_id]}),e.invalidateQueries({queryKey:["card-blocks-all",s.card_id]}),we.success("Block added")},onError:t=>we.error(t.message)})},mgt=()=>{const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("card_blocks").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["card-blocks"]}),e.invalidateQueries({queryKey:["card-blocks-all"]}),we.success("Block updated")},onError:t=>we.error(t.message)})},fgt=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("card_blocks").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["card-blocks"]}),e.invalidateQueries({queryKey:["card-blocks-all"]}),we.success("Block removed")},onError:t=>we.error(t.message)})};function pgt(e){const t=e.match(/(?:iframe\.mediadelivery\.net\/embed\/|video\.bunnycdn\.com\/play\/)(\d+)\/([a-f0-9-]+)/i);return t?`https://iframe.mediadelivery.net/embed/${t[1]}/${t[2]}?autoplay=false&responsive=true`:(e.includes("iframe.mediadelivery.net"),e)}function ggt(e){const t=e.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return t?`https://www.youtube.com/embed/${t[1]}`:null}const xgt={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 ygt({block:e,variant:t}){const s=e.config;if(!s.video_url)return null;const n=s.video_url.includes("mediadelivery.net")||s.video_url.includes("bunnycdn.com"),a=ggt(s.video_url),o=n||!!a,l=n?pgt(s.video_url):a||s.video_url;return r.jsx("div",{className:xgt[t],children:o?r.jsx("div",{style:{position:"relative",paddingTop:"56.25%"},children:r.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})}):r.jsx("video",{src:s.video_url,controls:!0,className:"w-full",preload:"metadata"})})}const vgt={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 _gt({block:e,variant:t}){const n=e.config.testimonials||[],[a,o]=A.useState(0);if(n.length===0)return null;const l=vgt[t],i=n[a];return r.jsxs("div",{className:l.container,children:[r.jsxs("div",{className:l.card,children:[r.jsx(AE,{className:"h-4 w-4 mb-2 opacity-30"}),r.jsxs("p",{className:`${l.quote} mb-3`,children:['"',i.quote,'"']}),r.jsxs("div",{children:[r.jsx("p",{className:l.name,children:i.name}),i.role&&r.jsx("p",{className:l.role,children:i.role})]})]}),n.length>1&&r.jsxs("div",{className:"flex items-center justify-center gap-3 mt-3",children:[r.jsx("button",{onClick:()=>o(d=>(d-1+n.length)%n.length),className:l.nav,children:r.jsx(jc,{className:"h-4 w-4"})}),r.jsx("div",{className:"flex gap-1.5",children:n.map((d,m)=>r.jsx("div",{className:`h-1.5 w-1.5 rounded-full transition-colors cursor-pointer ${m===a?l.dot:l.dotInactive}`,onClick:()=>o(m)},m))}),r.jsx("button",{onClick:()=>o(d=>(d+1)%n.length),className:l.nav,children:r.jsx(Zi,{className:"h-4 w-4"})})]})]})}const bgt={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 wgt({block:e,variant:t}){const n=e.config.tags||[];if(n.length===0)return null;const a=bgt[t];return r.jsx("div",{className:a.container,children:n.map((o,l)=>r.jsx("span",{className:a.tag,children:o},l))})}const jgt={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 kgt({block:e,cardId:t,variant:s}){const a=e.config.links||[];if(a.length===0)return null;const o=jgt[s];return r.jsx("div",{className:o.container,children:a.map((l,i)=>r.jsxs("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Gi(t,"button_click",`custom_link_${l.label}`),className:o.link,children:[r.jsx("span",{children:l.label}),r.jsx(jn,{className:`h-4 w-4 ${o.icon}`})]},i))})}const ppe={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 Ngt({path:e,color:t,size:s=20}){return r.jsx("svg",{viewBox:"0 0 24 24",width:s,height:s,fill:t,children:r.jsx("path",{d:e})})}const Sgt={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 Cgt({block:e,cardId:t,variant:s}){const a=e.config.platforms||[],o=Sgt[s];return a.length===0?null:r.jsxs("div",{className:o.container,children:[r.jsx("h3",{className:o.title,children:"Follow Me"}),r.jsx("div",{className:"flex flex-wrap gap-3 justify-center",children:a.map((l,i)=>{const d=ppe[l.platform.toLowerCase()];return!d||!l.url?null:r.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Gi(t,"button_click",`social_${l.platform}`),className:o.linkClass,title:d.label,children:r.jsx(Ngt,{path:d.icon,color:d.color})},i)})})]})}function _ie({cardId:e,variant:t}){const{data:s}=dgt(e);if(!s||s.length===0)return null;const n=s.filter(l=>l.block_type==="social_media"&&l.is_visible),a=s.filter(l=>l.block_type!=="social_media"),o=n.length>0?{...n[0],config:{platforms:n.flatMap(l=>l.config.platforms||[])}}:null;return s.findIndex(l=>l.block_type==="social_media"),r.jsxs(r.Fragment,{children:[a.map(l=>{switch(l.block_type){case"video_intro":return r.jsx(ygt,{block:l,variant:t},l.id);case"testimonials":return r.jsx(_gt,{block:l,variant:t},l.id);case"specialties":return r.jsx(wgt,{block:l,variant:t},l.id);case"custom_links":return r.jsx(kgt,{block:l,cardId:e,variant:t},l.id);default:return null}}),o&&r.jsx(Cgt,{block:o,cardId:e,variant:t})]})}async function Mgt(e){try{const t=await fetch(e);if(!t.ok)return null;const s=await t.blob(),n=s.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(s)})}catch{return null}}function Tgt(e){const t=e.trim().split(/\s+/);if(t.length<=1)return{first:t[0]||"",last:""};const s=t.pop();return{first:t.join(" "),last:s}}async function bie(e){const{first:t,last:s}=Tgt(e.name),n=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`,`N:${s};${t};;;`];if(e.phone&&n.push(`TEL;TYPE=CELL:${e.phone}`),e.email&&n.push(`EMAIL;TYPE=INTERNET:${e.email}`),e.brokerage&&n.push(`ORG:${e.brokerage}`),n.push(`URL:${e.cardUrl}`),e.avatarUrl){const i=await Mgt(e.avatarUrl);if(i){const m={"image/jpeg":"JPEG","image/jpg":"JPEG","image/png":"PNG","image/gif":"GIF","image/webp":"JPEG"}[i.mimeType]||"JPEG";n.push(`PHOTO;ENCODING=b;TYPE=${m}:${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=`${e.name.replace(/\s+/g,"_")}.vcf`,l.click(),URL.revokeObjectURL(o),we.success("Contact saved!")}function Agt({card:e}){var T;const[t,s]=A.useState(!1),[n,a]=A.useState("booking"),o=((T=e.profile)==null?void 0:T.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,I)=>{Gi(e.id,"button_click",C),I()},d=()=>i("call",()=>{var C;(C=e.profile)!=null&&C.phone?window.location.href=`tel:${e.profile.phone}`:we.error("Phone number not available")}),m=()=>i("text",()=>{var C;(C=e.profile)!=null&&C.phone?window.location.href=`sms:${e.profile.phone}`:we.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=e.profile)!=null&&C.email?window.location.href=`mailto:${e.profile.email}`:we.error("Email not available")}),g=()=>{e.booking_url?i("book",()=>window.open(e.booking_url,"_blank")):(a("booking"),s(!0),Gi(e.id,"button_click","book"))},v=()=>{var C,I;Gi(e.id,"contact_saved"),bie({name:o,phone:(C=e.profile)==null?void 0:C.phone,email:(I=e.profile)==null?void 0:I.email,brokerage:e.brokerage_name,avatarUrl:e.avatar_url,cardUrl:window.location.href})},_=async()=>{if(Gi(e.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:e.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),we.success("Link copied!")},k=()=>{a("referral"),s(!0),Gi(e.id,"button_click","refer")},w=()=>{a("connect"),s(!0),Gi(e.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return r.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 via-white to-slate-50",children:[r.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[e.show_photo&&r.jsxs(cn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[r.jsx(xa,{src:e.avatar_url||void 0,alt:o}),r.jsx(dn,{className:"text-2xl font-semibold bg-primary text-primary-foreground",children:l})]}),r.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-0.5",children:o}),e.title&&r.jsx("p",{className:"text-sm font-medium text-primary mb-1",children:e.title}),e.brokerage_name&&!e.brokerage_logo_url&&r.jsx("p",{className:"text-sm font-medium text-slate-500 mb-1",children:e.brokerage_name}),e.team_name&&!e.team_logo_url&&r.jsx("p",{className:"text-xs font-medium text-slate-400 mb-3",children:e.team_name}),e.positioning_statement&&r.jsxs("p",{className:"text-base text-slate-600 italic leading-relaxed max-w-xs mx-auto",children:['"',e.positioning_statement,'"']})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[r.jsxs(X,{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:[r.jsx(fi,{className:"h-5 w-5"}),r.jsx("span",{className:"text-xs font-medium",children:"Call"})]}),r.jsxs(X,{onClick:m,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:[r.jsx(Vo,{className:"h-5 w-5"}),r.jsx("span",{className:"text-xs font-medium",children:"Text"})]}),r.jsxs(X,{onClick:p,className:"flex flex-col items-center gap-1.5 h-auto py-4 bg-primary hover:bg-primary/90 text-primary-foreground rounded-2xl shadow-sm",children:[r.jsx(Vs,{className:"h-5 w-5"}),r.jsx("span",{className:"text-xs font-medium",children:"Email"})]})]}),r.jsxs(X,{onClick:g,className:"w-full h-12 text-base font-semibold rounded-2xl shadow-sm mb-6",variant:"outline",children:[r.jsx(An,{className:"h-5 w-5 mr-2"}),e.custom_cta_label||"Book a Call"]}),e.show_credentials&&e.review_snippet&&r.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm text-slate-600",children:r.jsxs("div",{className:"text-center flex items-center gap-1",children:[r.jsx(Dn,{className:"h-4 w-4 text-amber-500 fill-amber-500"}),r.jsx("span",{className:"font-bold text-slate-900",children:"5.0"})]})}),e.review_snippet&&r.jsx("div",{className:"bg-slate-50 rounded-2xl p-4 mb-6 border border-slate-100",children:r.jsxs("p",{className:"text-sm text-slate-600 italic text-center",children:['"',e.review_snippet,'"']})}),e.show_bio&&e.bio&&r.jsxs("div",{className:"mb-6",children:[r.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-2",children:"About Me"}),r.jsx("p",{className:"text-sm text-slate-600 leading-relaxed",children:e.bio})]}),r.jsx(yie,{card:e,variant:"standard"}),r.jsx(_ie,{cardId:e.id,variant:"standard"}),r.jsxs("div",{className:"space-y-2 mb-6",children:[e.show_save_contact&&r.jsxs(X,{variant:"ghost",onClick:v,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[r.jsx(Fi,{className:"h-4 w-4 mr-3 text-primary"}),"Save Contact"]}),e.show_leave_review&&e.review_source_url&&r.jsxs(X,{variant:"ghost",onClick:()=>{Gi(e.id,"button_click","review"),window.open(e.review_source_url,"_blank")},className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[r.jsx(Dn,{className:"h-4 w-4 mr-3 text-amber-500"}),"Leave a Review"]}),e.show_refer_friend&&r.jsxs(X,{variant:"ghost",onClick:k,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[r.jsx(ws,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),r.jsxs(X,{variant:"ghost",onClick:w,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[r.jsx(Kd,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),r.jsxs(X,{variant:"ghost",onClick:_,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[r.jsx(Uc,{className:"h-4 w-4 mr-3 text-primary"}),"Share My Card"]})]}),e.show_social_links&&e.social_links&&e.social_links.length>0&&r.jsx("div",{className:"flex justify-center gap-4 mb-8",children:e.social_links.slice(0,3).map((C,I)=>r.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Gi(e.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-slate-100 hover:bg-slate-200 flex items-center justify-center text-lg transition-colors",children:S[C.platform.toLowerCase()]||"🔗"},I))}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-xs text-slate-400",children:"Powered by LevelUp"})})]}),r.jsx(vie,{open:t,onOpenChange:s,cardId:e.id,type:n,agentName:o})]})}function Egt({card:e}){var T;const[t,s]=A.useState(!1),[n,a]=A.useState("booking"),o=((T=e.profile)==null?void 0:T.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,I)=>{Gi(e.id,"button_click",C),I()},d=()=>i("call",()=>{var C;(C=e.profile)!=null&&C.phone?window.location.href=`tel:${e.profile.phone}`:we.error("Phone number not available")}),m=()=>i("text",()=>{var C;(C=e.profile)!=null&&C.phone?window.location.href=`sms:${e.profile.phone}`:we.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=e.profile)!=null&&C.email?window.location.href=`mailto:${e.profile.email}`:we.error("Email not available")}),g=()=>{e.booking_url?i("book",()=>window.open(e.booking_url,"_blank")):(a("booking"),s(!0),Gi(e.id,"button_click","book"))},v=()=>{var C,I;Gi(e.id,"contact_saved"),bie({name:o,phone:(C=e.profile)==null?void 0:C.phone,email:(I=e.profile)==null?void 0:I.email,brokerage:e.brokerage_name,avatarUrl:e.avatar_url,cardUrl:window.location.href})},_=async()=>{if(Gi(e.id,"share_event"),navigator.share)try{await navigator.share({title:`${o} - Real Estate Agent`,text:e.positioning_statement||`Connect with ${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),we.success("Link copied!")},k=()=>{a("referral"),s(!0),Gi(e.id,"button_click","refer")},w=()=>{a("connect"),s(!0),Gi(e.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return r.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-[#0f1419] via-[#1a1f2e] to-[#0f1419]",children:[r.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[r.jsx("div",{className:"w-16 h-0.5 bg-gradient-to-r from-[#c9a84c] to-[#e8d48b] mx-auto mb-8"}),r.jsxs("div",{className:"text-center mb-8",children:[e.show_photo&&r.jsxs(cn,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[r.jsx(xa,{src:e.avatar_url||void 0,alt:o}),r.jsx(dn,{className:"text-2xl font-serif bg-[#c9a84c]/20 text-[#e8d48b]",children:l})]}),r.jsx("h1",{className:"text-2xl font-serif font-bold text-white tracking-wide mb-0.5",children:o}),e.title&&r.jsx("p",{className:"text-sm font-medium text-[#e8d48b] mb-1",children:e.title}),e.brokerage_name&&!e.brokerage_logo_url&&r.jsx("p",{className:"text-sm font-medium text-[#c9a84c] tracking-widest uppercase mb-1",children:e.brokerage_name}),e.team_name&&!e.team_logo_url&&r.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:e.team_name}),e.positioning_statement&&r.jsxs("p",{className:"text-base text-[#a0aec0] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',e.positioning_statement,'"']})]}),r.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:fi,label:"Call",handler:d},{icon:Vo,label:"Text",handler:m},{icon:Vs,label:"Email",handler:p}].map(({icon:C,label:I,handler:R})=>r.jsxs("button",{onClick:R,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:[r.jsx(C,{className:"h-5 w-5 text-[#c9a84c]"}),r.jsx("span",{className:"text-xs font-medium text-[#e2e8f0]",children:I})]},I))}),r.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:[r.jsx(An,{className:"h-5 w-5"}),e.custom_cta_label||"Book a Call"]}),e.show_credentials&&e.review_snippet&&r.jsx("div",{className:"flex items-center justify-center gap-4 mb-6 text-sm",children:r.jsxs("div",{className:"text-center flex items-center gap-1",children:[r.jsx(Dn,{className:"h-4 w-4 text-[#c9a84c] fill-[#c9a84c]"}),r.jsx("span",{className:"font-bold text-white",children:"5.0"})]})}),e.review_snippet&&r.jsx("div",{className:"bg-[#1e2636] rounded-xl p-4 mb-6 border border-[#c9a84c]/10",children:r.jsxs("p",{className:"text-sm text-[#a0aec0] italic text-center font-serif",children:['"',e.review_snippet,'"']})}),e.show_bio&&e.bio&&r.jsxs("div",{className:"mb-6",children:[r.jsx("h2",{className:"text-sm font-semibold text-[#c9a84c] mb-2 tracking-wide uppercase",children:"About"}),r.jsx("p",{className:"text-sm text-[#a0aec0] leading-relaxed",children:e.bio})]}),r.jsx(yie,{card:e,variant:"luxury"}),r.jsx(_ie,{cardId:e.id,variant:"luxury"}),r.jsxs("div",{className:"space-y-1 mb-6",children:[e.show_save_contact&&r.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:[r.jsx(Fi,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),e.show_leave_review&&e.review_source_url&&r.jsxs("button",{onClick:()=>{Gi(e.id,"button_click","review"),window.open(e.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:[r.jsx(Dn,{className:"h-4 w-4 text-[#c9a84c]"})," Leave a Review"]}),e.show_refer_friend&&r.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 rounded-xl text-[#e2e8f0] hover:bg-[#1e2636] transition-colors text-sm",children:[r.jsx(ws,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),r.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:[r.jsx(Kd,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),r.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:[r.jsx(Uc,{className:"h-4 w-4 text-[#c9a84c]"})," Share My Card"]})]}),e.show_social_links&&e.social_links&&e.social_links.length>0&&r.jsx("div",{className:"flex justify-center gap-4 mb-8",children:e.social_links.slice(0,3).map((C,I)=>r.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Gi(e.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-[#1e2636] border border-[#c9a84c]/20 hover:border-[#c9a84c]/50 flex items-center justify-center text-lg transition-colors",children:S[C.platform.toLowerCase()]||"🔗"},I))}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),r.jsx(vie,{open:t,onOpenChange:s,cardId:e.id,type:n,agentName:o})]})}function Igt({card:e}){var I,R,D,B;const[t,s]=A.useState(!1),[n,a]=A.useState("booking"),o=((I=e.profile)==null?void 0:I.name)||"Agent",l=o.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),i={accent:((R=e.bold_theme_colors)==null?void 0:R.accent)||"#ff5722",dark:((D=e.bold_theme_colors)==null?void 0:D.dark)||"#1a1a2e",button:((B=e.bold_theme_colors)==null?void 0:B.button)||"#ff5722"},d=($,q)=>{const W=parseInt($.replace("#",""),16),K=Math.max(0,(W>>16)-q),re=Math.max(0,(W>>8&255)-q),ae=Math.max(0,(W&255)-q);return`#${(K<<16|re<<8|ae).toString(16).padStart(6,"0")}`};d(i.accent,25),d(i.dark,-20),d(i.button,25);const m=($,q)=>{Gi(e.id,"button_click",$),q()},p=()=>m("call",()=>{var $;($=e.profile)!=null&&$.phone?window.location.href=`tel:${e.profile.phone}`:we.error("Phone number not available")}),g=()=>m("text",()=>{var $;($=e.profile)!=null&&$.phone?window.location.href=`sms:${e.profile.phone}`:we.error("Phone number not available")}),v=()=>m("email",()=>{var $;($=e.profile)!=null&&$.email?window.location.href=`mailto:${e.profile.email}`:we.error("Email not available")}),_=()=>{e.booking_url?m("book",()=>window.open(e.booking_url,"_blank")):(a("booking"),s(!0),Gi(e.id,"button_click","book"))},k=()=>{var $,q;Gi(e.id,"contact_saved"),bie({name:o,phone:($=e.profile)==null?void 0:$.phone,email:(q=e.profile)==null?void 0:q.email,brokerage:e.brokerage_name,avatarUrl:e.avatar_url,cardUrl:window.location.href})},w=async()=>{if(Gi(e.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),we.success("Link copied!")},S=()=>{a("referral"),s(!0),Gi(e.id,"button_click","refer")},T=()=>{a("connect"),s(!0),Gi(e.id,"button_click","connect")},C={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return r.jsxs("div",{className:"min-h-screen",style:{backgroundColor:i.accent},children:[r.jsxs("div",{className:"px-5 pt-10 pb-14 text-center relative",style:{backgroundColor:i.dark},children:[e.show_photo&&r.jsxs(cn,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[r.jsx(xa,{src:e.avatar_url||void 0,alt:o}),r.jsx(dn,{className:"text-2xl font-black text-white",style:{backgroundColor:i.accent},children:l})]}),r.jsx("h1",{className:"text-3xl font-black text-white tracking-tight mb-0.5",children:o}),e.title&&r.jsx("p",{className:"text-sm font-bold mb-1",style:{color:`${i.accent}cc`},children:e.title}),e.brokerage_name&&!e.brokerage_logo_url&&r.jsx("p",{className:"text-sm font-bold uppercase tracking-wider mb-1",style:{color:i.accent},children:e.brokerage_name}),e.team_name&&!e.team_logo_url&&r.jsx("p",{className:"text-xs font-bold text-white/60 uppercase tracking-wider",children:e.team_name})]}),r.jsxs("div",{className:"max-w-md mx-auto px-5 -mt-6",children:[r.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl px-5 py-8",children:[e.positioning_statement&&r.jsx("p",{className:"text-center font-bold text-lg leading-snug mb-6 max-w-xs mx-auto",style:{color:i.dark},children:e.positioning_statement}),r.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:fi,label:"Call",handler:p},{icon:Vo,label:"Text",handler:g},{icon:Vs,label:"Email",handler:v}].map(({icon:$,label:q,handler:W})=>r.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:[r.jsx($,{className:"h-5 w-5"}),r.jsx("span",{className:"text-xs",children:q})]},q))}),r.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:[r.jsx(An,{className:"h-5 w-5"}),e.custom_cta_label||"Book a Call"]}),e.show_credentials&&e.review_snippet&&r.jsx("div",{className:"flex items-center justify-center gap-5 mb-6",children:e.review_snippet&&r.jsxs("div",{className:"text-center flex items-center gap-1",children:[r.jsx(Dn,{className:"h-5 w-5",style:{color:i.accent,fill:i.accent}}),r.jsx("span",{className:"font-black text-2xl",style:{color:i.dark},children:"5.0"})]})}),e.review_snippet&&r.jsx("div",{className:"rounded-2xl p-4 mb-6",style:{backgroundColor:`${i.accent}15`},children:r.jsxs("p",{className:"text-sm font-medium text-center",style:{color:i.dark},children:['"',e.review_snippet,'"']})}),e.show_bio&&e.bio&&r.jsxs("div",{className:"mb-6",children:[r.jsx("h2",{className:"text-xs font-black mb-2 uppercase tracking-wider",style:{color:i.accent},children:"About Me"}),r.jsx("p",{className:"text-sm text-gray-600 leading-relaxed",children:e.bio})]}),r.jsx(yie,{card:e,variant:"bold"}),r.jsx(_ie,{cardId:e.id,variant:"bold"}),r.jsxs("div",{className:"space-y-1 mb-6",children:[e.show_save_contact&&r.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:[r.jsx(Fi,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),e.show_leave_review&&e.review_source_url&&r.jsxs("button",{onClick:()=>{Gi(e.id,"button_click","review"),window.open(e.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:[r.jsx(Dn,{className:"h-4 w-4",style:{color:i.accent}})," Leave a Review"]}),e.show_refer_friend&&r.jsxs("button",{onClick:S,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:[r.jsx(ws,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),r.jsxs("button",{onClick:T,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:[r.jsx(Kd,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),r.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:[r.jsx(Uc,{className:"h-4 w-4",style:{color:i.accent}})," Share My Card"]})]}),e.show_social_links&&e.social_links&&e.social_links.length>0&&r.jsx("div",{className:"flex justify-center gap-4 mb-6",children:e.social_links.slice(0,3).map(($,q)=>r.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Gi(e.id,"button_click",`social_${$.platform}`),className:"h-10 w-10 rounded-full flex items-center justify-center text-lg transition-opacity hover:opacity-85",style:{backgroundColor:i.dark},children:C[$.platform.toLowerCase()]||"🔗"},q))})]}),r.jsx("div",{className:"text-center py-6",children:r.jsx("p",{className:"text-xs text-white/50",children:"Powered by LevelUp"})})]}),r.jsx(vie,{open:t,onOpenChange:s,cardId:e.id,type:n,agentName:o})]})}function Pgt({card:e}){var T;const[t,s]=A.useState(!1),[n,a]=A.useState("booking"),o=((T=e.profile)==null?void 0:T.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,I)=>{Gi(e.id,"button_click",C),I()},d=()=>i("call",()=>{var C;(C=e.profile)!=null&&C.phone?window.location.href=`tel:${e.profile.phone}`:we.error("Phone number not available")}),m=()=>i("text",()=>{var C;(C=e.profile)!=null&&C.phone?window.location.href=`sms:${e.profile.phone}`:we.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=e.profile)!=null&&C.email?window.location.href=`mailto:${e.profile.email}`:we.error("Email not available")}),g=()=>{e.booking_url?i("book",()=>window.open(e.booking_url,"_blank")):(a("booking"),s(!0),Gi(e.id,"button_click","book"))},v=()=>{var C,I;Gi(e.id,"contact_saved"),bie({name:o,phone:(C=e.profile)==null?void 0:C.phone,email:(I=e.profile)==null?void 0:I.email,brokerage:e.brokerage_name,avatarUrl:e.avatar_url,cardUrl:window.location.href})},_=async()=>{if(Gi(e.id,"share_event"),navigator.share)try{await navigator.share({title:`${o}`,url:window.location.href})}catch{}else await navigator.clipboard.writeText(window.location.href),we.success("Link copied!")},k=()=>{a("referral"),s(!0),Gi(e.id,"button_click","refer")},w=()=>{a("connect"),s(!0),Gi(e.id,"button_click","connect")},S={instagram:"📸",facebook:"📘",linkedin:"💼",twitter:"🐦",youtube:"🎬",tiktok:"🎵"};return r.jsxs("div",{className:"min-h-screen bg-[#f5f1eb]",children:[r.jsx("div",{className:"bg-[#1b3a4b] h-2"}),r.jsxs("div",{className:"max-w-md mx-auto px-5 py-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[e.show_photo&&r.jsxs(cn,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[r.jsx(xa,{src:e.avatar_url||void 0,alt:o}),r.jsx(dn,{className:"text-2xl font-serif bg-[#1b3a4b] text-white",children:l})]}),r.jsx("h1",{className:"text-2xl font-serif font-bold text-[#1b3a4b] mb-0.5",children:o}),e.title&&r.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:e.title}),e.brokerage_name&&!e.brokerage_logo_url&&r.jsx("p",{className:"text-sm font-medium text-[#5a7a6f] mb-1",children:e.brokerage_name}),e.team_name&&!e.team_logo_url&&r.jsx("p",{className:"text-xs font-medium text-[#a0aec0] mb-3",children:e.team_name}),e.positioning_statement&&r.jsxs("p",{className:"text-base text-[#4a5568] italic leading-relaxed max-w-xs mx-auto font-serif",children:['"',e.positioning_statement,'"']})]}),r.jsx("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[{icon:fi,label:"Call",handler:d},{icon:Vo,label:"Text",handler:m},{icon:Vs,label:"Email",handler:p}].map(({icon:C,label:I,handler:R})=>r.jsxs("button",{onClick:R,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:[r.jsx(C,{className:"h-5 w-5 text-[#1b3a4b]"}),r.jsx("span",{className:"text-xs font-semibold text-[#1b3a4b]",children:I})]},I))}),r.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:[r.jsx(An,{className:"h-5 w-5"}),e.custom_cta_label||"Book a Call"]}),e.show_credentials&&e.review_snippet&&r.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:r.jsx("div",{className:"flex items-center justify-center gap-6",children:r.jsxs("div",{className:"text-center flex items-center gap-1",children:[r.jsx(Dn,{className:"h-4 w-4 text-[#d4a843] fill-[#d4a843]"}),r.jsx("span",{className:"font-bold text-[#1b3a4b] font-serif",children:"5.0"})]})})}),e.review_snippet&&r.jsx("div",{className:"bg-white rounded-lg border border-[#d4cfc5] p-4 mb-6 shadow-sm",children:r.jsxs("p",{className:"text-sm text-[#4a5568] italic text-center font-serif",children:['"',e.review_snippet,'"']})}),e.show_bio&&e.bio&&r.jsxs("div",{className:"mb-6",children:[r.jsx("h2",{className:"text-sm font-semibold text-[#1b3a4b] mb-2 font-serif",children:"About"}),r.jsx("p",{className:"text-sm text-[#4a5568] leading-relaxed",children:e.bio})]}),r.jsx(yie,{card:e,variant:"classic"}),r.jsx(_ie,{cardId:e.id,variant:"classic"}),r.jsxs("div",{className:"bg-white rounded-lg border border-[#d4cfc5] shadow-sm divide-y divide-[#e8e3db] mb-6",children:[e.show_save_contact&&r.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:[r.jsx(Fi,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),e.show_leave_review&&e.review_source_url&&r.jsxs("button",{onClick:()=>{Gi(e.id,"button_click","review"),window.open(e.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:[r.jsx(Dn,{className:"h-4 w-4 text-[#d4a843]"})," Leave a Review"]}),e.show_refer_friend&&r.jsxs("button",{onClick:k,className:"w-full flex items-center gap-3 h-12 px-4 text-[#1b3a4b] hover:bg-[#f5f1eb] transition-colors text-sm font-medium",children:[r.jsx(ws,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),r.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:[r.jsx(Kd,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),r.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:[r.jsx(Uc,{className:"h-4 w-4 text-[#5a7a6f]"})," Share My Card"]})]}),e.show_social_links&&e.social_links&&e.social_links.length>0&&r.jsx("div",{className:"flex justify-center gap-4 mb-8",children:e.social_links.slice(0,3).map((C,I)=>r.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>Gi(e.id,"button_click",`social_${C.platform}`),className:"h-10 w-10 rounded-full bg-white border border-[#d4cfc5] hover:bg-[#e8e3db] flex items-center justify-center text-lg transition-colors shadow-sm",children:S[C.platform.toLowerCase()]||"🔗"},I))}),r.jsx("div",{className:"text-center",children:r.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),r.jsx(vie,{open:t,onOpenChange:s,cardId:e.id,type:n,agentName:o})]})}function Sve({card:e}){switch(e.theme){case"luxury":return r.jsx(Egt,{card:e});case"bold":return r.jsx(Igt,{card:e});case"classic":return r.jsx(Pgt,{card:e});case"standard":default:return r.jsx(Agt,{card:e})}}function Lgt(){const e=sm();A.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]);const t=e.pathname.slice(1);return!t||t===""?r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Agent Cards"}),r.jsx("p",{className:"text-slate-500",children:"Visit a specific agent's card URL to view their digital business card."})]})}):r.jsx(Dgt,{slug:t})}function Dgt({slug:e}){return r.jsx(Ogt,{slug:e})}function Ogt({slug:e}){var o;const{data:t,isLoading:s,error:n}=a7e(e);if(A.useEffect(()=>{t!=null&&t.id&&Gi(t.id,"card_view")},[t==null?void 0:t.id]),s)return r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:r.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[r.jsxs("div",{className:"flex flex-col items-center gap-4",children:[r.jsx(pr,{className:"h-28 w-28 rounded-full"}),r.jsx(pr,{className:"h-6 w-48"}),r.jsx(pr,{className:"h-4 w-36"})]}),r.jsx(pr,{className:"h-12 w-full"}),r.jsx(pr,{className:"h-12 w-full"})]})});if(n||!t)return r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),r.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=t.profile)==null?void 0:o.name)||"Agent";return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsxs("title",{children:[a," | Real Estate Agent"]}),r.jsx("meta",{name:"description",content:t.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),r.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),r.jsx("meta",{property:"og:description",content:t.positioning_statement||`Connect with ${a}`}),t.avatar_url&&r.jsx("meta",{property:"og:image",content:t.avatar_url})]}),r.jsx(Sve,{card:t})]})}function c7e({presentationId:e,ctaLabel:t,agentName:s,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=A.useState(n||""),[d,m]=A.useState(a||""),[p,g]=A.useState(o||""),[v,_]=A.useState(""),[k,w]=A.useState(""),[S,T]=A.useState(!1),[C,I]=A.useState(!1),R=async D=>{if(D.preventDefault(),!l.trim()){we.error("Please enter your name");return}T(!0);try{const{error:B}=await Y.from("smart_presentation_leads").insert({presentation_id:e,name:l.trim(),email:d.trim()||null,phone:p.trim()||null,intent:v||null,message:k.trim()||null});if(B)throw B;try{await Y.rpc("log_presentation_view",{p_presentation_id:e,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}Y.functions.invoke("presentation-lead-notify",{body:{presentationId:e,name:l.trim(),email:d.trim()||void 0,phone:p.trim()||void 0,intent:v||void 0,message:k.trim()||void 0}}).catch($=>console.error("Presentation lead notify failed:",$)),I(!0)}catch{we.error("Something went wrong. Please try again.")}finally{T(!1)}};return C?r.jsxs("div",{className:"text-center py-8",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mx-auto mb-4",children:r.jsx(mi,{className:"h-8 w-8 text-emerald-600"})}),r.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you!"}),r.jsx("p",{className:"text-gray-500",children:s?`${s} will be in touch soon.`:"We'll be in touch soon."})]}):r.jsxs("form",{onSubmit:R,className:"space-y-4 max-w-md mx-auto",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"pres-lead-name",children:"Name *"}),r.jsx(Ye,{id:"pres-lead-name",value:l,onChange:D=>i(D.target.value),placeholder:"Your name",required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"pres-lead-phone",children:"Phone"}),r.jsx(Ye,{id:"pres-lead-phone",type:"tel",value:p,onChange:D=>g(D.target.value),placeholder:"(555) 123-4567"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"pres-lead-email",children:"Email"}),r.jsx(Ye,{id:"pres-lead-email",type:"email",value:d,onChange:D=>m(D.target.value),placeholder:"you@example.com"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),r.jsxs(ds,{value:v,onValueChange:_,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select one"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"buy",children:"Buy a home"}),r.jsx(Ut,{value:"sell",children:"Sell my home"}),r.jsx(Ut,{value:"both",children:"Buy & Sell"}),r.jsx(Ut,{value:"other",children:"Something else"})]})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"pres-lead-message",children:"Message (optional)"}),r.jsx(Ye,{id:"pres-lead-message",value:k,onChange:D=>w(D.target.value),placeholder:"Anything you'd like us to know"})]}),r.jsx(X,{type:"submit",className:"w-full text-lg py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",disabled:S,children:S?"Sending...":t})]})}function Rgt(){const e=sm();A.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]);const t=e.pathname.slice(1);return!t||t===""?r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Smart Presentations"}),r.jsx("p",{className:"text-slate-500",children:"Visit a specific presentation URL to view it."})]})}):r.jsx(Fgt,{shareToken:t})}function Fgt({shareToken:e}){var k;const[t,s]=A.useState(null),[n,a]=A.useState(!0),[o,l]=A.useState(0),[i,d]=A.useState(!1);A.useEffect(()=>{m()},[e]);const m=async()=>{const{data:w,error:S}=await Y.from("smart_presentations").select("*").eq("share_token",e).eq("status","published").single();if(S||!w){d(!0),a(!1);return}const{data:T}=await Y.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let C;if(T!=null&&T.brokerage_id){const{data:R}=await Y.from("brokerages").select("name").eq("id",T.brokerage_id).single();C=(R==null?void 0:R.name)||void 0}let I=null;if(w.contact_id){const{data:R}=await Y.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",w.contact_id).single();I=R}s({...w,owner_name:T==null?void 0:T.name,owner_email:T==null?void 0:T.email,owner_phone:T==null?void 0:T.phone,owner_avatar:T==null?void 0:T.avatar_url,owner_title:(T==null?void 0:T.title)||void 0,brokerage_name:C,contact_name:I?[I.first_name,I.last_name].filter(Boolean).join(" "):void 0,contact_email:(I==null?void 0:I.email)||void 0,contact_phone:(I==null?void 0:I.phone)||void 0}),a(!1);try{await Y.rpc("log_presentation_view",{p_presentation_id:w.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(t){try{await Y.rpc("log_presentation_view",{p_presentation_id:t.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}t.cta_url&&window.open(t.cta_url,"_blank")}},g=w=>{const S=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(S)return`https://www.youtube.com/embed/${S[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const I=w.replace("/play/","/embed/"),R=I.includes("?")?"&":"?";return`${I}${R}responsive=true`}if(w.includes("iframe.mediadelivery.net")){const I=w.includes("?")?"&":"?";return`${w}${I}responsive=true`}const T=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(T)return`https://www.loom.com/embed/${T[1]}`;const C=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return C?`https://iframe.mediadelivery.net/embed/${C[1]}/${C[2]}?responsive=true`:w};if(n)return r.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:r.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[r.jsx(pr,{className:"h-12 w-3/4 mx-auto"}),r.jsx(pr,{className:"h-64 w-full"}),r.jsx(pr,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!t)return r.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),r.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const v=t.sections.filter(w=>w.is_visible!==!1),_=v[o];return r.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[r.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:r.jsx("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-end",children:r.jsxs("div",{className:"flex items-center gap-3",children:[t.owner_avatar&&r.jsx("img",{src:t.owner_avatar,alt:t.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),r.jsxs("div",{className:"text-right text-sm",children:[r.jsx("p",{className:"font-semibold text-gray-900",children:t.owner_name}),t.owner_title&&r.jsx("p",{className:"text-gray-500 text-xs",children:t.owner_title}),t.brokerage_name&&!t.owner_title&&r.jsx("p",{className:"text-gray-500 text-xs",children:t.brokerage_name})]})]})})}),r.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:t.heading||(t.client_name?`Welcome, ${t.client_name}!`:t.title)}),t.property_address&&r.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",r.jsx("strong",{children:t.property_address}),"."]})]}),r.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[r.jsxs("div",{className:"md:col-span-3",children:[_!=null&&_.video_url?r.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:r.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?r.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:r.jsx("img",{src:_.image_url,alt:_.title,className:"w-full h-auto object-cover",loading:"lazy"})}):r.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:[r.jsx("span",{className:"text-5xl mb-3",children:_==null?void 0:_.icon}),r.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:_==null?void 0:_.title}),r.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:_==null?void 0:_.description})]}),(_==null?void 0:_.text)&&r.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}})]}),r.jsx("div",{className:"md:col-span-2 space-y-3",children:v.map((w,S)=>r.jsx("button",{onClick:()=>l(S),className:Vt("w-full text-left p-4 rounded-xl border transition-all",o===S?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(S+1).padStart(2,"0"),"."]}),r.jsxs("div",{children:[r.jsx("span",{className:"mr-2",children:w.icon}),r.jsx("span",{className:"font-semibold text-gray-900",children:w.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:w.description})]})]})},S))})]}),r.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:[t.owner_avatar&&r.jsx("img",{src:t.owner_avatar,alt:t.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),r.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t.owner_name}),t.owner_title&&r.jsx("p",{className:"text-sm text-gray-500",children:t.owner_title}),t.brokerage_name&&r.jsx("p",{className:"text-sm text-gray-500",children:t.brokerage_name}),r.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[t.owner_phone&&r.jsx("a",{href:`tel:${t.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:t.owner_phone}),t.owner_email&&r.jsx("a",{href:`mailto:${t.owner_email}`,className:"hover:text-blue-600 transition-colors",children:t.owner_email})]})]}),t.cta_label&&r.jsxs("div",{className:"text-center mt-8 py-8",children:[r.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),(k=t.cta_url)!=null&&k.trim()?r.jsxs(X,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[t.cta_label,r.jsx(jn,{className:"h-5 w-5 ml-2"})]}):r.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:r.jsx(c7e,{presentationId:t.id,ctaLabel:t.cta_label,agentName:t.owner_name||void 0,prefillName:t.contact_name,prefillEmail:t.contact_email,prefillPhone:t.contact_phone})})]})]}),r.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 zgt(){const{user:e}=Gr();return Ht({queryKey:["open-houses",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("open_houses").select("*").order("event_date",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function Bgt(e){const{user:t}=Gr(),s=Rr();return A.useEffect(()=>{if(!e)return;const n=Y.channel(`visitors-${e}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"open_house_visitors",filter:`open_house_id=eq.${e}`},()=>{s.invalidateQueries({queryKey:["open-house-visitors",e]}),s.invalidateQueries({queryKey:["open-houses"]})}).subscribe();return()=>{Y.removeChannel(n)}},[e,s]),Ht({queryKey:["open-house-visitors",e],queryFn:async()=>{const{data:n,error:a}=await Y.from("open_house_visitors").select("*").eq("open_house_id",e).order("created_at",{ascending:!1});if(a)throw a;return n},enabled:!!t&&!!e})}function $gt(){const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{data:n,error:a}=await Y.from("open_houses").insert({...s,agent_id:t.id}).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["open-houses"]}),ta({title:"Open house created!"})},onError:s=>{ta({title:"Error",description:s.message,variant:"destructive"})}})}function Ugt(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{error:n}=await Y.from("open_houses").update(s).eq("id",t);if(n)throw n},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["open-houses"]}),e.invalidateQueries({queryKey:["open-house",s.id]})}})}function Vgt(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("open_houses").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["open-houses"]}),ta({title:"Open house deleted"})}})}function d7e(e){return Ht({queryKey:["public-open-house",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("open_houses").select("*, profiles:agent_id(name, avatar_url, title)").eq("slug",e).eq("is_active",!0).single();if(s)throw s;let n=null;if(t.agent_id){const{data:a}=await Y.from("agent_cards").select("slug").eq("user_id",t.agent_id).eq("is_published",!0).maybeSingle();a&&(n=a.slug)}return{...t,agent_card_slug:n}},enabled:!!e})}function u7e(){return Qt({mutationFn:async e=>{const{error:t}=await Y.from("open_house_visitors").insert(e);if(t)throw t}})}function Hn(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Bo(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function dc(e,t){const s=Hn(e);return isNaN(t)?Bo(e,NaN):(t&&s.setDate(s.getDate()+t),s)}function rm(e,t){const s=Hn(e);if(isNaN(t))return Bo(e,NaN);if(!t)return s;const n=s.getDate(),a=Bo(e,s.getTime());a.setMonth(s.getMonth()+t+1,0);const o=a.getDate();return n>=o?a:(s.setFullYear(a.getFullYear(),a.getMonth(),n),s)}function h7e(e,t){const s=+Hn(e);return Bo(e,s+t)}const Cve=6048e5,qgt=864e5,m7e=6e4,Mve=36e5,Hgt=1e3,AO=43200,i4e=1440;function o4e(e,t){return h7e(e,t*Mve)}let Wgt={};function a_(){return Wgt}function Hm(e,t){var i,d,m,p;const s=a_(),n=(t==null?void 0:t.weekStartsOn)??((d=(i=t==null?void 0:t.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??s.weekStartsOn??((p=(m=s.locale)==null?void 0:m.options)==null?void 0:p.weekStartsOn)??0,a=Hn(e),o=a.getDay(),l=(o=a.getTime()?s+1:t.getTime()>=l.getTime()?s:s-1}function Wm(e){const t=Hn(e);return t.setHours(0,0,0,0),t}function q1(e){const t=Hn(e),s=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return s.setUTCFullYear(t.getFullYear()),+e-+s}function Yp(e,t){const s=Wm(e),n=Wm(t),a=+s-q1(s),o=+n-q1(n);return Math.round((a-o)/qgt)}function Ggt(e){const t=f7e(e),s=Bo(e,0);return s.setFullYear(t,0,4),s.setHours(0,0,0,0),n0(s)}function l4e(e,t){return h7e(e,t*m7e)}function Vj(e,t){const s=t*7;return dc(e,s)}function Kgt(e,t){return rm(e,t*12)}function Zgt(e){let t;return e.forEach(function(s){const n=Hn(s);(t===void 0||t{const n=Hn(s);(!t||t>n||isNaN(+n))&&(t=n)}),t||new Date(NaN)}function nre(e,t){const s=Hn(e),n=Hn(t),a=s.getTime()-n.getTime();return a<0?-1:a>0?1:a}function p7e(e){return Bo(e,Date.now())}function Xl(e,t){const s=Wm(e),n=Wm(t);return+s==+n}function Tve(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function gpe(e){if(!Tve(e)&&typeof e!="number")return!1;const t=Hn(e);return!isNaN(Number(t))}function E5(e,t){const s=Hn(e),n=Hn(t),a=s.getFullYear()-n.getFullYear(),o=s.getMonth()-n.getMonth();return a*12+o}function Xgt(e,t,s){const n=Hm(e,s),a=Hm(t,s),o=+n-q1(n),l=+a-q1(a);return Math.round((o-l)/Cve)}function jx(e,t){const s=Hn(e),n=Hn(t),a=c4e(s,n),o=Math.abs(Yp(s,n));s.setDate(s.getDate()-a*o);const l=+(c4e(s,n)===-a),i=a*(o-l);return i===0?0:i}function c4e(e,t){const s=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return s<0?-1:s>0?1:s}function g7e(e){return t=>{const s=Math.trunc,n=s(t);return n===0?0:n}}function x7e(e,t){return+Hn(e)-+Hn(t)}function Qgt(e,t,s){const n=x7e(e,t)/Mve;return g7e()(n)}function Jgt(e){const t=Hn(e);return t.setHours(23,59,59,999),t}function wie(e){const t=Hn(e),s=t.getMonth();return t.setFullYear(t.getFullYear(),s+1,0),t.setHours(23,59,59,999),t}function ext(e){const t=Hn(e);return+Jgt(t)==+wie(t)}function txt(e,t){const s=Hn(e),n=Hn(t),a=nre(s,n),o=Math.abs(E5(s,n));let l;if(o<1)l=0;else{s.getMonth()===1&&s.getDate()>27&&s.setDate(30),s.setMonth(s.getMonth()-a*o);let i=nre(s,n)===-a;ext(Hn(e))&&o===1&&nre(e,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function rxt(e,t,s){const n=x7e(e,t)/1e3;return g7e()(n)}function em(e){const t=Hn(e);return t.setDate(1),t.setHours(0,0,0,0),t}function y7e(e){const t=Hn(e),s=Bo(e,0);return s.setFullYear(t.getFullYear(),0,1),s.setHours(0,0,0,0),s}function Ave(e,t){var i,d,m,p;const s=a_(),n=(t==null?void 0:t.weekStartsOn)??((d=(i=t==null?void 0:t.locale)==null?void 0:i.options)==null?void 0:d.weekStartsOn)??s.weekStartsOn??((p=(m=s.locale)==null?void 0:m.options)==null?void 0:p.weekStartsOn)??0,a=Hn(e),o=a.getDay(),l=(o{let n;const a=sxt[e];return typeof a=="string"?n=a:t===1?n=a.one:n=a.other.replace("{{count}}",t.toString()),s!=null&&s.addSuffix?s.comparison&&s.comparison>0?"in "+n:n+" ago":n};function Nue(e){return(t={})=>{const s=t.width?String(t.width):e.defaultWidth;return e.formats[s]||e.formats[e.defaultWidth]}}const axt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ixt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},oxt={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},lxt={date:Nue({formats:axt,defaultWidth:"full"}),time:Nue({formats:ixt,defaultWidth:"full"}),dateTime:Nue({formats:oxt,defaultWidth:"full"})},cxt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},dxt=(e,t,s,n)=>cxt[e];function hA(e){return(t,s)=>{const n=s!=null&&s.context?String(s.context):"standalone";let a;if(n==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,i=s!=null&&s.width?String(s.width):l;a=e.formattingValues[i]||e.formattingValues[l]}else{const l=e.defaultWidth,i=s!=null&&s.width?String(s.width):e.defaultWidth;a=e.values[i]||e.values[l]}const o=e.argumentCallback?e.argumentCallback(t):t;return a[o]}}const uxt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},hxt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},mxt={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"]},fxt={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"]},pxt={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"}},gxt={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"}},xxt=(e,t)=>{const s=Number(e),n=s%100;if(n>20||n<10)switch(n%10){case 1:return s+"st";case 2:return s+"nd";case 3:return s+"rd"}return s+"th"},yxt={ordinalNumber:xxt,era:hA({values:uxt,defaultWidth:"wide"}),quarter:hA({values:hxt,defaultWidth:"wide",argumentCallback:e=>e-1}),month:hA({values:mxt,defaultWidth:"wide"}),day:hA({values:fxt,defaultWidth:"wide"}),dayPeriod:hA({values:pxt,defaultWidth:"wide",formattingValues:gxt,defaultFormattingWidth:"wide"})};function mA(e){return(t,s={})=>{const n=s.width,a=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],o=t.match(a);if(!o)return null;const l=o[0],i=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(i)?_xt(i,g=>g.test(l)):vxt(i,g=>g.test(l));let m;m=e.valueCallback?e.valueCallback(d):d,m=s.valueCallback?s.valueCallback(m):m;const p=t.slice(l.length);return{value:m,rest:p}}}function vxt(e,t){for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t(e[s]))return s}function _xt(e,t){for(let s=0;s{const n=t.match(e.matchPattern);if(!n)return null;const a=n[0],o=t.match(e.parsePattern);if(!o)return null;let l=e.valueCallback?e.valueCallback(o[0]):o[0];l=s.valueCallback?s.valueCallback(l):l;const i=t.slice(a.length);return{value:l,rest:i}}}const wxt=/^(\d+)(th|st|nd|rd)?/i,jxt=/\d+/i,kxt={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},Nxt={any:[/^b/i,/^(a|c)/i]},Sxt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Cxt={any:[/1/i,/2/i,/3/i,/4/i]},Mxt={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},Txt={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]},Axt={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},Ext={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]},Ixt={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},Pxt={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}},Lxt={ordinalNumber:bxt({matchPattern:wxt,parsePattern:jxt,valueCallback:e=>parseInt(e,10)}),era:mA({matchPatterns:kxt,defaultMatchWidth:"wide",parsePatterns:Nxt,defaultParseWidth:"any"}),quarter:mA({matchPatterns:Sxt,defaultMatchWidth:"wide",parsePatterns:Cxt,defaultParseWidth:"any",valueCallback:e=>e+1}),month:mA({matchPatterns:Mxt,defaultMatchWidth:"wide",parsePatterns:Txt,defaultParseWidth:"any"}),day:mA({matchPatterns:Axt,defaultMatchWidth:"wide",parsePatterns:Ext,defaultParseWidth:"any"}),dayPeriod:mA({matchPatterns:Ixt,defaultMatchWidth:"any",parsePatterns:Pxt,defaultParseWidth:"any"})},jie={code:"en-US",formatDistance:nxt,formatLong:lxt,formatRelative:dxt,localize:yxt,match:Lxt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Dxt(e){const t=Hn(e);return Yp(t,y7e(t))+1}function Eve(e){const t=Hn(e),s=+n0(t)-+Ggt(t);return Math.round(s/Cve)+1}function Ive(e,t){var p,g,v,_;const s=Hn(e),n=s.getFullYear(),a=a_(),o=(t==null?void 0:t.firstWeekContainsDate)??((g=(p=t==null?void 0:t.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??a.firstWeekContainsDate??((_=(v=a.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=Bo(e,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Hm(l,t),d=Bo(e,0);d.setFullYear(n,0,o),d.setHours(0,0,0,0);const m=Hm(d,t);return s.getTime()>=i.getTime()?n+1:s.getTime()>=m.getTime()?n:n-1}function Oxt(e,t){var i,d,m,p;const s=a_(),n=(t==null?void 0:t.firstWeekContainsDate)??((d=(i=t==null?void 0:t.locale)==null?void 0:i.options)==null?void 0:d.firstWeekContainsDate)??s.firstWeekContainsDate??((p=(m=s.locale)==null?void 0:m.options)==null?void 0:p.firstWeekContainsDate)??1,a=Ive(e,t),o=Bo(e,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Hm(o,t)}function Pve(e,t){const s=Hn(e),n=+Hm(s,t)-+Oxt(s,t);return Math.round(n/Cve)+1}function Fo(e,t){const s=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return s+n}const hv={y(e,t){const s=e.getFullYear(),n=s>0?s:1-s;return Fo(t==="yy"?n%100:n,t.length)},M(e,t){const s=e.getMonth();return t==="M"?String(s+1):Fo(s+1,2)},d(e,t){return Fo(e.getDate(),t.length)},a(e,t){const s=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return s.toUpperCase();case"aaa":return s;case"aaaaa":return s[0];case"aaaa":default:return s==="am"?"a.m.":"p.m."}},h(e,t){return Fo(e.getHours()%12||12,t.length)},H(e,t){return Fo(e.getHours(),t.length)},m(e,t){return Fo(e.getMinutes(),t.length)},s(e,t){return Fo(e.getSeconds(),t.length)},S(e,t){const s=t.length,n=e.getMilliseconds(),a=Math.trunc(n*Math.pow(10,s-3));return Fo(a,t.length)}},_C={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},d4e={G:function(e,t,s){const n=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return s.era(n,{width:"abbreviated"});case"GGGGG":return s.era(n,{width:"narrow"});case"GGGG":default:return s.era(n,{width:"wide"})}},y:function(e,t,s){if(t==="yo"){const n=e.getFullYear(),a=n>0?n:1-n;return s.ordinalNumber(a,{unit:"year"})}return hv.y(e,t)},Y:function(e,t,s,n){const a=Ive(e,n),o=a>0?a:1-a;if(t==="YY"){const l=o%100;return Fo(l,2)}return t==="Yo"?s.ordinalNumber(o,{unit:"year"}):Fo(o,t.length)},R:function(e,t){const s=f7e(e);return Fo(s,t.length)},u:function(e,t){const s=e.getFullYear();return Fo(s,t.length)},Q:function(e,t,s){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return Fo(n,2);case"Qo":return s.ordinalNumber(n,{unit:"quarter"});case"QQQ":return s.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return s.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return s.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,s){const n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return Fo(n,2);case"qo":return s.ordinalNumber(n,{unit:"quarter"});case"qqq":return s.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return s.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return s.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,s){const n=e.getMonth();switch(t){case"M":case"MM":return hv.M(e,t);case"Mo":return s.ordinalNumber(n+1,{unit:"month"});case"MMM":return s.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return s.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return s.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,s){const n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return Fo(n+1,2);case"Lo":return s.ordinalNumber(n+1,{unit:"month"});case"LLL":return s.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return s.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return s.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,s,n){const a=Pve(e,n);return t==="wo"?s.ordinalNumber(a,{unit:"week"}):Fo(a,t.length)},I:function(e,t,s){const n=Eve(e);return t==="Io"?s.ordinalNumber(n,{unit:"week"}):Fo(n,t.length)},d:function(e,t,s){return t==="do"?s.ordinalNumber(e.getDate(),{unit:"date"}):hv.d(e,t)},D:function(e,t,s){const n=Dxt(e);return t==="Do"?s.ordinalNumber(n,{unit:"dayOfYear"}):Fo(n,t.length)},E:function(e,t,s){const n=e.getDay();switch(t){case"E":case"EE":case"EEE":return s.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return s.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return s.day(n,{width:"short",context:"formatting"});case"EEEE":default:return s.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,s,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return Fo(o,2);case"eo":return s.ordinalNumber(o,{unit:"day"});case"eee":return s.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return s.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return s.day(a,{width:"short",context:"formatting"});case"eeee":default:return s.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,s,n){const a=e.getDay(),o=(a-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return Fo(o,t.length);case"co":return s.ordinalNumber(o,{unit:"day"});case"ccc":return s.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return s.day(a,{width:"narrow",context:"standalone"});case"cccccc":return s.day(a,{width:"short",context:"standalone"});case"cccc":default:return s.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,s){const n=e.getDay(),a=n===0?7:n;switch(t){case"i":return String(a);case"ii":return Fo(a,t.length);case"io":return s.ordinalNumber(a,{unit:"day"});case"iii":return s.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return s.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return s.day(n,{width:"short",context:"formatting"});case"iiii":default:return s.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,s){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return s.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return s.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return s.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return s.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,s){const n=e.getHours();let a;switch(n===12?a=_C.noon:n===0?a=_C.midnight:a=n/12>=1?"pm":"am",t){case"b":case"bb":return s.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return s.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return s.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return s.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,s){const n=e.getHours();let a;switch(n>=17?a=_C.evening:n>=12?a=_C.afternoon:n>=4?a=_C.morning:a=_C.night,t){case"B":case"BB":case"BBB":return s.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return s.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return s.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,s){if(t==="ho"){let n=e.getHours()%12;return n===0&&(n=12),s.ordinalNumber(n,{unit:"hour"})}return hv.h(e,t)},H:function(e,t,s){return t==="Ho"?s.ordinalNumber(e.getHours(),{unit:"hour"}):hv.H(e,t)},K:function(e,t,s){const n=e.getHours()%12;return t==="Ko"?s.ordinalNumber(n,{unit:"hour"}):Fo(n,t.length)},k:function(e,t,s){let n=e.getHours();return n===0&&(n=24),t==="ko"?s.ordinalNumber(n,{unit:"hour"}):Fo(n,t.length)},m:function(e,t,s){return t==="mo"?s.ordinalNumber(e.getMinutes(),{unit:"minute"}):hv.m(e,t)},s:function(e,t,s){return t==="so"?s.ordinalNumber(e.getSeconds(),{unit:"second"}):hv.s(e,t)},S:function(e,t){return hv.S(e,t)},X:function(e,t,s){const n=e.getTimezoneOffset();if(n===0)return"Z";switch(t){case"X":return h4e(n);case"XXXX":case"XX":return Mj(n);case"XXXXX":case"XXX":default:return Mj(n,":")}},x:function(e,t,s){const n=e.getTimezoneOffset();switch(t){case"x":return h4e(n);case"xxxx":case"xx":return Mj(n);case"xxxxx":case"xxx":default:return Mj(n,":")}},O:function(e,t,s){const n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+u4e(n,":");case"OOOO":default:return"GMT"+Mj(n,":")}},z:function(e,t,s){const n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+u4e(n,":");case"zzzz":default:return"GMT"+Mj(n,":")}},t:function(e,t,s){const n=Math.trunc(e.getTime()/1e3);return Fo(n,t.length)},T:function(e,t,s){const n=e.getTime();return Fo(n,t.length)}};function u4e(e,t=""){const s=e>0?"-":"+",n=Math.abs(e),a=Math.trunc(n/60),o=n%60;return o===0?s+String(a):s+String(a)+t+Fo(o,2)}function h4e(e,t){return e%60===0?(e>0?"-":"+")+Fo(Math.abs(e)/60,2):Mj(e,t)}function Mj(e,t=""){const s=e>0?"-":"+",n=Math.abs(e),a=Fo(Math.trunc(n/60),2),o=Fo(n%60,2);return s+a+t+o}const m4e=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},_7e=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},Rxt=(e,t)=>{const s=e.match(/(P+)(p+)?/)||[],n=s[1],a=s[2];if(!a)return m4e(e,t);let o;switch(n){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;case"PPPP":default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",m4e(n,t)).replace("{{time}}",_7e(a,t))},xpe={p:_7e,P:Rxt},Fxt=/^D+$/,zxt=/^Y+$/,Bxt=["D","DD","YY","YYYY"];function b7e(e){return Fxt.test(e)}function w7e(e){return zxt.test(e)}function ype(e,t,s){const n=$xt(e,t,s);if(console.warn(n),Bxt.includes(e))throw new RangeError(n)}function $xt(e,t,s){const n=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${s}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Uxt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Vxt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,qxt=/^'([^]*?)'?$/,Hxt=/''/g,Wxt=/[a-zA-Z]/;function Xr(e,t,s){var p,g,v,_,k,w,S,T;const n=a_(),a=(s==null?void 0:s.locale)??n.locale??jie,o=(s==null?void 0:s.firstWeekContainsDate)??((g=(p=s==null?void 0:s.locale)==null?void 0:p.options)==null?void 0:g.firstWeekContainsDate)??n.firstWeekContainsDate??((_=(v=n.locale)==null?void 0:v.options)==null?void 0:_.firstWeekContainsDate)??1,l=(s==null?void 0:s.weekStartsOn)??((w=(k=s==null?void 0:s.locale)==null?void 0:k.options)==null?void 0:w.weekStartsOn)??n.weekStartsOn??((T=(S=n.locale)==null?void 0:S.options)==null?void 0:T.weekStartsOn)??0,i=Hn(e);if(!gpe(i))throw new RangeError("Invalid time value");let d=t.match(Vxt).map(C=>{const I=C[0];if(I==="p"||I==="P"){const R=xpe[I];return R(C,a.formatLong)}return C}).join("").match(Uxt).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const I=C[0];if(I==="'")return{isToken:!1,value:Gxt(C)};if(d4e[I])return{isToken:!0,value:C};if(I.match(Wxt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");return{isToken:!1,value:C}});a.localize.preprocessor&&(d=a.localize.preprocessor(i,d));const m={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return d.map(C=>{if(!C.isToken)return C.value;const I=C.value;(!(s!=null&&s.useAdditionalWeekYearTokens)&&w7e(I)||!(s!=null&&s.useAdditionalDayOfYearTokens)&&b7e(I))&&ype(I,t,String(e));const R=d4e[I[0]];return R(i,I,a.localize,m)}).join("")}function Gxt(e){const t=e.match(qxt);return t?t[1].replace(Hxt,"'"):e}function Kxt(e,t,s){const n=a_(),a=(s==null?void 0:s.locale)??n.locale??jie,o=2520,l=nre(e,t);if(isNaN(l))throw new RangeError("Invalid time value");const i=Object.assign({},s,{addSuffix:s==null?void 0:s.addSuffix,comparison:l});let d,m;l>0?(d=Hn(t),m=Hn(e)):(d=Hn(e),m=Hn(t));const p=rxt(m,d),g=(q1(m)-q1(d))/1e3,v=Math.round((p-g)/60);let _;if(v<2)return s!=null&&s.includeSeconds?p<5?a.formatDistance("lessThanXSeconds",5,i):p<10?a.formatDistance("lessThanXSeconds",10,i):p<20?a.formatDistance("lessThanXSeconds",20,i):p<40?a.formatDistance("halfAMinute",0,i):p<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):v===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",v,i);if(v<45)return a.formatDistance("xMinutes",v,i);if(v<90)return a.formatDistance("aboutXHours",1,i);if(vn.getTime()}function kie(e,t){const s=Hn(e),n=Hn(t);return+s<+n}function tyt(e){return+Hn(e)>Date.now()}function ryt(e,t){const s=t instanceof Date?Bo(t,0):new t(0);return s.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),s.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),s}const syt=10;class j7e{constructor(){on(this,"subPriority",0)}validate(t,s){return!0}}class nyt extends j7e{constructor(t,s,n,a,o){super(),this.value=t,this.validateValue=s,this.setValue=n,this.priority=a,o&&(this.subPriority=o)}validate(t,s){return this.validateValue(t,this.value,s)}set(t,s,n){return this.setValue(t,s,this.value,n)}}class ayt extends j7e{constructor(){super(...arguments);on(this,"priority",syt);on(this,"subPriority",-1)}set(s,n){return n.timestampIsSet?s:Bo(s,ryt(s,Date))}}class Ao{run(t,s,n,a){const o=this.parse(t,s,n,a);return o?{setter:new nyt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(t,s,n){return!0}}class iyt extends Ao{constructor(){super(...arguments);on(this,"priority",140);on(this,"incompatibleTokens",["R","u","t","T"])}parse(s,n,a){switch(n){case"G":case"GG":case"GGG":return a.era(s,{width:"abbreviated"})||a.era(s,{width:"narrow"});case"GGGGG":return a.era(s,{width:"narrow"});case"GGGG":default:return a.era(s,{width:"wide"})||a.era(s,{width:"abbreviated"})||a.era(s,{width:"narrow"})}}set(s,n,a){return n.era=a,s.setFullYear(a,0,1),s.setHours(0,0,0,0),s}}const zc={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}/},ex={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 Bc(e,t){return e&&{value:t(e.value),rest:e.rest}}function Kl(e,t){const s=t.match(e);return s?{value:parseInt(s[0],10),rest:t.slice(s[0].length)}:null}function tx(e,t){const s=t.match(e);if(!s)return null;if(s[0]==="Z")return{value:0,rest:t.slice(1)};const n=s[1]==="+"?1:-1,a=s[2]?parseInt(s[2],10):0,o=s[3]?parseInt(s[3],10):0,l=s[5]?parseInt(s[5],10):0;return{value:n*(a*Mve+o*m7e+l*Hgt),rest:t.slice(s[0].length)}}function k7e(e){return Kl(zc.anyDigitsSigned,e)}function Nc(e,t){switch(e){case 1:return Kl(zc.singleDigit,t);case 2:return Kl(zc.twoDigits,t);case 3:return Kl(zc.threeDigits,t);case 4:return Kl(zc.fourDigits,t);default:return Kl(new RegExp("^\\d{1,"+e+"}"),t)}}function hse(e,t){switch(e){case 1:return Kl(zc.singleDigitSigned,t);case 2:return Kl(zc.twoDigitsSigned,t);case 3:return Kl(zc.threeDigitsSigned,t);case 4:return Kl(zc.fourDigitsSigned,t);default:return Kl(new RegExp("^-?\\d{1,"+e+"}"),t)}}function Lve(e){switch(e){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 N7e(e,t){const s=t>0,n=s?t:1-t;let a;if(n<=50)a=e||100;else{const o=n+50,l=Math.trunc(o/100)*100,i=e>=o%100;a=e+l-(i?100:0)}return s?a:1-a}function S7e(e){return e%400===0||e%4===0&&e%100!==0}class oyt extends Ao{constructor(){super(...arguments);on(this,"priority",130);on(this,"incompatibleTokens",["Y","R","u","w","I","i","e","c","t","T"])}parse(s,n,a){const o=l=>({year:l,isTwoDigitYear:n==="yy"});switch(n){case"y":return Bc(Nc(4,s),o);case"yo":return Bc(a.ordinalNumber(s,{unit:"year"}),o);default:return Bc(Nc(n.length,s),o)}}validate(s,n){return n.isTwoDigitYear||n.year>0}set(s,n,a){const o=s.getFullYear();if(a.isTwoDigitYear){const i=N7e(a.year,o);return s.setFullYear(i,0,1),s.setHours(0,0,0,0),s}const l=!("era"in n)||n.era===1?a.year:1-a.year;return s.setFullYear(l,0,1),s.setHours(0,0,0,0),s}}class lyt extends Ao{constructor(){super(...arguments);on(this,"priority",130);on(this,"incompatibleTokens",["y","R","u","Q","q","M","L","I","d","D","i","t","T"])}parse(s,n,a){const o=l=>({year:l,isTwoDigitYear:n==="YY"});switch(n){case"Y":return Bc(Nc(4,s),o);case"Yo":return Bc(a.ordinalNumber(s,{unit:"year"}),o);default:return Bc(Nc(n.length,s),o)}}validate(s,n){return n.isTwoDigitYear||n.year>0}set(s,n,a,o){const l=Ive(s,o);if(a.isTwoDigitYear){const d=N7e(a.year,l);return s.setFullYear(d,0,o.firstWeekContainsDate),s.setHours(0,0,0,0),Hm(s,o)}const i=!("era"in n)||n.era===1?a.year:1-a.year;return s.setFullYear(i,0,o.firstWeekContainsDate),s.setHours(0,0,0,0),Hm(s,o)}}class cyt extends Ao{constructor(){super(...arguments);on(this,"priority",130);on(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(s,n){return hse(n==="R"?4:n.length,s)}set(s,n,a){const o=Bo(s,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),n0(o)}}class dyt extends Ao{constructor(){super(...arguments);on(this,"priority",130);on(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(s,n){return hse(n==="u"?4:n.length,s)}set(s,n,a){return s.setFullYear(a,0,1),s.setHours(0,0,0,0),s}}class uyt extends Ao{constructor(){super(...arguments);on(this,"priority",120);on(this,"incompatibleTokens",["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"])}parse(s,n,a){switch(n){case"Q":case"QQ":return Nc(n.length,s);case"Qo":return a.ordinalNumber(s,{unit:"quarter"});case"QQQ":return a.quarter(s,{width:"abbreviated",context:"formatting"})||a.quarter(s,{width:"narrow",context:"formatting"});case"QQQQQ":return a.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return a.quarter(s,{width:"wide",context:"formatting"})||a.quarter(s,{width:"abbreviated",context:"formatting"})||a.quarter(s,{width:"narrow",context:"formatting"})}}validate(s,n){return n>=1&&n<=4}set(s,n,a){return s.setMonth((a-1)*3,1),s.setHours(0,0,0,0),s}}class hyt extends Ao{constructor(){super(...arguments);on(this,"priority",120);on(this,"incompatibleTokens",["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"])}parse(s,n,a){switch(n){case"q":case"qq":return Nc(n.length,s);case"qo":return a.ordinalNumber(s,{unit:"quarter"});case"qqq":return a.quarter(s,{width:"abbreviated",context:"standalone"})||a.quarter(s,{width:"narrow",context:"standalone"});case"qqqqq":return a.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return a.quarter(s,{width:"wide",context:"standalone"})||a.quarter(s,{width:"abbreviated",context:"standalone"})||a.quarter(s,{width:"narrow",context:"standalone"})}}validate(s,n){return n>=1&&n<=4}set(s,n,a){return s.setMonth((a-1)*3,1),s.setHours(0,0,0,0),s}}class myt extends Ao{constructor(){super(...arguments);on(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);on(this,"priority",110)}parse(s,n,a){const o=l=>l-1;switch(n){case"M":return Bc(Kl(zc.month,s),o);case"MM":return Bc(Nc(2,s),o);case"Mo":return Bc(a.ordinalNumber(s,{unit:"month"}),o);case"MMM":return a.month(s,{width:"abbreviated",context:"formatting"})||a.month(s,{width:"narrow",context:"formatting"});case"MMMMM":return a.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return a.month(s,{width:"wide",context:"formatting"})||a.month(s,{width:"abbreviated",context:"formatting"})||a.month(s,{width:"narrow",context:"formatting"})}}validate(s,n){return n>=0&&n<=11}set(s,n,a){return s.setMonth(a,1),s.setHours(0,0,0,0),s}}class fyt extends Ao{constructor(){super(...arguments);on(this,"priority",110);on(this,"incompatibleTokens",["Y","R","q","Q","M","w","I","D","i","e","c","t","T"])}parse(s,n,a){const o=l=>l-1;switch(n){case"L":return Bc(Kl(zc.month,s),o);case"LL":return Bc(Nc(2,s),o);case"Lo":return Bc(a.ordinalNumber(s,{unit:"month"}),o);case"LLL":return a.month(s,{width:"abbreviated",context:"standalone"})||a.month(s,{width:"narrow",context:"standalone"});case"LLLLL":return a.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return a.month(s,{width:"wide",context:"standalone"})||a.month(s,{width:"abbreviated",context:"standalone"})||a.month(s,{width:"narrow",context:"standalone"})}}validate(s,n){return n>=0&&n<=11}set(s,n,a){return s.setMonth(a,1),s.setHours(0,0,0,0),s}}function pyt(e,t,s){const n=Hn(e),a=Pve(n,s)-t;return n.setDate(n.getDate()-a*7),n}class gyt extends Ao{constructor(){super(...arguments);on(this,"priority",100);on(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(s,n,a){switch(n){case"w":return Kl(zc.week,s);case"wo":return a.ordinalNumber(s,{unit:"week"});default:return Nc(n.length,s)}}validate(s,n){return n>=1&&n<=53}set(s,n,a,o){return Hm(pyt(s,a,o),o)}}function xyt(e,t){const s=Hn(e),n=Eve(s)-t;return s.setDate(s.getDate()-n*7),s}class yyt extends Ao{constructor(){super(...arguments);on(this,"priority",100);on(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"])}parse(s,n,a){switch(n){case"I":return Kl(zc.week,s);case"Io":return a.ordinalNumber(s,{unit:"week"});default:return Nc(n.length,s)}}validate(s,n){return n>=1&&n<=53}set(s,n,a){return n0(xyt(s,a))}}const vyt=[31,28,31,30,31,30,31,31,30,31,30,31],_yt=[31,29,31,30,31,30,31,31,30,31,30,31];class byt extends Ao{constructor(){super(...arguments);on(this,"priority",90);on(this,"subPriority",1);on(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(s,n,a){switch(n){case"d":return Kl(zc.date,s);case"do":return a.ordinalNumber(s,{unit:"date"});default:return Nc(n.length,s)}}validate(s,n){const a=s.getFullYear(),o=S7e(a),l=s.getMonth();return o?n>=1&&n<=_yt[l]:n>=1&&n<=vyt[l]}set(s,n,a){return s.setDate(a),s.setHours(0,0,0,0),s}}class wyt extends Ao{constructor(){super(...arguments);on(this,"priority",90);on(this,"subpriority",1);on(this,"incompatibleTokens",["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"])}parse(s,n,a){switch(n){case"D":case"DD":return Kl(zc.dayOfYear,s);case"Do":return a.ordinalNumber(s,{unit:"date"});default:return Nc(n.length,s)}}validate(s,n){const a=s.getFullYear();return S7e(a)?n>=1&&n<=366:n>=1&&n<=365}set(s,n,a){return s.setMonth(0,a),s.setHours(0,0,0,0),s}}function Dve(e,t,s){var g,v,_,k;const n=a_(),a=(s==null?void 0:s.weekStartsOn)??((v=(g=s==null?void 0:s.locale)==null?void 0:g.options)==null?void 0:v.weekStartsOn)??n.weekStartsOn??((k=(_=n.locale)==null?void 0:_.options)==null?void 0:k.weekStartsOn)??0,o=Hn(e),l=o.getDay(),d=(t%7+7)%7,m=7-a,p=t<0||t>6?t-(l+m)%7:(d+m)%7-(l+m)%7;return dc(o,p)}class jyt extends Ao{constructor(){super(...arguments);on(this,"priority",90);on(this,"incompatibleTokens",["D","i","e","c","t","T"])}parse(s,n,a){switch(n){case"E":case"EE":case"EEE":return a.day(s,{width:"abbreviated",context:"formatting"})||a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"});case"EEEEE":return a.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"});case"EEEE":default:return a.day(s,{width:"wide",context:"formatting"})||a.day(s,{width:"abbreviated",context:"formatting"})||a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"})}}validate(s,n){return n>=0&&n<=6}set(s,n,a,o){return s=Dve(s,a,o),s.setHours(0,0,0,0),s}}class kyt extends Ao{constructor(){super(...arguments);on(this,"priority",90);on(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"])}parse(s,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 Bc(Nc(n.length,s),l);case"eo":return Bc(a.ordinalNumber(s,{unit:"day"}),l);case"eee":return a.day(s,{width:"abbreviated",context:"formatting"})||a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"});case"eeeee":return a.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"});case"eeee":default:return a.day(s,{width:"wide",context:"formatting"})||a.day(s,{width:"abbreviated",context:"formatting"})||a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"})}}validate(s,n){return n>=0&&n<=6}set(s,n,a,o){return s=Dve(s,a,o),s.setHours(0,0,0,0),s}}class Nyt extends Ao{constructor(){super(...arguments);on(this,"priority",90);on(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"])}parse(s,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 Bc(Nc(n.length,s),l);case"co":return Bc(a.ordinalNumber(s,{unit:"day"}),l);case"ccc":return a.day(s,{width:"abbreviated",context:"standalone"})||a.day(s,{width:"short",context:"standalone"})||a.day(s,{width:"narrow",context:"standalone"});case"ccccc":return a.day(s,{width:"narrow",context:"standalone"});case"cccccc":return a.day(s,{width:"short",context:"standalone"})||a.day(s,{width:"narrow",context:"standalone"});case"cccc":default:return a.day(s,{width:"wide",context:"standalone"})||a.day(s,{width:"abbreviated",context:"standalone"})||a.day(s,{width:"short",context:"standalone"})||a.day(s,{width:"narrow",context:"standalone"})}}validate(s,n){return n>=0&&n<=6}set(s,n,a,o){return s=Dve(s,a,o),s.setHours(0,0,0,0),s}}function Syt(e,t){const s=Hn(e),n=Xxt(s),a=t-n;return dc(s,a)}class Cyt extends Ao{constructor(){super(...arguments);on(this,"priority",90);on(this,"incompatibleTokens",["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"])}parse(s,n,a){const o=l=>l===0?7:l;switch(n){case"i":case"ii":return Nc(n.length,s);case"io":return a.ordinalNumber(s,{unit:"day"});case"iii":return Bc(a.day(s,{width:"abbreviated",context:"formatting"})||a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"}),o);case"iiiii":return Bc(a.day(s,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Bc(a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Bc(a.day(s,{width:"wide",context:"formatting"})||a.day(s,{width:"abbreviated",context:"formatting"})||a.day(s,{width:"short",context:"formatting"})||a.day(s,{width:"narrow",context:"formatting"}),o)}}validate(s,n){return n>=1&&n<=7}set(s,n,a){return s=Syt(s,a),s.setHours(0,0,0,0),s}}class Myt extends Ao{constructor(){super(...arguments);on(this,"priority",80);on(this,"incompatibleTokens",["b","B","H","k","t","T"])}parse(s,n,a){switch(n){case"a":case"aa":case"aaa":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"})||a.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaaa":return a.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return a.dayPeriod(s,{width:"wide",context:"formatting"})||a.dayPeriod(s,{width:"abbreviated",context:"formatting"})||a.dayPeriod(s,{width:"narrow",context:"formatting"})}}set(s,n,a){return s.setHours(Lve(a),0,0,0),s}}class Tyt extends Ao{constructor(){super(...arguments);on(this,"priority",80);on(this,"incompatibleTokens",["a","B","H","k","t","T"])}parse(s,n,a){switch(n){case"b":case"bb":case"bbb":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"})||a.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbbb":return a.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return a.dayPeriod(s,{width:"wide",context:"formatting"})||a.dayPeriod(s,{width:"abbreviated",context:"formatting"})||a.dayPeriod(s,{width:"narrow",context:"formatting"})}}set(s,n,a){return s.setHours(Lve(a),0,0,0),s}}class Ayt extends Ao{constructor(){super(...arguments);on(this,"priority",80);on(this,"incompatibleTokens",["a","b","t","T"])}parse(s,n,a){switch(n){case"B":case"BB":case"BBB":return a.dayPeriod(s,{width:"abbreviated",context:"formatting"})||a.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBBB":return a.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return a.dayPeriod(s,{width:"wide",context:"formatting"})||a.dayPeriod(s,{width:"abbreviated",context:"formatting"})||a.dayPeriod(s,{width:"narrow",context:"formatting"})}}set(s,n,a){return s.setHours(Lve(a),0,0,0),s}}class Eyt extends Ao{constructor(){super(...arguments);on(this,"priority",70);on(this,"incompatibleTokens",["H","K","k","t","T"])}parse(s,n,a){switch(n){case"h":return Kl(zc.hour12h,s);case"ho":return a.ordinalNumber(s,{unit:"hour"});default:return Nc(n.length,s)}}validate(s,n){return n>=1&&n<=12}set(s,n,a){const o=s.getHours()>=12;return o&&a<12?s.setHours(a+12,0,0,0):!o&&a===12?s.setHours(0,0,0,0):s.setHours(a,0,0,0),s}}class Iyt extends Ao{constructor(){super(...arguments);on(this,"priority",70);on(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(s,n,a){switch(n){case"H":return Kl(zc.hour23h,s);case"Ho":return a.ordinalNumber(s,{unit:"hour"});default:return Nc(n.length,s)}}validate(s,n){return n>=0&&n<=23}set(s,n,a){return s.setHours(a,0,0,0),s}}class Pyt extends Ao{constructor(){super(...arguments);on(this,"priority",70);on(this,"incompatibleTokens",["h","H","k","t","T"])}parse(s,n,a){switch(n){case"K":return Kl(zc.hour11h,s);case"Ko":return a.ordinalNumber(s,{unit:"hour"});default:return Nc(n.length,s)}}validate(s,n){return n>=0&&n<=11}set(s,n,a){return s.getHours()>=12&&a<12?s.setHours(a+12,0,0,0):s.setHours(a,0,0,0),s}}class Lyt extends Ao{constructor(){super(...arguments);on(this,"priority",70);on(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(s,n,a){switch(n){case"k":return Kl(zc.hour24h,s);case"ko":return a.ordinalNumber(s,{unit:"hour"});default:return Nc(n.length,s)}}validate(s,n){return n>=1&&n<=24}set(s,n,a){const o=a<=24?a%24:a;return s.setHours(o,0,0,0),s}}class Dyt extends Ao{constructor(){super(...arguments);on(this,"priority",60);on(this,"incompatibleTokens",["t","T"])}parse(s,n,a){switch(n){case"m":return Kl(zc.minute,s);case"mo":return a.ordinalNumber(s,{unit:"minute"});default:return Nc(n.length,s)}}validate(s,n){return n>=0&&n<=59}set(s,n,a){return s.setMinutes(a,0,0),s}}class Oyt extends Ao{constructor(){super(...arguments);on(this,"priority",50);on(this,"incompatibleTokens",["t","T"])}parse(s,n,a){switch(n){case"s":return Kl(zc.second,s);case"so":return a.ordinalNumber(s,{unit:"second"});default:return Nc(n.length,s)}}validate(s,n){return n>=0&&n<=59}set(s,n,a){return s.setSeconds(a,0),s}}class Ryt extends Ao{constructor(){super(...arguments);on(this,"priority",30);on(this,"incompatibleTokens",["t","T"])}parse(s,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Bc(Nc(n.length,s),a)}set(s,n,a){return s.setMilliseconds(a),s}}class Fyt extends Ao{constructor(){super(...arguments);on(this,"priority",10);on(this,"incompatibleTokens",["t","T","x"])}parse(s,n){switch(n){case"X":return tx(ex.basicOptionalMinutes,s);case"XX":return tx(ex.basic,s);case"XXXX":return tx(ex.basicOptionalSeconds,s);case"XXXXX":return tx(ex.extendedOptionalSeconds,s);case"XXX":default:return tx(ex.extended,s)}}set(s,n,a){return n.timestampIsSet?s:Bo(s,s.getTime()-q1(s)-a)}}class zyt extends Ao{constructor(){super(...arguments);on(this,"priority",10);on(this,"incompatibleTokens",["t","T","X"])}parse(s,n){switch(n){case"x":return tx(ex.basicOptionalMinutes,s);case"xx":return tx(ex.basic,s);case"xxxx":return tx(ex.basicOptionalSeconds,s);case"xxxxx":return tx(ex.extendedOptionalSeconds,s);case"xxx":default:return tx(ex.extended,s)}}set(s,n,a){return n.timestampIsSet?s:Bo(s,s.getTime()-q1(s)-a)}}class Byt extends Ao{constructor(){super(...arguments);on(this,"priority",40);on(this,"incompatibleTokens","*")}parse(s){return k7e(s)}set(s,n,a){return[Bo(s,a*1e3),{timestampIsSet:!0}]}}class $yt extends Ao{constructor(){super(...arguments);on(this,"priority",20);on(this,"incompatibleTokens","*")}parse(s){return k7e(s)}set(s,n,a){return[Bo(s,a),{timestampIsSet:!0}]}}const Uyt={G:new iyt,y:new oyt,Y:new lyt,R:new cyt,u:new dyt,Q:new uyt,q:new hyt,M:new myt,L:new fyt,w:new gyt,I:new yyt,d:new byt,D:new wyt,E:new jyt,e:new kyt,c:new Nyt,i:new Cyt,a:new Myt,b:new Tyt,B:new Ayt,h:new Eyt,H:new Iyt,K:new Pyt,k:new Lyt,m:new Dyt,s:new Oyt,S:new Ryt,X:new Fyt,x:new zyt,t:new Byt,T:new $yt},Vyt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,qyt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Hyt=/^'([^]*?)'?$/,Wyt=/''/g,Gyt=/\S/,Kyt=/[a-zA-Z]/;function Ove(e,t,s,n){var w,S,T,C;const a=Yxt(),o=a.locale??jie,l=a.firstWeekContainsDate??((S=(w=a.locale)==null?void 0:w.options)==null?void 0:S.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(T=a.locale)==null?void 0:T.options)==null?void 0:C.weekStartsOn)??0;if(t==="")return e===""?Hn(s):Bo(s,NaN);const d={firstWeekContainsDate:l,weekStartsOn:i,locale:o},m=[new ayt],p=t.match(qyt).map(I=>{const R=I[0];if(R in xpe){const D=xpe[R];return D(I,o.formatLong)}return I}).join("").match(Vyt),g=[];for(let I of p){w7e(I)&&ype(I,t,e),b7e(I)&&ype(I,t,e);const R=I[0],D=Uyt[R];if(D){const{incompatibleTokens:B}=D;if(Array.isArray(B)){const q=g.find(W=>B.includes(W.token)||W.token===R);if(q)throw new RangeError(`The format string mustn't contain \`${q.fullToken}\` and \`${I}\` at the same time`)}else if(D.incompatibleTokens==="*"&&g.length>0)throw new RangeError(`The format string mustn't contain \`${I}\` and any other token at the same time`);g.push({token:R,fullToken:I});const $=D.run(e,I,o.match,d);if(!$)return Bo(s,NaN);m.push($.setter),e=$.rest}else{if(R.match(Kyt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+R+"`");if(I==="''"?I="'":R==="'"&&(I=Zyt(I)),e.indexOf(I)===0)e=e.slice(I.length);else return Bo(s,NaN)}}if(e.length>0&&Gyt.test(e))return Bo(s,NaN);const v=m.map(I=>I.priority).sort((I,R)=>R-I).filter((I,R,D)=>D.indexOf(I)===R).map(I=>m.filter(R=>R.priority===I).sort((R,D)=>D.subPriority-R.subPriority)).map(I=>I[0]);let _=Hn(s);if(isNaN(_.getTime()))return Bo(s,NaN);const k={};for(const I of v){if(!I.validate(_,d))return Bo(s,NaN);const R=I.set(_,k,d);Array.isArray(R)?(_=R[0],Object.assign(k,R[1])):_=R}return Bo(s,_)}function Zyt(e){return e.match(Hyt)[1].replace(Wyt,"'")}function Rve(e){return+Hn(e)o-l);return s>=n&&s<=a}function Sue(e,t){return dc(e,-t)}function Cue(e,t){const s=Hn(e),n=s.getFullYear(),a=s.getDate(),o=Bo(e,0);o.setFullYear(n,t,15),o.setHours(0,0,0,0);const l=Zxt(o);return s.setMonth(t,Math.min(a,l)),s}function C7e(e,t){const s=Hn(e);return s.setHours(t),s}function M7e(e,t){const s=Hn(e);return s.setMinutes(t),s}function g4e(e,t){const s=Hn(e);return isNaN(+s)?Bo(e,NaN):(s.setFullYear(t),s)}function Xyt(e,t){return rm(e,-12)}var jo;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function s(a){throw new Error}e.assertNever=s,e.arrayToEnum=a=>{const o={};for(const l of a)o[l]=l;return o},e.getValidEnumValues=a=>{const o=e.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),l={};for(const i of o)l[i]=a[i];return e.objectValues(l)},e.objectValues=a=>e.objectKeys(a).map(function(o){return a[o]}),e.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},e.find=(a,o)=>{for(const l of a)if(o(l))return l},e.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)}e.joinValues=n,e.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(jo||(jo={}));var x4e;(function(e){e.mergeShapes=(t,s)=>({...t,...s})})(x4e||(x4e={}));const Zn=jo.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Sv=e=>{switch(typeof e){case"undefined":return Zn.undefined;case"string":return Zn.string;case"number":return Number.isNaN(e)?Zn.nan:Zn.number;case"boolean":return Zn.boolean;case"function":return Zn.function;case"bigint":return Zn.bigint;case"symbol":return Zn.symbol;case"object":return Array.isArray(e)?Zn.array:e===null?Zn.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Zn.promise:typeof Map<"u"&&e instanceof Map?Zn.map:typeof Set<"u"&&e instanceof Set?Zn.set:typeof Date<"u"&&e instanceof Date?Zn.date:Zn.object;default:return Zn.unknown}},$s=jo.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 kx extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=t}format(t){const s=t||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(s(l));else{let i=n,d=0;for(;ds.message){const s={},n=[];for(const a of this.issues)if(a.path.length>0){const o=a.path[0];s[o]=s[o]||[],s[o].push(t(a))}else n.push(t(a));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}kx.create=e=>new kx(e);const vpe=(e,t)=>{let s;switch(e.code){case $s.invalid_type:e.received===Zn.undefined?s="Required":s=`Expected ${e.expected}, received ${e.received}`;break;case $s.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,jo.jsonStringifyReplacer)}`;break;case $s.unrecognized_keys:s=`Unrecognized key(s) in object: ${jo.joinValues(e.keys,", ")}`;break;case $s.invalid_union:s="Invalid input";break;case $s.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${jo.joinValues(e.options)}`;break;case $s.invalid_enum_value:s=`Invalid enum value. Expected ${jo.joinValues(e.options)}, received '${e.received}'`;break;case $s.invalid_arguments:s="Invalid function arguments";break;case $s.invalid_return_type:s="Invalid function return type";break;case $s.invalid_date:s="Invalid date";break;case $s.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:jo.assertNever(e.validation):e.validation!=="regex"?s=`Invalid ${e.validation}`:s="Invalid";break;case $s.too_small:e.type==="array"?s=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?s=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?s=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?s=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?s=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:s="Invalid input";break;case $s.too_big:e.type==="array"?s=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?s=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?s=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?s=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?s=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:s="Invalid input";break;case $s.custom:s="Invalid input";break;case $s.invalid_intersection_types:s="Intersection results could not be merged";break;case $s.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case $s.not_finite:s="Number must be finite";break;default:s=t.defaultError,jo.assertNever(e)}return{message:s}};let Qyt=vpe;function Jyt(){return Qyt}const e0t=e=>{const{data:t,path:s,errorMaps:n,issueData:a}=e,o=[...s,...a.path||[]],l={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="";const d=n.filter(m=>!!m).slice().reverse();for(const m of d)i=m(l,{data:t,defaultError:i}).message;return{...a,path:o,message:i}};function Tn(e,t){const s=Jyt(),n=e0t({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===vpe?void 0:vpe].filter(a=>!!a)});e.common.issues.push(n)}class Gm{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,s){const n=[];for(const a of s){if(a.status==="aborted")return di;a.status==="dirty"&&t.dirty(),n.push(a.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,s){const n=[];for(const a of s){const o=await a.key,l=await a.value;n.push({key:o,value:l})}return Gm.mergeObjectSync(t,n)}static mergeObjectSync(t,s){const n={};for(const a of s){const{key:o,value:l}=a;if(o.status==="aborted"||l.status==="aborted")return di;o.status==="dirty"&&t.dirty(),l.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof l.value<"u"||a.alwaysSet)&&(n[o.value]=l.value)}return{status:t.value,value:n}}}const di=Object.freeze({status:"aborted"}),HA=e=>({status:"dirty",value:e}),Zf=e=>({status:"valid",value:e}),y4e=e=>e.status==="aborted",v4e=e=>e.status==="dirty",I5=e=>e.status==="valid",mse=e=>typeof Promise<"u"&&e instanceof Promise;var aa;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(aa||(aa={}));class H1{constructor(t,s,n,a){this._cachedPath=[],this.parent=t,this.data=s,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 _4e=(e,t)=>{if(I5(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new kx(e.common.issues);return this._error=s,this._error}}};function zi(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:n,description:a}=e;if(t&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(l,i)=>{const{message:d}=e;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??s??i.defaultError}},description:a}}class _o{get description(){return this._def.description}_getType(t){return Sv(t.data)}_getOrReturnCtx(t,s){return s||{common:t.parent.common,data:t.data,parsedType:Sv(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Gm,ctx:{common:t.parent.common,data:t.data,parsedType:Sv(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const s=this._parse(t);if(mse(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(t){const s=this._parse(t);return Promise.resolve(s)}parse(t,s){const n=this.safeParse(t,s);if(n.success)return n.data;throw n.error}safeParse(t,s){const n={common:{issues:[],async:(s==null?void 0:s.async)??!1,contextualErrorMap:s==null?void 0:s.errorMap},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Sv(t)},a=this._parseSync({data:t,path:n.path,parent:n});return _4e(n,a)}"~validate"(t){var n,a;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Sv(t)};if(!this["~standard"].async)try{const o=this._parseSync({data:t,path:[],parent:s});return I5(o)?{value:o.value}:{issues:s.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),s.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:s}).then(o=>I5(o)?{value:o.value}:{issues:s.common.issues})}async parseAsync(t,s){const n=await this.safeParseAsync(t,s);if(n.success)return n.data;throw n.error}async safeParseAsync(t,s){const n={common:{issues:[],contextualErrorMap:s==null?void 0:s.errorMap,async:!0},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Sv(t)},a=this._parse({data:t,path:n.path,parent:n}),o=await(mse(a)?a:Promise.resolve(a));return _4e(n,o)}refine(t,s){const n=a=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(a):s;return this._refinement((a,o)=>{const l=t(a),i=()=>o.addIssue({code:$s.custom,...n(a)});return typeof Promise<"u"&&l instanceof Promise?l.then(d=>d?!0:(i(),!1)):l?!0:(i(),!1)})}refinement(t,s){return this._refinement((n,a)=>t(n)?!0:(a.addIssue(typeof s=="function"?s(n,a):s),!1))}_refinement(t){return new D5({schema:this,typeName:hi.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:s=>this["~validate"](s)}}optional(){return E1.create(this,this._def)}nullable(){return O5.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return yx.create(this)}promise(){return xse.create(this,this._def)}or(t){return pse.create([this,t],this._def)}and(t){return gse.create(this,t,this._def)}transform(t){return new D5({...zi(this._def),schema:this,typeName:hi.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const s=typeof t=="function"?t:()=>t;return new jpe({...zi(this._def),innerType:this,defaultValue:s,typeName:hi.ZodDefault})}brand(){return new j0t({typeName:hi.ZodBranded,type:this,...zi(this._def)})}catch(t){const s=typeof t=="function"?t:()=>t;return new kpe({...zi(this._def),innerType:this,catchValue:s,typeName:hi.ZodCatch})}describe(t){const s=this.constructor;return new s({...this._def,description:t})}pipe(t){return zve.create(this,t)}readonly(){return Npe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const t0t=/^c[^\s-]{8,}$/i,r0t=/^[0-9a-z]+$/,s0t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,n0t=/^[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,a0t=/^[a-z0-9_-]{21}$/i,i0t=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,o0t=/^[-+]?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)?)??$/,l0t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,c0t="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Mue;const d0t=/^(?:(?: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])$/,u0t=/^(?:(?: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])$/,h0t=/^(([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]))$/,m0t=/^(([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])$/,f0t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,p0t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,T7e="((\\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])))",g0t=new RegExp(`^${T7e}$`);function A7e(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const s=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${s}`}function x0t(e){return new RegExp(`^${A7e(e)}$`)}function y0t(e){let t=`${T7e}T${A7e(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function v0t(e,t){return!!((t==="v4"||!t)&&d0t.test(e)||(t==="v6"||!t)&&h0t.test(e))}function _0t(e,t){if(!i0t.test(e))return!1;try{const[s]=e.split(".");if(!s)return!1;const n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.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||t&&a.alg!==t)}catch{return!1}}function b0t(e,t){return!!((t==="v4"||!t)&&u0t.test(e)||(t==="v6"||!t)&&m0t.test(e))}class r1 extends _o{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Zn.string){const o=this._getOrReturnCtx(t);return Tn(o,{code:$s.invalid_type,expected:Zn.string,received:o.parsedType}),di}const n=new Gm;let a;for(const o of this._def.checks)if(o.kind==="min")t.data.lengtho.value&&(a=this._getOrReturnCtx(t,a),Tn(a,{code:$s.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){const l=t.data.length>o.value,i=t.data.lengtht.test(a),{validation:s,code:$s.invalid_string,...aa.errToObj(n)})}_addCheck(t){return new r1({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...aa.errToObj(t)})}url(t){return this._addCheck({kind:"url",...aa.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...aa.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...aa.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...aa.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...aa.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...aa.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...aa.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...aa.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...aa.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...aa.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...aa.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...aa.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...aa.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...aa.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...aa.errToObj(t)})}regex(t,s){return this._addCheck({kind:"regex",regex:t,...aa.errToObj(s)})}includes(t,s){return this._addCheck({kind:"includes",value:t,position:s==null?void 0:s.position,...aa.errToObj(s==null?void 0:s.message)})}startsWith(t,s){return this._addCheck({kind:"startsWith",value:t,...aa.errToObj(s)})}endsWith(t,s){return this._addCheck({kind:"endsWith",value:t,...aa.errToObj(s)})}min(t,s){return this._addCheck({kind:"min",value:t,...aa.errToObj(s)})}max(t,s){return this._addCheck({kind:"max",value:t,...aa.errToObj(s)})}length(t,s){return this._addCheck({kind:"length",value:t,...aa.errToObj(s)})}nonempty(t){return this.min(1,aa.errToObj(t))}trim(){return new r1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r1({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t}get maxLength(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.valuenew r1({checks:[],typeName:hi.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...zi(e)});function w0t(e,t){const s=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,a=s>n?s:n,o=Number.parseInt(e.toFixed(a).replace(".","")),l=Number.parseInt(t.toFixed(a).replace(".",""));return o%l/10**a}class P5 extends _o{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Zn.number){const o=this._getOrReturnCtx(t);return Tn(o,{code:$s.invalid_type,expected:Zn.number,received:o.parsedType}),di}let n;const a=new Gm;for(const o of this._def.checks)o.kind==="int"?jo.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),Tn(n,{code:$s.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),Tn(n,{code:$s.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?w0t(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),Tn(n,{code:$s.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),Tn(n,{code:$s.not_finite,message:o.message}),a.dirty()):jo.assertNever(o);return{status:a.value,value:t.data}}gte(t,s){return this.setLimit("min",t,!0,aa.toString(s))}gt(t,s){return this.setLimit("min",t,!1,aa.toString(s))}lte(t,s){return this.setLimit("max",t,!0,aa.toString(s))}lt(t,s){return this.setLimit("max",t,!1,aa.toString(s))}setLimit(t,s,n,a){return new P5({...this._def,checks:[...this._def.checks,{kind:t,value:s,inclusive:n,message:aa.toString(a)}]})}_addCheck(t){return new P5({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:aa.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:aa.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:aa.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:aa.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:aa.toString(t)})}multipleOf(t,s){return this._addCheck({kind:"multipleOf",value:t,message:aa.toString(s)})}finite(t){return this._addCheck({kind:"finite",message:aa.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:aa.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:aa.toString(t)})}get minValue(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t}get maxValue(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.valuet.kind==="int"||t.kind==="multipleOf"&&jo.isInteger(t.value))}get isFinite(){let t=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(t===null||n.valuenew P5({checks:[],typeName:hi.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...zi(e)});class XI extends _o{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Zn.bigint)return this._getInvalidInput(t);let n;const a=new Gm;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?t.datao.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),Tn(n,{code:$s.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),Tn(n,{code:$s.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):jo.assertNever(o);return{status:a.value,value:t.data}}_getInvalidInput(t){const s=this._getOrReturnCtx(t);return Tn(s,{code:$s.invalid_type,expected:Zn.bigint,received:s.parsedType}),di}gte(t,s){return this.setLimit("min",t,!0,aa.toString(s))}gt(t,s){return this.setLimit("min",t,!1,aa.toString(s))}lte(t,s){return this.setLimit("max",t,!0,aa.toString(s))}lt(t,s){return this.setLimit("max",t,!1,aa.toString(s))}setLimit(t,s,n,a){return new XI({...this._def,checks:[...this._def.checks,{kind:t,value:s,inclusive:n,message:aa.toString(a)}]})}_addCheck(t){return new XI({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:aa.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:aa.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:aa.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:aa.toString(t)})}multipleOf(t,s){return this._addCheck({kind:"multipleOf",value:t,message:aa.toString(s)})}get minValue(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t}get maxValue(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.valuenew XI({checks:[],typeName:hi.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...zi(e)});class _pe extends _o{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Zn.boolean){const n=this._getOrReturnCtx(t);return Tn(n,{code:$s.invalid_type,expected:Zn.boolean,received:n.parsedType}),di}return Zf(t.data)}}_pe.create=e=>new _pe({typeName:hi.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...zi(e)});class fse extends _o{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Zn.date){const o=this._getOrReturnCtx(t);return Tn(o,{code:$s.invalid_type,expected:Zn.date,received:o.parsedType}),di}if(Number.isNaN(t.data.getTime())){const o=this._getOrReturnCtx(t);return Tn(o,{code:$s.invalid_date}),di}const n=new Gm;let a;for(const o of this._def.checks)o.kind==="min"?t.data.getTime()o.value&&(a=this._getOrReturnCtx(t,a),Tn(a,{code:$s.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):jo.assertNever(o);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new fse({...this._def,checks:[...this._def.checks,t]})}min(t,s){return this._addCheck({kind:"min",value:t.getTime(),message:aa.toString(s)})}max(t,s){return this._addCheck({kind:"max",value:t.getTime(),message:aa.toString(s)})}get minDate(){let t=null;for(const s of this._def.checks)s.kind==="min"&&(t===null||s.value>t)&&(t=s.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const s of this._def.checks)s.kind==="max"&&(t===null||s.valuenew fse({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:hi.ZodDate,...zi(e)});class b4e extends _o{_parse(t){if(this._getType(t)!==Zn.symbol){const n=this._getOrReturnCtx(t);return Tn(n,{code:$s.invalid_type,expected:Zn.symbol,received:n.parsedType}),di}return Zf(t.data)}}b4e.create=e=>new b4e({typeName:hi.ZodSymbol,...zi(e)});class w4e extends _o{_parse(t){if(this._getType(t)!==Zn.undefined){const n=this._getOrReturnCtx(t);return Tn(n,{code:$s.invalid_type,expected:Zn.undefined,received:n.parsedType}),di}return Zf(t.data)}}w4e.create=e=>new w4e({typeName:hi.ZodUndefined,...zi(e)});class j4e extends _o{_parse(t){if(this._getType(t)!==Zn.null){const n=this._getOrReturnCtx(t);return Tn(n,{code:$s.invalid_type,expected:Zn.null,received:n.parsedType}),di}return Zf(t.data)}}j4e.create=e=>new j4e({typeName:hi.ZodNull,...zi(e)});class k4e extends _o{constructor(){super(...arguments),this._any=!0}_parse(t){return Zf(t.data)}}k4e.create=e=>new k4e({typeName:hi.ZodAny,...zi(e)});class N4e extends _o{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Zf(t.data)}}N4e.create=e=>new N4e({typeName:hi.ZodUnknown,...zi(e)});class W1 extends _o{_parse(t){const s=this._getOrReturnCtx(t);return Tn(s,{code:$s.invalid_type,expected:Zn.never,received:s.parsedType}),di}}W1.create=e=>new W1({typeName:hi.ZodNever,...zi(e)});class S4e extends _o{_parse(t){if(this._getType(t)!==Zn.undefined){const n=this._getOrReturnCtx(t);return Tn(n,{code:$s.invalid_type,expected:Zn.void,received:n.parsedType}),di}return Zf(t.data)}}S4e.create=e=>new S4e({typeName:hi.ZodVoid,...zi(e)});class yx extends _o{_parse(t){const{ctx:s,status:n}=this._processInputParams(t),a=this._def;if(s.parsedType!==Zn.array)return Tn(s,{code:$s.invalid_type,expected:Zn.array,received:s.parsedType}),di;if(a.exactLength!==null){const l=s.data.length>a.exactLength.value,i=s.data.lengtha.maxLength.value&&(Tn(s,{code:$s.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((l,i)=>a.type._parseAsync(new H1(s,l,s.path,i)))).then(l=>Gm.mergeArray(n,l));const o=[...s.data].map((l,i)=>a.type._parseSync(new H1(s,l,s.path,i)));return Gm.mergeArray(n,o)}get element(){return this._def.type}min(t,s){return new yx({...this._def,minLength:{value:t,message:aa.toString(s)}})}max(t,s){return new yx({...this._def,maxLength:{value:t,message:aa.toString(s)}})}length(t,s){return new yx({...this._def,exactLength:{value:t,message:aa.toString(s)}})}nonempty(t){return this.min(1,t)}}yx.create=(e,t)=>new yx({type:e,minLength:null,maxLength:null,exactLength:null,typeName:hi.ZodArray,...zi(t)});function PC(e){if(e instanceof td){const t={};for(const s in e.shape){const n=e.shape[s];t[s]=E1.create(PC(n))}return new td({...e._def,shape:()=>t})}else return e instanceof yx?new yx({...e._def,type:PC(e.element)}):e instanceof E1?E1.create(PC(e.unwrap())):e instanceof O5?O5.create(PC(e.unwrap())):e instanceof eN?eN.create(e.items.map(t=>PC(t))):e}class td extends _o{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),s=jo.objectKeys(t);return this._cached={shape:t,keys:s},this._cached}_parse(t){if(this._getType(t)!==Zn.object){const m=this._getOrReturnCtx(t);return Tn(m,{code:$s.invalid_type,expected:Zn.object,received:m.parsedType}),di}const{status:n,ctx:a}=this._processInputParams(t),{shape:o,keys:l}=this._getCached(),i=[];if(!(this._def.catchall instanceof W1&&this._def.unknownKeys==="strip"))for(const m in a.data)l.includes(m)||i.push(m);const d=[];for(const m of l){const p=o[m],g=a.data[m];d.push({key:{status:"valid",value:m},value:p._parse(new H1(a,g,a.path,m)),alwaysSet:m in a.data})}if(this._def.catchall instanceof W1){const m=this._def.unknownKeys;if(m==="passthrough")for(const p of i)d.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(m==="strict")i.length>0&&(Tn(a,{code:$s.unrecognized_keys,keys:i}),n.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const p of i){const g=a.data[p];d.push({key:{status:"valid",value:p},value:m._parse(new H1(a,g,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const m=[];for(const p of d){const g=await p.key,v=await p.value;m.push({key:g,value:v,alwaysSet:p.alwaysSet})}return m}).then(m=>Gm.mergeObjectSync(n,m)):Gm.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(t){return aa.errToObj,new td({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(s,n)=>{var o,l;const a=((l=(o=this._def).errorMap)==null?void 0:l.call(o,s,n).message)??n.defaultError;return s.code==="unrecognized_keys"?{message:aa.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new td({...this._def,unknownKeys:"strip"})}passthrough(){return new td({...this._def,unknownKeys:"passthrough"})}extend(t){return new td({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new td({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:hi.ZodObject})}setKey(t,s){return this.augment({[t]:s})}catchall(t){return new td({...this._def,catchall:t})}pick(t){const s={};for(const n of jo.objectKeys(t))t[n]&&this.shape[n]&&(s[n]=this.shape[n]);return new td({...this._def,shape:()=>s})}omit(t){const s={};for(const n of jo.objectKeys(this.shape))t[n]||(s[n]=this.shape[n]);return new td({...this._def,shape:()=>s})}deepPartial(){return PC(this)}partial(t){const s={};for(const n of jo.objectKeys(this.shape)){const a=this.shape[n];t&&!t[n]?s[n]=a:s[n]=a.optional()}return new td({...this._def,shape:()=>s})}required(t){const s={};for(const n of jo.objectKeys(this.shape))if(t&&!t[n])s[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof E1;)o=o._def.innerType;s[n]=o}return new td({...this._def,shape:()=>s})}keyof(){return E7e(jo.objectKeys(this.shape))}}td.create=(e,t)=>new td({shape:()=>e,unknownKeys:"strip",catchall:W1.create(),typeName:hi.ZodObject,...zi(t)});td.strictCreate=(e,t)=>new td({shape:()=>e,unknownKeys:"strict",catchall:W1.create(),typeName:hi.ZodObject,...zi(t)});td.lazycreate=(e,t)=>new td({shape:e,unknownKeys:"strip",catchall:W1.create(),typeName:hi.ZodObject,...zi(t)});class pse extends _o{_parse(t){const{ctx:s}=this._processInputParams(t),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 s.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(i=>new kx(i.ctx.common.issues));return Tn(s,{code:$s.invalid_union,unionErrors:l}),di}if(s.common.async)return Promise.all(n.map(async o=>{const l={...s,common:{...s.common,issues:[]},parent:null};return{result:await o._parseAsync({data:s.data,path:s.path,parent:l}),ctx:l}})).then(a);{let o;const l=[];for(const d of n){const m={...s,common:{...s.common,issues:[]},parent:null},p=d._parseSync({data:s.data,path:s.path,parent:m});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:m}),m.common.issues.length&&l.push(m.common.issues)}if(o)return s.common.issues.push(...o.ctx.common.issues),o.result;const i=l.map(d=>new kx(d));return Tn(s,{code:$s.invalid_union,unionErrors:i}),di}}get options(){return this._def.options}}pse.create=(e,t)=>new pse({options:e,typeName:hi.ZodUnion,...zi(t)});function bpe(e,t){const s=Sv(e),n=Sv(t);if(e===t)return{valid:!0,data:e};if(s===Zn.object&&n===Zn.object){const a=jo.objectKeys(t),o=jo.objectKeys(e).filter(i=>a.indexOf(i)!==-1),l={...e,...t};for(const i of o){const d=bpe(e[i],t[i]);if(!d.valid)return{valid:!1};l[i]=d.data}return{valid:!0,data:l}}else if(s===Zn.array&&n===Zn.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let o=0;o{if(y4e(o)||y4e(l))return di;const i=bpe(o.value,l.value);return i.valid?((v4e(o)||v4e(l))&&s.dirty(),{status:s.value,value:i.data}):(Tn(n,{code:$s.invalid_intersection_types}),di)};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}))}}gse.create=(e,t,s)=>new gse({left:e,right:t,typeName:hi.ZodIntersection,...zi(s)});class eN extends _o{_parse(t){const{status:s,ctx:n}=this._processInputParams(t);if(n.parsedType!==Zn.array)return Tn(n,{code:$s.invalid_type,expected:Zn.array,received:n.parsedType}),di;if(n.data.lengththis._def.items.length&&(Tn(n,{code:$s.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const o=[...n.data].map((l,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new H1(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>Gm.mergeArray(s,l)):Gm.mergeArray(s,o)}get items(){return this._def.items}rest(t){return new eN({...this._def,rest:t})}}eN.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new eN({items:e,typeName:hi.ZodTuple,rest:null,...zi(t)})};class C4e extends _o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:s,ctx:n}=this._processInputParams(t);if(n.parsedType!==Zn.map)return Tn(n,{code:$s.invalid_type,expected:Zn.map,received:n.parsedType}),di;const a=this._def.keyType,o=this._def.valueType,l=[...n.data.entries()].map(([i,d],m)=>({key:a._parse(new H1(n,i,n.path,[m,"key"])),value:o._parse(new H1(n,d,n.path,[m,"value"]))}));if(n.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of l){const m=await d.key,p=await d.value;if(m.status==="aborted"||p.status==="aborted")return di;(m.status==="dirty"||p.status==="dirty")&&s.dirty(),i.set(m.value,p.value)}return{status:s.value,value:i}})}else{const i=new Map;for(const d of l){const m=d.key,p=d.value;if(m.status==="aborted"||p.status==="aborted")return di;(m.status==="dirty"||p.status==="dirty")&&s.dirty(),i.set(m.value,p.value)}return{status:s.value,value:i}}}}C4e.create=(e,t,s)=>new C4e({valueType:t,keyType:e,typeName:hi.ZodMap,...zi(s)});class QI extends _o{_parse(t){const{status:s,ctx:n}=this._processInputParams(t);if(n.parsedType!==Zn.set)return Tn(n,{code:$s.invalid_type,expected:Zn.set,received:n.parsedType}),di;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Tn(n,{code:$s.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),s.dirty());const o=this._def.valueType;function l(d){const m=new Set;for(const p of d){if(p.status==="aborted")return di;p.status==="dirty"&&s.dirty(),m.add(p.value)}return{status:s.value,value:m}}const i=[...n.data.values()].map((d,m)=>o._parse(new H1(n,d,n.path,m)));return n.common.async?Promise.all(i).then(d=>l(d)):l(i)}min(t,s){return new QI({...this._def,minSize:{value:t,message:aa.toString(s)}})}max(t,s){return new QI({...this._def,maxSize:{value:t,message:aa.toString(s)}})}size(t,s){return this.min(t,s).max(t,s)}nonempty(t){return this.min(1,t)}}QI.create=(e,t)=>new QI({valueType:e,minSize:null,maxSize:null,typeName:hi.ZodSet,...zi(t)});class M4e extends _o{get schema(){return this._def.getter()}_parse(t){const{ctx:s}=this._processInputParams(t);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}M4e.create=(e,t)=>new M4e({getter:e,typeName:hi.ZodLazy,...zi(t)});class wpe extends _o{_parse(t){if(t.data!==this._def.value){const s=this._getOrReturnCtx(t);return Tn(s,{received:s.data,code:$s.invalid_literal,expected:this._def.value}),di}return{status:"valid",value:t.data}}get value(){return this._def.value}}wpe.create=(e,t)=>new wpe({value:e,typeName:hi.ZodLiteral,...zi(t)});function E7e(e,t){return new L5({values:e,typeName:hi.ZodEnum,...zi(t)})}class L5 extends _o{_parse(t){if(typeof t.data!="string"){const s=this._getOrReturnCtx(t),n=this._def.values;return Tn(s,{expected:jo.joinValues(n),received:s.parsedType,code:$s.invalid_type}),di}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const s=this._getOrReturnCtx(t),n=this._def.values;return Tn(s,{received:s.data,code:$s.invalid_enum_value,options:n}),di}return Zf(t.data)}get options(){return this._def.values}get enum(){const t={};for(const s of this._def.values)t[s]=s;return t}get Values(){const t={};for(const s of this._def.values)t[s]=s;return t}get Enum(){const t={};for(const s of this._def.values)t[s]=s;return t}extract(t,s=this._def){return L5.create(t,{...this._def,...s})}exclude(t,s=this._def){return L5.create(this.options.filter(n=>!t.includes(n)),{...this._def,...s})}}L5.create=E7e;class T4e extends _o{_parse(t){const s=jo.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==Zn.string&&n.parsedType!==Zn.number){const a=jo.objectValues(s);return Tn(n,{expected:jo.joinValues(a),received:n.parsedType,code:$s.invalid_type}),di}if(this._cache||(this._cache=new Set(jo.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const a=jo.objectValues(s);return Tn(n,{received:n.data,code:$s.invalid_enum_value,options:a}),di}return Zf(t.data)}get enum(){return this._def.values}}T4e.create=(e,t)=>new T4e({values:e,typeName:hi.ZodNativeEnum,...zi(t)});class xse extends _o{unwrap(){return this._def.type}_parse(t){const{ctx:s}=this._processInputParams(t);if(s.parsedType!==Zn.promise&&s.common.async===!1)return Tn(s,{code:$s.invalid_type,expected:Zn.promise,received:s.parsedType}),di;const n=s.parsedType===Zn.promise?s.data:Promise.resolve(s.data);return Zf(n.then(a=>this._def.type.parseAsync(a,{path:s.path,errorMap:s.common.contextualErrorMap})))}}xse.create=(e,t)=>new xse({type:e,typeName:hi.ZodPromise,...zi(t)});class D5 extends _o{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===hi.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:s,ctx:n}=this._processInputParams(t),a=this._def.effect||null,o={addIssue:l=>{Tn(n,l),l.fatal?s.abort():s.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(s.value==="aborted")return di;const d=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return d.status==="aborted"?di:d.status==="dirty"||s.value==="dirty"?HA(d.value):d});{if(s.value==="aborted")return di;const i=this._def.schema._parseSync({data:l,path:n.path,parent:n});return i.status==="aborted"?di:i.status==="dirty"||s.value==="dirty"?HA(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"?di:(i.status==="dirty"&&s.dirty(),l(i.value),{status:s.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?di:(i.status==="dirty"&&s.dirty(),l(i.value).then(()=>({status:s.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(!I5(l))return di;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:s.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>I5(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:s.value,value:i})):di);jo.assertNever(a)}}D5.create=(e,t,s)=>new D5({schema:e,typeName:hi.ZodEffects,effect:t,...zi(s)});D5.createWithPreprocess=(e,t,s)=>new D5({schema:t,effect:{type:"preprocess",transform:e},typeName:hi.ZodEffects,...zi(s)});class E1 extends _o{_parse(t){return this._getType(t)===Zn.undefined?Zf(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}E1.create=(e,t)=>new E1({innerType:e,typeName:hi.ZodOptional,...zi(t)});class O5 extends _o{_parse(t){return this._getType(t)===Zn.null?Zf(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}O5.create=(e,t)=>new O5({innerType:e,typeName:hi.ZodNullable,...zi(t)});class jpe extends _o{_parse(t){const{ctx:s}=this._processInputParams(t);let n=s.data;return s.parsedType===Zn.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}jpe.create=(e,t)=>new jpe({innerType:e,typeName:hi.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...zi(t)});class kpe extends _o{_parse(t){const{ctx:s}=this._processInputParams(t),n={...s,common:{...s.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return mse(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new kx(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new kx(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}kpe.create=(e,t)=>new kpe({innerType:e,typeName:hi.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...zi(t)});class A4e extends _o{_parse(t){if(this._getType(t)!==Zn.nan){const n=this._getOrReturnCtx(t);return Tn(n,{code:$s.invalid_type,expected:Zn.nan,received:n.parsedType}),di}return{status:"valid",value:t.data}}}A4e.create=e=>new A4e({typeName:hi.ZodNaN,...zi(e)});class j0t extends _o{_parse(t){const{ctx:s}=this._processInputParams(t),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class zve extends _o{_parse(t){const{status:s,ctx:n}=this._processInputParams(t);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"?di:o.status==="dirty"?(s.dirty(),HA(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"?di:a.status==="dirty"?(s.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(t,s){return new zve({in:t,out:s,typeName:hi.ZodPipeline})}}class Npe extends _o{_parse(t){const s=this._def.innerType._parse(t),n=a=>(I5(a)&&(a.value=Object.freeze(a.value)),a);return mse(s)?s.then(a=>n(a)):n(s)}unwrap(){return this._def.innerType}}Npe.create=(e,t)=>new Npe({innerType:e,typeName:hi.ZodReadonly,...zi(t)});var hi;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(hi||(hi={}));const zo=r1.create,KE=P5.create,k0t=_pe.create;W1.create;yx.create;const i_=td.create;pse.create;gse.create;eN.create;const R5=wpe.create,I7e=L5.create;xse.create;E1.create;O5.create;function N0t(){const t=sm().pathname.slice(1);return A.useEffect(()=>(document.body.classList.add("guestbook-page"),()=>{document.body.classList.remove("guestbook-page")}),[]),!t||t===""?r.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:r.jsxs("div",{className:"text-center text-white",children:[r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Guest Book"}),r.jsx("p",{className:"text-white/60",children:"The modern open house sign-in experience."}),r.jsx("p",{className:"text-white/40 text-sm mt-2",children:"Visit a specific open house link to sign in."})]})}):r.jsx(S0t,{slug:t})}function S0t({slug:e}){return r.jsx(T0t,{slug:e})}const C0t=i_({first_name:zo().trim().min(1,"First name is required").max(50),last_name:zo().trim().max(50).optional(),email:zo().trim().email("Please enter a valid email").max(255).optional().or(R5("")),phone:zo().trim().max(20).optional().or(R5(""))}),M0t=[{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 T0t({slug:e}){var C;const{data:t,isLoading:s,error:n}=d7e(e),a=u7e(),[o,l]=A.useState("welcome"),[i,d]=A.useState({first_name:"",last_name:"",email:"",phone:""}),[m,p]=A.useState(!1),[g,v]=A.useState(""),_=I=>{if(!I)return"";const[R,D]=I.split(":"),B=parseInt(R),$=B>=12?"PM":"AM";return`${B>12?B-12:B||12}:${D} ${$}`},k=()=>{v("");const I=C0t.safeParse(i);if(!I.success){v(I.error.issues[0].message);return}if(!i.email&&!i.phone){v("Please provide either an email or phone number");return}l("intent")},w=async I=>{try{await a.mutateAsync({open_house_id:t.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:I,wants_market_updates:m}),l("done")}catch{v("Something went wrong. Please try again.")}};if(s)return r.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:r.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(n||!t)return r.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:r.jsxs("div",{className:"text-center text-white",children:[r.jsx(Vn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),r.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const S=t.profiles,T=((C=S==null?void 0:S.name)==null?void 0:C.split(" ").map(I=>I[0]).join("").slice(0,2))||"?";return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsxs("title",{children:["Open House | ",t.property_address]}),r.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),r.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:r.jsxs("div",{className:"w-full max-w-md",children:[r.jsxs("div",{className:"text-center mb-6",children:[r.jsxs(cn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[r.jsx(xa,{src:(S==null?void 0:S.avatar_url)||"",alt:(S==null?void 0:S.name)||""}),r.jsx(dn,{className:"bg-white/10 text-white text-lg",children:T})]}),r.jsx("p",{className:"text-white/60 text-sm",children:S==null?void 0:S.name}),(S==null?void 0:S.title)&&r.jsx("p",{className:"text-white/40 text-xs",children:S.title})]}),r.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[t.photo_url&&r.jsxs("div",{className:"relative w-full h-48 overflow-hidden",children:[r.jsx("img",{src:t.photo_url,alt:t.property_address,className:"w-full h-full object-cover"}),r.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/60 to-transparent"})]}),r.jsx("div",{className:`${t.photo_url?"px-6 py-4":"px-6 py-5"} bg-gradient-to-r from-slate-800 to-slate-700`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:r.jsx(Vn,{className:"h-5 w-5 text-white"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:t.property_address}),r.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[t.city&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Yi,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""," ",t.zip]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),_(t.start_time),t.end_time?` – ${_(t.end_time)}`:""]})]})]})]})}),r.jsxs("div",{className:"p-6",children:[o==="welcome"&&r.jsxs("div",{className:"text-center space-y-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),r.jsx("p",{className:"text-slate-500 text-sm",children:t.agent_greeting||"Please sign in below."})]}),r.jsxs(X,{onClick:()=>l("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",r.jsx(Ki,{className:"h-5 w-5 ml-2"})]}),r.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),o==="info"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("button",{onClick:()=>l("welcome"),className:"text-slate-400 hover:text-slate-600",children:r.jsx(gi,{className:"h-4 w-4"})}),r.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Your Info"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"First Name *"}),r.jsx(Ye,{value:i.first_name,onChange:I=>d(R=>({...R,first_name:I.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"Last Name"}),r.jsx(Ye,{value:i.last_name,onChange:I=>d(R=>({...R,last_name:I.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"Email"}),r.jsx(Ye,{type:"email",value:i.email,onChange:I=>d(R=>({...R,email:I.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"Phone"}),r.jsx(Ye,{type:"tel",value:i.phone,onChange:I=>d(R=>({...R,phone:I.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[r.jsx("input",{type:"checkbox",checked:m,onChange:I=>p(I.target.checked),className:"rounded border-slate-300"}),r.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),g&&r.jsx("p",{className:"text-red-500 text-sm",children:g}),r.jsxs(X,{onClick:k,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",r.jsx(Ki,{className:"h-5 w-5 ml-2"})]})]}),o==="intent"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("button",{onClick:()=>l("info"),className:"text-slate-400 hover:text-slate-600",children:r.jsx(gi,{className:"h-4 w-4"})}),r.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"What brings you here?"})]}),r.jsx("div",{className:"grid grid-cols-2 gap-3",children:M0t.map(I=>r.jsxs("button",{onClick:()=>w(I.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:[r.jsx("span",{className:"text-2xl",children:I.emoji}),r.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:I.label})]},I.value))}),g&&r.jsx("p",{className:"text-red-500 text-sm text-center",children:g})]}),o==="done"&&r.jsx(A0t,{firstName:i.first_name,agentName:S==null?void 0:S.name,agentCardSlug:t.agent_card_slug})]})]}),r.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function A0t({firstName:e,agentName:t,agentCardSlug:s}){const[n,a]=A.useState(3);return A.useEffect(()=>{if(!s)return;const o=setInterval(()=>{a(l=>l<=1?(clearInterval(o),window.location.href=`https://cards.relevelup.com/${s}`,0):l-1)},1e3);return()=>clearInterval(o)},[s]),r.jsxs("div",{className:"text-center space-y-4 py-4",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:r.jsx(Ri,{className:"h-8 w-8 text-green-600"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),r.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",e,". Enjoy the open house!"]})]}),t&&r.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",r.jsx("strong",{className:"text-slate-600",children:t})]}),s&&r.jsxs("p",{className:"text-xs text-slate-400 animate-pulse",children:["Redirecting to ",t?`${t}'s`:"your agent's"," card in ",n,"s…"]})]})}function E0t({dealData:e,agentProfile:t,welcomeMessage:s,isWon:n}){var o;const a=e!=null&&e.property_address?`${e.property_address}, ${e.city||""}, ${e.state||""}`.replace(/,\s*,/g,",").replace(/,\s*$/,""):null;return r.jsxs("div",{className:"relative overflow-hidden",children:[r.jsxs("div",{className:"bg-gradient-to-br from-[#2a4c64] via-[#345e7a] to-[#406E71] text-white px-4 pt-10 pb-16",children:[r.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:"radial-gradient(circle at 25% 25%, white 1px, transparent 1px)",backgroundSize:"24px 24px"}}),r.jsxs("div",{className:"relative text-center max-w-lg mx-auto",children:[t&&r.jsxs("div",{className:"mb-6",children:[t.avatar_url?r.jsx("img",{src:t.avatar_url,alt:t.name,className:"w-20 h-20 rounded-full border-[3px] border-white/30 shadow-xl mx-auto mb-3 object-cover"}):r.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:r.jsx("span",{className:"text-2xl font-bold text-white/70",children:((o=t.name)==null?void 0:o.charAt(0))||"?"})}),r.jsx("p",{className:"text-sm font-medium text-white/90",children:t.name}),r.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:"Your Real Estate Agent"})]}),r.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:[r.jsx(Vn,{className:"w-3 h-3"}),(e==null?void 0:e.deal_type)==="listing"?"Listing":(e==null?void 0:e.deal_type)==="buy-side"?"Purchase":"Transaction"]}),r.jsx("h1",{className:"text-2xl font-bold tracking-tight mb-1.5 font-serif",children:(e==null?void 0:e.deal_name)||"Your Transaction Portal"}),a&&r.jsxs("div",{className:"flex items-center justify-center gap-1 text-white/60 text-sm",children:[r.jsx(Yi,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:a})]}),s&&r.jsx("p",{className:"mt-4 text-sm text-white/70 leading-relaxed max-w-sm mx-auto",children:s})]})]}),t&&r.jsx("div",{className:"max-w-lg mx-auto px-4 -mt-8 relative z-10",children:r.jsx("div",{className:"bg-white rounded-2xl shadow-lg border border-slate-100 p-4",children:r.jsxs("div",{className:"flex items-center justify-center gap-3",children:[t.phone&&r.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[r.jsx(fi,{className:"w-4 h-4 text-[#406E71]"}),r.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Call"})]}),t.email&&r.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[r.jsx(Vs,{className:"w-4 h-4 text-[#406E71]"}),r.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Email"})]}),t.phone&&r.jsxs("a",{href:`sms:${t.phone}`,className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-[#406E71]/10 hover:bg-[#406E71]/20 transition-colors",children:[r.jsx(Rl,{className:"w-4 h-4 text-[#406E71]"}),r.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function I0t({journeyStages:e,currentIndex:t}){return e.length===0?null:r.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[r.jsx("h2",{className:"text-base font-semibold text-slate-800 mb-1",children:"Your Home Journey"}),r.jsx("p",{className:"text-xs text-slate-400 mb-5",children:"Follow along as your transaction progresses"}),r.jsx("div",{className:"relative",children:e.map((s,n)=>{const a=nt;return r.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 r.jsxs("div",{className:"bg-gradient-to-br from-[#406E71]/5 via-white to-[#406E71]/5 rounded-2xl border border-[#406E71]/15 overflow-hidden",children:[r.jsx("div",{className:"bg-[#406E71] px-5 py-3",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ki,{className:"w-4 h-4 text-white/80"}),r.jsx("h3",{className:"text-sm font-semibold text-white",children:"Current Stage"})]})}),r.jsxs("div",{className:"p-5 space-y-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-lg font-bold text-slate-800",children:e.label}),r.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:e.description})]}),t&&r.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 border border-slate-100",children:[r.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wider mb-1.5",children:"Update from your agent"}),r.jsx("p",{className:"text-sm text-slate-700 leading-relaxed",children:t})]}),s&&r.jsxs("div",{className:"bg-blue-50/60 rounded-xl p-4 border border-blue-100",children:[r.jsx("p",{className:"text-xs font-semibold text-blue-600 uppercase tracking-wider mb-1.5",children:"What's Next"}),r.jsx("p",{className:"text-sm text-blue-800 leading-relaxed",children:s})]}),n&&r.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-900 aspect-video shadow-md",children:r.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 E4e(e){const t=e.split(/[-/T]/);return new Date(Number(t[0]),Number(t[1])-1,Number(t[2]))}function D0t(e,t){const s=Xr(t,"yyyyMMdd");return`https://calendar.google.com/calendar/render?${new URLSearchParams({action:"TEMPLATE",text:e,dates:`${s}/${s}`,details:"Added from your Client Portal"}).toString()}`}function O0t(e,t){const s=Xr(t,"yyyyMMdd");return`data:text/calendar;charset=utf-8,${encodeURIComponent(`BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT DTSTART;VALUE=DATE:${s} DTEND;VALUE=DATE:${s} SUMMARY:${e} DESCRIPTION:Added from your Client Portal END:VEVENT END:VCALENDAR`)}`}function R0t({targetCloseDate:e,contractDate:t,inspectionDate:s,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:t,icon:j4,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:s,icon:qn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Vn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||e,icon:An,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,d,m)=>{const p=E4e(d);if(m==="google")window.open(D0t(i,p),"_blank");else{const g=O0t(i,p),v=document.createElement("a");v.href=g,v.download=`${i.replace(/\s+/g,"-").toLowerCase()}.ics`,v.click()}};return r.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[r.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Key Dates"}),r.jsx("div",{className:"space-y-3",children:o.map(({label:i,date:d,icon:m,color:p})=>{const g=E4e(d),v=Rve(g)&&!Dj(g),_=Dj(g),k=!v&&!_;return r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${p}`,children:r.jsx(m,{className:"w-4 h-4"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"text-xs text-slate-500",children:i}),r.jsxs("p",{className:`text-sm font-medium ${_?"text-emerald-600":v?"text-slate-400":"text-slate-800"}`,children:[Xr(g,"MMM d, yyyy"),_&&r.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&&r.jsx("span",{className:"text-xs text-slate-400",children:"✓"}),k&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.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:r.jsx(y1,{className:"w-3.5 h-3.5"})}),r.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 F0t({documents:e}){const t=n=>n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(0)} KB`:`${(n/1048576).toFixed(1)} MB`,s=async n=>{const{data:a}=await Y.storage.from("deal-files").createSignedUrl(n.storage_path,300);a!=null&&a.signedUrl&&window.open(a.signedUrl,"_blank")};return r.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[r.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-3",children:"Documents"}),r.jsx("div",{className:"space-y-2",children:e.map(n=>r.jsxs("button",{onClick:()=>s(n),className:"w-full flex items-center gap-3 p-3 rounded-xl hover:bg-slate-50 transition-colors text-left group",children:[r.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:r.jsx(ya,{className:"w-4 h-4 text-slate-500 group-hover:text-blue-600"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium text-slate-700 truncate",children:n.file_name}),r.jsx("p",{className:"text-xs text-slate-400",children:t(n.file_size)})]}),r.jsx(Fi,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function z0t({updates:e}){const t=s=>{var n,a;if(s.includes("youtube.com/watch")){const o=new URL(s).searchParams.get("v");return o?`https://www.youtube.com/embed/${o}`:null}if(s.includes("youtu.be/")){const o=(n=s.split("youtu.be/")[1])==null?void 0:n.split("?")[0];return o?`https://www.youtube.com/embed/${o}`:null}if(s.includes("loom.com/share/")){const o=(a=s.split("loom.com/share/")[1])==null?void 0:a.split("?")[0];return o?`https://www.loom.com/embed/${o}`:null}return s};return r.jsxs("div",{className:"bg-white rounded-2xl p-5 shadow-sm border border-slate-100",children:[r.jsx("h2",{className:"text-sm font-semibold text-slate-800 mb-4",children:"Updates from Your Agent"}),r.jsx("div",{className:"space-y-4",children:e.map((s,n)=>r.jsx("div",{className:`${n>0?"pt-4 border-t border-slate-100":""}`,children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ${s.is_stage_change?"bg-emerald-100":"bg-blue-100"}`,children:s.is_stage_change?r.jsx(eg,{className:"w-3.5 h-3.5 text-emerald-600"}):r.jsx(tg,{className:"w-3.5 h-3.5 text-blue-600"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[r.jsx("h3",{className:"text-sm font-medium text-slate-800",children:s.title}),r.jsx("span",{className:"text-xs text-slate-400 flex-shrink-0",children:Xr(new Date(s.created_at),"MMM d")})]}),s.content&&r.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:s.content}),s.video_url&&r.jsx("div",{className:"mt-3 rounded-xl overflow-hidden bg-slate-900 aspect-video",children:r.jsx("iframe",{src:t(s.video_url)||s.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:s.title})})]})]})},s.id))})]})}function B0t({portal:e,dealData:t,agentProfile:s,customQuestions:n,deviceFingerprint:a,onComplete:o}){var k,w;const[l,i]=A.useState({first_name:((k=e.client_name)==null?void 0:k.split(" ")[0])||"",last_name:((w=e.client_name)==null?void 0:w.split(" ").slice(1).join(" "))||"",email:e.client_email||"",phone:e.client_phone||"",preferred_contact_method:"email",client_role:"buyer",notes:"",spouse_first_name:"",spouse_last_name:"",spouse_email:"",spouse_phone:""}),[d,m]=A.useState({}),[p,g]=A.useState(!1),v=Qt({mutationFn:async()=>{const{error:S}=await Y.from("portal_onboarding_submissions").insert({portal_id:e.id,first_name:l.first_name,last_name:l.last_name||null,email:l.email||null,phone:l.phone||null,preferred_contact_method:l.preferred_contact_method,client_role:l.client_role,notes:l.notes||null,device_fingerprint:a,custom_answers:Object.keys(d).length>0?d:null,spouse_first_name:p&&l.spouse_first_name||null,spouse_last_name:p&&l.spouse_last_name||null,spouse_email:p&&l.spouse_email||null,spouse_phone:p&&l.spouse_phone||null});if(S)throw S},onSuccess:o}),_=t!=null&&t.property_address?`${t.property_address}, ${t.city||""}, ${t.state||""}`:null;return r.jsxs("div",{className:"max-w-md mx-auto px-4 py-10",children:[r.jsxs("div",{className:"text-center mb-8",children:[(s==null?void 0:s.avatar_url)&&r.jsx("img",{src:s.avatar_url,alt:s.name,className:"w-14 h-14 rounded-full border-2 border-slate-200 mx-auto mb-3 object-cover"}),r.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Welcome to Your Portal"}),_&&r.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[r.jsx(Yi,{className:"w-3.5 h-3.5"}),r.jsx("span",{children:_.replace(/,\s*,/g,",").replace(/,\s*$/,"")})]}),r.jsx("p",{className:"text-sm text-slate-500 mt-2",children:"Please fill in your details to access your transaction portal."})]}),r.jsxs("form",{onSubmit:S=>{S.preventDefault(),v.mutate()},className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"First Name *"}),r.jsx(Ye,{required:!0,value:l.first_name,onChange:S=>i(T=>({...T,first_name:S.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Last Name"}),r.jsx(Ye,{value:l.last_name,onChange:S=>i(T=>({...T,last_name:S.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Email"}),r.jsx(Ye,{type:"email",value:l.email,onChange:S=>i(T=>({...T,email:S.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Phone"}),r.jsx(Ye,{type:"tel",value:l.phone,onChange:S=>i(T=>({...T,phone:S.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Preferred Contact Method"}),r.jsx("div",{className:"flex gap-2 mt-1.5",children:["email","phone","text"].map(S=>r.jsx("button",{type:"button",onClick:()=>i(T=>({...T,preferred_contact_method:S})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===S?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:S.charAt(0).toUpperCase()+S.slice(1)},S))})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Your Role"}),r.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(S=>r.jsx("button",{type:"button",onClick:()=>i(T=>({...T,client_role:S})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===S?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:S.charAt(0).toUpperCase()+S.slice(1)},S))})]}),n.map(S=>r.jsxs("div",{children:[r.jsxs(Ee,{className:"text-xs text-slate-600",children:[S.question_text," ",S.is_required&&"*"]}),S.field_type==="text"&&r.jsx(Ye,{required:S.is_required,value:d[S.id]||"",onChange:T=>m(C=>({...C,[S.id]:T.target.value})),className:"mt-1 rounded-xl"}),S.field_type==="textarea"&&r.jsx("textarea",{required:S.is_required,value:d[S.id]||"",onChange:T=>m(C=>({...C,[S.id]:T.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"}),S.field_type==="dropdown"&&r.jsxs("select",{required:S.is_required,value:d[S.id]||"",onChange:T=>m(C=>({...C,[S.id]:T.target.value})),className:"mt-1 w-full rounded-xl border border-input bg-background px-3 py-2 text-sm h-10",children:[r.jsx("option",{value:"",children:"Select..."}),(S.options||[]).map(T=>r.jsx("option",{value:T,children:T},T))]}),S.field_type==="toggle"&&r.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(T=>r.jsx("button",{type:"button",onClick:()=>m(C=>({...C,[S.id]:T})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${d[S.id]===T?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:T},T))})]},S.id)),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Notes for your agent"}),r.jsx("textarea",{value:l.notes,onChange:S=>i(T=>({...T,notes:S.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..."})]}),e.allow_spouse&&r.jsxs("div",{children:[r.jsx("button",{type:"button",onClick:()=>g(!p),className:"text-sm text-blue-600 hover:text-blue-700 font-medium",children:p?"− Remove spouse/partner":"+ Add spouse/partner"}),p&&r.jsxs("div",{className:"mt-3 p-4 bg-slate-50 rounded-xl space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"First Name"}),r.jsx(Ye,{value:l.spouse_first_name,onChange:S=>i(T=>({...T,spouse_first_name:S.target.value})),className:"mt-1 rounded-xl"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Last Name"}),r.jsx(Ye,{value:l.spouse_last_name,onChange:S=>i(T=>({...T,spouse_last_name:S.target.value})),className:"mt-1 rounded-xl"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Email"}),r.jsx(Ye,{type:"email",value:l.spouse_email,onChange:S=>i(T=>({...T,spouse_email:S.target.value})),className:"mt-1 rounded-xl"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-slate-600",children:"Phone"}),r.jsx(Ye,{type:"tel",value:l.spouse_phone,onChange:S=>i(T=>({...T,spouse_phone:S.target.value})),className:"mt-1 rounded-xl"})]})]})]}),r.jsx(X,{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 $0t(e){return e==="buy-side"?"Home Search in Progress":e==="listing"?"Your Home Is On The Market":"Active Phase"}function U0t(e){return e==="buy-side"?"We're actively searching for homes that match your criteria.":e==="listing"?"Your property is now being marketed to potential buyers.":"Your transaction is actively moving forward."}const V0t={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. 🎉"}},P7e=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function L7e(e){return P7e.map(t=>{if(t==="Active")return{key:"Active",label:$0t(e),description:U0t(e)};const s=V0t[t];return{key:t,label:s.label,description:s.description}})}function q0t(e){if(!e)return 0;const t=P7e.indexOf(e);return t>=0?t:0}function D7e({slug:e}){var K,re;const[t,s]=A.useState(!1),[n]=A.useState(()=>{const ae=`portal_fp_${e}`;let oe=localStorage.getItem(ae);return oe||(oe=localStorage.getItem("portal_fp"),oe?localStorage.setItem(ae,oe):(oe=crypto.randomUUID(),localStorage.setItem(ae,oe),localStorage.setItem("portal_fp",oe))),oe});A.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:a,isLoading:o,error:l}=Ht({queryKey:["client-portal-public",e],queryFn:async()=>{const{data:ae,error:oe}=await Y.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",e).eq("is_enabled",!0).maybeSingle();if(oe)throw oe;return ae}}),i=(K=a==null?void 0:a.deal_pipeline)==null?void 0:K.owner_user_id,{data:d}=Ht({queryKey:["portal-stages",i],queryFn:async()=>{const{data:ae,error:oe}=await Y.from("deal_pipeline_stages").select("*").eq("owner_user_id",i).order("sort_order",{ascending:!0});if(oe)throw oe;return ae},enabled:!!i}),{data:m}=Ht({queryKey:["portal-agent",i],queryFn:async()=>{const{data:ae,error:oe}=await Y.from("profiles").select("id, name, avatar_url, phone, email").eq("id",i).single();if(oe)throw oe;return ae},enabled:!!i}),p=a==null?void 0:a.id,{data:g}=Ht({queryKey:["portal-updates-public",p],queryFn:async()=>{const{data:ae,error:oe}=await Y.from("portal_updates").select("*").eq("portal_id",p).order("created_at",{ascending:!1});if(oe)throw oe;return ae},enabled:!!p}),v=(re=a==null?void 0:a.deal_pipeline)==null?void 0:re.id,{data:_}=Ht({queryKey:["portal-documents",v],queryFn:async()=>{const{data:ae,error:oe}=await Y.from("deal_files").select("*").eq("deal_id",v).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(oe)throw oe;return ae},enabled:!!v}),{data:k,isLoading:w}=Ht({queryKey:["portal-onboarding-check",p,n],queryFn:async()=>{const{data:ae,error:oe}=await Y.from("portal_onboarding_submissions").select("id").eq("portal_id",p).eq("device_fingerprint",n).maybeSingle();if(oe)throw oe;return ae},enabled:!!p&&!!(a!=null&&a.require_onboarding)}),{data:S}=Ht({queryKey:["portal-custom-questions-public",i],queryFn:async()=>{const{data:ae,error:oe}=await Y.from("portal_custom_questions").select("*").eq("owner_user_id",i).eq("is_active",!0).order("sort_order",{ascending:!0});if(oe)throw oe;return ae},enabled:!!i&&!!(a!=null&&a.require_onboarding)}),T=!!k||t||!(a!=null&&a.require_onboarding);if(o||a!=null&&a.require_onboarding&&w)return r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:r.jsxs("div",{className:"w-full max-w-lg mx-auto p-6 space-y-6",children:[r.jsx(pr,{className:"h-48 w-full rounded-2xl"}),r.jsx(pr,{className:"h-10 w-48 mx-auto"}),r.jsx(pr,{className:"h-32 w-full rounded-2xl"}),r.jsx(pr,{className:"h-24 w-full rounded-2xl"})]})});if(l||!a)return r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"w-16 h-16 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:r.jsx("span",{className:"text-2xl",children:"🔒"})}),r.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Available"}),r.jsx("p",{className:"text-slate-500",children:"This portal is no longer active or doesn't exist."})]})});const C=a,I=C==null?void 0:C.deal_pipeline,R=I==null?void 0:I.deal_pipeline_stages,D=R==null?void 0:R.is_won_stage,B=I==null?void 0:I.deal_type,$=L7e(B),q=q0t(R==null?void 0:R.name),W=$[q];return g==null||g.find(ae=>!ae.is_stage_change),T?r.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white pb-12",children:[r.jsx(E0t,{dealData:I,agentProfile:m,welcomeMessage:a.welcome_message,isWon:D}),r.jsxs("div",{className:"max-w-lg mx-auto px-4 space-y-5 mt-6",children:[r.jsx(P0t,{targetCloseDate:I==null?void 0:I.target_close_date,actualCloseDate:I==null?void 0:I.actual_close_date,clientName:a.client_name}),r.jsx(I0t,{journeyStages:$,currentIndex:q}),W&&r.jsx(L0t,{currentStage:W,nextStepText:a.next_step_text,nextStepVideoUrl:a.next_step_video_url}),r.jsx(R0t,{targetCloseDate:I==null?void 0:I.target_close_date,contractDate:I==null?void 0:I.contract_date,inspectionDate:a.inspection_date,appraisalDate:a.appraisal_date,actualCloseDate:I==null?void 0:I.actual_close_date}),_&&_.length>0&&r.jsx(F0t,{documents:_}),g&&g.length>0&&r.jsx(z0t,{updates:g}),D&&a.show_post_close_tips&&r.jsxs("div",{className:"bg-gradient-to-br from-emerald-50 to-teal-50 rounded-2xl p-6 border border-emerald-100 text-center",children:[r.jsx("span",{className:"text-4xl mb-3 block",children:"🎉"}),r.jsx("h3",{className:"text-lg font-bold text-emerald-900 mb-2",children:"Congratulations!"}),r.jsx("p",{className:"text-sm text-emerald-700",children:"Your transaction has been completed. Welcome to your new home!"}),a.review_url&&r.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 ⭐"})]}),r.jsxs("div",{className:"text-center pt-6 pb-2 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-slate-400",children:[r.jsx(Ou,{className:"w-3.5 h-3.5"}),r.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),m&&r.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",r.jsx("span",{className:"font-medium text-slate-500",children:m.name})]}),r.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]}):r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:r.jsx(B0t,{portal:a,dealData:I,agentProfile:m,customQuestions:S||[],deviceFingerprint:n,onComplete:()=>s(!0)})})}function H0t(){const t=sm().pathname.slice(1);return A.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>{document.body.classList.remove("client-portal-page")}),[]),!t||t===""?r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Client Portal"}),r.jsx("p",{className:"text-slate-500",children:"Visit your personalized portal link to view your transaction details."})]})}):r.jsx(D7e,{slug:t})}const Spe="levelup_affiliate_ref",W0t=30,G0t=()=>{const[e]=Cc();A.useEffect(()=>{const t=e.get("ref");if(t){const s={code:t.toUpperCase(),timestamp:Date.now()};localStorage.setItem(Spe,JSON.stringify(s)),console.log("[Affiliate] Stored referral code:",t)}},[e])},K0t=()=>{try{const e=localStorage.getItem(Spe);if(!e)return null;const t=JSON.parse(e),s=W0t*24*60*60*1e3;return Date.now()-t.timestamp>s?(localStorage.removeItem(Spe),console.log("[Affiliate] Referral code expired"),null):t.code}catch{return null}},yse="/assets/levelup-logo-header-_ZX7DvlA.png",Z0t="/assets/scale-your-team-ku4MPatU.png";function Y0t({open:e,onOpenChange:t}){return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[r.jsx(zr,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-[#4a6b6d]/10 rounded-lg",children:r.jsx(Ni,{className:"h-5 w-5 text-[#4a6b6d]"})}),r.jsxs("div",{children:[r.jsx(Fr,{children:"Schedule a Brokerage Interest Meeting"}),r.jsx(Zs,{children:"Learn how LevelUp can empower your entire team"})]})]})}),e&&r.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 zd={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"]}},X0t=[{icon:kf,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:id,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:An,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Rl,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:ya,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:po,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],Q0t=[{icon:ws,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:bn,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:fi,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Lm,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Yi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Rc,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ai,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:gx,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],J0t=[{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."}],evt=()=>{const{user:e,loading:t}=Gr(),s=Ks(),[n]=Cc();A.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=window.location.pathname==="/";if($&&q){s("/public/listings",{replace:!0});return}},[s]);const[a,o]=A.useState(null),[l,i]=A.useState(null),[d,m]=A.useState(!1),[p,g]=A.useState(""),[v,_]=A.useState(""),[k,w]=A.useState(""),[S,T]=A.useState(!1),[C,I]=A.useState(!1),R=($,q=!1)=>{i({tier:$,skipTrial:q}),m(!0)};G0t(),A.useEffect(()=>{const $=window.location.host==="listings.relevelup.com",q=location.pathname.startsWith("/public/");!t&&e&&!$&&!q&&s("/dashboard")},[e,t,s,location.pathname]),A.useEffect(()=>{n.get("canceled")==="true"&&we.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const D=async($,q=!1)=>{if(!p){we.error("Please enter your email address");return}if(!v.trim()){we.error("Please enter your full name");return}T(!0),o($+(q?"_direct":""));const W=K0t();try{const{data:K,error:re}=await Y.functions.invoke("create-checkout",{body:{tier:$,email:p,name:v.trim(),couponCode:k.trim()||void 0,skipTrial:q,referralCode:W}});if(re)throw re;if(K!=null&&K.url)window.open(K.url,"_blank","noopener,noreferrer"),we.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(K){console.error("Checkout error:",K),we.error(K.message||"Failed to start checkout. Please try again.")}finally{T(!1),o(null),m(!1),i(null)}},B=()=>{l&&D(l.tier,l.skipTrial)};return t?r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-[#4a6b6d]",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-white border-t-transparent"})}):r.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[r.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:r.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center",children:r.jsx("img",{src:yse,alt:"LevelUp",className:"h-8 md:h-10"})}),r.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[r.jsx(X,{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"}),r.jsx(X,{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"}),r.jsx(X,{onClick:()=>s("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),r.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsx("div",{className:"container mx-auto px-4 relative",children:r.jsxs("div",{className:"max-w-5xl mx-auto text-center space-y-8",children:[r.jsx("div",{className:"flex justify-center mb-8",children:r.jsx("img",{alt:"LevelUp Consulting Group",className:"h-[136px] md:h-[164px] drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),r.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.",r.jsx("br",{}),r.jsx("em",{children:"The platform you need to keep it going."})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center items-center pt-4",children:[r.jsxs(X,{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",r.jsx(Ki,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),r.jsx(X,{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"})]})]})})]}),r.jsx("section",{className:"py-20 bg-background",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[r.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."}),r.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[r.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),r.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),r.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."}),r.jsx("p",{className:"text-lg text-muted-foreground",children:"Learn how we support agents and empower brokerages to grow—together."}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center pt-4",children:[r.jsxs(X,{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:[r.jsx(Ni,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),r.jsxs(X,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[r.jsx(Fl,{className:"mr-2 h-5 w-5"}),"Individual Membership"]})]})]})})}),r.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:r.jsxs("div",{className:"container mx-auto px-4",children:[r.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[r.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),r.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:X0t.map(($,q)=>r.jsxs(ze,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[r.jsxs(Wt,{children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:r.jsx($.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),r.jsx(Zt,{className:"text-xl font-sans",children:$.title})]}),r.jsx(qe,{children:r.jsx("p",{className:"text-muted-foreground leading-relaxed",children:$.description})})]},q))})]})}),r.jsxs("section",{id:"agent-os",className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsxs("div",{className:"container mx-auto px-4 relative",children:[r.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[r.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:[r.jsx(bn,{className:"w-4 h-4"}),"Included with Membership"]}),r.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",r.jsx("span",{className:"italic",children:"Agent OS"})]}),r.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."})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:Q0t.map(($,q)=>r.jsxs(ze,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[r.jsxs(Wt,{className:"pb-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:r.jsx($.icon,{className:"w-6 h-6 text-white"})}),r.jsx(Zt,{className:"text-lg font-semibold text-white",children:$.title})]}),r.jsx(qe,{children:r.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:$.description})})]},q))}),r.jsx("div",{className:"text-center mt-12",children:r.jsxs(X,{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",r.jsx(Ki,{className:"ml-2 w-5 h-5"})]})})]})]}),r.jsx("section",{id:"brokerage",className:"py-20 bg-[#4a6b6d]/5",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsx("div",{className:"max-w-6xl mx-auto",children:r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-12 items-center",children:[r.jsxs("div",{className:"space-y-6",children:[r.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:[r.jsx(Ni,{className:"w-4 h-4"}),"For Brokerages"]}),r.jsxs("h2",{className:"text-3xl font-sans font-bold md:text-6xl",children:["Empower Your"," ",r.jsx("span",{className:"italic text-[#4a6b6d]",children:"Entire Team"})]}),r.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."}),r.jsx("ul",{className:"space-y-4",children:["Dedicated brokerage manager dashboard","Invite and manage agents with one click","Exclusive brokerage-only resources","Team analytics and performance tracking","Simplified agent onboarding","Share resources across your team"].map(($,q)=>r.jsxs("li",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center flex-shrink-0",children:r.jsx(mi,{className:"w-4 h-4 text-[#4a6b6d]"})}),r.jsx("span",{className:"text-foreground",children:$})]},q))}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[r.jsxs(X,{size:"lg",onClick:()=>{var $;return($=document.getElementById("pricing"))==null?void 0:$.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",r.jsx(Zi,{className:"ml-2 w-5 h-5"})]}),r.jsxs(X,{size:"lg",variant:"outline",onClick:()=>I(!0),className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/10",children:[r.jsx(An,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),r.jsx("div",{className:"relative hidden md:block",children:r.jsx("img",{src:Z0t,alt:"Scale Your Team from 5 to 500 Agents",className:"w-full rounded-3xl shadow-lg"})})]})})})}),r.jsx("section",{className:"py-20 bg-background",children:r.jsxs("div",{className:"container mx-auto px-4",children:[r.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[r.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Agents Love ",r.jsx("span",{className:"italic text-[#4a6b6d]",children:"LevelUp"})]}),r.jsx("p",{className:"text-lg text-muted-foreground",children:"See what top producers are saying about the platform."})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 max-w-6xl mx-auto",children:J0t.map(($,q)=>r.jsx(ze,{className:"bg-muted/30 border-0",children:r.jsxs(qe,{className:"pt-8",children:[r.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(W=>r.jsx(Dn,{className:"w-5 h-5 fill-yellow-400 text-yellow-400"},W))}),r.jsxs("p",{className:"text-lg mb-6 italic text-muted-foreground",children:['"',$.quote,'"']}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:$.name}),r.jsx("p",{className:"text-sm text-muted-foreground",children:$.role})]})]})},q))})]})}),r.jsxs("section",{id:"free-trial",className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsx("div",{className:"container mx-auto px-4 relative",children:r.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-8",children:[r.jsxs("h2",{className:"text-3xl md:text-5xl font-bold text-white",children:["Start Your Free Trial ",r.jsx("span",{className:"italic",children:"Today"})]}),r.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."}),r.jsx("div",{className:"pt-4",children:r.jsxs(X,{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:()=>R("individual_agent"),children:["Start Free Trial",r.jsx(Ki,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})})]})})]}),r.jsx("section",{id:"pricing",className:"py-20 bg-muted/30",children:r.jsxs("div",{className:"container mx-auto px-4",children:[r.jsxs("div",{className:"text-center mb-16",children:[r.jsxs("h2",{className:"text-3xl mb-6 font-sans md:text-5xl font-bold",children:["Simple, Transparent ",r.jsx("span",{className:"italic text-[#4a6b6d]",children:"Pricing"})]}),r.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."})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:[r.jsxs(ze,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[r.jsxs(Wt,{className:"pb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:r.jsx(Fl,{className:"w-5 h-5 text-[#4a6b6d]"})}),r.jsx(Zt,{className:"text-xl font-sans",children:zd.individual_agent.name})]}),r.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[r.jsx("span",{className:"text-5xl font-bold",children:zd.individual_agent.price}),r.jsx("span",{className:"text-muted-foreground text-lg",children:zd.individual_agent.period})]}),r.jsx(Cs,{className:"text-base mt-2",children:zd.individual_agent.description}),r.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:[r.jsx(Pa,{className:"w-4 h-4"}),zd.individual_agent.trial]})]}),r.jsx(qe,{className:"flex-1 pt-0",children:r.jsx("ul",{className:"space-y-3",children:zd.individual_agent.features.map(($,q)=>r.jsxs("li",{className:"flex items-center gap-3",children:[r.jsx(mi,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),r.jsx("span",{children:$})]},q))})}),r.jsxs(GE,{className:"flex flex-col gap-3 pt-4",children:[r.jsx(X,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>R("individual_agent"),children:"Start Free Trial"}),r.jsx(X,{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:()=>R("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),r.jsxs(ze,{className:"relative flex flex-col border-2 border-[#4a6b6d] shadow-2xl scale-105 bg-background",children:[r.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"}),r.jsxs(Wt,{className:"pb-4 pt-8",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/20 flex items-center justify-center",children:r.jsx(Ni,{className:"w-5 h-5 text-[#4a6b6d]"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-xl font-sans",children:zd.brokerage_under_25.name}),r.jsx("span",{className:"text-sm text-muted-foreground",children:zd.brokerage_under_25.subtitle})]})]}),r.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[r.jsx("span",{className:"text-5xl font-bold",children:zd.brokerage_under_25.price}),r.jsx("span",{className:"text-muted-foreground text-lg",children:zd.brokerage_under_25.period})]}),r.jsx(Cs,{className:"text-base mt-2",children:zd.brokerage_under_25.description})]}),r.jsx(qe,{className:"flex-1 pt-0",children:r.jsx("ul",{className:"space-y-3",children:zd.brokerage_under_25.features.map(($,q)=>r.jsxs("li",{className:"flex items-center gap-3",children:[r.jsx(mi,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),r.jsx("span",{children:$})]},q))})}),r.jsx(GE,{className:"pt-4",children:r.jsx(X,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>R("brokerage_under_25"),children:"Get Started"})})]}),r.jsxs(ze,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[r.jsxs(Wt,{className:"pb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#4a6b6d]/10 flex items-center justify-center",children:r.jsx(Ni,{className:"w-5 h-5 text-[#4a6b6d]"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-xl font-sans",children:zd.brokerage_over_25.name}),r.jsx("span",{className:"text-sm text-muted-foreground",children:zd.brokerage_over_25.subtitle})]})]}),r.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[r.jsx("span",{className:"text-5xl font-bold",children:zd.brokerage_over_25.price}),r.jsx("span",{className:"text-muted-foreground text-lg",children:zd.brokerage_over_25.period})]}),r.jsx(Cs,{className:"text-base mt-2",children:zd.brokerage_over_25.description})]}),r.jsx(qe,{className:"flex-1 pt-0",children:r.jsx("ul",{className:"space-y-3",children:zd.brokerage_over_25.features.map(($,q)=>r.jsxs("li",{className:"flex items-center gap-3",children:[r.jsx(mi,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),r.jsx("span",{children:$})]},q))})}),r.jsx(GE,{className:"pt-4",children:r.jsx(X,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>R("brokerage_over_25"),children:"Get Started"})})]})]})]})}),r.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] relative overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsx("div",{className:"container mx-auto px-4 relative",children:r.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[r.jsx("h2",{className:"text-3xl text-white font-sans md:text-5xl",children:"Ready to Level Up?"}),r.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."}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[r.jsxs(X,{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",r.jsx(Ki,{className:"ml-2 w-5 h-5"})]}),r.jsx(X,{size:"lg",onClick:()=>s("/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"})]})]})})]}),r.jsx("footer",{className:"py-12 bg-[#3d5a5c] text-white/80",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsxs("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[r.jsx("img",{src:yse,alt:"LevelUp",className:"h-8"}),r.jsxs("p",{className:"text-sm",children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),r.jsxs("div",{className:"flex items-center gap-6",children:[r.jsx("a",{href:"/privacy-policy",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Privacy Policy"}),r.jsx("a",{href:"mailto:support@relevelup.com",className:"text-white/60 hover:text-white transition-colors text-sm",children:"Contact Support"})]})]})})}),r.jsx(Y0t,{open:C,onOpenChange:I}),r.jsx(Ir,{open:d,onOpenChange:m,children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsx(Fr,{className:"text-xl font-sans font-semibold",children:"Enter your details to get started"}),r.jsx(Zs,{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)"})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{children:[r.jsxs(Ee,{htmlFor:"dialog-name",children:["Full Name ",r.jsx("span",{className:"text-red-500",children:"*"})]}),r.jsx(Ye,{id:"dialog-name",type:"text",placeholder:"John Smith",value:v,onChange:$=>_($.target.value),className:"mt-1",required:!0})]}),r.jsxs("div",{children:[r.jsxs(Ee,{htmlFor:"dialog-email",children:["Email Address ",r.jsx("span",{className:"text-red-500",children:"*"})]}),r.jsx(Ye,{id:"dialog-email",type:"email",placeholder:"you@example.com",value:p,onChange:$=>g($.target.value),className:"mt-1",required:!0})]}),r.jsxs("div",{children:[r.jsxs(Ee,{htmlFor:"dialog-coupon",children:["Discount Code ",r.jsx("span",{className:"text-muted-foreground",children:"(Optional)"})]}),r.jsx(Ye,{id:"dialog-coupon",type:"text",placeholder:"Enter discount code",value:k,onChange:$=>w($.target.value),className:"mt-1"})]})]}),r.jsx(X,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:B,disabled:S,children:S?"Loading...":"Continue to Checkout"})]})})]})},tvt=()=>r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsx("title",{children:"Privacy Policy | LevelUp"}),r.jsx("meta",{name:"description",content:"Privacy Policy for LevelUp platform"})]}),r.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:r.jsxs("div",{className:"max-w-3xl mx-auto",children:[r.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Privacy Policy"}),r.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Introduction"}),r.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.'})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Information We Collect"}),r.jsx("p",{children:"We collect information that you provide directly to us, including:"}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Name and contact information (email address, phone number)"}),r.jsx("li",{children:"Account credentials"}),r.jsx("li",{children:"Profile information"}),r.jsx("li",{children:"Transaction and billing information"}),r.jsx("li",{children:"Communications you send to us"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. How We Use Your Information"}),r.jsx("p",{children:"We use the information we collect to:"}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Provide, maintain, and improve our services"}),r.jsx("li",{children:"Process transactions and send related information"}),r.jsx("li",{children:"Send you technical notices and support messages"}),r.jsx("li",{children:"Respond to your comments and questions"}),r.jsx("li",{children:"Communicate with you about products, services, and events"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Information Sharing"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Data Security"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Your Rights"}),r.jsx("p",{children:"You have the right to:"}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Access your personal information"}),r.jsx("li",{children:"Correct inaccurate data"}),r.jsx("li",{children:"Request deletion of your data"}),r.jsx("li",{children:"Opt-out of marketing communications"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Third-Party Services"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Contact Us"}),r.jsxs("p",{children:["If you have questions about this Privacy Policy, please contact us at"," ",r.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),rvt=()=>r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsx("title",{children:"Terms of Service | LevelUp"}),r.jsx("meta",{name:"description",content:"Terms of Service for LevelUp platform"})]}),r.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:r.jsxs("div",{className:"max-w-3xl mx-auto",children:[r.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Terms of Service"}),r.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"1. Acceptance of Terms"}),r.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.'})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"2. Description of Service"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"3. User Accounts"}),r.jsx("p",{children:"To use certain features, you must create an account. You agree to:"}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Provide accurate and complete information"}),r.jsx("li",{children:"Maintain the security of your account credentials"}),r.jsx("li",{children:"Notify us immediately of any unauthorized access"}),r.jsx("li",{children:"Accept responsibility for all activities under your account"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"4. Acceptable Use"}),r.jsx("p",{children:"You agree not to:"}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Violate any applicable laws or regulations"}),r.jsx("li",{children:"Infringe on the rights of others"}),r.jsx("li",{children:"Upload malicious code or interfere with the Service"}),r.jsx("li",{children:"Attempt to gain unauthorized access to any part of the Service"}),r.jsx("li",{children:"Use the Service for any unlawful purpose"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"5. Intellectual Property"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"6. Third-Party Integrations"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"7. Payment Terms"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"8. Limitation of Liability"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"9. Termination"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"10. Changes to Terms"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"11. Contact Us"}),r.jsxs("p",{children:["If you have questions about these Terms, please contact us at"," ",r.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),svt=()=>r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsx("title",{children:"Data Deletion | LevelUp"}),r.jsx("meta",{name:"description",content:"Data deletion instructions for LevelUp platform"})]}),r.jsx("div",{className:"min-h-screen bg-background py-12 px-4 sm:px-6 lg:px-8",children:r.jsxs("div",{className:"max-w-3xl mx-auto",children:[r.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Data Deletion Instructions"}),r.jsxs("div",{className:"prose prose-sm max-w-none text-muted-foreground space-y-6",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Last updated: January 17, 2026"}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"How to Request Data Deletion"}),r.jsx("p",{children:"If you wish to have your data deleted from LevelUp, you can request deletion through one of the following methods:"})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 1: Email Request"}),r.jsxs("p",{children:["Send an email to"," ",r.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:']}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Your full name"}),r.jsx("li",{children:"The email address associated with your account"}),r.jsx("li",{children:"A clear statement requesting deletion of your data"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Option 2: Account Settings"}),r.jsx("p",{children:"If you have an active account, you can request data deletion through your account settings:"}),r.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Log in to your LevelUp account"}),r.jsx("li",{children:"Navigate to your Profile settings"}),r.jsx("li",{children:"Contact support through the Support page to request account deletion"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"What Data Will Be Deleted"}),r.jsx("p",{children:"Upon a valid deletion request, we will delete:"}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Your account information (name, email, profile data)"}),r.jsx("li",{children:"Any content you have created or uploaded"}),r.jsx("li",{children:"Your activity history and preferences"}),r.jsx("li",{children:"Connected social media account tokens and data"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Data Retention"}),r.jsx("p",{children:"Some data may be retained for legal or legitimate business purposes, such as:"}),r.jsxs("ul",{className:"list-disc pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Transaction records required for financial reporting"}),r.jsx("li",{children:"Data necessary to comply with legal obligations"}),r.jsx("li",{children:"Anonymized or aggregated data that cannot identify you"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Facebook/Instagram Data"}),r.jsx("p",{children:"If you have connected your Facebook or Instagram account to LevelUp, you can also manage your data through Facebook's settings:"}),r.jsxs("ol",{className:"list-decimal pl-6 mt-2 space-y-1",children:[r.jsx("li",{children:"Go to your Facebook Settings & Privacy → Settings"}),r.jsx("li",{children:'Click on "Apps and Websites"'}),r.jsx("li",{children:'Find LevelUp and click "Remove"'}),r.jsx("li",{children:"This will revoke our access to your Facebook/Instagram data"})]})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Processing Time"}),r.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."})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold text-foreground mt-8 mb-4",children:"Contact Us"}),r.jsxs("p",{children:["If you have questions about data deletion, please contact us at"," ",r.jsx("a",{href:"mailto:support@relevelup.com",className:"text-primary hover:underline",children:"support@relevelup.com"})]})]})]})]})})]}),nvt=i_({email:zo().email("Invalid email address"),password:zo().min(6,"Password must be at least 6 characters")}),avt=()=>{const{signIn:e,user:t}=Gr(),s=Ks(),[n,a]=A.useState(!1),[o,l]=A.useState({}),[i,d]=A.useState(""),[m,p]=A.useState(!1),[g,v]=A.useState(!1);A.useEffect(()=>{t&&s("/dashboard")},[t,s]);const _=async w=>{w.preventDefault(),l({}),a(!0);const S=new FormData(w.currentTarget),T=S.get("email"),C=S.get("password");try{nvt.parse({email:T,password:C}),await e(T,C)}catch(I){if(I instanceof kx){const R={};I.errors.forEach(D=>{D.path[0]&&(R[D.path[0]]=D.message)}),l(R)}}finally{a(!1)}},k=async()=>{if(!i){we.error("Please enter your email address");return}p(!0);try{const{error:w}=await Y.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(w)throw w;we.success("Password reset email sent! Check your inbox."),v(!1),d("")}catch(w){we.error(w.message||"Failed to send reset email")}finally{p(!1)}};return r.jsxs("div",{className:"min-h-screen relative overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-[#4a6b6d] via-[#3d5a5c] to-[#2a4347]",children:r.jsxs("div",{className:"absolute inset-0 opacity-30",children:[r.jsx("div",{className:"absolute top-0 left-0 w-96 h-96 bg-white/10 rounded-full blur-3xl animate-pulse"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-96 h-96 bg-white/5 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),r.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"}})]})}),r.jsxs("div",{className:"relative z-10 flex flex-col min-h-screen",children:[r.jsx("header",{className:"p-6",children:r.jsxs(vo,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Home"]})}),r.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:r.jsxs("div",{className:"w-full max-w-md",children:[r.jsx("div",{className:"flex justify-center mb-8",children:r.jsx("div",{className:"bg-white rounded-xl p-4 shadow-2xl",children:r.jsx("img",{src:fze,alt:"LevelUp",className:"h-12 w-auto"})})}),r.jsxs(ze,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[r.jsxs(Wt,{className:"space-y-1 text-center pb-4",children:[r.jsx(Zt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),r.jsx(Cs,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),r.jsx(qe,{children:r.jsxs("form",{onSubmit:_,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"signin-email",className:"text-gray-700",children:"Email"}),r.jsx(Ye,{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&&r.jsx("p",{className:"text-sm text-red-600",children:o.email})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"signin-password",className:"text-gray-700",children:"Password"}),r.jsx(Ye,{id:"signin-password",name:"password",type:"password",required:!0,className:"border-gray-300 focus:border-[#4a6b6d] focus:ring-[#4a6b6d]"}),o.password&&r.jsx("p",{className:"text-sm text-red-600",children:o.password})]}),r.jsx(X,{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"}),r.jsxs(Ir,{open:g,onOpenChange:v,children:[r.jsx(Qi,{asChild:!0,children:r.jsx(X,{variant:"link",className:"w-full text-sm text-[#4a6b6d] hover:text-[#3d5a5c]",children:"Forgot password?"})}),r.jsxs(Er,{className:"bg-white",children:[r.jsxs(zr,{children:[r.jsx(Fr,{className:"text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Reset Password"}),r.jsx(Zs,{className:"text-gray-600",children:"Enter your email address and we'll send you a link to reset your password."})]}),r.jsxs("div",{className:"space-y-4 pt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),r.jsx(Ye,{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]"})]}),r.jsx(X,{onClick:k,className:"w-full bg-[#4a6b6d] hover:bg-[#3d5a5c] text-white",disabled:m,children:m?"Sending...":"Send Reset Link"})]})]})]})]})})]}),r.jsxs("p",{className:"text-center text-white/70 text-sm mt-6",children:["Don't have an account?"," ",r.jsx(vo,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},ivt=()=>{const[e]=Cc(),t=e.get("tier"),s=t==null?void 0:t.includes("brokerage");return r.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:r.jsxs(ze,{className:"max-w-lg w-full",children:[r.jsxs(Wt,{className:"text-center",children:[r.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-green-500/10 flex items-center justify-center mb-4",children:r.jsx(ui,{className:"w-10 h-10 text-green-500"})}),r.jsx(Zt,{className:"text-2xl",children:"Welcome to LevelUp!"}),r.jsx(Cs,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"p-4 rounded-lg bg-primary/10 border border-primary/20 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[r.jsx(Vs,{className:"w-5 h-5"}),r.jsx("span",{className:"font-semibold",children:"Check your email to sign in"})]}),r.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."})]}),s?r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"font-semibold",children:"What's next?"}),r.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[r.jsxs("li",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),r.jsxs("li",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"font-bold text-primary",children:"2."}),"Create and name your brokerage"]}),r.jsxs("li",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"font-bold text-primary",children:"3."}),"Set your password and complete your profile"]}),r.jsxs("li",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"font-bold text-primary",children:"4."}),"Start inviting agents to join your team"]})]})]}):r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"font-semibold",children:"What's next?"}),r.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[r.jsxs("li",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"font-bold text-primary",children:"1."}),"Click the link in your email to sign in"]}),r.jsxs("li",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"font-bold text-primary",children:"2."}),"Set your password and complete your profile"]}),r.jsxs("li",{className:"flex items-start gap-2",children:[r.jsx("span",{className:"font-bold text-primary",children:"3."}),"Start exploring templates, training videos, and more!"]})]}),r.jsx("p",{className:"text-sm text-green-600 font-medium mt-4",children:"🎉 Your 7-day free trial has started!"})]}),r.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:r.jsx("p",{className:"text-sm text-muted-foreground",children:"Didn't receive the email? Check your spam folder or contact support."})})]})]})})},O7e=e=>{const[t,s]=A.useState(null),[n,a]=A.useState(!0);return A.useEffect(()=>{if(!e){a(!1);return}(async()=>{try{const{data:i}=await Y.storage.from("avatars").list(`${e}`);if(i&&i.length>0){const{data:d}=Y.storage.from("avatars").getPublicUrl(`${e}/${i[0].name}`);s(`${d.publicUrl}?t=${Date.now()}`)}else s(null)}catch(i){console.error("Error fetching avatar:",i),s(null)}finally{a(!1)}})()},[e]),{avatarUrl:t,loading:n,refreshAvatar:async()=>{if(e)try{const{data:l}=await Y.storage.from("avatars").list(`${e}`);if(l&&l.length>0){const{data:i}=Y.storage.from("avatars").getPublicUrl(`${e}/${l[0].name}`);s(`${i.publicUrl}?t=${Date.now()}`)}}catch(l){console.error("Error refreshing avatar:",l)}}}},R7e=async e=>{const t=new Map;return await Promise.all(e.map(async s=>{try{const{data:n}=await Y.storage.from("avatars").list(`${s}`);if(n&&n.length>0){const{data:a}=Y.storage.from("avatars").getPublicUrl(`${s}/${n[0].name}`);t.set(s,a.publicUrl)}}catch{}})),t},ovt=e=>{const[t,s]=A.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return A.useEffect(()=>{if(!e){s(a=>({...a,loading:!1}));return}(async()=>{try{const{data:a,error:o}=await Y.from("profiles").select("is_trial, trial_expires_at, subscription_status, subscription_end_date").eq("id",e).single();if(o){console.error("Error fetching trial status:",o),s(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(),m=new Date(a.subscription_end_date).getTime(),p=Math.ceil((m-d)/(1e3*60*60*24)),g=p<=0;s({isTrial:!0,isExpired:g,expiresAt:a.subscription_end_date,daysLeft:g?0:p,loading:!1})}else if(i){const d=new Date().getTime(),m=new Date(a.trial_expires_at).getTime(),p=Math.ceil((m-d)/(1e3*60*60*24)),g=p<=0;s({isTrial:!0,isExpired:g,expiresAt:a.trial_expires_at,daysLeft:g?0:p,loading:!1})}else s({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!1})}catch(a){console.error("Error in useTrialStatus:",a),s(o=>({...o,loading:!1}))}})()},[e]),t},F7e=()=>{const{data:e,isLoading:t}=Ht({queryKey:["feature-flags"],queryFn:async()=>{const{data:n,error:a}=await Y.from("feature_flags").select("*");if(a)throw a;return n}}),s=n=>{if(!e)return!1;const a=e.find(o=>o.key===n);return(a==null?void 0:a.enabled)??!1};return{flags:e,isLoading:t,isFeatureEnabled:s,isAgentOSEnabled:s("agent_os_enabled"),isInnerCircleEnabled:s("innercircle_enabled"),isMarketplaceEnabled:s("marketplace")}},I4e="community_last_seen_post_at";function lvt(){const{user:e}=Gr(),t=sm(),[s,n]=A.useState(0),[a,o]=A.useState(null);A.useEffect(()=>{if(!e)return;const i=localStorage.getItem(`${I4e}_${e.id}`);o(i)},[e]),A.useEffect(()=>{if(!e)return;(async()=>{let d=Y.from("community_posts").select("id",{count:"exact",head:!0});a&&(d=d.gt("created_at",a));const{data:m}=await Y.from("profiles").select("brokerage_id").eq("id",e.id).single(),{count:p,error:g}=await d;!g&&p!==null&&n(p)})()},[e,a]),A.useEffect(()=>{if(!e)return;const i=Y.channel("community-new-posts").on("postgres_changes",{event:"INSERT",schema:"public",table:"community_posts"},async d=>{const m=d.new;if(m.user_id===e.id)return;const p=t.pathname==="/community";p||n(k=>k+1);const{data:g}=await Y.from("profiles").select("name").eq("id",m.user_id).single(),v=(g==null?void 0:g.name)||"Someone",_=m.content.length>50?m.content.substring(0,50)+"...":m.content;p||we("New Community Post",{description:`${v}: ${_}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{Y.removeChannel(i)}},[e,t.pathname]);const l=A.useCallback(()=>{if(!e)return;const i=new Date().toISOString();localStorage.setItem(`${I4e}_${e.id}`,i),o(i),n(0)},[e]);return A.useEffect(()=>{t.pathname==="/community"&&s>0&&l()},[t.pathname,s,l]),{unreadCount:s,markAsRead:l}}function cvt(){const{isAdmin:e}=Gr(),{data:t=0}=Ht({queryKey:["wishlist-open-count"],queryFn:async()=>{const{count:s,error:n}=await Y.from("wishlist_items").select("*",{count:"exact",head:!0}).eq("status","open");if(n)throw n;return s||0},enabled:e,staleTime:6e4});return{openCount:e?t:0}}const o_=()=>{const{user:e}=Gr();return Ht({queryKey:["user-team",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("team_members").select("id, team_id, role").eq("user_id",e.id).maybeSingle();if(console.log("[useUserTeam] membership query:",{userId:e.id,membership:t,error:s}),s)throw s;if(!t)return null;const{data:n,error:a}=await Y.from("teams").select("*").eq("id",t.team_id).single();if(a)throw a;return{membershipId:t.id,teamId:t.team_id,role:t.role,team:n}},enabled:!!e,staleTime:5*60*1e3})},Nie=hie,Bve=jve,dvt=mie,z7e=A.forwardRef(({className:e,...t},s)=>r.jsx(I3,{className:Vt("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",e),...t,ref:s}));z7e.displayName=I3.displayName;const uvt=_3("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"}}),M6=A.forwardRef(({side:e="right",className:t,children:s,...n},a)=>r.jsxs(dvt,{children:[r.jsx(z7e,{}),r.jsxs(P3,{ref:a,className:Vt(uvt({side:e}),t),...n,children:[s,r.jsxs(fie,{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:[r.jsx(Xs,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));M6.displayName=P3.displayName;const Sie=({className:e,...t})=>r.jsx("div",{className:Vt("flex flex-col space-y-2 text-center sm:text-left",e),...t});Sie.displayName="SheetHeader";const Cie=A.forwardRef(({className:e,...t},s)=>r.jsx(N6,{ref:s,className:Vt("text-lg font-semibold text-foreground",e),...t}));Cie.displayName=N6.displayName;const hvt=A.forwardRef(({className:e,...t},s)=>r.jsx(S6,{ref:s,className:Vt("text-sm text-muted-foreground",e),...t}));hvt.displayName=S6.displayName;function mvt(e,t){return A.useReducer((s,n)=>t[s][n]??s,e)}var $ve="ScrollArea",[B7e]=Sc($ve),[fvt,Yf]=B7e($ve),$7e=A.forwardRef((e,t)=>{const{__scopeScrollArea:s,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=e,[i,d]=A.useState(null),[m,p]=A.useState(null),[g,v]=A.useState(null),[_,k]=A.useState(null),[w,S]=A.useState(null),[T,C]=A.useState(0),[I,R]=A.useState(0),[D,B]=A.useState(!1),[$,q]=A.useState(!1),W=va(t,re=>d(re)),K=vN(a);return r.jsx(fvt,{scope:s,type:n,dir:K,scrollHideDelay:o,scrollArea:i,viewport:m,onViewportChange:p,content:g,onContentChange:v,scrollbarX:_,onScrollbarXChange:k,scrollbarXEnabled:D,onScrollbarXEnabledChange:B,scrollbarY:w,onScrollbarYChange:S,scrollbarYEnabled:$,onScrollbarYEnabledChange:q,onCornerWidthChange:C,onCornerHeightChange:R,children:r.jsx(Hs.div,{dir:K,...l,ref:W,style:{position:"relative","--radix-scroll-area-corner-width":T+"px","--radix-scroll-area-corner-height":I+"px",...e.style}})})});$7e.displayName=$ve;var U7e="ScrollAreaViewport",V7e=A.forwardRef((e,t)=>{const{__scopeScrollArea:s,children:n,nonce:a,...o}=e,l=Yf(U7e,s),i=A.useRef(null),d=va(t,i,l.onViewportChange);return r.jsxs(r.Fragment,{children:[r.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}),r.jsx(Hs.div,{"data-radix-scroll-area-viewport":"",...o,ref:d,style:{overflowX:l.scrollbarXEnabled?"scroll":"hidden",overflowY:l.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r.jsx("div",{ref:l.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});V7e.displayName=U7e;var Lx="ScrollAreaScrollbar",Uve=A.forwardRef((e,t)=>{const{forceMount:s,...n}=e,a=Yf(Lx,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=e.orientation==="horizontal";return A.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?r.jsx(pvt,{...n,ref:t,forceMount:s}):a.type==="scroll"?r.jsx(gvt,{...n,ref:t,forceMount:s}):a.type==="auto"?r.jsx(q7e,{...n,ref:t,forceMount:s}):a.type==="always"?r.jsx(Vve,{...n,ref:t}):null});Uve.displayName=Lx;var pvt=A.forwardRef((e,t)=>{const{forceMount:s,...n}=e,a=Yf(Lx,e.__scopeScrollArea),[o,l]=A.useState(!1);return A.useEffect(()=>{const i=a.scrollArea;let d=0;if(i){const m=()=>{window.clearTimeout(d),l(!0)},p=()=>{d=window.setTimeout(()=>l(!1),a.scrollHideDelay)};return i.addEventListener("pointerenter",m),i.addEventListener("pointerleave",p),()=>{window.clearTimeout(d),i.removeEventListener("pointerenter",m),i.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),r.jsx(Wc,{present:s||o,children:r.jsx(q7e,{"data-state":o?"visible":"hidden",...n,ref:t})})}),gvt=A.forwardRef((e,t)=>{const{forceMount:s,...n}=e,a=Yf(Lx,e.__scopeScrollArea),o=e.orientation==="horizontal",l=Tie(()=>d("SCROLL_END"),100),[i,d]=mvt("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 A.useEffect(()=>{if(i==="idle"){const m=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(m)}},[i,a.scrollHideDelay,d]),A.useEffect(()=>{const m=a.viewport,p=o?"scrollLeft":"scrollTop";if(m){let g=m[p];const v=()=>{const _=m[p];g!==_&&(d("SCROLL"),l()),g=_};return m.addEventListener("scroll",v),()=>m.removeEventListener("scroll",v)}},[a.viewport,o,d,l]),r.jsx(Wc,{present:s||i!=="hidden",children:r.jsx(Vve,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:t,onPointerEnter:bs(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:bs(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),q7e=A.forwardRef((e,t)=>{const s=Yf(Lx,e.__scopeScrollArea),{forceMount:n,...a}=e,[o,l]=A.useState(!1),i=e.orientation==="horizontal",d=Tie(()=>{if(s.viewport){const m=s.viewport.offsetWidth{const{orientation:s="vertical",...n}=e,a=Yf(Lx,e.__scopeScrollArea),o=A.useRef(null),l=A.useRef(0),[i,d]=A.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=Z7e(i.viewport,i.content),p={...n,sizes:i,onSizesChange:d,hasThumb:m>0&&m<1,onThumbChange:v=>o.current=v,onThumbPointerUp:()=>l.current=0,onThumbPointerDown:v=>l.current=v};function g(v,_){return wvt(v,l.current,i,_)}return s==="horizontal"?r.jsx(xvt,{...p,ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollLeft,_=P4e(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))}}):s==="vertical"?r.jsx(yvt,{...p,ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const v=a.viewport.scrollTop,_=P4e(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}),xvt=A.forwardRef((e,t)=>{const{sizes:s,onSizesChange:n,...a}=e,o=Yf(Lx,e.__scopeScrollArea),[l,i]=A.useState(),d=A.useRef(null),m=va(t,d,o.onScrollbarXChange);return A.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),r.jsx(W7e,{"data-orientation":"horizontal",...a,ref:m,sizes:s,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":Mie(s)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,g)=>{if(o.viewport){const v=o.viewport.scrollLeft+p.deltaX;e.onWheelScroll(v),X7e(v,g)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:_se(l.paddingLeft),paddingEnd:_se(l.paddingRight)}})}})}),yvt=A.forwardRef((e,t)=>{const{sizes:s,onSizesChange:n,...a}=e,o=Yf(Lx,e.__scopeScrollArea),[l,i]=A.useState(),d=A.useRef(null),m=va(t,d,o.onScrollbarYChange);return A.useEffect(()=>{d.current&&i(getComputedStyle(d.current))},[d]),r.jsx(W7e,{"data-orientation":"vertical",...a,ref:m,sizes:s,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":Mie(s)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,g)=>{if(o.viewport){const v=o.viewport.scrollTop+p.deltaY;e.onWheelScroll(v),X7e(v,g)&&p.preventDefault()}},onResize:()=>{d.current&&o.viewport&&l&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:_se(l.paddingTop),paddingEnd:_se(l.paddingBottom)}})}})}),[vvt,H7e]=B7e(Lx),W7e=A.forwardRef((e,t)=>{const{__scopeScrollArea:s,sizes:n,hasThumb:a,onThumbChange:o,onThumbPointerUp:l,onThumbPointerDown:i,onThumbPositionChange:d,onDragScroll:m,onWheelScroll:p,onResize:g,...v}=e,_=Yf(Lx,s),[k,w]=A.useState(null),S=va(t,W=>w(W)),T=A.useRef(null),C=A.useRef(""),I=_.viewport,R=n.content-n.viewport,D=gc(p),B=gc(d),$=Tie(g,10);function q(W){if(T.current){const K=W.clientX-T.current.left,re=W.clientY-T.current.top;m({x:K,y:re})}}return A.useEffect(()=>{const W=K=>{const re=K.target;(k==null?void 0:k.contains(re))&&D(K,R)};return document.addEventListener("wheel",W,{passive:!1}),()=>document.removeEventListener("wheel",W,{passive:!1})},[I,k,R,D]),A.useEffect(B,[n,B]),F5(k,$),F5(_.content,$),r.jsx(vvt,{scope:s,scrollbar:k,hasThumb:a,onThumbChange:gc(o),onThumbPointerUp:gc(l),onThumbPositionChange:B,onThumbPointerDown:gc(i),children:r.jsx(Hs.div,{...v,ref:S,style:{position:"absolute",...v.style},onPointerDown:bs(e.onPointerDown,W=>{W.button===0&&(W.target.setPointerCapture(W.pointerId),T.current=k.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",_.viewport&&(_.viewport.style.scrollBehavior="auto"),q(W))}),onPointerMove:bs(e.onPointerMove,q),onPointerUp:bs(e.onPointerUp,W=>{const K=W.target;K.hasPointerCapture(W.pointerId)&&K.releasePointerCapture(W.pointerId),document.body.style.webkitUserSelect=C.current,_.viewport&&(_.viewport.style.scrollBehavior=""),T.current=null})})})}),vse="ScrollAreaThumb",G7e=A.forwardRef((e,t)=>{const{forceMount:s,...n}=e,a=H7e(vse,e.__scopeScrollArea);return r.jsx(Wc,{present:s||a.hasThumb,children:r.jsx(_vt,{ref:t,...n})})}),_vt=A.forwardRef((e,t)=>{const{__scopeScrollArea:s,style:n,...a}=e,o=Yf(vse,s),l=H7e(vse,s),{onThumbPositionChange:i}=l,d=va(t,g=>l.onThumbChange(g)),m=A.useRef(void 0),p=Tie(()=>{m.current&&(m.current(),m.current=void 0)},100);return A.useEffect(()=>{const g=o.viewport;if(g){const v=()=>{if(p(),!m.current){const _=jvt(g,i);m.current=_,i()}};return i(),g.addEventListener("scroll",v),()=>g.removeEventListener("scroll",v)}},[o.viewport,p,i]),r.jsx(Hs.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:bs(e.onPointerDownCapture,g=>{const _=g.target.getBoundingClientRect(),k=g.clientX-_.left,w=g.clientY-_.top;l.onThumbPointerDown({x:k,y:w})}),onPointerUp:bs(e.onPointerUp,l.onThumbPointerUp)})});G7e.displayName=vse;var qve="ScrollAreaCorner",K7e=A.forwardRef((e,t)=>{const s=Yf(qve,e.__scopeScrollArea),n=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&n?r.jsx(bvt,{...e,ref:t}):null});K7e.displayName=qve;var bvt=A.forwardRef((e,t)=>{const{__scopeScrollArea:s,...n}=e,a=Yf(qve,s),[o,l]=A.useState(0),[i,d]=A.useState(0),m=!!(o&&i);return F5(a.scrollbarX,()=>{var g;const p=((g=a.scrollbarX)==null?void 0:g.offsetHeight)||0;a.onCornerHeightChange(p),d(p)}),F5(a.scrollbarY,()=>{var g;const p=((g=a.scrollbarY)==null?void 0:g.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),m?r.jsx(Hs.div,{...n,ref:t,style:{width:o,height:i,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function _se(e){return e?parseInt(e,10):0}function Z7e(e,t){const s=e/t;return isNaN(s)?0:s}function Mie(e){const t=Z7e(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,n=(e.scrollbar.size-s)*t;return Math.max(n,18)}function wvt(e,t,s,n="ltr"){const a=Mie(s),o=a/2,l=t||o,i=a-l,d=s.scrollbar.paddingStart+l,m=s.scrollbar.size-s.scrollbar.paddingEnd-i,p=s.content-s.viewport,g=n==="ltr"?[0,p]:[p*-1,0];return Y7e([d,m],g)(e)}function P4e(e,t,s="ltr"){const n=Mie(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=t.scrollbar.size-a,l=t.content-t.viewport,i=o-n,d=s==="ltr"?[0,l]:[l*-1,0],m=YI(e,d);return Y7e([0,l],[0,i])(m)}function Y7e(e,t){return s=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(s-e[0])}}function X7e(e,t){return e>0&&e{})=>{let s={left:e.scrollLeft,top:e.scrollTop},n=0;return function a(){const o={left:e.scrollLeft,top:e.scrollTop},l=s.left!==o.left,i=s.top!==o.top;(l||i)&&t(),s=o,n=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(n)};function Tie(e,t){const s=gc(e),n=A.useRef(0);return A.useEffect(()=>()=>window.clearTimeout(n.current),[]),A.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(s,t)},[s,t])}function F5(e,t){const s=gc(t);kc(()=>{let n=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(s)});return a.observe(e),()=>{window.cancelAnimationFrame(n),a.unobserve(e)}}},[e,s])}var Q7e=$7e,kvt=V7e,Nvt=K7e;const To=A.forwardRef(({className:e,children:t,...s},n)=>r.jsxs(Q7e,{ref:n,className:Vt("relative overflow-hidden",e),...s,children:[r.jsx(kvt,{className:"h-full w-full rounded-[inherit]",children:t}),r.jsx(Hve,{}),r.jsx(Nvt,{})]}));To.displayName=Q7e.displayName;const Hve=A.forwardRef(({className:e,orientation:t="vertical",...s},n)=>r.jsx(Uve,{ref:n,orientation:t,className:Vt("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...s,children:r.jsx(G7e,{className:"relative flex-1 rounded-full bg-border"})}));Hve.displayName=Uve.displayName;var Aie="Collapsible",[Svt]=Sc(Aie),[Cvt,Wve]=Svt(Aie),J7e=A.forwardRef((e,t)=>{const{__scopeCollapsible:s,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=e,[d,m]=bh({prop:n,defaultProp:a??!1,onChange:l,caller:Aie});return r.jsx(Cvt,{scope:s,disabled:o,contentId:Md(),open:d,onOpenToggle:A.useCallback(()=>m(p=>!p),[m]),children:r.jsx(Hs.div,{"data-state":Kve(d),"data-disabled":o?"":void 0,...i,ref:t})})});J7e.displayName=Aie;var eBe="CollapsibleTrigger",tBe=A.forwardRef((e,t)=>{const{__scopeCollapsible:s,...n}=e,a=Wve(eBe,s);return r.jsx(Hs.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":Kve(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:t,onClick:bs(e.onClick,a.onOpenToggle)})});tBe.displayName=eBe;var Gve="CollapsibleContent",rBe=A.forwardRef((e,t)=>{const{forceMount:s,...n}=e,a=Wve(Gve,e.__scopeCollapsible);return r.jsx(Wc,{present:s||a.open,children:({present:o})=>r.jsx(Mvt,{...n,ref:t,present:o})})});rBe.displayName=Gve;var Mvt=A.forwardRef((e,t)=>{const{__scopeCollapsible:s,present:n,children:a,...o}=e,l=Wve(Gve,s),[i,d]=A.useState(n),m=A.useRef(null),p=va(t,m),g=A.useRef(0),v=g.current,_=A.useRef(0),k=_.current,w=l.open||i,S=A.useRef(w),T=A.useRef(void 0);return A.useEffect(()=>{const C=requestAnimationFrame(()=>S.current=!1);return()=>cancelAnimationFrame(C)},[]),kc(()=>{const C=m.current;if(C){T.current=T.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const I=C.getBoundingClientRect();g.current=I.height,_.current=I.width,S.current||(C.style.transitionDuration=T.current.transitionDuration,C.style.animationName=T.current.animationName),d(n)}},[l.open,n]),r.jsx(Hs.div,{"data-state":Kve(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!w,...o,ref:p,style:{"--radix-collapsible-content-height":v?`${v}px`:void 0,"--radix-collapsible-content-width":k?`${k}px`:void 0,...e.style},children:w&&a})});function Kve(e){return e?"open":"closed"}var Tvt=J7e;const Ek=Tvt,Ik=tBe,Pk=rBe,Avt="/assets/levelup-logo-Eif24dqY.png",Evt="/assets/levelup-logo-icon-C-7iromj.png",Ivt="/assets/levelup-logo-mobile-B9skSjUG.png";var T6=e=>e.type==="checkbox",qj=e=>e instanceof Date,lh=e=>e==null;const sBe=e=>typeof e=="object";var qc=e=>!lh(e)&&!Array.isArray(e)&&sBe(e)&&!qj(e),nBe=e=>qc(e)&&e.target?T6(e.target)?e.target.checked:e.target.value:e,Pvt=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,aBe=(e,t)=>e.has(Pvt(t)),Lvt=e=>{const t=e.constructor&&e.constructor.prototype;return qc(t)&&t.hasOwnProperty("isPrototypeOf")},Zve=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function yd(e){let t;const s=Array.isArray(e),n=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(!(Zve&&(e instanceof Blob||n))&&(s||qc(e)))if(t=s?[]:{},!s&&!Lvt(e))t=e;else for(const a in e)e.hasOwnProperty(a)&&(t[a]=yd(e[a]));else return e;return t}var Eie=e=>/^\w*$/.test(e),Dc=e=>e===void 0,Yve=e=>Array.isArray(e)?e.filter(Boolean):[],Xve=e=>Yve(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ln=(e,t,s)=>{if(!t||!qc(e))return s;const n=(Eie(t)?[t]:Xve(t)).reduce((a,o)=>lh(a)?a:a[o],e);return Dc(n)||n===e?Dc(e[t])?s:e[t]:n},km=e=>typeof e=="boolean",Ro=(e,t,s)=>{let n=-1;const a=Eie(t)?[t]:Xve(t),o=a.length,l=o-1;for(;++nlt.useContext(Qve),Dvt=e=>{const{children:t,...s}=e;return lt.createElement(Qve.Provider,{value:s},t)};var iBe=(e,t,s,n=!0)=>{const a={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(a,o,{get:()=>{const l=o;return t._proxyFormState[l]!==qp.all&&(t._proxyFormState[l]=!n||qp.all),s&&(s[l]=!0),e[l]}});return a};const Jve=typeof window<"u"?lt.useLayoutEffect:lt.useEffect;function Ovt(e){const t=Iie(),{control:s=t.control,disabled:n,name:a,exact:o}=e||{},[l,i]=lt.useState(s._formState),d=lt.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Jve(()=>s._subscribe({name:a,formState:d.current,exact:o,callback:m=>{!n&&i({...s._formState,...m})}}),[a,n,o]),lt.useEffect(()=>{d.current.isValid&&s._setValid(!0)},[s]),lt.useMemo(()=>iBe(l,s,d.current,!1),[l,s])}var sx=e=>typeof e=="string",oBe=(e,t,s,n,a)=>sx(e)?(n&&t.watch.add(e),ln(s,e,a)):Array.isArray(e)?e.map(o=>(n&&t.watch.add(o),ln(s,o))):(n&&(t.watchAll=!0),s),Cpe=e=>lh(e)||!sBe(e);function ky(e,t,s=new WeakSet){if(Cpe(e)||Cpe(t))return e===t;if(qj(e)&&qj(t))return e.getTime()===t.getTime();const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;if(s.has(e)||s.has(t))return!0;s.add(e),s.add(t);for(const o of n){const l=e[o];if(!a.includes(o))return!1;if(o!=="ref"){const i=t[o];if(qj(l)&&qj(i)||qc(l)&&qc(i)||Array.isArray(l)&&Array.isArray(i)?!ky(l,i,s):l!==i)return!1}}return!0}function Rvt(e){const t=Iie(),{control:s=t.control,name:n,defaultValue:a,disabled:o,exact:l,compute:i}=e||{},d=lt.useRef(a),m=lt.useRef(i),p=lt.useRef(void 0);m.current=i;const g=lt.useMemo(()=>s._getWatch(n,d.current),[s,n]),[v,_]=lt.useState(m.current?m.current(g):g);return Jve(()=>s._subscribe({name:n,formState:{values:!0},exact:l,callback:k=>{if(!o){const w=oBe(n,s._names,k.values||s._formValues,!1,d.current);if(m.current){const S=m.current(w);ky(S,p.current)||(_(S),p.current=S)}else _(w)}}}),[s,o,n,l]),lt.useEffect(()=>s._removeUnmounted()),v}function Fvt(e){const t=Iie(),{name:s,disabled:n,control:a=t.control,shouldUnregister:o,defaultValue:l}=e,i=aBe(a._names.array,s),d=lt.useMemo(()=>ln(a._formValues,s,ln(a._defaultValues,s,l)),[a,s,l]),m=Rvt({control:a,name:s,defaultValue:d,exact:!0}),p=Ovt({control:a,name:s,exact:!0}),g=lt.useRef(e),v=lt.useRef(a.register(s,{...e.rules,value:m,...km(e.disabled)?{disabled:e.disabled}:{}}));g.current=e;const _=lt.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ln(p.errors,s)},isDirty:{enumerable:!0,get:()=>!!ln(p.dirtyFields,s)},isTouched:{enumerable:!0,get:()=>!!ln(p.touchedFields,s)},isValidating:{enumerable:!0,get:()=>!!ln(p.validatingFields,s)},error:{enumerable:!0,get:()=>ln(p.errors,s)}}),[p,s]),k=lt.useCallback(C=>v.current.onChange({target:{value:nBe(C),name:s},type:bse.CHANGE}),[s]),w=lt.useCallback(()=>v.current.onBlur({target:{value:ln(a._formValues,s),name:s},type:bse.BLUR}),[s,a._formValues]),S=lt.useCallback(C=>{const I=ln(a._fields,s);I&&C&&(I._f.ref={focus:()=>C.focus&&C.focus(),select:()=>C.select&&C.select(),setCustomValidity:R=>C.setCustomValidity(R),reportValidity:()=>C.reportValidity()})},[a._fields,s]),T=lt.useMemo(()=>({name:s,value:m,...km(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:k,onBlur:w,ref:S}),[s,n,p.disabled,k,w,S,m]);return lt.useEffect(()=>{const C=a._options.shouldUnregister||o;a.register(s,{...g.current.rules,...km(g.current.disabled)?{disabled:g.current.disabled}:{}});const I=(R,D)=>{const B=ln(a._fields,R);B&&B._f&&(B._f.mount=D)};if(I(s,!0),C){const R=yd(ln(a._options.defaultValues,s));Ro(a._defaultValues,s,R),Dc(ln(a._formValues,s))&&Ro(a._formValues,s,R)}return!i&&a.register(s),()=>{(i?C&&!a._state.action:C)?a.unregister(s):I(s,!1)}},[s,a,i,o]),lt.useEffect(()=>{a._setDisabledField({disabled:n,name:s})},[n,s,a]),lt.useMemo(()=>({field:T,formState:p,fieldState:_}),[T,p,_])}const zvt=e=>e.render(Fvt(e));var lBe=(e,t,s,n,a)=>t?{...s[e],types:{...s[e]&&s[e].types?s[e].types:{},[n]:a||!0}}:{},ZE=e=>Array.isArray(e)?e:[e],L4e=()=>{let e=[];return{get observers(){return e},next:a=>{for(const o of e)o.next&&o.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(o=>o!==a)}}),unsubscribe:()=>{e=[]}}},zh=e=>qc(e)&&!Object.keys(e).length,e1e=e=>e.type==="file",Hp=e=>typeof e=="function",wse=e=>{if(!Zve)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},cBe=e=>e.type==="select-multiple",t1e=e=>e.type==="radio",Bvt=e=>t1e(e)||T6(e),Tue=e=>wse(e)&&e.isConnected;function $vt(e,t){const s=t.slice(0,-1).length;let n=0;for(;n{for(const t in e)if(Hp(e[t]))return!0;return!1};function jse(e,t={}){const s=Array.isArray(e);if(qc(e)||s)for(const n in e)Array.isArray(e[n])||qc(e[n])&&!dBe(e[n])?(t[n]=Array.isArray(e[n])?[]:{},jse(e[n],t[n])):lh(e[n])||(t[n]=!0);return t}function uBe(e,t,s){const n=Array.isArray(e);if(qc(e)||n)for(const a in e)Array.isArray(e[a])||qc(e[a])&&!dBe(e[a])?Dc(t)||Cpe(s[a])?s[a]=Array.isArray(e[a])?jse(e[a],[]):{...jse(e[a])}:uBe(e[a],lh(t)?{}:t[a],s[a]):s[a]=!ky(e[a],t[a]);return s}var fA=(e,t)=>uBe(e,t,jse(t));const D4e={value:!1,isValid:!1},O4e={value:!0,isValid:!0};var hBe=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(s=>s&&s.checked&&!s.disabled).map(s=>s.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Dc(e[0].attributes.value)?Dc(e[0].value)||e[0].value===""?O4e:{value:e[0].value,isValid:!0}:O4e:D4e}return D4e},mBe=(e,{valueAsNumber:t,valueAsDate:s,setValueAs:n})=>Dc(e)?e:t?e===""?NaN:e&&+e:s&&sx(e)?new Date(e):n?n(e):e;const R4e={isValid:!1,value:null};var fBe=e=>Array.isArray(e)?e.reduce((t,s)=>s&&s.checked&&!s.disabled?{isValid:!0,value:s.value}:t,R4e):R4e;function F4e(e){const t=e.ref;return e1e(t)?t.files:t1e(t)?fBe(e.refs).value:cBe(t)?[...t.selectedOptions].map(({value:s})=>s):T6(t)?hBe(e.refs).value:mBe(Dc(t.value)?e.ref.value:t.value,e)}var Vvt=(e,t,s,n)=>{const a={};for(const o of e){const l=ln(t,o);l&&Ro(a,o,l._f)}return{criteriaMode:s,names:[...e],fields:a,shouldUseNativeValidation:n}},kse=e=>e instanceof RegExp,pA=e=>Dc(e)?e:kse(e)?e.source:qc(e)?kse(e.value)?e.value.source:e.value:e,z4e=e=>({isOnSubmit:!e||e===qp.onSubmit,isOnBlur:e===qp.onBlur,isOnChange:e===qp.onChange,isOnAll:e===qp.all,isOnTouch:e===qp.onTouched});const B4e="AsyncFunction";var qvt=e=>!!e&&!!e.validate&&!!(Hp(e.validate)&&e.validate.constructor.name===B4e||qc(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===B4e)),Hvt=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),$4e=(e,t,s)=>!s&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(n)&&/^\.\w+/.test(e.slice(n.length))));const YE=(e,t,s,n)=>{for(const a of s||Object.keys(e)){const o=ln(e,a);if(o){const{_f:l,...i}=o;if(l){if(l.refs&&l.refs[0]&&t(l.refs[0],a)&&!n)return!0;if(l.ref&&t(l.ref,l.name)&&!n)return!0;if(YE(i,t))break}else if(qc(i)&&YE(i,t))break}}};function U4e(e,t,s){const n=ln(e,s);if(n||Eie(s))return{error:n,name:s};const a=s.split(".");for(;a.length;){const o=a.join("."),l=ln(t,o),i=ln(e,o);if(l&&!Array.isArray(l)&&s!==o)return{name:s};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:s}}var Wvt=(e,t,s,n)=>{s(e);const{name:a,...o}=e;return zh(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(l=>t[l]===(!n||qp.all))},Gvt=(e,t,s)=>!e||!t||e===t||ZE(e).some(n=>n&&(s?n===t:n.startsWith(t)||t.startsWith(n))),Kvt=(e,t,s,n,a)=>a.isOnAll?!1:!s&&a.isOnTouch?!(t||e):(s?n.isOnBlur:a.isOnBlur)?!e:(s?n.isOnChange:a.isOnChange)?e:!0,Zvt=(e,t)=>!Yve(ln(e,t)).length&&Qc(e,t),Yvt=(e,t,s)=>{const n=ZE(ln(e,s));return Ro(n,"root",t[s]),Ro(e,s,n),e},are=e=>sx(e);function V4e(e,t,s="validate"){if(are(e)||Array.isArray(e)&&e.every(are)||km(e)&&!e)return{type:s,message:are(e)?e:"",ref:t}}var bC=e=>qc(e)&&!kse(e)?e:{value:e,message:""},q4e=async(e,t,s,n,a,o)=>{const{ref:l,refs:i,required:d,maxLength:m,minLength:p,min:g,max:v,pattern:_,validate:k,name:w,valueAsNumber:S,mount:T}=e._f,C=ln(s,w);if(!T||t.has(w))return{};const I=i?i[0]:l,R=ae=>{a&&I.reportValidity&&(I.setCustomValidity(km(ae)?"":ae||""),I.reportValidity())},D={},B=t1e(l),$=T6(l),q=B||$,W=(S||e1e(l))&&Dc(l.value)&&Dc(C)||wse(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,K=lBe.bind(null,w,n,D),re=(ae,oe,se,pe=oy.maxLength,ie=oy.minLength)=>{const de=ae?oe:se;D[w]={type:ae?pe:ie,message:de,ref:l,...K(ae?pe:ie,de)}};if(o?!Array.isArray(C)||!C.length:d&&(!q&&(W||lh(C))||km(C)&&!C||$&&!hBe(i).isValid||B&&!fBe(i).isValid)){const{value:ae,message:oe}=are(d)?{value:!!d,message:d}:bC(d);if(ae&&(D[w]={type:oy.required,message:oe,ref:I,...K(oy.required,oe)},!n))return R(oe),D}if(!W&&(!lh(g)||!lh(v))){let ae,oe;const se=bC(v),pe=bC(g);if(!lh(C)&&!isNaN(C)){const ie=l.valueAsNumber||C&&+C;lh(se.value)||(ae=ie>se.value),lh(pe.value)||(oe=ienew Date(new Date().toDateString()+" "+Te),ce=l.type=="time",ge=l.type=="week";sx(se.value)&&C&&(ae=ce?de(C)>de(se.value):ge?C>se.value:ie>new Date(se.value)),sx(pe.value)&&C&&(oe=ce?de(C)+ae.value,pe=!lh(oe.value)&&C.length<+oe.value;if((se||pe)&&(re(se,ae.message,oe.message),!n))return R(D[w].message),D}if(_&&!W&&sx(C)){const{value:ae,message:oe}=bC(_);if(kse(ae)&&!C.match(ae)&&(D[w]={type:oy.pattern,message:oe,ref:l,...K(oy.pattern,oe)},!n))return R(oe),D}if(k){if(Hp(k)){const ae=await k(C,s),oe=V4e(ae,I);if(oe&&(D[w]={...oe,...K(oy.validate,oe.message)},!n))return R(oe.message),D}else if(qc(k)){let ae={};for(const oe in k){if(!zh(ae)&&!n)break;const se=V4e(await k[oe](C,s),I,oe);se&&(ae={...se,...K(oe,se.message)},R(se.message),n&&(D[w]=ae))}if(!zh(ae)&&(D[w]={ref:I,...ae},!n))return D}}return R(!0),D};const Xvt={mode:qp.onSubmit,reValidateMode:qp.onChange,shouldFocusError:!0};function Qvt(e={}){let t={...Xvt,...e},s={submitCount:0,isDirty:!1,isReady:!1,isLoading:Hp(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},n={},a=qc(t.defaultValues)||qc(t.values)?yd(t.defaultValues||t.values)||{}:{},o=t.shouldUnregister?{}:yd(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,m=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let g={...p};const v={array:L4e(),state:L4e()},_=t.criteriaMode===qp.all,k=Se=>et=>{clearTimeout(m),m=setTimeout(Se,et)},w=async Se=>{if(!t.disabled&&(p.isValid||g.isValid||Se)){const et=t.resolver?zh((await $()).errors):await W(n,!0);et!==s.isValid&&v.state.next({isValid:et})}},S=(Se,et)=>{!t.disabled&&(p.isValidating||p.validatingFields||g.isValidating||g.validatingFields)&&((Se||Array.from(i.mount)).forEach(Qe=>{Qe&&(et?Ro(s.validatingFields,Qe,et):Qc(s.validatingFields,Qe))}),v.state.next({validatingFields:s.validatingFields,isValidating:!zh(s.validatingFields)}))},T=(Se,et=[],Qe,He,ot=!0,ut=!0)=>{if(He&&Qe&&!t.disabled){if(l.action=!0,ut&&Array.isArray(ln(n,Se))){const ft=Qe(ln(n,Se),He.argA,He.argB);ot&&Ro(n,Se,ft)}if(ut&&Array.isArray(ln(s.errors,Se))){const ft=Qe(ln(s.errors,Se),He.argA,He.argB);ot&&Ro(s.errors,Se,ft),Zvt(s.errors,Se)}if((p.touchedFields||g.touchedFields)&&ut&&Array.isArray(ln(s.touchedFields,Se))){const ft=Qe(ln(s.touchedFields,Se),He.argA,He.argB);ot&&Ro(s.touchedFields,Se,ft)}(p.dirtyFields||g.dirtyFields)&&(s.dirtyFields=fA(a,o)),v.state.next({name:Se,isDirty:re(Se,et),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else Ro(o,Se,et)},C=(Se,et)=>{Ro(s.errors,Se,et),v.state.next({errors:s.errors})},I=Se=>{s.errors=Se,v.state.next({errors:s.errors,isValid:!1})},R=(Se,et,Qe,He)=>{const ot=ln(n,Se);if(ot){const ut=ln(o,Se,Dc(Qe)?ln(a,Se):Qe);Dc(ut)||He&&He.defaultChecked||et?Ro(o,Se,et?ut:F4e(ot._f)):se(Se,ut),l.mount&&w()}},D=(Se,et,Qe,He,ot)=>{let ut=!1,ft=!1;const ct={name:Se};if(!t.disabled){if(!Qe||He){(p.isDirty||g.isDirty)&&(ft=s.isDirty,s.isDirty=ct.isDirty=re(),ut=ft!==ct.isDirty);const Tt=ky(ln(a,Se),et);ft=!!ln(s.dirtyFields,Se),Tt?Qc(s.dirtyFields,Se):Ro(s.dirtyFields,Se,!0),ct.dirtyFields=s.dirtyFields,ut=ut||(p.dirtyFields||g.dirtyFields)&&ft!==!Tt}if(Qe){const Tt=ln(s.touchedFields,Se);Tt||(Ro(s.touchedFields,Se,Qe),ct.touchedFields=s.touchedFields,ut=ut||(p.touchedFields||g.touchedFields)&&Tt!==Qe)}ut&&ot&&v.state.next(ct)}return ut?ct:{}},B=(Se,et,Qe,He)=>{const ot=ln(s.errors,Se),ut=(p.isValid||g.isValid)&&km(et)&&s.isValid!==et;if(t.delayError&&Qe?(d=k(()=>C(Se,Qe)),d(t.delayError)):(clearTimeout(m),d=null,Qe?Ro(s.errors,Se,Qe):Qc(s.errors,Se)),(Qe?!ky(ot,Qe):ot)||!zh(He)||ut){const ft={...He,...ut&&km(et)?{isValid:et}:{},errors:s.errors,name:Se};s={...s,...ft},v.state.next(ft)}},$=async Se=>{S(Se,!0);const et=await t.resolver(o,t.context,Vvt(Se||i.mount,n,t.criteriaMode,t.shouldUseNativeValidation));return S(Se),et},q=async Se=>{const{errors:et}=await $(Se);if(Se)for(const Qe of Se){const He=ln(et,Qe);He?Ro(s.errors,Qe,He):Qc(s.errors,Qe)}else s.errors=et;return et},W=async(Se,et,Qe={valid:!0})=>{for(const He in Se){const ot=Se[He];if(ot){const{_f:ut,...ft}=ot;if(ut){const ct=i.array.has(ut.name),Tt=ot._f&&qvt(ot._f);Tt&&p.validatingFields&&S([He],!0);const Ot=await q4e(ot,i.disabled,o,_,t.shouldUseNativeValidation&&!et,ct);if(Tt&&p.validatingFields&&S([He]),Ot[ut.name]&&(Qe.valid=!1,et))break;!et&&(ln(Ot,ut.name)?ct?Yvt(s.errors,Ot,ut.name):Ro(s.errors,ut.name,Ot[ut.name]):Qc(s.errors,ut.name))}!zh(ft)&&await W(ft,et,Qe)}}return Qe.valid},K=()=>{for(const Se of i.unMount){const et=ln(n,Se);et&&(et._f.refs?et._f.refs.every(Qe=>!Tue(Qe)):!Tue(et._f.ref))&&Ue(Se)}i.unMount=new Set},re=(Se,et)=>!t.disabled&&(Se&&et&&Ro(o,Se,et),!ky(Te(),a)),ae=(Se,et,Qe)=>oBe(Se,i,{...l.mount?o:Dc(et)?a:sx(Se)?{[Se]:et}:et},Qe,et),oe=Se=>Yve(ln(l.mount?o:a,Se,t.shouldUnregister?ln(a,Se,[]):[])),se=(Se,et,Qe={})=>{const He=ln(n,Se);let ot=et;if(He){const ut=He._f;ut&&(!ut.disabled&&Ro(o,Se,mBe(et,ut)),ot=wse(ut.ref)&&lh(et)?"":et,cBe(ut.ref)?[...ut.ref.options].forEach(ft=>ft.selected=ot.includes(ft.value)):ut.refs?T6(ut.ref)?ut.refs.forEach(ft=>{(!ft.defaultChecked||!ft.disabled)&&(Array.isArray(ot)?ft.checked=!!ot.find(ct=>ct===ft.value):ft.checked=ot===ft.value||!!ot)}):ut.refs.forEach(ft=>ft.checked=ft.value===ot):e1e(ut.ref)?ut.ref.value="":(ut.ref.value=ot,ut.ref.type||v.state.next({name:Se,values:yd(o)})))}(Qe.shouldDirty||Qe.shouldTouch)&&D(Se,ot,Qe.shouldTouch,Qe.shouldDirty,!0),Qe.shouldValidate&&ge(Se)},pe=(Se,et,Qe)=>{for(const He in et){if(!et.hasOwnProperty(He))return;const ot=et[He],ut=Se+"."+He,ft=ln(n,ut);(i.array.has(Se)||qc(ot)||ft&&!ft._f)&&!qj(ot)?pe(ut,ot,Qe):se(ut,ot,Qe)}},ie=(Se,et,Qe={})=>{const He=ln(n,Se),ot=i.array.has(Se),ut=yd(et);Ro(o,Se,ut),ot?(v.array.next({name:Se,values:yd(o)}),(p.isDirty||p.dirtyFields||g.isDirty||g.dirtyFields)&&Qe.shouldDirty&&v.state.next({name:Se,dirtyFields:fA(a,o),isDirty:re(Se,ut)})):He&&!He._f&&!lh(ut)?pe(Se,ut,Qe):se(Se,ut,Qe),$4e(Se,i)&&v.state.next({...s,name:Se}),v.state.next({name:l.mount?Se:void 0,values:yd(o)})},de=async Se=>{l.mount=!0;const et=Se.target;let Qe=et.name,He=!0;const ot=ln(n,Qe),ut=Tt=>{He=Number.isNaN(Tt)||qj(Tt)&&isNaN(Tt.getTime())||ky(Tt,ln(o,Qe,Tt))},ft=z4e(t.mode),ct=z4e(t.reValidateMode);if(ot){let Tt,Ot;const rr=et.type?F4e(ot._f):nBe(Se),Lr=Se.type===bse.BLUR||Se.type===bse.FOCUS_OUT,cr=!Hvt(ot._f)&&!t.resolver&&!ln(s.errors,Qe)&&!ot._f.deps||Kvt(Lr,ln(s.touchedFields,Qe),s.isSubmitted,ct,ft),Mr=$4e(Qe,i,Lr);Ro(o,Qe,rr),Lr?(ot._f.onBlur&&ot._f.onBlur(Se),d&&d(0)):ot._f.onChange&&ot._f.onChange(Se);const As=D(Qe,rr,Lr),Et=!zh(As)||Mr;if(!Lr&&v.state.next({name:Qe,type:Se.type,values:yd(o)}),cr)return(p.isValid||g.isValid)&&(t.mode==="onBlur"?Lr&&w():Lr||w()),Et&&v.state.next({name:Qe,...Mr?{}:As});if(!Lr&&Mr&&v.state.next({...s}),t.resolver){const{errors:Pt}=await $([Qe]);if(ut(rr),He){const Sr=U4e(s.errors,n,Qe),fs=U4e(Pt,n,Sr.name||Qe);Tt=fs.error,Qe=fs.name,Ot=zh(Pt)}}else S([Qe],!0),Tt=(await q4e(ot,i.disabled,o,_,t.shouldUseNativeValidation))[Qe],S([Qe]),ut(rr),He&&(Tt?Ot=!1:(p.isValid||g.isValid)&&(Ot=await W(n,!0)));He&&(ot._f.deps&&ge(ot._f.deps),B(Qe,Ot,Tt,As))}},ce=(Se,et)=>{if(ln(s.errors,et)&&Se.focus)return Se.focus(),1},ge=async(Se,et={})=>{let Qe,He;const ot=ZE(Se);if(t.resolver){const ut=await q(Dc(Se)?Se:ot);Qe=zh(ut),He=Se?!ot.some(ft=>ln(ut,ft)):Qe}else Se?(He=(await Promise.all(ot.map(async ut=>{const ft=ln(n,ut);return await W(ft&&ft._f?{[ut]:ft}:ft)}))).every(Boolean),!(!He&&!s.isValid)&&w()):He=Qe=await W(n);return v.state.next({...!sx(Se)||(p.isValid||g.isValid)&&Qe!==s.isValid?{}:{name:Se},...t.resolver||!Se?{isValid:Qe}:{},errors:s.errors}),et.shouldFocus&&!He&&YE(n,ce,Se?ot:i.mount),He},Te=Se=>{const et={...l.mount?o:a};return Dc(Se)?et:sx(Se)?ln(et,Se):Se.map(Qe=>ln(et,Qe))},_e=(Se,et)=>({invalid:!!ln((et||s).errors,Se),isDirty:!!ln((et||s).dirtyFields,Se),error:ln((et||s).errors,Se),isValidating:!!ln(s.validatingFields,Se),isTouched:!!ln((et||s).touchedFields,Se)}),ve=Se=>{Se&&ZE(Se).forEach(et=>Qc(s.errors,et)),v.state.next({errors:Se?s.errors:{}})},Me=(Se,et,Qe)=>{const He=(ln(n,Se,{_f:{}})._f||{}).ref,ot=ln(s.errors,Se)||{},{ref:ut,message:ft,type:ct,...Tt}=ot;Ro(s.errors,Se,{...Tt,...et,ref:He}),v.state.next({name:Se,errors:s.errors,isValid:!1}),Qe&&Qe.shouldFocus&&He&&He.focus&&He.focus()},Ze=(Se,et)=>Hp(Se)?v.state.subscribe({next:Qe=>"values"in Qe&&Se(ae(void 0,et),Qe)}):ae(Se,et,!0),Ae=Se=>v.state.subscribe({next:et=>{Gvt(Se.name,et.name,Se.exact)&&Wvt(et,Se.formState||p,rt,Se.reRenderRoot)&&Se.callback({values:{...o},...s,...et,defaultValues:a})}}).unsubscribe,Le=Se=>(l.mount=!0,g={...g,...Se.formState},Ae({...Se,formState:g})),Ue=(Se,et={})=>{for(const Qe of Se?ZE(Se):i.mount)i.mount.delete(Qe),i.array.delete(Qe),et.keepValue||(Qc(n,Qe),Qc(o,Qe)),!et.keepError&&Qc(s.errors,Qe),!et.keepDirty&&Qc(s.dirtyFields,Qe),!et.keepTouched&&Qc(s.touchedFields,Qe),!et.keepIsValidating&&Qc(s.validatingFields,Qe),!t.shouldUnregister&&!et.keepDefaultValue&&Qc(a,Qe);v.state.next({values:yd(o)}),v.state.next({...s,...et.keepDirty?{isDirty:re()}:{}}),!et.keepIsValid&&w()},Ve=({disabled:Se,name:et})=>{(km(Se)&&l.mount||Se||i.disabled.has(et))&&(Se?i.disabled.add(et):i.disabled.delete(et))},Ie=(Se,et={})=>{let Qe=ln(n,Se);const He=km(et.disabled)||km(t.disabled);return Ro(n,Se,{...Qe||{},_f:{...Qe&&Qe._f?Qe._f:{ref:{name:Se}},name:Se,mount:!0,...et}}),i.mount.add(Se),Qe?Ve({disabled:km(et.disabled)?et.disabled:t.disabled,name:Se}):R(Se,!0,et.value),{...He?{disabled:et.disabled||t.disabled}:{},...t.progressive?{required:!!et.required,min:pA(et.min),max:pA(et.max),minLength:pA(et.minLength),maxLength:pA(et.maxLength),pattern:pA(et.pattern)}:{},name:Se,onChange:de,onBlur:de,ref:ot=>{if(ot){Ie(Se,et),Qe=ln(n,Se);const ut=Dc(ot.value)&&ot.querySelectorAll&&ot.querySelectorAll("input,select,textarea")[0]||ot,ft=Bvt(ut),ct=Qe._f.refs||[];if(ft?ct.find(Tt=>Tt===ut):ut===Qe._f.ref)return;Ro(n,Se,{_f:{...Qe._f,...ft?{refs:[...ct.filter(Tue),ut,...Array.isArray(ln(a,Se))?[{}]:[]],ref:{type:ut.type,name:Se}}:{ref:ut}}}),R(Se,!1,void 0,ut)}else Qe=ln(n,Se,{}),Qe._f&&(Qe._f.mount=!1),(t.shouldUnregister||et.shouldUnregister)&&!(aBe(i.array,Se)&&l.action)&&i.unMount.add(Se)}}},We=()=>t.shouldFocusError&&YE(n,ce,i.mount),wt=Se=>{km(Se)&&(v.state.next({disabled:Se}),YE(n,(et,Qe)=>{const He=ln(n,Qe);He&&(et.disabled=He._f.disabled||Se,Array.isArray(He._f.refs)&&He._f.refs.forEach(ot=>{ot.disabled=He._f.disabled||Se}))},0,!1))},Pe=(Se,et)=>async Qe=>{let He;Qe&&(Qe.preventDefault&&Qe.preventDefault(),Qe.persist&&Qe.persist());let ot=yd(o);if(v.state.next({isSubmitting:!0}),t.resolver){const{errors:ut,values:ft}=await $();s.errors=ut,ot=yd(ft)}else await W(n);if(i.disabled.size)for(const ut of i.disabled)Qc(ot,ut);if(Qc(s.errors,"root"),zh(s.errors)){v.state.next({errors:{}});try{await Se(ot,Qe)}catch(ut){He=ut}}else et&&await et({...s.errors},Qe),We(),setTimeout(We);if(v.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:zh(s.errors)&&!He,submitCount:s.submitCount+1,errors:s.errors}),He)throw He},st=(Se,et={})=>{ln(n,Se)&&(Dc(et.defaultValue)?ie(Se,yd(ln(a,Se))):(ie(Se,et.defaultValue),Ro(a,Se,yd(et.defaultValue))),et.keepTouched||Qc(s.touchedFields,Se),et.keepDirty||(Qc(s.dirtyFields,Se),s.isDirty=et.defaultValue?re(Se,yd(ln(a,Se))):re()),et.keepError||(Qc(s.errors,Se),p.isValid&&w()),v.state.next({...s}))},ue=(Se,et={})=>{const Qe=Se?yd(Se):a,He=yd(Qe),ot=zh(Se),ut=ot?a:He;if(et.keepDefaultValues||(a=Qe),!et.keepValues){if(et.keepDirtyValues){const ft=new Set([...i.mount,...Object.keys(fA(a,o))]);for(const ct of Array.from(ft))ln(s.dirtyFields,ct)?Ro(ut,ct,ln(o,ct)):ie(ct,ln(ut,ct))}else{if(Zve&&Dc(Se))for(const ft of i.mount){const ct=ln(n,ft);if(ct&&ct._f){const Tt=Array.isArray(ct._f.refs)?ct._f.refs[0]:ct._f.ref;if(wse(Tt)){const Ot=Tt.closest("form");if(Ot){Ot.reset();break}}}}if(et.keepFieldsRef)for(const ft of i.mount)ie(ft,ln(ut,ft));else n={}}o=t.shouldUnregister?et.keepDefaultValues?yd(a):{}:yd(ut),v.array.next({values:{...ut}}),v.state.next({values:{...ut}})}i={mount:et.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!et.keepIsValid||!!et.keepDirtyValues,l.watch=!!t.shouldUnregister,v.state.next({submitCount:et.keepSubmitCount?s.submitCount:0,isDirty:ot?!1:et.keepDirty?s.isDirty:!!(et.keepDefaultValues&&!ky(Se,a)),isSubmitted:et.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:ot?{}:et.keepDirtyValues?et.keepDefaultValues&&o?fA(a,o):s.dirtyFields:et.keepDefaultValues&&Se?fA(a,Se):et.keepDirty?s.dirtyFields:{},touchedFields:et.keepTouched?s.touchedFields:{},errors:et.keepErrors?s.errors:{},isSubmitSuccessful:et.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1})},$e=(Se,et)=>ue(Hp(Se)?Se(o):Se,et),tt=(Se,et={})=>{const Qe=ln(n,Se),He=Qe&&Qe._f;if(He){const ot=He.refs?He.refs[0]:He.ref;ot.focus&&(ot.focus(),et.shouldSelect&&Hp(ot.select)&&ot.select())}},rt=Se=>{s={...s,...Se}},it={control:{register:Ie,unregister:Ue,getFieldState:_e,handleSubmit:Pe,setError:Me,_subscribe:Ae,_runSchema:$,_focusError:We,_getWatch:ae,_getDirty:re,_setValid:w,_setFieldArray:T,_setDisabledField:Ve,_setErrors:I,_getFieldArray:oe,_reset:ue,_resetDefaultValues:()=>Hp(t.defaultValues)&&t.defaultValues().then(Se=>{$e(Se,t.resetOptions),v.state.next({isLoading:!1})}),_removeUnmounted:K,_disableForm:wt,_subjects:v,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(Se){l=Se},get _defaultValues(){return a},get _names(){return i},set _names(Se){i=Se},get _formState(){return s},get _options(){return t},set _options(Se){t={...t,...Se}}},subscribe:Le,trigger:ge,register:Ie,handleSubmit:Pe,watch:Ze,setValue:ie,getValues:Te,reset:$e,resetField:st,clearErrors:ve,unregister:Ue,setError:Me,setFocus:tt,getFieldState:_e};return{...it,formControl:it}}function Pie(e={}){const t=lt.useRef(void 0),s=lt.useRef(void 0),[n,a]=lt.useState({isDirty:!1,isValidating:!1,isLoading:Hp(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:Hp(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:n},e.defaultValues&&!Hp(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...i}=Qvt(e);t.current={...i,formState:n}}const o=t.current.control;return o._options=e,Jve(()=>{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(e.disabled),[o,e.disabled]),lt.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),lt.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),lt.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.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(()=>{e.values&&!ky(e.values,s.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),s.current=e.values,a(l=>({...l}))):o._resetDefaultValues()},[o,e.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()}),t.current.formState=iBe(n,o),t.current}const H4e=(e,t,s)=>{if(e&&"reportValidity"in e){const n=ln(s,t);e.setCustomValidity(n&&n.message||""),e.reportValidity()}},pBe=(e,t)=>{for(const s in t.fields){const n=t.fields[s];n&&n.ref&&"reportValidity"in n.ref?H4e(n.ref,s,e):n.refs&&n.refs.forEach(a=>H4e(a,s,e))}},Jvt=(e,t)=>{t.shouldUseNativeValidation&&pBe(e,t);const s={};for(const n in e){const a=ln(t.fields,n),o=Object.assign(e[n]||{},{ref:a&&a.ref});if(e1t(t.names||Object.keys(e),n)){const l=Object.assign({},ln(s,n));Ro(l,"root",o),Ro(s,n,l)}else Ro(s,n,o)}return s},e1t=(e,t)=>e.some(s=>s.startsWith(t+"."));var t1t=function(e,t){for(var s={};e.length;){var n=e[0],a=n.code,o=n.message,l=n.path.join(".");if(!s[l])if("unionErrors"in n){var i=n.unionErrors[0].errors[0];s[l]={message:i.message,type:i.code}}else s[l]={message:o,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(p){return p.errors.forEach(function(g){return e.push(g)})}),t){var d=s[l].types,m=d&&d[n.code];s[l]=lBe(l,t,s,a,m?[].concat(m,n.message):n.message)}e.shift()}return s},Lie=function(e,t,s){return s===void 0&&(s={}),function(n,a,o){try{return Promise.resolve(function(l,i){try{var d=Promise.resolve(e[s.mode==="sync"?"parse":"parseAsync"](n,t)).then(function(m){return o.shouldUseNativeValidation&&pBe({},o),{errors:{},values:s.raw?n:m}})}catch(m){return i(m)}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:Jvt(t1t(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const Die=Dvt,gBe=A.createContext({}),Hl=({...e})=>r.jsx(gBe.Provider,{value:{name:e.name},children:r.jsx(zvt,{...e})}),Oie=()=>{const e=A.useContext(gBe),t=A.useContext(xBe),{getFieldState:s,formState:n}=Iie(),a=s(e.name,n);if(!e)throw new Error("useFormField should be used within ");const{id:o}=t;return{id:o,name:e.name,formItemId:`${o}-form-item`,formDescriptionId:`${o}-form-item-description`,formMessageId:`${o}-form-item-message`,...a}},xBe=A.createContext({}),Il=A.forwardRef(({className:e,...t},s)=>{const n=A.useId();return r.jsx(xBe.Provider,{value:{id:n},children:r.jsx("div",{ref:s,className:Vt("space-y-2",e),...t})})});Il.displayName="FormItem";const Pl=A.forwardRef(({className:e,...t},s)=>{const{error:n,formItemId:a}=Oie();return r.jsx(Ee,{ref:s,className:Vt(n&&"text-destructive",e),htmlFor:a,...t})});Pl.displayName="FormLabel";const Ll=A.forwardRef(({...e},t)=>{const{error:s,formItemId:n,formDescriptionId:a,formMessageId:o}=Oie();return r.jsx(S0e,{ref:t,id:n,"aria-describedby":s?`${a} ${o}`:`${a}`,"aria-invalid":!!s,...e})});Ll.displayName="FormControl";const ire=A.forwardRef(({className:e,...t},s)=>{const{formDescriptionId:n}=Oie();return r.jsx("p",{ref:s,id:n,className:Vt("text-sm text-muted-foreground",e),...t})});ire.displayName="FormDescription";const uh=A.forwardRef(({className:e,children:t,...s},n)=>{const{error:a,formMessageId:o}=Oie(),l=a?String(a==null?void 0:a.message):t;return l?r.jsx("p",{ref:n,id:o,className:Vt("text-sm font-medium text-destructive",e),...s,children:l}):null});uh.displayName="FormMessage";const qs=A.forwardRef(({className:e,...t},s)=>r.jsx("textarea",{className:Vt("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",e),ref:s,...t}));qs.displayName="Textarea";const r1t=i_({category:I7e(["general","technology","crm","marketing"]),subject:zo().min(5,"Subject must be at least 5 characters").max(200),description:zo().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),s1t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Mpe({trigger:e}){const[t,s]=A.useState(!1),[n,a]=A.useState(!1),{user:o}=Gr(),l=Pie({resolver:Lie(r1t),defaultValues:{category:"general",subject:"",description:""}}),i=async d=>{if(!o){we.error("You must be logged in to submit a ticket");return}a(!0);try{const{error:m}=await Y.from("support_tickets").insert({user_id:o.id,category:d.category,subject:d.subject,description:d.description});if(m)throw m;try{await Y.functions.invoke("support-ticket-notify",{body:{category:s1t[d.category],subject:d.subject}})}catch(p){console.log("Notification send attempted:",p)}we.success("Support ticket submitted successfully!"),l.reset(),s(!1)}catch(m){console.error("Error submitting ticket:",m),we.error("Failed to submit ticket. Please try again.")}finally{a(!1)}};return r.jsxs(Ir,{open:t,onOpenChange:s,children:[r.jsx(Qi,{asChild:!0,children:e||r.jsxs(X,{variant:"ghost",size:"icon",className:"relative",children:[r.jsx(wE,{className:"h-5 w-5"}),r.jsx("span",{className:"sr-only",children:"Support"})]})}),r.jsxs(Er,{className:"sm:max-w-[500px]",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Need Help?"}),r.jsx(Zs,{children:"Submit a support ticket and we'll get back to you as soon as possible."})]}),r.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg mb-4",children:[r.jsx(fi,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["You can also text us at: ",r.jsx("span",{className:"font-medium text-foreground",children:"1-866-527-8668"})]})]}),r.jsx(Die,{...l,children:r.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[r.jsx(Hl,{control:l.control,name:"category",render:({field:d})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Category"}),r.jsxs(ds,{onValueChange:d.onChange,defaultValue:d.value,children:[r.jsx(Ll,{children:r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a category"})})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"general",children:"General Support"}),r.jsx(Ut,{value:"technology",children:"Technology Support"}),r.jsx(Ut,{value:"crm",children:"CRM Support"}),r.jsx(Ut,{value:"marketing",children:"Marketing Support"})]})]}),r.jsx(uh,{})]})}),r.jsx(Hl,{control:l.control,name:"subject",render:({field:d})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Subject"}),r.jsx(Ll,{children:r.jsx(Ye,{placeholder:"Brief description of your issue",...d})}),r.jsx(uh,{})]})}),r.jsx(Hl,{control:l.control,name:"description",render:({field:d})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Description"}),r.jsx(Ll,{children:r.jsx(qs,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...d})}),r.jsx(uh,{})]})}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),r.jsx(X,{type:"submit",disabled:n,children:n?"Submitting...":"Submit Ticket"})]})]})})]})]})}const n1t=()=>{const{user:e}=Gr(),t=Ks(),[s,n]=A.useState([]),[a,o]=A.useState(0),[l,i]=A.useState(!1),[d,m]=A.useState(null);A.useEffect(()=>{if(!e)return;const k=`notification_last_read_${e.id}`;let w=d;if(!w){const C=localStorage.getItem(k);C&&(w=C,m(C))}(async()=>{const{data:C,error:I}=await Y.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!I&&C){n(C);const R=w?new Date(w):null,D=C.filter(B=>R?new Date(B.created_at)>R:!0);o(D.length)}})();const T=Y.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},C=>{const I=C.new;n(D=>[I,...D].slice(0,20));const R=w?new Date(w):null;(!R||new Date(I.created_at)>R)&&o(D=>D+1),Notification.permission==="granted"&&new Notification(I.title,{body:I.body,icon:"/favicon.ico"})}).subscribe();return()=>{Y.removeChannel(T)}},[e,d]);const p=k=>{const w=k.toLowerCase();return w.includes("community")||w.includes("post")?Vo:w.includes("academy")||w.includes("video")?ma:w.includes("template")?id:w.includes("event")?An:w.includes("newsletter")?Vy:w.includes("brokerage")?Pu:w.includes("swag")||w.includes("social")?po:w.includes("toolbox")||w.includes("tool")?Hy:w.includes("brief")?bn:Vo},g=k=>{i(!1),k.url&&k.url!=="/"&&t(k.url)},v=()=>{if(!e)return;const k=new Date().toISOString(),w=`notification_last_read_${e.id}`;localStorage.setItem(w,k),m(k),o(0)},_=k=>{i(k),k&&a>0&&v()};return r.jsxs(Bu,{open:l,onOpenChange:_,children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{variant:"ghost",size:"icon",className:"relative",children:[r.jsx(tg,{className:"h-5 w-5"}),a>0&&r.jsx(_t,{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})]})}),r.jsxs(vu,{align:"end",className:"w-80",children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b",children:[r.jsx("span",{className:"font-semibold",children:"Notifications"}),s.length>0&&r.jsx(X,{variant:"ghost",size:"sm",className:"text-xs h-6",onClick:v,children:"Mark all read"})]}),r.jsx(To,{className:"h-[300px]",children:s.length===0?r.jsx("div",{className:"p-4 text-center text-muted-foreground text-sm",children:"No notifications yet"}):s.map(k=>{const w=p(k.title);return r.jsxs(Ba,{className:"group flex items-start gap-3 p-3 cursor-pointer data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground",onClick:()=>g(k),children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.jsx(w,{className:"h-4 w-4 text-primary"})}),r.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[r.jsx("span",{className:"font-medium text-sm",children:k.title}),r.jsx("span",{className:"text-xs text-muted-foreground line-clamp-2 group-data-[highlighted]:text-accent-foreground/80",children:k.body}),r.jsx("span",{className:"text-xs text-muted-foreground group-data-[highlighted]:text-accent-foreground/80",children:gu(new Date(k.created_at),{addSuffix:!0})})]})]},k.id)})})]})]})};var W4e=1,a1t=.9,i1t=.8,o1t=.17,Aue=.1,Eue=.999,l1t=.9999,c1t=.99,d1t=/[\\\/_+.#"@\[\(\{&]/,u1t=/[\\\/_+.#"@\[\(\{&]/g,h1t=/[\s-]/,yBe=/[\s-]/g;function Tpe(e,t,s,n,a,o,l){if(o===t.length)return a===e.length?W4e:c1t;var i=`${a},${o}`;if(l[i]!==void 0)return l[i];for(var d=n.charAt(o),m=s.indexOf(d,a),p=0,g,v,_,k;m>=0;)g=Tpe(e,t,s,n,m+1,o+1,l),g>p&&(m===a?g*=W4e:d1t.test(e.charAt(m-1))?(g*=i1t,_=e.slice(a,m-1).match(u1t),_&&a>0&&(g*=Math.pow(Eue,_.length))):h1t.test(e.charAt(m-1))?(g*=a1t,k=e.slice(a,m-1).match(yBe),k&&a>0&&(g*=Math.pow(Eue,k.length))):(g*=o1t,a>0&&(g*=Math.pow(Eue,m-a))),e.charAt(m)!==t.charAt(o)&&(g*=l1t)),(gg&&(g=v*Aue)),g>p&&(p=g),m=s.indexOf(d,m+1);return l[i]=p,p}function G4e(e){return e.toLowerCase().replace(yBe," ")}function m1t(e,t,s){return e=s&&s.length>0?`${e+" "+s.join(" ")}`:e,Tpe(e,t,G4e(e),G4e(t),0,0,{})}var gA='[cmdk-group=""]',Iue='[cmdk-group-items=""]',f1t='[cmdk-group-heading=""]',vBe='[cmdk-item=""]',K4e=`${vBe}:not([aria-disabled="true"])`,Ape="cmdk-item-select",LC="data-value",p1t=(e,t,s)=>m1t(e,t,s),_Be=A.createContext(void 0),A6=()=>A.useContext(_Be),bBe=A.createContext(void 0),r1e=()=>A.useContext(bBe),wBe=A.createContext(void 0),jBe=A.forwardRef((e,t)=>{let s=DC(()=>{var ve,Me;return{search:"",value:(Me=(ve=e.value)!=null?ve:e.defaultValue)!=null?Me:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=DC(()=>new Set),a=DC(()=>new Map),o=DC(()=>new Map),l=DC(()=>new Set),i=kBe(e),{label:d,children:m,value:p,onValueChange:g,filter:v,shouldFilter:_,loop:k,disablePointerSelection:w=!1,vimBindings:S=!0,...T}=e,C=Md(),I=Md(),R=Md(),D=A.useRef(null),B=S1t();tN(()=>{if(p!==void 0){let ve=p.trim();s.current.value=ve,$.emit()}},[p]),tN(()=>{B(6,oe)},[]);let $=A.useMemo(()=>({subscribe:ve=>(l.current.add(ve),()=>l.current.delete(ve)),snapshot:()=>s.current,setState:(ve,Me,Ze)=>{var Ae,Le,Ue,Ve;if(!Object.is(s.current[ve],Me)){if(s.current[ve]=Me,ve==="search")ae(),K(),B(1,re);else if(ve==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Ie=document.getElementById(R);Ie?Ie.focus():(Ae=document.getElementById(C))==null||Ae.focus()}if(B(7,()=>{var Ie;s.current.selectedItemId=(Ie=se())==null?void 0:Ie.id,$.emit()}),Ze||B(5,oe),((Le=i.current)==null?void 0:Le.value)!==void 0){let Ie=Me??"";(Ve=(Ue=i.current).onValueChange)==null||Ve.call(Ue,Ie);return}}$.emit()}},emit:()=>{l.current.forEach(ve=>ve())}}),[]),q=A.useMemo(()=>({value:(ve,Me,Ze)=>{var Ae;Me!==((Ae=o.current.get(ve))==null?void 0:Ae.value)&&(o.current.set(ve,{value:Me,keywords:Ze}),s.current.filtered.items.set(ve,W(Me,Ze)),B(2,()=>{K(),$.emit()}))},item:(ve,Me)=>(n.current.add(ve),Me&&(a.current.has(Me)?a.current.get(Me).add(ve):a.current.set(Me,new Set([ve]))),B(3,()=>{ae(),K(),s.current.value||re(),$.emit()}),()=>{o.current.delete(ve),n.current.delete(ve),s.current.filtered.items.delete(ve);let Ze=se();B(4,()=>{ae(),(Ze==null?void 0:Ze.getAttribute("id"))===ve&&re(),$.emit()})}),group:ve=>(a.current.has(ve)||a.current.set(ve,new Set),()=>{o.current.delete(ve),a.current.delete(ve)}),filter:()=>i.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:C,inputId:R,labelId:I,listInnerRef:D}),[]);function W(ve,Me){var Ze,Ae;let Le=(Ae=(Ze=i.current)==null?void 0:Ze.filter)!=null?Ae:p1t;return ve?Le(ve,s.current.search,Me):0}function K(){if(!s.current.search||i.current.shouldFilter===!1)return;let ve=s.current.filtered.items,Me=[];s.current.filtered.groups.forEach(Ae=>{let Le=a.current.get(Ae),Ue=0;Le.forEach(Ve=>{let Ie=ve.get(Ve);Ue=Math.max(Ie,Ue)}),Me.push([Ae,Ue])});let Ze=D.current;pe().sort((Ae,Le)=>{var Ue,Ve;let Ie=Ae.getAttribute("id"),We=Le.getAttribute("id");return((Ue=ve.get(We))!=null?Ue:0)-((Ve=ve.get(Ie))!=null?Ve:0)}).forEach(Ae=>{let Le=Ae.closest(Iue);Le?Le.appendChild(Ae.parentElement===Le?Ae:Ae.closest(`${Iue} > *`)):Ze.appendChild(Ae.parentElement===Ze?Ae:Ae.closest(`${Iue} > *`))}),Me.sort((Ae,Le)=>Le[1]-Ae[1]).forEach(Ae=>{var Le;let Ue=(Le=D.current)==null?void 0:Le.querySelector(`${gA}[${LC}="${encodeURIComponent(Ae[0])}"]`);Ue==null||Ue.parentElement.appendChild(Ue)})}function re(){let ve=pe().find(Ze=>Ze.getAttribute("aria-disabled")!=="true"),Me=ve==null?void 0:ve.getAttribute(LC);$.setState("value",Me||void 0)}function ae(){var ve,Me,Ze,Ae;if(!s.current.search||i.current.shouldFilter===!1){s.current.filtered.count=n.current.size;return}s.current.filtered.groups=new Set;let Le=0;for(let Ue of n.current){let Ve=(Me=(ve=o.current.get(Ue))==null?void 0:ve.value)!=null?Me:"",Ie=(Ae=(Ze=o.current.get(Ue))==null?void 0:Ze.keywords)!=null?Ae:[],We=W(Ve,Ie);s.current.filtered.items.set(Ue,We),We>0&&Le++}for(let[Ue,Ve]of a.current)for(let Ie of Ve)if(s.current.filtered.items.get(Ie)>0){s.current.filtered.groups.add(Ue);break}s.current.filtered.count=Le}function oe(){var ve,Me,Ze;let Ae=se();Ae&&(((ve=Ae.parentElement)==null?void 0:ve.firstChild)===Ae&&((Ze=(Me=Ae.closest(gA))==null?void 0:Me.querySelector(f1t))==null||Ze.scrollIntoView({block:"nearest"})),Ae.scrollIntoView({block:"nearest"}))}function se(){var ve;return(ve=D.current)==null?void 0:ve.querySelector(`${vBe}[aria-selected="true"]`)}function pe(){var ve;return Array.from(((ve=D.current)==null?void 0:ve.querySelectorAll(K4e))||[])}function ie(ve){let Me=pe()[ve];Me&&$.setState("value",Me.getAttribute(LC))}function de(ve){var Me;let Ze=se(),Ae=pe(),Le=Ae.findIndex(Ve=>Ve===Ze),Ue=Ae[Le+ve];(Me=i.current)!=null&&Me.loop&&(Ue=Le+ve<0?Ae[Ae.length-1]:Le+ve===Ae.length?Ae[0]:Ae[Le+ve]),Ue&&$.setState("value",Ue.getAttribute(LC))}function ce(ve){let Me=se(),Ze=Me==null?void 0:Me.closest(gA),Ae;for(;Ze&&!Ae;)Ze=ve>0?k1t(Ze,gA):N1t(Ze,gA),Ae=Ze==null?void 0:Ze.querySelector(K4e);Ae?$.setState("value",Ae.getAttribute(LC)):de(ve)}let ge=()=>ie(pe().length-1),Te=ve=>{ve.preventDefault(),ve.metaKey?ge():ve.altKey?ce(1):de(1)},_e=ve=>{ve.preventDefault(),ve.metaKey?ie(0):ve.altKey?ce(-1):de(-1)};return A.createElement(Hs.div,{ref:t,tabIndex:-1,...T,"cmdk-root":"",onKeyDown:ve=>{var Me;(Me=T.onKeyDown)==null||Me.call(T,ve);let Ze=ve.nativeEvent.isComposing||ve.keyCode===229;if(!(ve.defaultPrevented||Ze))switch(ve.key){case"n":case"j":{S&&ve.ctrlKey&&Te(ve);break}case"ArrowDown":{Te(ve);break}case"p":case"k":{S&&ve.ctrlKey&&_e(ve);break}case"ArrowUp":{_e(ve);break}case"Home":{ve.preventDefault(),ie(0);break}case"End":{ve.preventDefault(),ge();break}case"Enter":{ve.preventDefault();let Ae=se();if(Ae){let Le=new Event(Ape);Ae.dispatchEvent(Le)}}}}},A.createElement("label",{"cmdk-label":"",htmlFor:q.inputId,id:q.labelId,style:M1t},d),Rie(e,ve=>A.createElement(bBe.Provider,{value:$},A.createElement(_Be.Provider,{value:q},ve))))}),g1t=A.forwardRef((e,t)=>{var s,n;let a=Md(),o=A.useRef(null),l=A.useContext(wBe),i=A6(),d=kBe(e),m=(n=(s=d.current)==null?void 0:s.forceMount)!=null?n:l==null?void 0:l.forceMount;tN(()=>{if(!m)return i.item(a,l==null?void 0:l.id)},[m]);let p=NBe(a,o,[e.value,e.children,o],e.keywords),g=r1e(),v=G1(B=>B.value&&B.value===p.current),_=G1(B=>m||i.filter()===!1?!0:B.search?B.filtered.items.get(a)>0:!0);A.useEffect(()=>{let B=o.current;if(!(!B||e.disabled))return B.addEventListener(Ape,k),()=>B.removeEventListener(Ape,k)},[_,e.onSelect,e.disabled]);function k(){var B,$;w(),($=(B=d.current).onSelect)==null||$.call(B,p.current)}function w(){g.setState("value",p.current,!0)}if(!_)return null;let{disabled:S,value:T,onSelect:C,forceMount:I,keywords:R,...D}=e;return A.createElement(Hs.div,{ref:t0(o,t),...D,id:a,"cmdk-item":"",role:"option","aria-disabled":!!S,"aria-selected":!!v,"data-disabled":!!S,"data-selected":!!v,onPointerMove:S||i.getDisablePointerSelection()?void 0:w,onClick:S?void 0:k},e.children)}),x1t=A.forwardRef((e,t)=>{let{heading:s,children:n,forceMount:a,...o}=e,l=Md(),i=A.useRef(null),d=A.useRef(null),m=Md(),p=A6(),g=G1(_=>a||p.filter()===!1?!0:_.search?_.filtered.groups.has(l):!0);tN(()=>p.group(l),[]),NBe(l,i,[e.value,e.heading,d]);let v=A.useMemo(()=>({id:l,forceMount:a}),[a]);return A.createElement(Hs.div,{ref:t0(i,t),...o,"cmdk-group":"",role:"presentation",hidden:g?void 0:!0},s&&A.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:m},s),Rie(e,_=>A.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":s?m:void 0},A.createElement(wBe.Provider,{value:v},_))))}),y1t=A.forwardRef((e,t)=>{let{alwaysRender:s,...n}=e,a=A.useRef(null),o=G1(l=>!l.search);return!s&&!o?null:A.createElement(Hs.div,{ref:t0(a,t),...n,"cmdk-separator":"",role:"separator"})}),v1t=A.forwardRef((e,t)=>{let{onValueChange:s,...n}=e,a=e.value!=null,o=r1e(),l=G1(m=>m.search),i=G1(m=>m.selectedItemId),d=A6();return A.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),A.createElement(Hs.input,{ref:t,...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?e.value:l,onChange:m=>{a||o.setState("search",m.target.value),s==null||s(m.target.value)}})}),_1t=A.forwardRef((e,t)=>{let{children:s,label:n="Suggestions",...a}=e,o=A.useRef(null),l=A.useRef(null),i=G1(m=>m.selectedItemId),d=A6();return A.useEffect(()=>{if(l.current&&o.current){let m=l.current,p=o.current,g,v=new ResizeObserver(()=>{g=requestAnimationFrame(()=>{let _=m.offsetHeight;p.style.setProperty("--cmdk-list-height",_.toFixed(1)+"px")})});return v.observe(m),()=>{cancelAnimationFrame(g),v.unobserve(m)}}},[]),A.createElement(Hs.div,{ref:t0(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:d.listId},Rie(e,m=>A.createElement("div",{ref:t0(l,d.listInnerRef),"cmdk-list-sizer":""},m)))}),b1t=A.forwardRef((e,t)=>{let{open:s,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=e;return A.createElement(hie,{open:s,onOpenChange:n},A.createElement(mie,{container:l},A.createElement(I3,{"cmdk-overlay":"",className:a}),A.createElement(P3,{"aria-label":e.label,"cmdk-dialog":"",className:o},A.createElement(jBe,{ref:t,...i}))))}),w1t=A.forwardRef((e,t)=>G1(s=>s.filtered.count===0)?A.createElement(Hs.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),j1t=A.forwardRef((e,t)=>{let{progress:s,children:n,label:a="Loading...",...o}=e;return A.createElement(Hs.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Rie(e,l=>A.createElement("div",{"aria-hidden":!0},l)))}),am=Object.assign(jBe,{List:_1t,Item:g1t,Input:v1t,Group:x1t,Separator:y1t,Dialog:b1t,Empty:w1t,Loading:j1t});function k1t(e,t){let s=e.nextElementSibling;for(;s;){if(s.matches(t))return s;s=s.nextElementSibling}}function N1t(e,t){let s=e.previousElementSibling;for(;s;){if(s.matches(t))return s;s=s.previousElementSibling}}function kBe(e){let t=A.useRef(e);return tN(()=>{t.current=e}),t}var tN=typeof window>"u"?A.useEffect:A.useLayoutEffect;function DC(e){let t=A.useRef();return t.current===void 0&&(t.current=e()),t}function G1(e){let t=r1e(),s=()=>e(t.snapshot());return A.useSyncExternalStore(t.subscribe,s,s)}function NBe(e,t,s,n=[]){let a=A.useRef(),o=A6();return tN(()=>{var l;let i=(()=>{var m;for(let p of s){if(typeof p=="string")return p.trim();if(typeof p=="object"&&"current"in p)return p.current?(m=p.current.textContent)==null?void 0:m.trim():a.current}})(),d=n.map(m=>m.trim());o.value(e,i,d),(l=t.current)==null||l.setAttribute(LC,i),a.current=i}),a}var S1t=()=>{let[e,t]=A.useState(),s=DC(()=>new Map);return tN(()=>{s.current.forEach(n=>n()),s.current=new Map},[e]),(n,a)=>{s.current.set(n,a),t({})}};function C1t(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Rie({asChild:e,children:t},s){return e&&A.isValidElement(t)?A.cloneElement(C1t(t),{ref:t.ref},s(t.props.children)):s(t)}var M1t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const a0=A.forwardRef(({className:e,...t},s)=>r.jsx(am,{ref:s,className:Vt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));a0.displayName=am.displayName;const T1t=({children:e,...t})=>r.jsx(Ir,{...t,children:r.jsx(Er,{className:"overflow-hidden p-0 shadow-lg",children:r.jsx(a0,{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:e})})}),i0=A.forwardRef(({className:e,...t},s)=>r.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[r.jsx(qn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx(am.Input,{ref:s,className:Vt("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",e),...t})]}));i0.displayName=am.Input.displayName;const o0=A.forwardRef(({className:e,...t},s)=>r.jsx(am.List,{ref:s,className:Vt("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));o0.displayName=am.List.displayName;const l0=A.forwardRef((e,t)=>r.jsx(am.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));l0.displayName=am.Empty.displayName;const c0=A.forwardRef(({className:e,...t},s)=>r.jsx(am.Group,{ref:s,className:Vt("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",e),...t}));c0.displayName=am.Group.displayName;const A1t=A.forwardRef(({className:e,...t},s)=>r.jsx(am.Separator,{ref:s,className:Vt("-mx-1 h-px bg-border",e),...t}));A1t.displayName=am.Separator.displayName;const d0=A.forwardRef(({className:e,...t},s)=>r.jsx(am.Item,{ref:s,className:Vt("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",e),...t}));d0.displayName=am.Item.displayName;const E1t={event:{label:"Events",icon:sg,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:id,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:w1,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Hy,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:bn,color:"bg-fuchsia-500/10 text-fuchsia-600"}},Z4e=()=>{const[e,t]=A.useState(!1),[s,n]=A.useState(""),[a,o]=A.useState([]),[l,i]=A.useState(!1),d=Ks();A.useEffect(()=>{const v=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),t(k=>!k))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[]);const m=A.useCallback(async v=>{if(!v.trim()){o([]);return}i(!0);const _=`%${v}%`;try{const[k,w,S,T,C]=await Promise.all([Y.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),Y.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${_},description.ilike.${_}`).limit(5),Y.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5),Y.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${_},description.ilike.${_}`).limit(5),Y.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${_},description.ilike.${_}`).limit(5)]),I=[];k.data&&k.data.forEach(R=>{I.push({id:R.id,title:R.title,description:R.description,type:"event",date:R.event_date,path:`/event/${R.id}`})}),w.data&&w.data.forEach(R=>{I.push({id:R.id,title:R.name,description:R.description,type:"template",date:R.publish_date,path:`/templates/${R.id}`})}),S.data&&S.data.forEach(R=>{I.push({id:R.id,title:R.title,description:R.description,type:"academy",date:R.publish_date,path:`/academy/${R.id}`})}),T.data&&T.data.forEach(R=>{I.push({id:R.id,title:R.name,description:R.description,type:"toolbox",date:R.publish_date,path:`/toolbox/${R.id}`})}),C.data&&C.data.forEach(R=>{I.push({id:R.id,title:R.title,description:R.description,type:"social-swag",date:R.publish_date,path:`/social-swag/${R.id}`})}),o(I)}catch(k){console.error("Search error:",k)}finally{i(!1)}},[]);A.useEffect(()=>{const v=setTimeout(()=>{m(s)},300);return()=>clearTimeout(v)},[s,m]);const p=v=>{t(!1),n(""),d(v)},g=a.reduce((v,_)=>(v[_.type]||(v[_.type]=[]),v[_.type].push(_),v),{});return r.jsxs(r.Fragment,{children:[r.jsxs(X,{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:()=>t(!0),children:[r.jsx(qn,{className:"h-4 w-4 xl:mr-2"}),r.jsx("span",{className:"hidden xl:inline-flex text-muted-foreground text-sm",children:"Search..."}),r.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:[r.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),r.jsxs(T1t,{open:e,onOpenChange:t,children:[r.jsx(i0,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:s,onValueChange:n}),r.jsxs(o0,{children:[l&&r.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&s&&a.length===0&&r.jsxs(l0,{children:['No results found for "',s,'"']}),!l&&!s&&r.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 k=E1t[v],w=k.icon;return r.jsx(c0,{heading:k.label,children:_.map(S=>r.jsxs(d0,{value:`${S.type}-${S.id}-${S.title}`,onSelect:()=>p(S.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[r.jsx("div",{className:`p-2 rounded-md ${k.color}`,children:r.jsx(w,{className:"h-4 w-4"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"font-medium truncate",children:S.title}),S.description&&r.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:S.description})]}),r.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[r.jsx(_t,{variant:"secondary",className:"text-xs",children:k.label}),r.jsx("span",{className:"text-xs text-muted-foreground",children:gu(new Date(S.date),{addSuffix:!0})})]})]},`${S.type}-${S.id}`))},v)})]})]})]})},I1t=({expiresAt:e,className:t,showUpgradeButton:s=!0})=>{const[n,a]=A.useState(null),o=Ks();if(A.useEffect(()=>{const m=()=>{const g=new Date().getTime(),_=new Date(e).getTime()-g;if(_<=0){a({days:0,hours:0,minutes:0});return}const k=Math.floor(_/(1e3*60*60*24)),w=Math.floor(_%(1e3*60*60*24)/(1e3*60*60)),S=Math.floor(_%(1e3*60*60)/(1e3*60));a({days:k,hours:w,minutes:S})};m();const p=setInterval(m,6e4);return()=>clearInterval(p)},[e]),!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?r.jsxs("div",{className:Vt("flex items-center justify-between gap-3 px-4 py-2 rounded-lg bg-destructive/10 border border-destructive/20",t),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ch,{className:"h-4 w-4 text-destructive"}),r.jsx("span",{className:"text-sm font-medium text-destructive",children:"Your free trial has expired"})]}),s&&r.jsxs(X,{size:"sm",onClick:()=>o("/subscription"),className:"bg-primary hover:bg-primary/90 text-xs h-7 px-3",children:[r.jsx(bn,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):r.jsxs("div",{className:Vt("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",t),children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Pa,{className:Vt("h-4 w-4",i?"text-destructive":d?"text-amber-500":"text-primary")}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:Vt("text-sm font-medium",i?"text-destructive":d?"text-amber-600":"text-primary"),children:"Free Trial:"}),r.jsxs("div",{className:"flex items-center gap-1",children:[n.days>0&&r.jsxs("span",{className:Vt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.days,"d"]}),r.jsxs("span",{className:Vt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),r.jsxs("span",{className:Vt("text-sm font-bold",i?"text-destructive":d?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),r.jsx("span",{className:Vt("text-xs",i?"text-destructive/70":d?"text-amber-600/70":"text-primary/70"),children:"remaining"})]})]})]}),s&&r.jsxs(X,{size:"sm",onClick:()=>o("/subscription"),variant:i?"destructive":d?"default":"outline",className:Vt("text-xs h-7 px-3",d&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[r.jsx(bn,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},P1t=()=>{const e=Ks();return r.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:r.jsxs(ze,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[r.jsxs(Wt,{className:"text-center pb-2",children:[r.jsx("div",{className:"mx-auto mb-4 h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:r.jsx(ch,{className:"h-8 w-8 text-destructive"})}),r.jsx(Zt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),r.jsx(Cs,{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!"})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[r.jsx(ze,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>e("/subscription"),children:r.jsxs(qe,{className:"p-5 text-center",children:[r.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:r.jsx(ws,{className:"h-6 w-6 text-primary"})}),r.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Individual Agent"}),r.jsxs("p",{className:"text-2xl font-bold text-primary mb-2",children:["$39",r.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Perfect for solo agents ready to level up"}),r.jsxs(X,{className:"w-full",onClick:t=>{t.stopPropagation(),e("/subscription")},children:[r.jsx(bn,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),r.jsx(ze,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>e("/subscription"),children:r.jsxs(qe,{className:"p-5 text-center",children:[r.jsx("div",{className:"mx-auto mb-3 h-12 w-12 rounded-full bg-amber-500/10 flex items-center justify-center",children:r.jsx(Ni,{className:"h-6 w-6 text-amber-600"})}),r.jsx("h3",{className:"font-semibold text-lg mb-1",children:"Brokerage"}),r.jsxs("p",{className:"text-2xl font-bold text-amber-600 mb-2",children:["$299",r.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:"/mo"})]}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"For teams and brokerages"}),r.jsxs(X,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",onClick:t=>{t.stopPropagation(),e("/subscription")},children:[r.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Choose Brokerage"]})]})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"With a full membership, you'll get:"}),r.jsxs("ul",{className:"text-sm space-y-1 text-muted-foreground grid sm:grid-cols-2 gap-x-4",children:[r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"✓"})," Unlimited access to all marketing templates"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"✓"})," Complete Academy training library"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"✓"})," AI-powered tools and resources"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"✓"})," Community forums and support"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"✓"})," Exclusive member events and workshops"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"✓"})," Deal pipeline & scorecard tracking"]})]})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:[r.jsx("p",{className:"text-sm font-medium text-center",children:"Questions? Contact us:"}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[r.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[r.jsx(fi,{className:"h-4 w-4"}),r.jsx("span",{children:"1-866-527-8668"})]}),r.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[r.jsx(Vs,{className:"h-4 w-4"}),r.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},L1t=({hasUnseenBrief:e,onClick:t,className:s})=>r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsxs(X,{variant:"ghost",size:"icon",onClick:t,className:Vt("relative transition-colors",e&&"text-primary hover:text-primary",s),children:[r.jsx(ag,{className:"h-5 w-5"}),e&&r.jsx("span",{className:"absolute top-1 right-1 h-2 w-2 rounded-full bg-primary animate-pulse"})]})}),r.jsx(dh,{children:r.jsx("p",{children:"The LevelUp Brief"})})]});var Fie="Checkbox",[D1t]=Sc(Fie),[O1t,s1e]=D1t(Fie);function R1t(e){const{__scopeCheckbox:t,checked:s,children:n,defaultChecked:a,disabled:o,form:l,name:i,onCheckedChange:d,required:m,value:p="on",internal_do_not_use_render:g}=e,[v,_]=bh({prop:s,defaultProp:a??!1,onChange:d,caller:Fie}),[k,w]=A.useState(null),[S,T]=A.useState(null),C=A.useRef(!1),I=k?!!l||!!k.closest("form"):!0,R={checked:v,disabled:o,setChecked:_,control:k,setControl:w,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:C,required:m,defaultChecked:I1(a)?!1:a,isFormControl:I,bubbleInput:S,setBubbleInput:T};return r.jsx(O1t,{scope:t,...R,children:F1t(g)?g(R):n})}var SBe="CheckboxTrigger",CBe=A.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:s,...n},a)=>{const{control:o,value:l,disabled:i,checked:d,required:m,setControl:p,setChecked:g,hasConsumerStoppedPropagationRef:v,isFormControl:_,bubbleInput:k}=s1e(SBe,e),w=va(a,p),S=A.useRef(d);return A.useEffect(()=>{const T=o==null?void 0:o.form;if(T){const C=()=>g(S.current);return T.addEventListener("reset",C),()=>T.removeEventListener("reset",C)}},[o,g]),r.jsx(Hs.button,{type:"button",role:"checkbox","aria-checked":I1(d)?"mixed":d,"aria-required":m,"data-state":IBe(d),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:w,onKeyDown:bs(t,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:bs(s,T=>{g(C=>I1(C)?!0:!C),k&&_&&(v.current=T.isPropagationStopped(),v.current||T.stopPropagation())})})});CBe.displayName=SBe;var n1e=A.forwardRef((e,t)=>{const{__scopeCheckbox:s,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d,onCheckedChange:m,form:p,...g}=e;return r.jsx(R1t,{__scopeCheckbox:s,checked:a,defaultChecked:o,disabled:i,required:l,onCheckedChange:m,name:n,form:p,value:d,internal_do_not_use_render:({isFormControl:v})=>r.jsxs(r.Fragment,{children:[r.jsx(CBe,{...g,ref:t,__scopeCheckbox:s}),v&&r.jsx(EBe,{__scopeCheckbox:s})]})})});n1e.displayName=Fie;var MBe="CheckboxIndicator",TBe=A.forwardRef((e,t)=>{const{__scopeCheckbox:s,forceMount:n,...a}=e,o=s1e(MBe,s);return r.jsx(Wc,{present:n||I1(o.checked)||o.checked===!0,children:r.jsx(Hs.span,{"data-state":IBe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});TBe.displayName=MBe;var ABe="CheckboxBubbleInput",EBe=A.forwardRef(({__scopeCheckbox:e,...t},s)=>{const{control:n,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:l,required:i,disabled:d,name:m,value:p,form:g,bubbleInput:v,setBubbleInput:_}=s1e(ABe,e),k=va(s,_),w=C6(o),S=p6(n);A.useEffect(()=>{const C=v;if(!C)return;const I=window.HTMLInputElement.prototype,D=Object.getOwnPropertyDescriptor(I,"checked").set,B=!a.current;if(w!==o&&D){const $=new Event("click",{bubbles:B});C.indeterminate=I1(o),D.call(C,I1(o)?!1:o),C.dispatchEvent($)}},[v,w,o,a]);const T=A.useRef(I1(o)?!1:o);return r.jsx(Hs.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??T.current,required:i,disabled:d,name:m,value:p,form:g,...t,tabIndex:-1,ref:k,style:{...t.style,...S,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});EBe.displayName=ABe;function F1t(e){return typeof e=="function"}function I1(e){return e==="indeterminate"}function IBe(e){return I1(e)?"indeterminate":e?"checked":"unchecked"}const Qo=A.forwardRef(({className:e,...t},s)=>r.jsx(n1e,{ref:s,className:Vt("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",e),...t,children:r.jsx(TBe,{className:Vt("flex items-center justify-center text-current"),children:r.jsx(mi,{className:"h-4 w-4"})})}));Qo.displayName=n1e.displayName;var a1e="Radio",[z1t,PBe]=Sc(a1e),[B1t,$1t]=z1t(a1e),LBe=A.forwardRef((e,t)=>{const{__scopeRadio:s,name:n,checked:a=!1,required:o,disabled:l,value:i="on",onCheck:d,form:m,...p}=e,[g,v]=A.useState(null),_=va(t,S=>v(S)),k=A.useRef(!1),w=g?m||!!g.closest("form"):!0;return r.jsxs(B1t,{scope:s,checked:a,disabled:l,children:[r.jsx(Hs.button,{type:"button",role:"radio","aria-checked":a,"data-state":FBe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:_,onClick:bs(e.onClick,S=>{a||d==null||d(),w&&(k.current=S.isPropagationStopped(),k.current||S.stopPropagation())})}),w&&r.jsx(RBe,{control:g,bubbles:!k.current,name:n,value:i,checked:a,required:o,disabled:l,form:m,style:{transform:"translateX(-100%)"}})]})});LBe.displayName=a1e;var DBe="RadioIndicator",OBe=A.forwardRef((e,t)=>{const{__scopeRadio:s,forceMount:n,...a}=e,o=$1t(DBe,s);return r.jsx(Wc,{present:n||o.checked,children:r.jsx(Hs.span,{"data-state":FBe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t})})});OBe.displayName=DBe;var U1t="RadioBubbleInput",RBe=A.forwardRef(({__scopeRadio:e,control:t,checked:s,bubbles:n=!0,...a},o)=>{const l=A.useRef(null),i=va(l,o),d=C6(s),m=p6(t);return A.useEffect(()=>{const p=l.current;if(!p)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"checked").set;if(d!==s&&_){const k=new Event("click",{bubbles:n});_.call(p,s),p.dispatchEvent(k)}},[d,s,n]),r.jsx(Hs.input,{type:"radio","aria-hidden":!0,defaultChecked:s,...a,tabIndex:-1,ref:i,style:{...a.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});RBe.displayName=U1t;function FBe(e){return e?"checked":"unchecked"}var V1t=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],zie="RadioGroup",[q1t]=Sc(zie,[E3,PBe]),zBe=E3(),BBe=PBe(),[H1t,W1t]=q1t(zie),$Be=A.forwardRef((e,t)=>{const{__scopeRadioGroup:s,name:n,defaultValue:a,value:o,required:l=!1,disabled:i=!1,orientation:d,dir:m,loop:p=!0,onValueChange:g,...v}=e,_=zBe(s),k=vN(m),[w,S]=bh({prop:o,defaultProp:a??null,onChange:g,caller:zie});return r.jsx(H1t,{scope:s,name:n,required:l,disabled:i,value:w,onValueChange:S,children:r.jsx(dve,{asChild:!0,..._,orientation:d,dir:k,loop:p,children:r.jsx(Hs.div,{role:"radiogroup","aria-required":l,"aria-orientation":d,"data-disabled":i?"":void 0,dir:k,...v,ref:t})})})});$Be.displayName=zie;var UBe="RadioGroupItem",VBe=A.forwardRef((e,t)=>{const{__scopeRadioGroup:s,disabled:n,...a}=e,o=W1t(UBe,s),l=o.disabled||n,i=zBe(s),d=BBe(s),m=A.useRef(null),p=va(t,m),g=o.value===a.value,v=A.useRef(!1);return A.useEffect(()=>{const _=w=>{V1t.includes(w.key)&&(v.current=!0)},k=()=>v.current=!1;return document.addEventListener("keydown",_),document.addEventListener("keyup",k),()=>{document.removeEventListener("keydown",_),document.removeEventListener("keyup",k)}},[]),r.jsx(uve,{asChild:!0,...i,focusable:!l,active:g,children:r.jsx(LBe,{disabled:l,required:o.required,checked:g,...d,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:bs(_=>{_.key==="Enter"&&_.preventDefault()}),onFocus:bs(a.onFocus,()=>{var _;v.current&&((_=m.current)==null||_.click())})})})});VBe.displayName=UBe;var G1t="RadioGroupIndicator",qBe=A.forwardRef((e,t)=>{const{__scopeRadioGroup:s,...n}=e,a=BBe(s);return r.jsx(OBe,{...a,...n,ref:t})});qBe.displayName=G1t;var HBe=$Be,WBe=VBe,K1t=qBe;const i1e=A.forwardRef(({className:e,...t},s)=>r.jsx(HBe,{className:Vt("grid gap-2",e),...t,ref:s}));i1e.displayName=HBe.displayName;const Nse=A.forwardRef(({className:e,...t},s)=>r.jsx(WBe,{ref:s,className:Vt("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",e),...t,children:r.jsx(K1t,{className:"flex items-center justify-center",children:r.jsx(vh,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Nse.displayName=WBe.displayName;const Z1t=({brief:e,open:t,onClose:s,onDismiss:n})=>{const{user:a}=Gr(),[o,l]=A.useState({}),[i,d]=A.useState({}),[m,p]=A.useState([]);A.useEffect(()=>{t&&a&&e.polls.length>0&&g()},[t,a,e.polls]);const g=async()=>{if(!a)return;const S=e.polls.map(C=>C.id),{data:T}=await Y.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",S);if(T){const C={};T.forEach(I=>{C[I.poll_id]||(C[I.poll_id]=[]),C[I.poll_id].push(I.option_id)}),d(C)}},v=(S,T)=>{l(C=>({...C,[S]:T}))},_=(S,T,C)=>{l(I=>{const R=I[S]||[];return C?{...I,[S]:[...R,T]}:{...I,[S]:R.filter(D=>D!==T)}})},k=async S=>{if(!a)return;const T=o[S];if(!T||Array.isArray(T)&&T.length===0){we.error("Please select an option");return}p(C=>[...C,S]);try{await Y.from("levelup_brief_poll_responses").delete().eq("poll_id",S).eq("user_id",a.id);const C=Array.isArray(T)?T:[T],I=C.map(D=>({poll_id:S,option_id:D,user_id:a.id})),{error:R}=await Y.from("levelup_brief_poll_responses").insert(I);if(R)throw R;d(D=>({...D,[S]:C})),we.success("Response submitted!")}catch(C){console.error("Error submitting poll response:",C),we.error("Failed to submit response")}finally{p(C=>C.filter(I=>I!==S))}},w=S=>(S.includes("mediadelivery.net")||S.includes("bunny"),S);return r.jsx(Ir,{open:t,onOpenChange:S=>!S&&s(),children:r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] p-0 overflow-hidden [&>button]:hidden",children:[r.jsxs("div",{className:"bg-gradient-to-r from-primary to-primary/80 p-4 pr-12 text-primary-foreground relative",children:[r.jsx("button",{onClick:s,className:"absolute top-3 right-3 p-1.5 rounded-full bg-white/30 hover:bg-white/50 transition-colors","aria-label":"Close",children:r.jsx(Xs,{className:"h-5 w-5 text-white"})}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-white/20 rounded-lg",children:r.jsx(ag,{className:"h-6 w-6"})}),r.jsxs("div",{children:[r.jsx(_t,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),r.jsx(Fr,{className:"text-xl font-bold text-white",children:e.brief.title})]})]})]}),r.jsx(To,{className:"max-h-[calc(90vh-240px)]",children:r.jsxs("div",{className:"p-6 space-y-6",children:[e.brief.description&&r.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:e.brief.description}}),e.brief.video_url&&r.jsx("div",{className:"relative w-full aspect-video rounded-lg overflow-hidden bg-muted",children:r.jsx("iframe",{src:w(e.brief.video_url),className:"absolute inset-0 w-full h-full",allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})}),e.brief.graphic_url&&!e.brief.video_url&&r.jsx("div",{className:"rounded-lg overflow-hidden bg-muted",children:e.brief.graphic_link_url?r.jsx("a",{href:e.brief.graphic_link_url,target:"_blank",rel:"noopener noreferrer",className:"block",children:r.jsx("img",{src:e.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain cursor-pointer hover:opacity-90 transition-opacity"})}):r.jsx("img",{src:e.brief.graphic_url,alt:"Brief graphic",className:"w-full object-contain"})}),e.links.length>0&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("h4",{className:"font-semibold text-foreground",children:"Quick Links"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:e.links.map(S=>r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>window.open(S.url,"_blank"),className:"gap-2",children:[r.jsx(jn,{className:"h-4 w-4"}),S.title]},S.id))})]}),e.polls.map(S=>{var I,R;const T=((I=i[S.id])==null?void 0:I.length)>0,C=m.includes(S.id);return r.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg border",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h4",{className:"font-semibold text-foreground",children:S.question}),T&&r.jsxs(_t,{variant:"secondary",className:"gap-1",children:[r.jsx(Ri,{className:"h-3 w-3"}),"Responded"]})]}),S.poll_type==="single"?r.jsx(i1e,{value:o[S.id]||((R=i[S.id])==null?void 0:R[0])||"",onValueChange:D=>v(S.id,D),className:"space-y-2",children:S.options.map(D=>r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Nse,{value:D.id,id:D.id}),r.jsx(Ee,{htmlFor:D.id,className:"cursor-pointer",children:D.option_text})]},D.id))}):r.jsx("div",{className:"space-y-2",children:S.options.map(D=>{const $=(o[S.id]||i[S.id]||[]).includes(D.id);return r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Qo,{id:D.id,checked:$,onCheckedChange:q=>_(S.id,D.id,q)}),r.jsx(Ee,{htmlFor:D.id,className:"cursor-pointer",children:D.option_text})]},D.id)})}),r.jsx(X,{size:"sm",onClick:()=>k(S.id),disabled:C,children:C?"Submitting...":T?"Update Response":"Submit"})]},S.id)})]})}),r.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:[r.jsx(X,{onClick:s,className:"w-full max-w-xs",children:"Got it!"}),r.jsx(X,{variant:"ghost",size:"sm",onClick:n,children:"Don't show again"})]})]})})},Y1t=()=>{const{user:e}=Gr(),[t,s]=A.useState(null),[n,a]=A.useState(!1),[o,l]=A.useState(!0),[i,d]=A.useState(!1),m=A.useCallback(async()=>{if(!e){l(!1);return}try{const{data:k,error:w}=await Y.from("levelup_briefs").select("*").eq("is_published",!0).lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(1).single();if(w||!k){l(!1);return}const{data:S}=await Y.from("levelup_brief_views").select("*").eq("brief_id",k.id).eq("user_id",e.id).maybeSingle(),[T,C]=await Promise.all([Y.from("levelup_brief_links").select("*").eq("brief_id",k.id).order("sort_order"),Y.from("levelup_brief_polls").select("*").eq("brief_id",k.id).order("sort_order")]),I=[];if(C.data)for(const q of C.data){const{data:W}=await Y.from("levelup_brief_poll_options").select("*").eq("poll_id",q.id).order("sort_order");I.push({...q,options:W||[]})}const R={brief:k,links:T.data||[],polls:I};s(R);const D=!!S,B=(S==null?void 0:S.dismissed_at)!=null,$=localStorage.getItem(`brief-dismissed-${k.id}`)==="true";if(B||$)d(!1),a(!1);else if(!D)a(!0),d(!0);else if(k.show_frequency==="every_login")a(!0),d(!0);else if(k.show_frequency==="daily"){const q=new Date(S.viewed_at);(new Date().getTime()-q.getTime())/(1e3*60*60)>=24&&(a(!0),d(!0))}else d(!1)}catch(k){console.error("Error fetching brief:",k)}finally{l(!1)}},[e]);A.useEffect(()=>{m()},[m]);const p=async()=>{if(!(!e||!t))try{const{data:k}=await Y.from("levelup_brief_views").select("id").eq("brief_id",t.brief.id).eq("user_id",e.id).maybeSingle();k?await Y.from("levelup_brief_views").update({viewed_at:new Date().toISOString()}).eq("id",k.id):await Y.from("levelup_brief_views").insert({brief_id:t.brief.id,user_id:e.id})}catch(k){console.error("Error marking brief as viewed:",k)}};return{currentBrief:t,shouldShowPopup:n,hasUnseenBrief:i,loading:o,openBrief:()=>{a(!0)},closeBrief:()=>{a(!1),p()},dismissBrief:async()=>{if(!(!e||!t)){a(!1),d(!1);try{const{data:k,error:w}=await Y.from("levelup_brief_views").select("id").eq("brief_id",t.brief.id).eq("user_id",e.id).maybeSingle();if(w&&console.error("Error checking existing brief view:",w),k){const{error:S}=await Y.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",k.id).eq("user_id",e.id);S&&console.error("Error updating brief dismiss:",S)}else{const{error:S}=await Y.from("levelup_brief_views").insert({brief_id:t.brief.id,user_id:e.id,dismissed_at:new Date().toISOString()});S&&console.error("Error inserting brief dismiss:",S)}localStorage.setItem(`brief-dismissed-${t.brief.id}`,"true")}catch(k){console.error("Error dismissing brief:",k),t&&localStorage.setItem(`brief-dismissed-${t.brief.id}`,"true")}}},refetch:m}};function X1t(){const[e,t]=A.useState(!1),[s,n]=A.useState(!1),[a,o]=A.useState(null);A.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),t(!0);const v=_=>{_.preventDefault(),o(_)};return window.addEventListener("beforeinstallprompt",v),()=>{window.removeEventListener("beforeinstallprompt",v)}},[]);const l=()=>{localStorage.setItem("install-banner-dismissed","true"),t(!1)},i=async()=>{if(a){await a.prompt();const{outcome:d}=await a.userChoice;d==="accepted"&&l(),o(null)}};return e?r.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:r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[r.jsx("div",{className:"flex-shrink-0 p-2 bg-primary-foreground/10 rounded-full",children:r.jsx(Fi,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-medium text-sm",children:"Add LevelUp to your home screen"}),s?r.jsxs("p",{className:"text-xs opacity-80 flex items-center gap-1",children:["Tap ",r.jsx(LE,{className:"h-3 w-3 inline"}),' then "Add to Home Screen"']}):r.jsx("p",{className:"text-xs opacity-80",children:"Quick access anytime"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!s&&a&&r.jsx(X,{size:"sm",variant:"secondary",onClick:i,className:"text-xs",children:"Install"}),r.jsx("button",{onClick:l,className:"p-1.5 hover:bg-primary-foreground/10 rounded-full transition-colors","aria-label":"Dismiss",children:r.jsx(Xs,{className:"h-4 w-4"})})]})]})}):null}const Q1t=({children:e,onRefresh:t})=>{const[s,n]=A.useState(!1),[a,o]=A.useState(0),[l,i]=A.useState(!1),d=A.useRef(null),m=A.useRef(0),p=Rr(),g=80,v=120,_=A.useCallback(C=>{const I=d.current;I&&I.scrollTop<=0&&(m.current=C.touches[0].clientY,n(!0))},[]),k=A.useCallback(C=>{if(!s||l)return;const I=d.current;if(!I||I.scrollTop>0){n(!1),o(0);return}const D=C.touches[0].clientY-m.current;if(D>0){const $=Math.min(D*.5,v);o($),$>10&&C.preventDefault()}},[s,l]),w=A.useCallback(async()=>{if(s)if(n(!1),a>=g&&!l){i(!0),o(g);try{t?await t():await p.invalidateQueries()}catch(C){console.error("Refresh failed:",C)}finally{i(!1),o(0)}}else o(0)},[s,a,l,t,p]),S=Math.min(a/g,1),T=S*180;return r.jsxs("div",{ref:d,className:"h-full overflow-auto",onTouchStart:_,onTouchMove:k,onTouchEnd:w,children:[r.jsx("div",{className:"flex justify-center items-center overflow-hidden transition-all duration-200 ease-out",style:{height:a>0?a:0,opacity:S},children:r.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${T}deg)`,transition:l?void 0:"transform 0.1s ease-out"},children:r.jsx(Yo,{className:"h-5 w-5 text-primary"})})}),r.jsx("div",{style:{transform:a>0?`translateY(${Math.max(0,a-60)}px)`:void 0,transition:s?void 0:"transform 0.2s ease-out"},children:e})]})},GBe=()=>{const{user:e}=Gr(),[t,s]=A.useState(!1),[n,a]=A.useState(!1),[o,l]=A.useState(0),[i,d]=A.useState(!0);A.useEffect(()=>{(async()=>{if(!e){d(!1);return}try{const{data:_}=await Y.from("membership_reviews").select("id").eq("user_id",e.id).maybeSingle();if(_){a(!0),s(!1),d(!1);return}const{data:k}=await Y.from("profiles").select("login_count").eq("id",e.id).single(),w=(k==null?void 0:k.login_count)||0;l(w);const S=sessionStorage.getItem("review-prompt-dismissed");s(w>=4&&!S)}catch(_){console.error("Error checking review eligibility:",_)}finally{d(!1)}})()},[e]);const m=A.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),s(!1)},[]),p=A.useCallback(async(v,_)=>{if(!e)return{success:!1,error:"Not authenticated"};try{const{error:k}=await Y.from("membership_reviews").insert({user_id:e.id,rating:v,review_text:_});if(k)throw k;return a(!0),s(!1),{success:!0,pointsAwarded:25}}catch(k){return console.error("Error submitting review:",k),{success:!1,error:k.message}}},[e]),g=A.useCallback(async()=>{if(e)try{await Y.from("membership_reviews").update({posted_to_google:!0}).eq("user_id",e.id)}catch(v){console.error("Error updating Google review status:",v)}},[e]);return{shouldShowPrompt:t,hasSubmittedReview:n,loginCount:o,isLoading:i,dismissPrompt:m,submitReview:p,markPostedToGoogle:g}},J1t="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",e_t=()=>{const{shouldShowPrompt:e,isLoading:t,dismissPrompt:s,submitReview:n,markPostedToGoogle:a}=GBe(),[o,l]=A.useState(!1),[i,d]=A.useState("review"),[m,p]=A.useState(0),[g,v]=A.useState(0),[_,k]=A.useState(""),[w,S]=A.useState(!1),[T,C]=A.useState(!1);if(t||!e&&!T)return null;const I=async()=>{if(m===0){ta({title:"Please select a rating",variant:"destructive"});return}S(!0);const B=await n(m,_);S(!1),B.success?(C(!0),ta({title:"Thank you for your feedback!",description:"Your review helps us improve."}),d("google")):ta({title:"Error submitting review",description:B.error,variant:"destructive"})},R=async B=>{B&&(await navigator.clipboard.writeText(_||`${m} star rating for LevelUp!`),ta({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(J1t,"_blank")),l(!1),s()},D=()=>{l(!1),s()};return r.jsxs(r.Fragment,{children:[r.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:[r.jsx(Dn,{className:"h-3.5 w-3.5 fill-current"}),r.jsx("span",{className:"hidden sm:inline",children:"Leave a Review"})]}),r.jsx(Ir,{open:o,onOpenChange:D,children:r.jsx(Er,{className:"sm:max-w-md",children:i==="review"?r.jsxs(r.Fragment,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{className:"text-center",children:"How are you enjoying LevelUp?"}),r.jsx(Zs,{className:"text-center",children:"Your feedback helps us improve the experience for all members."})]}),r.jsxs("div",{className:"space-y-6 py-4",children:[r.jsx("div",{className:"flex justify-center gap-1",children:[1,2,3,4,5].map(B=>r.jsx("button",{type:"button",onClick:()=>p(B),onMouseEnter:()=>v(B),onMouseLeave:()=>v(0),className:"p-1 transition-transform hover:scale-110",children:r.jsx(Dn,{className:Vt("h-8 w-8 transition-colors",(g||m)>=B?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},B))}),r.jsx(qs,{placeholder:"Tell us about your experience (optional)",value:_,onChange:B=>k(B.target.value),rows:4,className:"resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"outline",onClick:D,className:"flex-1",children:"Maybe Later"}),r.jsx(X,{onClick:I,disabled:w||m===0,className:"flex-1",children:w?"Submitting...":"Submit Review"})]})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{className:"text-center",children:"🎉 Thank you!"}),r.jsx(Zs,{className:"text-center",children:"Would you mind sharing your review on Google? It really helps other agents discover LevelUp!"})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx("p",{className:"text-center text-sm text-muted-foreground",children:"We'll copy your review so you can easily paste it."}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>R(!1),className:"flex-1",children:"No Thanks"}),r.jsx(X,{onClick:()=>R(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function t_t(e){const t="=".repeat((4-e.length%4)%4),s=(e+t).replace(/-/g,"+").replace(/_/g,"/"),n=window.atob(s),a=new Uint8Array(n.length);for(let o=0;o{if(!g){l(!1);return}(async()=>{try{const w="vapid_public_key";let S=localStorage.getItem(w);if(!S){const{data:I,error:R}=await Y.functions.invoke("get-vapid-public-key",{body:{}});if(R)throw R;if(S=(I==null?void 0:I.vapidPublicKey)??null,!S)throw new Error("Missing VAPID public key");localStorage.setItem(w,S)}p(S);const T=await navigator.serviceWorker.register("/push-sw.js");d(T),s(Notification.permission);const C=await T.pushManager.getSubscription();a(!!C)}catch(w){console.error("Error initializing push notifications:",w)}finally{l(!1)}})()},[g]);const v=A.useCallback(async()=>{if(!g||!i||!e)return console.error("Push notifications not supported or user not logged in"),!1;if(!m)return we.error("Push notifications are not ready yet. Please try again in a moment."),!1;try{l(!0);const k=await i.pushManager.getSubscription();if(k){try{await k.unsubscribe()}catch(R){console.warn("Failed to unsubscribe existing push subscription:",R)}const{error:I}=await Y.from("push_subscriptions").delete().eq("user_id",e.id);I&&console.warn("Failed to cleanup push_subscriptions rows:",I)}if(Notification.permission!=="granted"){const I=await Notification.requestPermission();if(s(I),I!=="granted")return I==="denied"?we.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):we.error("Notification permission was dismissed. Please try again."),!1}const w=t_t(m);let S;try{S=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:w})}catch(I){console.error("PushManager.subscribe() failed:",I);const R=(I==null?void 0:I.message)||String(I);return R.includes("permission")?we.error("Push permission denied. Check your browser notification settings."):R.includes("key")||R.includes("VAPID")?we.error("Push configuration error. Please contact support."):R.includes("AbortError")?we.error("Push subscription was cancelled. Please try again."):we.error(`Failed to subscribe: ${R}`),!1}const T=S.toJSON(),{error:C}=await Y.from("push_subscriptions").upsert({user_id:e.id,endpoint:T.endpoint,p256dh_key:T.keys.p256dh,auth_key:T.keys.auth},{onConflict:"user_id,endpoint"});if(C)throw console.error("Error saving subscription:",C),we.error("Failed to save notification preferences. Please try again."),C;return a(!0),we.success("Push notifications enabled!"),!0}catch(k){if(console.error("Error subscribing to push notifications:",k),!(k instanceof Error&&k.message.includes("toast"))){const w=k instanceof Error?k.message:"Unknown error";we.error("Failed to enable push notifications: "+w)}return!1}finally{l(!1)}},[g,i,e,m]),_=A.useCallback(async()=>{if(!i||!e)return!1;try{l(!0);const k=await i.pushManager.getSubscription();return k&&await k.unsubscribe(),await Y.from("push_subscriptions").delete().eq("user_id",e.id),a(!1),we.success("Push notifications disabled"),!0}catch(k){console.error("Error unsubscribing:",k);const w=k instanceof Error?k.message:"Unknown error";return we.error("Failed to disable push notifications: "+w),!1}finally{l(!1)}},[i,e]);return{isSupported:g,permission:t,isSubscribed:n,isLoading:o,vapidPublicKey:m,subscribe:v,unsubscribe:_}}const Y4e="push_notification_prompt_dismissed",r_t=()=>{const{user:e}=Gr(),{isSupported:t,isSubscribed:s,isLoading:n,subscribe:a}=KBe(),[o,l]=A.useState(!1),[i,d]=A.useState(!1);A.useEffect(()=>{if(!e||!t||s||n||localStorage.getItem(`${Y4e}_${e.id}`))return;const v=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(v)},[e,t,s,n]);const m=async()=>{d(!0);const g=await a();d(!1),g&&l(!1)},p=()=>{e&&localStorage.setItem(`${Y4e}_${e.id}`,"true"),l(!1)};return!t||s?null:r.jsx(Ir,{open:o,onOpenChange:g=>!g&&p(),children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:r.jsx(tg,{className:"h-6 w-6 text-primary"})}),r.jsx(Fr,{className:"text-center",children:"Stay in the Loop!"}),r.jsx(Zs,{className:"text-center",children:"Enable push notifications to get alerted when:"})]}),r.jsxs("ul",{className:"my-4 space-y-2 text-sm text-muted-foreground",children:[r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"•"})," New events go live"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"•"})," Fresh templates are added"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"•"})," New toolbox resources drop"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"•"})," Social swag updates"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"•"})," New newsletters arrive"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-primary",children:"•"})," Posts in your community groups"]})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(X,{onClick:m,disabled:i,className:"w-full",children:i?"Enabling...":"Enable Notifications"}),r.jsx(X,{variant:"ghost",onClick:p,className:"w-full",children:"Not Now"})]}),r.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"You can always change this in your Profile settings."})]})})},X4e=e=>{let t;const s=new Set,n=(m,p)=>{const g=typeof m=="function"?m(t):m;if(!Object.is(g,t)){const v=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),s.forEach(_=>_(t,v))}},a=()=>t,i={setState:n,getState:a,getInitialState:()=>d,subscribe:m=>(s.add(m),()=>s.delete(m))},d=t=e(n,a,i);return i},s_t=e=>e?X4e(e):X4e,n_t=e=>e;function a_t(e,t=n_t){const s=lt.useSyncExternalStore(e.subscribe,lt.useCallback(()=>t(e.getState()),[e,t]),lt.useCallback(()=>t(e.getInitialState()),[e,t]));return lt.useDebugValue(s),s}const i_t=e=>{const t=s_t(e),s=n=>a_t(t,n);return Object.assign(s,t),s},o_t=e=>i_t;function l_t(e,t){let s;try{s=e()}catch{return}return{getItem:a=>{var o;const l=d=>d===null?null:JSON.parse(d,void 0),i=(o=s.getItem(a))!=null?o:null;return i instanceof Promise?i.then(l):l(i)},setItem:(a,o)=>s.setItem(a,JSON.stringify(o,void 0)),removeItem:a=>s.removeItem(a)}}const Epe=e=>t=>{try{const s=e(t);return s instanceof Promise?s:{then(n){return Epe(n)(s)},catch(n){return this}}}catch(s){return{then(n){return this},catch(n){return Epe(n)(s)}}}},c_t=(e,t)=>(s,n,a)=>{let o={storage:l_t(()=>localStorage),partialize:w=>w,version:0,merge:(w,S)=>({...S,...w}),...t},l=!1;const i=new Set,d=new Set;let m=o.storage;if(!m)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),s(...w)},n,a);const p=()=>{const w=o.partialize({...n()});return m.setItem(o.name,{state:w,version:o.version})},g=a.setState;a.setState=(w,S)=>(g(w,S),p());const v=e((...w)=>(s(...w),p()),n,a);a.getInitialState=()=>v;let _;const k=()=>{var w,S;if(!m)return;l=!1,i.forEach(C=>{var I;return C((I=n())!=null?I:v)});const T=((S=o.onRehydrateStorage)==null?void 0:S.call(o,(w=n())!=null?w:v))||void 0;return Epe(m.getItem.bind(m))(o.name).then(C=>{if(C)if(typeof C.version=="number"&&C.version!==o.version){if(o.migrate){const I=o.migrate(C.state,C.version);return I instanceof Promise?I.then(R=>[!0,R]):[!0,I]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,C.state];return[!1,void 0]}).then(C=>{var I;const[R,D]=C;if(_=o.merge(D,(I=n())!=null?I:v),s(_,!0),R)return p()}).then(()=>{T==null||T(_,void 0),_=n(),l=!0,d.forEach(C=>C(_))}).catch(C=>{T==null||T(void 0,C)})};return a.persist={setOptions:w=>{o={...o,...w},w.storage&&(m=w.storage)},clearStorage:()=>{m==null||m.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:w=>(i.add(w),()=>{i.delete(w)}),onFinishHydration:w=>(d.add(w),()=>{d.delete(w)})},o.skipHydration||k(),_||v},d_t=c_t,Bie=o_t()(d_t((e,t)=>({cartItems:[],addToCart:(s,n,a=1,o)=>{e(l=>{const i=l.cartItems.findIndex(d=>{var m;return d.product.id===s.id&&((m=d.variant)==null?void 0:m.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:s,variant:n,quantity:a,artworkUrl:o}]}})},removeFromCart:(s,n)=>{e(a=>({cartItems:a.cartItems.filter(o=>{var l;return!(o.product.id===s&&((l=o.variant)==null?void 0:l.id)===n)})}))},updateQuantity:(s,n,a)=>{e(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===s&&((i=l.variant)==null?void 0:i.id)===n?{...l,quantity:Math.max(1,a)}:l})}))},updateArtwork:(s,n,a)=>{e(o=>({cartItems:o.cartItems.map(l=>{var i;return l.product.id===s&&((i=l.variant)==null?void 0:i.id)===n?{...l,artworkUrl:a}:l})}))},clearCart:()=>e({cartItems:[]}),getItemPrice:s=>{const n=Number(s.product.base_price),a=s.variant?Number(s.variant.price_adjustment):0;return n+a},getSubtotal:()=>{const{cartItems:s,getItemPrice:n}=t();return s.reduce((a,o)=>a+n(o)*o.quantity,0)},getShippingTotal:()=>{const{cartItems:s}=t();return s.reduce((n,a)=>n+Number(a.product.shipping_fee)*a.quantity,0)},getTotal:()=>{const{getSubtotal:s,getShippingTotal:n}=t();return s()+n()}}),{name:"marketplace-cart",partialize:e=>({cartItems:e.cartItems})})),ZBe=A.createContext({onlineUsers:[],totalOnline:0}),u_t=async e=>{try{const{data:t}=await Y.storage.from("avatars").list(`${e}`);if(t&&t.length>0){const{data:s}=Y.storage.from("avatars").getPublicUrl(`${e}/${t[0].name}`);return s.publicUrl}}catch{}},h_t=({children:e})=>{const{user:t,brokerageId:s,isAdmin:n}=Gr(),[a,o]=A.useState([]),[l,i]=A.useState(null);A.useEffect(()=>{if(!t)return;const m=Y.channel("app-presence",{config:{presence:{key:t.id}}});return m.on("presence",{event:"sync"},()=>{const p=m.presenceState(),g=[];Object.entries(p).forEach(([v,_])=>{if(_&&_.length>0){const k=_[0];g.push({id:v,name:k.name||"Unknown",avatarUrl:k.avatarUrl,brokerageId:k.brokerageId,onlineSince:k.onlineSince})}}),o(g)}).on("presence",{event:"join"},()=>{}).on("presence",{event:"leave"},()=>{}).subscribe(async p=>{var g;if(p==="SUBSCRIBED"){const{data:v}=await Y.from("profiles").select("name, brokerage_id").eq("id",t.id).single(),_=await u_t(t.id);await m.track({name:(v==null?void 0:v.name)||((g=t.email)==null?void 0:g.split("@")[0])||"User",avatarUrl:_,brokerageId:v==null?void 0:v.brokerage_id,onlineSince:new Date().toISOString()})}}),i(m),()=>{m.unsubscribe()}},[t]);const d=a.filter(m=>m.id===(t==null?void 0:t.id)?!1:!!(n||s&&m.brokerageId===s||!s&&!m.brokerageId));return r.jsx(ZBe.Provider,{value:{onlineUsers:d,totalOnline:a.length},children:e})},YBe=()=>A.useContext(ZBe),Q4e="dashboard-sidebar-collapsed",Ur=({children:e,title:t})=>{var Ue,Ve,Ie;const{user:s,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Gr(),{isAssistant:i,actingAsAgent:d,hasPermission:m}=lve(),{isImpersonating:p}=ove(),v=(i&&!!d?40:0)+(p?40:0),{avatarUrl:_}=O7e(s==null?void 0:s.id),{isTrial:k,isExpired:w,expiresAt:S}=ovt(s==null?void 0:s.id),{isMarketplaceEnabled:T}=F7e(),{currentBrief:C,shouldShowPopup:I,hasUnseenBrief:R,openBrief:D,closeBrief:B,dismissBrief:$}=Y1t(),{unreadCount:q}=lvt(),{openCount:W}=cvt(),{data:K}=o_(),re=!!K,oe=Bie(We=>We.cartItems).reduce((We,wt)=>We+wt.quantity,0),se=Ks(),pe=sm(),[ie,de]=A.useState(()=>typeof window<"u"?localStorage.getItem(Q4e)==="true":!1);A.useEffect(()=>{localStorage.setItem(Q4e,String(ie))},[ie]);const[ce,ge]=A.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,help:!1}),Te=We=>{ge(wt=>({...wt,[We]:!wt[We]}))},_e=We=>We.split(" ").map(wt=>wt[0]).join("").toUpperCase().slice(0,2),ve=We=>pe.pathname===We,Me=We=>We.some(wt=>pe.pathname===wt),Ze=({path:We,icon:wt,label:Pe,badgeCount:st})=>{const ue=r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",ve(We)&&"bg-sidebar-accent text-sidebar-accent-foreground",ie?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>se(We),children:[r.jsxs("div",{className:"relative",children:[r.jsx(wt,{className:"h-4 w-4 shrink-0"}),ie&&st!=null&&st>0&&r.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!ie&&Pe,!ie&&st!=null&&st>0&&r.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 ie?r.jsxs(Gh,{delayDuration:0,children:[r.jsx(Kh,{asChild:!0,children:ue}),r.jsxs(dh,{side:"right",className:"flex items-center gap-2",children:[Pe,st!=null&&st>0&&r.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})]})]}):ue},Ae=({id:We,label:wt,icon:Pe,children:st,activePaths:ue,showBetaBadge:$e,defaultPath:tt,badgeCount:rt})=>{if(ie){const je=tt||ue[0];return r.jsxs(Gh,{delayDuration:0,children:[r.jsx(Kh,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"sm",className:Vt("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Me(ue)&&"text-primary"),onClick:()=>se(je),children:r.jsxs("div",{className:"relative",children:[r.jsx(Pe,{className:"h-4 w-4"}),rt!=null&&rt>0&&r.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]})})}),r.jsxs(dh,{side:"right",className:"flex items-center gap-2",children:[wt,$e&&r.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"}),rt!=null&&rt>0&&r.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:rt>9?"9+":rt})]})]})}return r.jsxs(Ek,{open:ce[We],onOpenChange:()=>Te(We),children:[r.jsx(Ik,{asChild:!0,children:r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(ue)&&"text-primary"),children:[r.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[r.jsx(Pe,{className:"h-4 w-4"}),wt,$e&&r.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"})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[rt!=null&&rt>0&&r.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:rt>9?"9+":rt}),r.jsx(ad,{className:Vt("h-4 w-4 transition-transform duration-200",ce[We]&&"rotate-180")})]})]})}),r.jsx(Pk,{className:"pl-4 space-y-1 mt-1",children:st})]})},Le=({isMobile:We=!1})=>{const wt=We?!1:ie;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsxs("div",{className:Vt("p-3 border-b border-sidebar-border",wt?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[wt?r.jsx("img",{src:Evt,alt:"LevelUp",className:"h-8 w-auto"}):r.jsx("img",{src:Avt,alt:"LevelUp",className:"h-8 w-auto"}),!We&&r.jsxs(Gh,{delayDuration:0,children:[r.jsx(Kh,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>de(!wt),children:r.jsx(jc,{className:Vt("h-4 w-4 transition-transform duration-300",wt&&"rotate-180")})})}),r.jsx(dh,{side:"right",children:wt?"Expand sidebar":"Collapse sidebar"})]})]}),r.jsx(To,{className:"flex-1",children:r.jsxs("nav",{className:Vt("p-3 space-y-1",wt&&"flex flex-col items-center"),children:[r.jsx(Ze,{path:"/dashboard",icon:bk,label:"Dashboard"}),r.jsx(Ze,{path:"/events",icon:sg,label:"Events"}),r.jsxs(Ae,{id:"agentos",label:"Agent OS",icon:w4,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"],showBetaBadge:!0,defaultPath:"/mission-control",children:[m("contacts")&&r.jsx(Ze,{path:"/mission-control",icon:Ai,label:"Mission Control"}),m("contacts")&&r.jsx(Ze,{path:"/mission-control/contacts",icon:ws,label:"Contacts"}),m("contacts")&&r.jsx(Ze,{path:"/mission-control/plans",icon:sg,label:"TouchPlans"}),m("pipeline")&&r.jsx(Ze,{path:"/mission-control/pipeline",icon:By,label:"Deal Pipeline"}),m("popbys")&&r.jsx(Ze,{path:"/mission-control/popbys",icon:po,label:"Popbys"}),m("videos")&&r.jsx(Ze,{path:"/mission-control/video-library",icon:ma,label:"Video Library"}),m("scorecard")&&r.jsx(Ze,{path:"/mission-control/scorecard",icon:Rc,label:"Scorecard"}),m("listings")&&r.jsx(Ze,{path:"/mission-control/listings",icon:Ni,label:"Listing Exchange"})]}),r.jsxs(Ae,{id:"tools",label:"Tools",icon:bm,activePaths:["/apps","/ai-toolkit","/mission-control/my-card","/mission-control/presentations","/mission-control/guest-book"],defaultPath:"/apps",children:[r.jsx(Ze,{path:"/apps",icon:bm,label:"Apps"}),m("digital_card")&&!wt&&r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/mission-control/my-card")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/mission-control/my-card"),children:[r.jsx(Dm,{className:"h-4 w-4"}),"Smart Card",r.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"})]}),m("digital_card")&&wt&&r.jsx(Ze,{path:"/mission-control/my-card",icon:Dm,label:"Smart Card"}),m("presentations")&&!wt&&r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground overflow-hidden",pe.pathname.startsWith("/mission-control/presentations")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/mission-control/presentations"),children:[r.jsx(Ff,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:"Presentations"}),r.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"})]}),m("presentations")&&wt&&r.jsx(Ze,{path:"/mission-control/presentations",icon:Ff,label:"Smart Presentations"}),m("guest_book")&&!wt&&r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/mission-control/guest-book")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/mission-control/guest-book"),children:[r.jsx(Oy,{className:"h-4 w-4"}),"Guest Book",r.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"})]}),m("guest_book")&&wt&&r.jsx(Ze,{path:"/mission-control/guest-book",icon:Oy,label:"Guest Book"}),!wt&&r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/mission-control/card-studio")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/mission-control/card-studio"),children:[r.jsx(Vs,{className:"h-4 w-4"}),"Card Studio",r.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&&r.jsx(Ze,{path:"/mission-control/card-studio",icon:Vs,label:"Card Studio"})]}),r.jsxs(Ae,{id:"marketing",label:"Marketing",icon:ag,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[r.jsx(Ze,{path:"/templates",icon:id,label:"Templates"}),r.jsx(Ze,{path:"/social-swag-2",icon:qy,label:"Social Swag"}),r.jsx(Ze,{path:"/newsletters",icon:Vy,label:"Newsletters"})]}),r.jsxs(Ae,{id:"learning",label:"Learning",icon:Oy,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[r.jsx(Ze,{path:"/academy",icon:w1,label:"Academy"}),r.jsx(Ze,{path:"/toolbox",icon:Hy,label:"Toolbox"})]}),r.jsxs(Ae,{id:"community",label:"Community",icon:Vo,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:q,children:[r.jsx(Ze,{path:"/community",icon:ws,label:"Community",badgeCount:q}),r.jsx(Ze,{path:"/wishlist",icon:$y,label:"Wishlist",badgeCount:W}),!wt&&r.jsxs(X,{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:[r.jsx(jn,{className:"h-4 w-4"}),"Facebook Group"]})]}),r.jsxs(Ae,{id:"goods",label:"The Goods",icon:Wh,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[T&&!wt&&r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/marketplace"),children:[r.jsx(Wh,{className:"h-4 w-4"}),"Marketplace",r.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"})]}),T&&wt&&r.jsx(Ze,{path:"/marketplace",icon:Wh,label:"Marketplace"}),r.jsx(Ze,{path:"/reward-store",icon:go,label:"Reward Store"})]}),r.jsxs(Ae,{id:"help",label:"Help & Services",icon:by,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[r.jsx(Ze,{path:"/support",icon:A4,label:"Support"}),r.jsx(Ze,{path:"/additional-services",icon:bn,label:"Additional Services"})]}),a&&r.jsxs(r.Fragment,{children:[!wt&&r.jsx("div",{className:"pt-3 pb-1",children:r.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Admin"})}),wt?r.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:r.jsx(Ze,{path:"/admin",icon:Du,label:"Admin Dashboard"})}):r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",pe.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/admin"),children:[r.jsx(Du,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&r.jsxs(r.Fragment,{children:[!wt&&r.jsx("div",{className:"pt-3 pb-1",children:r.jsx("p",{className:"px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"My Brokerage"})}),wt?r.jsxs("div",{className:"border-t border-sidebar-border mt-3 pt-3 space-y-1",children:[l&&r.jsx(Ze,{path:"/my-brokerage",icon:Ni,label:"My Brokerage"}),re&&!o&&r.jsx(Ze,{path:"/my-team",icon:ws,label:"My Team"}),o&&r.jsxs(r.Fragment,{children:[r.jsx(Ze,{path:"/brokerage/dashboard",icon:ld,label:"Manage Brokerages"}),r.jsx(Ze,{path:"/brokerage/teams",icon:ws,label:"Teams"}),r.jsx(Ze,{path:"/brokerage-resources",icon:Pu,label:"Brokerage Resources"})]})]}):r.jsxs(r.Fragment,{children:[l&&r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/my-brokerage"),children:[r.jsx(Ni,{className:"h-4 w-4"}),"My Brokerage"]}),re&&!o&&r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/my-team"),children:[r.jsx(ws,{className:"h-4 w-4"}),"My Team"]}),o&&r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/brokerage/dashboard"),children:[r.jsx(ld,{className:"h-4 w-4"}),"Manage Brokerages"]}),r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/brokerage/teams"),children:[r.jsx(ws,{className:"h-4 w-4"}),"Teams",r.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"})]}),r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/brokerage-resources"),children:[r.jsx(Pu,{className:"h-4 w-4"}),"Brokerage Resources"]})]})]})]})]})}),r.jsxs("div",{className:"p-3 border-t border-sidebar-border md:hidden",children:[r.jsxs(X,{variant:"ghost",size:"sm",className:Vt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",ve("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>se("/profile"),children:[r.jsx(Fl,{className:"h-4 w-4"}),"Profile"]}),r.jsxs(X,{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:[r.jsx(P4,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return r.jsx(h_t,{children:r.jsx(xN,{children:r.jsxs("div",{className:"min-h-screen bg-background flex",children:[k&&w&&r.jsx(P1t,{}),typeof document<"u"&&Hh.createPortal(r.jsx("aside",{className:Vt("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-[2147483647] isolate !pointer-events-auto transition-[width] duration-300",ie?"w-16":"w-52"),style:{top:`${v}px`,height:`calc(100vh - ${v}px)`},children:r.jsx(Le,{})}),document.body),r.jsxs("div",{className:Vt("flex-1 flex flex-col overflow-hidden transition-all duration-300",ie?"md:ml-16":"md:ml-52"),style:{height:`calc(100vh - ${v}px)`,marginTop:`${v}px`},children:[r.jsx("header",{className:"sticky top-0 z-40 bg-card border-b border-border flex-shrink-0",children:r.jsxs("div",{className:"flex items-center justify-between px-6 py-3",children:[r.jsxs(Nie,{children:[r.jsx(Bve,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"md:hidden",children:r.jsx(bE,{className:"h-5 w-5"})})}),r.jsx(M6,{side:"left",className:"w-52 p-0 bg-card",children:r.jsx(Le,{isMobile:!0})})]}),r.jsx("div",{className:"flex-1 md:hidden",children:r.jsx("img",{src:Ivt,alt:"LevelUp",className:"h-8 w-auto"})}),r.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:r.jsx(Z4e,{})}),r.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[k&&!w&&S&&r.jsx(I1t,{expiresAt:S,className:"hidden lg:flex"}),r.jsx("div",{className:"md:hidden",children:r.jsx(Z4e,{})}),C&&r.jsx(L1t,{hasUnseenBrief:R,onClick:D}),T&&r.jsxs(X,{variant:"ghost",size:"icon",className:"relative",onClick:()=>se("/marketplace/cart"),children:[r.jsx(Wh,{className:"h-5 w-5"}),oe>0&&r.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:oe>99?"99+":oe})]}),r.jsx(n1t,{}),r.jsx(Mpe,{}),r.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",((Ve=(Ue=s==null?void 0:s.user_metadata)==null?void 0:Ue.name)==null?void 0:Ve.split(" ")[0])||"User","!"]}),r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx("button",{className:"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded-full",children:r.jsxs(cn,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[r.jsx(xa,{src:_||void 0}),r.jsx(dn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:_e(((Ie=s==null?void 0:s.user_metadata)==null?void 0:Ie.name)||(s==null?void 0:s.email)||"U")})]})})}),r.jsxs(vu,{align:"end",className:"w-48",children:[r.jsxs(Ba,{onClick:()=>se("/profile"),className:"cursor-pointer",children:[r.jsx(Fl,{className:"h-4 w-4 mr-2"}),"Profile"]}),r.jsxs(Ba,{onClick:()=>se("/mission-control/integrations"),className:"cursor-pointer",children:[r.jsx(ME,{className:"h-4 w-4 mr-2"}),"Integrations"]}),r.jsx(Yk,{}),r.jsxs(Ba,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[r.jsx(P4,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),r.jsx(Q1t,{children:r.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:e})}),C&&r.jsx(Z1t,{brief:C,open:I,onClose:B,onDismiss:$}),r.jsx(X1t,{}),r.jsx(e_t,{}),r.jsx(r_t,{})]})]})})})},m_t=()=>{const{user:e}=Gr(),[t,s]=A.useState(!1),[n,a]=A.useState(null),[o,l]=A.useState(""),i=async g=>{var v;if(!(e!=null&&e.email)){we.error("Please sign in to upgrade");return}s(!0),a(g);try{const{data:_,error:k}=await Y.functions.invoke("create-checkout",{body:{tier:g,email:e.email,name:((v=e.user_metadata)==null?void 0:v.full_name)||e.email,couponCode:o.trim()||void 0,skipTrial:!0}});if(k)throw k;if(_!=null&&_.url)window.open(_.url,"_blank","noopener,noreferrer"),we.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(_){console.error("Checkout error:",_),we.error(_.message||"Failed to start checkout. Please try again.")}finally{s(!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"],m=["Everything in Individual plan","Up to 25 agent seats","Brokerage admin dashboard","Team performance analytics","Custom branding options","Priority support","Agent onboarding tools","Brokerage-wide announcements"],p=["Everything in Brokerage plan","Unlimited agent seats","Dedicated account manager","Advanced analytics & reporting","White-label options","API access","Custom integrations","Enterprise-level support"];return r.jsx(Ur,{children:r.jsxs("div",{className:"container max-w-6xl py-8 px-4",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Upgrade Your Membership"}),r.jsx("p",{className:"text-muted-foreground text-lg",children:"Choose the plan that's right for you and unlock the full power of LevelUp"})]}),r.jsxs("div",{className:"max-w-md mx-auto mb-8",children:[r.jsx(Ee,{htmlFor:"coupon",className:"text-sm font-medium",children:"Have a discount code?"}),r.jsx(Ye,{id:"coupon",placeholder:"Enter discount code",value:o,onChange:g=>l(g.target.value),className:"mt-1"})]}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mb-8",children:[r.jsxs(ze,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors relative overflow-hidden",children:[r.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"}),r.jsxs(Wt,{className:"text-center pb-2",children:[r.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center",children:r.jsx(ws,{className:"h-7 w-7 text-primary"})}),r.jsx(Zt,{className:"text-xl",children:"Individual Agent"}),r.jsx(Cs,{children:"Perfect for solo agents ready to level up"})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("span",{className:"text-4xl font-bold text-primary",children:"$39"}),r.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),r.jsx("ul",{className:"space-y-2",children:d.map((g,v)=>r.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[r.jsx(mi,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),r.jsx("span",{children:g})]},v))}),r.jsxs(X,{className:"w-full",size:"lg",onClick:()=>i("individual_agent"),disabled:t,children:[t&&n==="individual_agent"?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(bn,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),r.jsxs(ze,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[r.jsxs(Wt,{className:"text-center pb-2",children:[r.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:r.jsx(Ni,{className:"h-7 w-7 text-amber-600"})}),r.jsx(Zt,{className:"text-xl",children:"Brokerage"}),r.jsx(Cs,{children:"For teams and brokerages up to 25 agents"})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("span",{className:"text-4xl font-bold text-amber-600",children:"$299"}),r.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),r.jsx("ul",{className:"space-y-2",children:m.map((g,v)=>r.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[r.jsx(mi,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}),r.jsx("span",{children:g})]},v))}),r.jsxs(X,{variant:"outline",className:"w-full border-amber-500 text-amber-600 hover:bg-amber-50",size:"lg",onClick:()=>i("brokerage_under_25"),disabled:t,children:[t&&n==="brokerage_under_25"?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),r.jsxs(ze,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[r.jsxs(Wt,{className:"text-center pb-2",children:[r.jsx("div",{className:"mx-auto mb-3 h-14 w-14 rounded-full bg-purple-500/10 flex items-center justify-center",children:r.jsx(Ni,{className:"h-7 w-7 text-purple-600"})}),r.jsx(Zt,{className:"text-xl",children:"Brokerage 25+"}),r.jsx(Cs,{children:"For larger brokerages with 25+ agents"})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("span",{className:"text-4xl font-bold text-purple-600",children:"$499"}),r.jsx("span",{className:"text-muted-foreground",children:"/month"})]}),r.jsx("ul",{className:"space-y-2",children:p.map((g,v)=>r.jsxs("li",{className:"flex items-start gap-2 text-sm",children:[r.jsx(mi,{className:"h-4 w-4 text-purple-600 mt-0.5 shrink-0"}),r.jsx("span",{children:g})]},v))}),r.jsxs(X,{variant:"outline",className:"w-full border-purple-500 text-purple-600 hover:bg-purple-50",size:"lg",onClick:()=>i("brokerage_over_25"),disabled:t,children:[t&&n==="brokerage_over_25"?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(Ni,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),r.jsx(ze,{className:"bg-muted/50",children:r.jsxs(qe,{className:"py-6",children:[r.jsx("p",{className:"text-center font-medium mb-4",children:"Questions? We're here to help!"}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[r.jsxs("a",{href:"tel:1-866-527-8668",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[r.jsx(fi,{className:"h-4 w-4"}),r.jsx("span",{children:"1-866-527-8668"})]}),r.jsxs("a",{href:"mailto:support@relevelup.com",className:"flex items-center justify-center gap-2 text-primary hover:underline",children:[r.jsx(Vs,{className:"h-4 w-4"}),r.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},f_t=()=>{const{user:e,loading:t,isBrokerageManager:s,brokerageId:n}=Gr(),a=Ks(),[o,l]=A.useState(""),[i,d]=A.useState(!1),[m,p]=A.useState(!1);A.useEffect(()=>{!t&&!e&&a("/auth")},[e,t,a]),A.useEffect(()=>{!t&&e&&n&&a("/profile?setup=true")},[e,t,n,a]);const g=async()=>{if(!o.trim()){we.error("Please enter a brokerage name");return}const{data:v}=await Y.auth.getSession(),_=v.session;if(!e||!_){we.error("Please sign in again to create your brokerage."),a("/auth");return}d(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!e,hasSession:!!_,userId:e==null?void 0:e.id});const{data:k,error:w}=await Y.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:k,error:w}),w)throw w;if(!(k!=null&&k.ok))throw new Error((k==null?void 0:k.error)||"Failed to create brokerage");d(!1),p(!0),we.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(k){console.error("Error creating brokerage:",k),we.error(k.message||"Failed to create brokerage"),d(!1)}};return t?r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):m?r.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:r.jsxs(ze,{className:"max-w-lg w-full",children:[r.jsxs(Wt,{className:"text-center",children:[r.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:r.jsx($r,{className:"w-10 h-10 text-primary animate-spin"})}),r.jsx(Zt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),r.jsx(Cs,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[r.jsx(ui,{className:"w-5 h-5 text-green-500"}),r.jsx("span",{children:"Brokerage created"})]}),r.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[r.jsx($r,{className:"w-5 h-5 animate-spin text-primary"}),r.jsx("span",{children:"Assigning you as manager..."})]}),r.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."})]})]})}):r.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:r.jsxs(ze,{className:"max-w-lg w-full",children:[r.jsxs(Wt,{className:"text-center",children:[r.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:r.jsx(Ni,{className:"w-10 h-10 text-primary"})}),r.jsx(Zt,{className:"text-2xl",children:"Set Up Your Brokerage"}),r.jsx(Cs,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"brokerage-name",children:"Brokerage Name"}),r.jsx(Ye,{id:"brokerage-name",placeholder:"Enter your brokerage name",value:o,onChange:v=>l(v.target.value),onKeyDown:v=>v.key==="Enter"&&g()}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"This is how your brokerage will appear to your agents"})]}),r.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-3",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2",children:[r.jsx(ws,{className:"w-4 h-4 text-primary"}),"What you can do as a Brokerage Manager:"]}),r.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground",children:[r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-4 h-4 text-green-500"}),"Invite agents to join your brokerage"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-4 h-4 text-green-500"}),"Track your team's activity and engagement"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"w-4 h-4 text-green-500"}),"Share resources with your agents"]})]})]}),r.jsxs(X,{onClick:g,className:"w-full",disabled:i||!o.trim(),children:[i?"Creating...":"Create Brokerage",r.jsx(Ki,{className:"w-4 h-4 ml-2"})]})]})]})})},J4e=()=>{const e=Ks(),[t,s]=A.useState("verifying"),[n,a]=A.useState("");A.useEffect(()=>{(async()=>{try{const{data:{session:i},error:d}=await Y.auth.getSession();if(d)throw d;if(i!=null&&i.user){const{data:m}=await Y.from("profiles").select("login_count").eq("id",i.user.id).single();if(((m==null?void 0:m.login_count)||0)>1){console.log("Account already claimed, redirecting to dashboard"),s("already_claimed");return}console.log("User logged in successfully:",i.user.email),s("success");try{await Y.functions.invoke("trial-claim-hook",{body:{userId:i.user.id}})}catch(p){console.log("Trial claim hook (non-critical):",p)}setTimeout(()=>{e("/profile?setup=true")},1500)}else setTimeout(()=>{s("already_claimed")},2e3)}catch(i){console.error("Claim error:",i),s("already_claimed")}})()},[e]);const o=()=>{window.location.href="https://dashboard.relevelup.com/auth"};return r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"space-y-1 text-center",children:[r.jsxs("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:[t==="verifying"&&r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"}),t==="success"&&r.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),t==="already_claimed"&&r.jsx("svg",{className:"h-8 w-8 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})}),t==="error"&&r.jsx("svg",{className:"h-8 w-8 text-destructive",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})]}),r.jsxs(Zt,{className:"text-2xl",children:[t==="verifying"&&"Claiming Your Account...",t==="success"&&"Account Claimed!",t==="already_claimed"&&"Account Already Claimed",t==="error"&&"Claim Failed"]}),r.jsxs(Cs,{children:[t==="verifying"&&"Please wait while we verify your account...",t==="success"&&"Redirecting you to complete your profile...",t==="already_claimed"&&"This account has already been set up. Please log in to access your dashboard.",t==="error"&&n]})]}),(t==="already_claimed"||t==="error")&&r.jsx(qe,{children:r.jsx(X,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},p_t=()=>{const e=Ks(),[t]=Cc(),[s,n]=A.useState(t.get("code")||""),[a,o]=A.useState(""),[l,i]=A.useState(""),[d,m]=A.useState(""),[p,g]=A.useState(!1),[v,_]=A.useState(!1),[k,w]=A.useState(!1),[S,T]=A.useState(!1),[C,I]=A.useState(null),[R,D]=A.useState(null),[B,$]=A.useState(null),[q,W]=A.useState(null);A.useEffect(()=>{const oe=t.get("code");oe&&(n(oe),K(oe))},[t]);const K=async oe=>{w(!0);const{data:se,error:pe}=await Y.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",oe.toUpperCase().trim()).single();if(pe||!se){we.error("Invalid invite code"),w(!1);return}if(!se.is_active){we.error("This invite code is no longer active"),w(!1);return}if(se.max_uses&&se.uses_count>=se.max_uses){we.error("This invite code has reached its maximum uses"),w(!1);return}if(se.expires_at&&new Date(se.expires_at){oe.preventDefault(),K(s)},ae=async oe=>{var se;if(oe.preventDefault(),!d.trim()){we.error("Please enter your name");return}if(l.length<6){we.error("Password must be at least 6 characters");return}_(!0);try{const pe=`${window.location.origin}/`,{data:ie,error:de}=await Y.auth.signUp({email:a.trim(),password:l,options:{emailRedirectTo:pe,data:{name:d.trim()}}});if(de){de.message.includes("already registered")?we.error("This email is already registered. Please sign in instead."):we.error(de.message);return}ie.user&&(await Y.rpc("add_default_signup_tag",{user_id:ie.user.id}),R?await Y.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,brokerageId:R}}):q?await Y.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,trialDays:q}}):await Y.functions.invoke("assign-brokerage",{body:{userId:ie.user.id,grandfathered:!0}}),C&&await Y.from("invite_codes").update({uses_count:((se=(await Y.from("invite_codes").select("uses_count").eq("id",C).single()).data)==null?void 0:se.uses_count)+1}).eq("id",C),we.success("Account created! You can now access the dashboard."),e("/dashboard"))}catch(pe){console.error("Signup error:",pe),we.error("An unexpected error occurred")}finally{_(!1)}};return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"text-center",children:[r.jsx(Zt,{className:"text-2xl font-bold text-primary",children:B?`Join ${B}`:"Join LevelUp"}),r.jsx(Cs,{children:S?B?`Create your account to join ${B}`:"Create your account to get started":"Enter your invite code to continue"})]}),r.jsx(qe,{children:S?r.jsxs("form",{onSubmit:ae,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Full Name"}),r.jsx(Ye,{id:"name",type:"text",placeholder:"John Doe",value:d,onChange:oe=>m(oe.target.value),required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"email",children:"Email"}),r.jsx(Ye,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:oe=>o(oe.target.value),required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"password",children:"Password"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ye,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:oe=>i(oe.target.value),required:!0,minLength:6}),r.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>g(!p),children:p?r.jsx(Lf,{className:"h-4 w-4"}):r.jsx(Ii,{className:"h-4 w-4"})})]})]}),r.jsx(X,{type:"submit",className:"w-full",disabled:v,children:v?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):r.jsxs("form",{onSubmit:re,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"inviteCode",children:"Invite Code"}),r.jsx(Ye,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:s,onChange:oe=>n(oe.target.value),required:!0,autoFocus:!0})]}),r.jsx(X,{type:"submit",className:"w-full",disabled:k,children:k?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},g_t="/assets/testimonial-avatar-1-BsCQFauB.jpg",x_t="/assets/testimonial-avatar-2-B6VPVc2t.jpg",y_t="/assets/testimonial-avatar-3-GuEFwYUE.jpg",v_t="/assets/testimonial-avatar-4-98iKMtkB.jpg",__t="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",b_t=[g_t,x_t,y_t,v_t,__t],w_t=i_({name:zo().trim().min(2,"Name must be at least 2 characters").max(100),email:zo().trim().email("Please enter a valid email address").max(255),phone:zo().trim().min(10,"Please enter a valid phone number").max(20).optional().or(R5("")),brokerage:zo().trim().max(200).optional().or(R5(""))}),j_t=[{icon:kf,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:id,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:An,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:Rl,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:ya,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:po,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],k_t=[{icon:ws,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:bn,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:fi,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Lm,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Yi,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Rc,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:Ai,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:gx,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],N_t=[{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."}],S_t=()=>{const e=Ks(),[t,s]=A.useState(!1),[n,a]=A.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=A.useState({}),i=async d=>{var p,g;d.preventDefault(),l({});const m=w_t.safeParse(n);if(!m.success){const v={};m.error.errors.forEach(_=>{_.path[0]&&(v[_.path[0]]=_.message)}),l(v);return}s(!0);try{const{data:v,error:_}=await Y.functions.invoke("create-trial-signup",{body:{name:n.name.trim(),email:n.email.trim().toLowerCase(),phone:((p=n.phone)==null?void 0:p.trim())||void 0,brokerage:((g=n.brokerage)==null?void 0:g.trim())||void 0}});if(_){console.error("Trial signup error:",_),we.error(_.message||"Something went wrong. Please try again.");return}if(v!=null&&v.error){we.error(v.error);return}we.success("🎉 Welcome aboard! Check your email to claim your account."),e("/trial/success")}catch(v){console.error("Trial signup error:",v),we.error("Something went wrong. Please try again.")}finally{s(!1)}};return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsx("title",{children:"Start Your Free 7-Day Trial | LevelUp Dashboard"}),r.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."}),r.jsx("meta",{property:"og:title",content:"Start Your Free 7-Day Trial | LevelUp"}),r.jsx("meta",{property:"og:description",content:"Take LevelUp for a free 7-day test drive. No credit card required."}),r.jsx("meta",{property:"og:type",content:"website"})]}),r.jsxs("div",{className:"min-h-screen bg-background overflow-hidden",children:[r.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:r.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center",children:r.jsx("img",{src:yse,alt:"LevelUp",className:"h-8 md:h-10"})}),r.jsxs("div",{className:"flex items-center gap-2 md:gap-4",children:[r.jsx(X,{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"}),r.jsx(X,{onClick:()=>e("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})]})}),r.jsxs("section",{className:"relative pt-24 pb-20 bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsx("div",{className:"container mx-auto px-4 relative",children:r.jsxs("div",{className:"grid lg:grid-cols-2 gap-12 items-center",children:[r.jsxs("div",{className:"space-y-8 text-center lg:text-left",children:[r.jsx("div",{className:"flex justify-center lg:justify-start",children:r.jsx("img",{alt:"LevelUp Consulting Group",className:"h-24 md:h-32 drop-shadow-lg",src:"/lovable-uploads/3a0c7ef9-9e79-411f-a9af-6f2a99e8bd7b.webp"})}),r.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:[r.jsx(bn,{className:"h-4 w-4 text-yellow-400"}),r.jsx("span",{children:"7-Day Free Trial • No Credit Card Required"})]}),r.jsxs("h1",{className:"text-3xl md:text-4xl lg:text-5xl font-bold text-white leading-tight font-sans",children:["Take LevelUp for a"," ",r.jsx("span",{className:"italic",children:"Free Test Drive"})]}),r.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.",r.jsx("br",{}),r.jsx("em",{children:"The platform you need to keep it going."})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center lg:justify-start",children:[r.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[r.jsx(Ri,{className:"h-5 w-5 text-green-400"}),r.jsx("span",{children:"No credit card required"})]}),r.jsxs("div",{className:"flex items-center gap-2 text-white/80",children:[r.jsx(Ri,{className:"h-5 w-5 text-green-400"}),r.jsx("span",{children:"Full access to all features"})]})]}),r.jsxs("div",{className:"flex items-center gap-4 justify-center lg:justify-start pt-4",children:[r.jsx("div",{className:"flex -space-x-3",children:b_t.map((d,m)=>r.jsx("img",{src:d,alt:`Agent ${m+1}`,className:"w-10 h-10 rounded-full border-2 border-white/20 object-cover"},m))}),r.jsxs("div",{children:[r.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(d=>r.jsx(Dn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},d))}),r.jsx("p",{className:"text-sm text-white/60",children:"Trusted by 3,000+ agents"})]})]})]}),r.jsx("div",{className:"lg:pl-8",children:r.jsx(ze,{className:"bg-white shadow-2xl border-0",children:r.jsxs(qe,{className:"p-8",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-[#4a6b6d] mb-4",children:r.jsx(hx,{className:"h-8 w-8 text-white"})}),r.jsx("h2",{className:"text-2xl font-bold text-foreground font-sans",children:"Start Your Free Trial"}),r.jsx("p",{className:"text-muted-foreground mt-2",children:"Get instant access • No credit card needed"})]}),r.jsxs("form",{onSubmit:i,className:"space-y-5",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Full Name *"}),r.jsx(Ye,{id:"name",type:"text",placeholder:"John Smith",value:n.name,onChange:d=>a({...n,name:d.target.value}),required:!0}),o.name&&r.jsx("p",{className:"text-sm text-destructive",children:o.name})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"email",children:"Email Address *"}),r.jsx(Ye,{id:"email",type:"email",placeholder:"john@example.com",value:n.email,onChange:d=>a({...n,email:d.target.value}),required:!0}),o.email&&r.jsx("p",{className:"text-sm text-destructive",children:o.email})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"phone",children:"Phone Number"}),r.jsx(Ye,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:n.phone,onChange:d=>a({...n,phone:d.target.value})}),o.phone&&r.jsx("p",{className:"text-sm text-destructive",children:o.phone})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"brokerage",children:"Brokerage Name"}),r.jsx(Ye,{id:"brokerage",type:"text",placeholder:"Your brokerage or team name",value:n.brokerage,onChange:d=>a({...n,brokerage:d.target.value})}),o.brokerage&&r.jsx("p",{className:"text-sm text-destructive",children:o.brokerage})]}),r.jsx(X,{type:"submit",className:"w-full h-12 text-lg font-semibold bg-[#4a6b6d] hover:bg-[#3d5a5c]",disabled:t,children:t?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):r.jsxs(r.Fragment,{children:["Start My Free Trial",r.jsx(Ki,{className:"ml-2 h-5 w-5"})]})}),r.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["By signing up, you agree to our"," ",r.jsx("a",{href:"/terms-of-service",className:"text-[#4a6b6d] hover:underline",children:"Terms"})," ","and"," ",r.jsx("a",{href:"/privacy-policy",className:"text-[#4a6b6d] hover:underline",children:"Privacy Policy"})]})]})]})})})]})})]}),r.jsx("section",{className:"py-20 bg-background",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[r.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."}),r.jsxs("div",{className:"space-y-2 text-lg text-muted-foreground",children:[r.jsx("p",{children:"Agents get weekly coaching + plug-and-play marketing."}),r.jsx("p",{children:"Brokerages get higher adoption, consistency, and real engagement."})]}),r.jsx("p",{className:"text-2xl md:text-4xl text-[#4a6b6d] pt-4 font-sans font-bold",children:"LEVELUP EQUIPS BOTH TO THRIVE."})]})})}),r.jsx("section",{id:"features",className:"py-20 bg-muted/30",children:r.jsxs("div",{className:"container mx-auto px-4",children:[r.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[r.jsx("h2",{className:"text-3xl md:text-4xl mb-6 font-sans font-bold",children:"What's inside our members only portal?"}),r.jsx("p",{className:"text-lg text-muted-foreground",children:"Everything you need to grow your business, all in one place."})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto",children:j_t.map((d,m)=>r.jsxs(ze,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[r.jsxs(Wt,{children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:r.jsx(d.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),r.jsx(Zt,{className:"text-xl font-sans",children:d.title})]}),r.jsx(qe,{children:r.jsx("p",{className:"text-muted-foreground leading-relaxed",children:d.description})})]},m))})]})}),r.jsxs("section",{className:"py-20 bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] relative overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsxs("div",{className:"container mx-auto px-4 relative",children:[r.jsxs("div",{className:"text-center max-w-3xl mx-auto mb-16",children:[r.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:[r.jsx(bn,{className:"w-4 h-4"}),"Included with Your Trial"]}),r.jsxs("h2",{className:"text-3xl mb-6 text-white font-sans font-bold md:text-6xl",children:["Meet ",r.jsx("span",{className:"italic",children:"Agent OS"})]}),r.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."})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl mx-auto",children:k_t.map((d,m)=>r.jsxs(ze,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[r.jsxs(Wt,{className:"pb-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl bg-white/20 flex items-center justify-center mb-3",children:r.jsx(d.icon,{className:"w-6 h-6 text-white"})}),r.jsx(Zt,{className:"text-lg font-semibold text-white",children:d.title})]}),r.jsx(qe,{children:r.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:d.description})})]},m))})]})]}),r.jsx("section",{className:"py-20 bg-background",children:r.jsxs("div",{className:"container mx-auto px-4",children:[r.jsxs("div",{className:"text-center mb-16",children:[r.jsx("h2",{className:"text-3xl md:text-4xl font-bold mb-4 font-sans",children:"Loved by Top Producers"}),r.jsx("p",{className:"text-lg text-muted-foreground",children:"See what agents are saying about LevelUp"})]}),r.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:N_t.map((d,m)=>r.jsx(ze,{className:"border hover:shadow-lg transition-shadow",children:r.jsxs(qe,{className:"p-6",children:[r.jsx("div",{className:"flex gap-1 mb-4",children:[1,2,3,4,5].map(p=>r.jsx(Dn,{className:"h-4 w-4 fill-yellow-400 text-yellow-400"},p))}),r.jsxs("p",{className:"text-muted-foreground mb-4 italic",children:['"',d.quote,'"']}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:d.name}),r.jsx("p",{className:"text-sm text-muted-foreground",children:d.role})]})]})},m))})]})}),r.jsx("section",{className:"py-16 bg-muted/30",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsxs("div",{className:"flex flex-wrap justify-center gap-8 md:gap-16",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:r.jsx(Ou,{className:"h-6 w-6 text-[#4a6b6d]"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:"Secure & Private"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Bank-level encryption"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:r.jsx(gx,{className:"h-6 w-6 text-[#4a6b6d]"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:"Fast Setup"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Start in 2 minutes"})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/10 flex items-center justify-center",children:r.jsx(ws,{className:"h-6 w-6 text-[#4a6b6d]"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:"Expert Support"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Real estate pros"})]})]})]})})}),r.jsx("section",{id:"free-trial",className:"py-20 bg-background",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsxs(ze,{className:"bg-gradient-to-br from-[#1e3a4c] via-[#2a4f5f] to-[#3d6b6b] border-0 shadow-2xl overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsxs(qe,{className:"p-12 text-center relative",children:[r.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-white mb-4 font-sans",children:"Ready to Level Up Your Business?"}),r.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."}),r.jsxs(X,{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",r.jsx(Ki,{className:"ml-2 h-5 w-5"})]})]})]})})}),r.jsx("footer",{className:"bg-[#1e3a4c] py-12",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-6",children:[r.jsx("img",{src:kve,alt:"LevelUp",className:"h-8"}),r.jsxs("div",{className:"flex gap-6 text-sm text-white/60",children:[r.jsx("a",{href:"/privacy-policy",className:"hover:text-white transition-colors",children:"Privacy Policy"}),r.jsx("a",{href:"/terms-of-service",className:"hover:text-white transition-colors",children:"Terms of Service"})]}),r.jsx("p",{className:"text-sm text-white/40",children:"© 2025 LevelUp Consulting Group. All rights reserved."})]})})})]})]})},C_t=()=>{const e=Ks();return r.jsxs(r.Fragment,{children:[r.jsx(nm,{children:r.jsx("title",{children:"Welcome to LevelUp! | Check Your Email"})}),r.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[r.jsx("nav",{className:"fixed top-0 left-0 right-0 z-50 bg-[#4a6b6d] shadow-md",children:r.jsxs("div",{className:"container mx-auto px-4 py-3 flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center",children:r.jsx("img",{src:yse,alt:"LevelUp",className:"h-8 md:h-10"})}),r.jsx(X,{onClick:()=>e("/auth"),className:"bg-white text-[#4a6b6d] hover:bg-gray-100 font-medium shadow-md",children:"Sign In"})]})}),r.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:[r.jsx("div",{className:"absolute inset-0 opacity-10",children:r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmZmZmYiIGZpbGwtb3BhY2l0eT0iMC40Ij48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnY0em0wLTZ2LTRoLTJ2NGgyem0tNiA2aC0ydi00aDJ2NHptMC02di00aC0ydjRoMnoiLz48L2c+PC9nPjwvc3ZnPg==')]"})}),r.jsx("div",{className:"container mx-auto px-4 relative",children:r.jsx("div",{className:"flex justify-center",children:r.jsx(ze,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:r.jsxs(qe,{className:"p-8 md:p-12 text-center",children:[r.jsxs("div",{className:"relative inline-block mb-8",children:[r.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4a6b6d] to-[#3d5a5c] flex items-center justify-center",children:r.jsx(Ri,{className:"h-12 w-12 text-white"})}),r.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:r.jsx(od,{className:"h-5 w-5 text-white"})})]}),r.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4 font-sans",children:"You're In! 🎉"}),r.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"Your 7-day LevelUp adventure starts now!"}),r.jsxs("div",{className:"bg-[#4a6b6d]/10 rounded-xl p-6 mb-8",children:[r.jsxs("div",{className:"flex items-center justify-center gap-3 mb-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-[#4a6b6d]/20 flex items-center justify-center",children:r.jsx(Vs,{className:"h-6 w-6 text-[#4a6b6d]"})}),r.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Check Your Inbox"})]}),r.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!"})]}),r.jsxs("div",{className:"text-left space-y-3 mb-8",children:[r.jsx("p",{className:"text-sm text-muted-foreground font-medium uppercase tracking-wide",children:"What happens next:"}),r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:r.jsx("span",{className:"text-xs font-bold text-white",children:"1"})}),r.jsx("p",{className:"text-foreground",children:"Check your email for the welcome message"})]}),r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:r.jsx("span",{className:"text-xs font-bold text-white",children:"2"})}),r.jsx("p",{className:"text-foreground",children:'Click "Claim Your Account" to set your password'})]}),r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-6 h-6 rounded-full bg-[#4a6b6d] flex items-center justify-center flex-shrink-0 mt-0.5",children:r.jsx("span",{className:"text-xs font-bold text-white",children:"3"})}),r.jsx("p",{className:"text-foreground",children:"Start exploring all the features!"})]})]}),r.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Didn't receive the email? Check your spam folder or"," ",r.jsx("button",{onClick:()=>e("/trial"),className:"text-[#4a6b6d] hover:underline font-medium",children:"try again"})]}),r.jsxs(X,{onClick:()=>e("/auth"),className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["Go to Sign In",r.jsx(Ki,{className:"ml-2 h-4 w-4"})]})]})})})})]}),r.jsx("footer",{className:"bg-[#1e3a4c] py-8",children:r.jsx("div",{className:"container mx-auto px-4",children:r.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4",children:[r.jsx("img",{src:kve,alt:"LevelUp",className:"h-8"}),r.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},M_t=i_({viewerName:zo().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:zo().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:zo().max(20,"Phone must be less than 20 characters").optional(),message:zo().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function T_t({shareToken:e,agentName:t,hasContact:s}){const[n,a]=A.useState(!1),[o,l]=A.useState(!1),[i,d]=A.useState(null),m=Pie({resolver:Lie(M_t),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async g=>{a(!0),d(null);try{const{data:v,error:_}=await Y.functions.invoke("video-reply-notify",{body:{shareToken:e,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?r.jsx(ze,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:r.jsxs(qe,{className:"py-8 text-center",children:[r.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-primary/20 mb-4",children:r.jsx(Ri,{className:"h-8 w-8 text-primary"})}),r.jsx("h3",{className:"text-xl font-semibold mb-2",children:"Message Sent!"}),r.jsxs("p",{className:"text-muted-foreground",children:[t?`${t} will`:"They'll"," get back to you soon."]})]})}):r.jsxs(ze,{children:[r.jsxs(Wt,{className:"pb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Rl,{className:"h-5 w-5 text-primary"}),r.jsx(Zt,{className:"text-lg",children:"Reply to this video"})]}),r.jsx(Cs,{children:s?`Have a question or want to connect? Send ${t||"them"} a message.`:`Interested? Share your info and ${t||"your agent"} will be in touch.`})]}),r.jsx(qe,{children:r.jsx(Die,{...m,children:r.jsxs("form",{onSubmit:m.handleSubmit(p),className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[r.jsx(Hl,{control:m.control,name:"viewerName",render:({field:g})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Your Name *"}),r.jsx(Ll,{children:r.jsx(Ye,{placeholder:"John Smith",...g})}),r.jsx(uh,{})]})}),r.jsx(Hl,{control:m.control,name:"viewerEmail",render:({field:g})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Email *"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"email",placeholder:"john@example.com",...g})}),r.jsx(uh,{})]})})]}),!s&&r.jsx(Hl,{control:m.control,name:"viewerPhone",render:({field:g})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Phone (optional)"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"tel",placeholder:"(555) 123-4567",...g})}),r.jsx(uh,{})]})}),r.jsx(Hl,{control:m.control,name:"message",render:({field:g})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Message *"}),r.jsx(Ll,{children:r.jsx(qs,{placeholder:s?"Thanks for the video! I had a question about...":"I'm interested in learning more about...",className:"min-h-[100px] resize-none",...g})}),r.jsx(uh,{})]})}),i&&r.jsx("p",{className:"text-sm text-destructive",children:i}),r.jsx(X,{type:"submit",className:"w-full gap-2",disabled:n,children:n?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ai,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const A_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsxs("div",{className:"absolute inset-0 opacity-[0.08]",children:[r.jsx("div",{className:"absolute top-0 left-0 right-0 h-[8%] bg-red-600"}),r.jsx("div",{className:"absolute top-[16%] left-0 right-0 h-[8%] bg-red-600"}),r.jsx("div",{className:"absolute top-[32%] left-0 right-0 h-[8%] bg-red-600"}),r.jsx("div",{className:"absolute top-[48%] left-0 right-0 h-[8%] bg-red-600"}),r.jsx("div",{className:"absolute top-[64%] left-0 right-0 h-[8%] bg-red-600"}),r.jsx("div",{className:"absolute top-[80%] left-0 right-0 h-[8%] bg-red-600"})]}),r.jsx("div",{className:"absolute top-0 left-0 w-[35%] h-[45%] bg-blue-900/10 rounded-br-3xl"}),r.jsx(Dn,{className:"absolute top-[5%] left-[8%] w-6 h-6 text-blue-600/30 fill-blue-600/20"}),r.jsx(Dn,{className:"absolute top-[15%] left-[20%] w-4 h-4 text-blue-600/25 fill-blue-600/15"}),r.jsx(Dn,{className:"absolute top-[8%] left-[28%] w-5 h-5 text-blue-600/30 fill-blue-600/20"}),r.jsx(Dn,{className:"absolute top-[25%] left-[12%] w-4 h-4 text-blue-600/20 fill-blue-600/10"}),r.jsx(Dn,{className:"absolute top-[20%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse"}),r.jsx(zy,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 rotate-12"})]}),E_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-500/5 via-transparent to-blue-500/5"}),r.jsxs("div",{className:"absolute top-[10%] left-[15%] w-32 h-32",children:[r.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-red-400/20 animate-ping",style:{animationDuration:"3s"}}),r.jsx(bn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-8 text-red-400/40"})]}),r.jsxs("div",{className:"absolute top-[5%] right-[20%] w-24 h-24",children:[r.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-blue-400/20 animate-ping",style:{animationDuration:"4s",animationDelay:"1s"}}),r.jsx(Dn,{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"})]}),r.jsxs("div",{className:"absolute top-[20%] left-[50%] w-20 h-20",children:[r.jsx("div",{className:"absolute inset-0 rounded-full border border-white/10 animate-ping",style:{animationDuration:"3.5s",animationDelay:"0.5s"}}),r.jsx(bn,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-5 h-5 text-amber-400/40"})]}),r.jsx(Dn,{className:"absolute bottom-[25%] left-[10%] w-6 h-6 text-blue-500/25 fill-blue-500/15 animate-pulse"}),r.jsx(Dn,{className:"absolute bottom-[15%] right-[15%] w-5 h-5 text-red-500/25 fill-red-500/15 animate-pulse",style:{animationDelay:"0.5s"}}),r.jsx(zy,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),I_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-200/20 via-rose-100/10 to-purple-200/15"}),r.jsx("div",{className:"absolute top-[5%] left-[5%] opacity-20",children:r.jsx(Kp,{className:"w-20 h-20 text-pink-400 rotate-12"})}),r.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:r.jsx(Kp,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),r.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:r.jsx(Kp,{className:"w-14 h-14 text-purple-400 rotate-45"})}),r.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:r.jsx(Kp,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),r.jsx(Ai,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),r.jsx(Ai,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-300/40 fill-pink-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),r.jsx(Ai,{className:"absolute top-[10%] left-[60%] w-4 h-4 text-rose-400/30 fill-rose-400/15 animate-pulse",style:{animationDelay:"0.6s"}}),r.jsx("div",{className:"absolute top-[8%] left-[45%] w-8 h-8 rounded-full bg-pink-300/10 blur-sm"}),r.jsx("div",{className:"absolute bottom-[25%] right-[30%] w-6 h-6 rounded-full bg-rose-300/10 blur-sm"})]}),P_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/5 via-slate-800/3 to-indigo-900/5"}),r.jsx("div",{className:"absolute top-[5%] right-[10%] opacity-15",children:r.jsxs("div",{className:"w-12 h-24 relative",children:[r.jsx("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-10 h-3 bg-blue-600 rounded-full"}),r.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"})]})}),r.jsx(Yl,{className:"absolute top-[8%] left-[12%] w-12 h-12 text-blue-600/15"}),r.jsx(Dn,{className:"absolute top-[15%] left-[22%] w-5 h-5 text-amber-500/25 fill-amber-500/15"}),r.jsx(Yl,{className:"absolute bottom-[20%] right-[8%] w-14 h-14 text-indigo-500/12"}),r.jsx("div",{className:"absolute top-[3%] left-[40%] opacity-12",children:r.jsxs("div",{className:"flex gap-1",children:[r.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tr-none rotate-6"}),r.jsx("div",{className:"w-10 h-5 bg-slate-700 rounded-full rounded-tl-none -rotate-6"})]})}),r.jsx(Dn,{className:"absolute bottom-[25%] left-[15%] w-6 h-6 text-blue-500/20 fill-blue-500/10 animate-pulse"}),r.jsx(Dn,{className:"absolute top-[20%] right-[22%] w-5 h-5 text-indigo-400/20 fill-indigo-400/10 animate-pulse",style:{animationDelay:"0.5s"}})]}),L_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-100/20 via-purple-100/15 to-sky-100/20"}),r.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"}),r.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"}),r.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"}),r.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"}),r.jsx("div",{className:"absolute top-[10%] left-[10%] w-6 h-1 bg-white/30 rounded-full rotate-12"}),r.jsx("div",{className:"absolute top-[12%] right-[15%] w-5 h-1 bg-white/25 rounded-full -rotate-6"}),r.jsx(Kp,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),r.jsx(Kp,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),r.jsx(k4,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),D_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/12 via-purple-900/8 to-slate-900/12"}),r.jsx(vk,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),r.jsx(vk,{className:"absolute top-[10%] right-[12%] w-12 h-12 text-purple-400/20 animate-pulse"}),r.jsxs("div",{className:"absolute bottom-[18%] left-[8%]",children:[r.jsx("div",{className:"w-14 h-12 rounded-full bg-orange-500/20"}),r.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-4 bg-green-600/25 rounded-t-full"})]}),r.jsxs("div",{className:"absolute bottom-[22%] right-[12%]",children:[r.jsx("div",{className:"w-12 h-10 rounded-full bg-orange-400/15"}),r.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"})]}),r.jsx("div",{className:"absolute top-[15%] left-[40%] opacity-20",children:r.jsx("svg",{viewBox:"0 0 24 12",className:"w-10 h-5 text-slate-800 fill-current",children:r.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"})})}),r.jsx(bn,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),r.jsx(bn,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),O_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-red-900/8 via-green-900/5 to-emerald-900/8"}),r.jsx(M1,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),r.jsx(M1,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),r.jsx(M1,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),r.jsx(e1,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),r.jsx(e1,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),r.jsx(e1,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),r.jsx(e1,{className:"absolute top-[8%] left-[70%] w-8 h-8 text-blue-200/20 animate-pulse",style:{animationDelay:"0.9s"}}),r.jsx("div",{className:"absolute top-[12%] left-[10%] w-5 h-5 rounded-full bg-red-500/25"}),r.jsx("div",{className:"absolute top-[15%] right-[15%] w-4 h-4 rounded-full bg-amber-400/25"}),r.jsx("div",{className:"absolute top-[20%] left-[55%] w-4 h-4 rounded-full bg-green-500/20"}),r.jsx(Dn,{className:"absolute top-[3%] left-[50%] -translate-x-1/2 w-10 h-10 text-amber-400/35 fill-amber-400/25"})]}),R_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-orange-900/10 via-amber-800/6 to-red-900/10"}),r.jsx("div",{className:"absolute top-[5%] left-[10%] w-10 h-8 rounded-full bg-orange-500/25 rotate-45"}),r.jsx("div",{className:"absolute top-[10%] right-[15%] w-8 h-6 rounded-full bg-red-500/20 -rotate-12"}),r.jsx("div",{className:"absolute top-[15%] left-[35%] w-7 h-5 rounded-full bg-amber-500/22 rotate-30"}),r.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-10 h-7 rounded-full bg-yellow-600/18 -rotate-45"}),r.jsx("div",{className:"absolute bottom-[22%] right-[10%] w-9 h-6 rounded-full bg-orange-600/15 rotate-12"}),r.jsxs("div",{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2",children:[r.jsx("div",{className:"w-16 h-14 rounded-full bg-orange-400/15"}),r.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-2 h-5 bg-green-600/18 rounded-t-full"})]}),r.jsx(Ai,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),r.jsx(Ai,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),F_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-yellow-900/8 via-amber-900/4 to-purple-900/8"}),r.jsx(Dn,{className:"absolute top-[5%] left-[15%] w-12 h-12 text-yellow-400/35 fill-yellow-400/25 animate-pulse"}),r.jsx(Dn,{className:"absolute top-[8%] right-[12%] w-10 h-10 text-amber-400/30 fill-amber-400/20 animate-pulse",style:{animationDelay:"0.3s"}}),r.jsx(Dn,{className:"absolute top-[15%] left-[40%] w-7 h-7 text-yellow-300/25 fill-yellow-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),r.jsx(Dn,{className:"absolute top-[12%] right-[35%] w-8 h-8 text-amber-300/28 fill-amber-300/18 animate-pulse",style:{animationDelay:"0.9s"}}),r.jsx("div",{className:"absolute top-[20%] left-[25%] w-4 h-4 rounded-full bg-pink-400/30"}),r.jsx("div",{className:"absolute top-[18%] right-[30%] w-3 h-3 rounded-full bg-sky-400/30"}),r.jsx("div",{className:"absolute top-[25%] left-[60%] w-2.5 h-2.5 rounded-full bg-emerald-400/30"}),r.jsx("div",{className:"absolute top-[22%] right-[42%] w-3 h-3 rounded-full bg-purple-400/30"}),r.jsx(bn,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),r.jsx(od,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),r.jsx(od,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),z_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),r.jsxs("div",{className:"absolute bottom-[12%] left-1/2 -translate-x-1/2 flex items-end gap-3",children:[r.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"}),r.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),r.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),r.jsx("div",{className:"w-2.5 h-20 bg-blue-500/22 rounded-full"})," ",r.jsx("div",{className:"w-2 h-16 bg-blue-400/20 rounded-full"}),r.jsx("div",{className:"w-2 h-12 bg-blue-300/15 rounded-full"}),r.jsx("div",{className:"w-2 h-14 bg-blue-400/18 rounded-full"})]}),r.jsx("div",{className:"absolute bottom-[38%] left-[calc(50%-42px)] w-3 h-4 bg-yellow-400/30 rounded-full blur-sm"}),r.jsx("div",{className:"absolute bottom-[35%] left-[calc(50%-28px)] w-2.5 h-3 bg-yellow-300/25 rounded-full blur-sm"}),r.jsx("div",{className:"absolute bottom-[40%] left-[calc(50%-14px)] w-3 h-4 bg-amber-400/30 rounded-full blur-sm"}),r.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"}),r.jsx(Dn,{className:"absolute top-[8%] left-[50%] -translate-x-1/2 w-14 h-14 text-yellow-400/28 fill-yellow-400/18"}),r.jsx(bn,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),r.jsx(bn,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),B_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-green-900/12 via-emerald-900/6 to-teal-900/10"}),r.jsx(My,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),r.jsx(My,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),r.jsx(My,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),r.jsx(My,{className:"absolute bottom-[22%] right-[10%] w-11 h-11 text-emerald-400/18"}),r.jsx("div",{className:"absolute top-[15%] left-[35%] w-6 h-6 rounded-full bg-yellow-500/30 border-2 border-yellow-600/25"}),r.jsx("div",{className:"absolute top-[20%] right-[28%] w-5 h-5 rounded-full bg-amber-500/25 border-2 border-amber-600/20"}),r.jsx("div",{className:"absolute bottom-[28%] left-[45%] w-5 h-5 rounded-full bg-yellow-400/25 border-2 border-yellow-500/20"}),r.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 opacity-12 rounded-bl-full overflow-hidden",children:r.jsx("div",{className:"absolute inset-0 bg-gradient-to-bl from-red-400/60 via-yellow-400/60 to-green-400/60"})}),r.jsxs("div",{className:"absolute bottom-[10%] right-[5%] opacity-15",children:[r.jsx("div",{className:"w-12 h-8 bg-slate-700 rounded-b-full"}),r.jsx("div",{className:"absolute -top-1 left-1/2 -translate-x-1/2 w-10 h-3 bg-slate-600 rounded-full"}),r.jsxs("div",{className:"absolute top-0 left-1/2 -translate-x-1/2 flex gap-0.5",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"}),r.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-400"}),r.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-400"})]})]})]}),$_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-blue-900/10 via-indigo-900/6 to-sky-900/10"}),r.jsx("div",{className:"absolute top-[8%] left-[12%] w-16 h-16 rounded-full border-4 border-blue-500/18"}),r.jsx("div",{className:"absolute top-[10%] right-[10%] w-14 h-14 rounded-full border-4 border-indigo-500/15"}),r.jsx("div",{className:"absolute bottom-[18%] left-[18%] w-12 h-12 rounded-full border-3 border-sky-500/12"}),r.jsx(Dn,{className:"absolute top-[5%] left-[42%] w-10 h-10 text-amber-400/30 fill-amber-400/20"}),r.jsx(Dn,{className:"absolute top-[15%] right-[25%] w-7 h-7 text-yellow-400/25 fill-yellow-400/15"}),r.jsx(Yl,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),r.jsx(Yl,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),r.jsx(zy,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),U_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/6 via-rose-900/6 to-purple-900/6"}),r.jsx(Lm,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-amber-400/18"}),r.jsxs("div",{className:"absolute top-[5%] left-[15%]",children:[r.jsx("div",{className:"w-12 h-14 rounded-full bg-rose-400/25"}),r.jsx("div",{className:"w-0.5 h-10 bg-rose-400/18 mx-auto"})]}),r.jsxs("div",{className:"absolute top-[3%] left-[25%]",children:[r.jsx("div",{className:"w-10 h-12 rounded-full bg-sky-400/25"}),r.jsx("div",{className:"w-0.5 h-12 bg-sky-400/18 mx-auto"})]}),r.jsxs("div",{className:"absolute top-[8%] right-[18%]",children:[r.jsx("div",{className:"w-11 h-13 rounded-full bg-purple-400/25"}),r.jsx("div",{className:"w-0.5 h-9 bg-purple-400/18 mx-auto"})]}),r.jsxs("div",{className:"absolute top-[5%] right-[10%]",children:[r.jsx("div",{className:"w-10 h-12 rounded-full bg-amber-400/25"}),r.jsx("div",{className:"w-0.5 h-11 bg-amber-400/18 mx-auto"})]}),r.jsx("div",{className:"absolute top-[20%] left-[35%] w-3 h-3 bg-pink-400/35 rounded-full"}),r.jsx("div",{className:"absolute top-[18%] right-[40%] w-2.5 h-2.5 bg-emerald-400/35 rounded-full"}),r.jsx("div",{className:"absolute top-[25%] left-[55%] w-2 h-2 bg-amber-400/35 rounded-full"}),r.jsx("div",{className:"absolute top-[22%] right-[30%] w-2.5 h-2.5 bg-sky-400/35 rounded-full"}),r.jsx(od,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),r.jsx(po,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),V_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-rose-900/12 via-pink-900/8 to-red-900/12"}),r.jsx(Ai,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),r.jsx(Ai,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),r.jsx(Ai,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),r.jsx(Ai,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),r.jsx(Ai,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),r.jsx(Ai,{className:"absolute top-[20%] right-[35%] w-5 h-5 text-rose-300/35 fill-rose-300/20 animate-pulse",style:{animationDelay:"0.3s"}}),r.jsx(Ai,{className:"absolute top-[12%] left-[55%] w-5 h-5 text-red-300/30 fill-red-300/15 animate-pulse",style:{animationDelay:"0.6s"}}),r.jsx(Ai,{className:"absolute top-[25%] right-[25%] w-4 h-4 text-pink-400/30 fill-pink-400/15 animate-pulse",style:{animationDelay:"0.9s"}}),r.jsx("div",{className:"absolute top-[18%] left-[45%] w-8 h-8 rounded-full bg-rose-300/18 blur-sm"}),r.jsx("div",{className:"absolute bottom-[25%] right-[40%] w-6 h-6 rounded-full bg-pink-300/15 blur-sm"})]}),q_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),r.jsxs("div",{className:"absolute top-[5%] right-[12%]",children:[r.jsx("div",{className:"w-24 h-24 rounded-full bg-yellow-400/25 blur-sm"}),r.jsx(C1,{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-14 h-14 text-amber-400/45"})]}),r.jsx("div",{className:"absolute bottom-[12%] left-[20%] w-20 h-10 bg-slate-800/12 rounded-full blur-md"}),r.jsx(C1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),r.jsx(bn,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),r.jsx(C1,{className:"absolute bottom-[22%] right-[25%] w-8 h-8 text-orange-400/25"}),r.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[15%] bg-gradient-to-t from-amber-900/10 to-transparent"})]}),H_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-cyan-900/6 to-emerald-900/10"}),r.jsx(Vn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),r.jsx(Vn,{className:"absolute bottom-[15%] right-[8%] w-16 h-16 text-emerald-500/18"}),r.jsx(Rm,{className:"absolute top-[12%] right-[18%] w-10 h-10 text-amber-400/25"}),r.jsx(Rm,{className:"absolute bottom-[22%] left-[22%] w-8 h-8 text-yellow-400/22"}),r.jsx(Ai,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),r.jsx(Ai,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),r.jsx(bn,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),r.jsx(od,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),W_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),r.jsx(od,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),r.jsx(od,{className:"absolute top-[8%] right-[10%] w-12 h-12 text-teal-400/22 -rotate-12"}),r.jsx(Rm,{className:"absolute bottom-[18%] left-[18%] w-12 h-12 text-amber-400/25"}),r.jsx(Vn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),r.jsx(bn,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),r.jsx(bn,{className:"absolute top-[20%] right-[32%] w-7 h-7 text-cyan-400/30"}),r.jsx("div",{className:"absolute top-[25%] left-[55%] w-3 h-3 bg-amber-400/30 rounded-full"}),r.jsx("div",{className:"absolute top-[22%] right-[42%] w-2.5 h-2.5 bg-teal-400/30 rounded-full"}),r.jsx("div",{className:"absolute top-[28%] left-[35%] w-2 h-2 bg-emerald-400/30 rounded-full"})]}),G_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-amber-900/10 via-yellow-900/6 to-orange-900/10"}),r.jsx(Rm,{className:"absolute bottom-[12%] left-[50%] -translate-x-1/2 w-24 h-24 text-amber-400/25 rotate-45"}),r.jsx(Rm,{className:"absolute top-[10%] left-[12%] w-10 h-10 text-yellow-400/30"}),r.jsx(Rm,{className:"absolute top-[12%] right-[15%] w-9 h-9 text-amber-300/25"}),r.jsx(Vn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),r.jsx(od,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),r.jsx(bn,{className:"absolute top-[5%] right-[35%] w-8 h-8 text-yellow-400/35"}),r.jsx(Dn,{className:"absolute top-[18%] left-[28%] w-6 h-6 text-amber-400/25 fill-amber-400/15"})]}),K_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-teal-900/10 via-emerald-900/6 to-green-900/10"}),r.jsx(Vn,{className:"absolute bottom-[10%] left-[50%] -translate-x-1/2 w-20 h-20 text-teal-500/22"}),r.jsx("div",{className:"absolute bottom-[18%] left-[12%] w-12 h-10 bg-amber-400/18 rounded-sm"}),r.jsx("div",{className:"absolute bottom-[20%] left-[20%] w-10 h-8 bg-orange-400/15 rounded-sm"}),r.jsx("div",{className:"absolute bottom-[16%] right-[15%] w-11 h-9 bg-amber-300/18 rounded-sm"}),r.jsx(Rm,{className:"absolute top-[10%] right-[12%] w-10 h-10 text-amber-400/28"}),r.jsx(Ai,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),r.jsx(bn,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),r.jsx(Fy,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),e5e=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx("div",{className:"absolute top-4 left-[10%] w-3 h-3 bg-amber-400/60 rounded-full animate-pulse"}),r.jsx("div",{className:"absolute top-12 right-[15%] w-2 h-2 bg-rose-400/60 rounded-full animate-pulse delay-100"}),r.jsx("div",{className:"absolute top-8 left-[30%] w-2.5 h-2.5 bg-sky-400/60 rounded-full animate-pulse delay-200"}),r.jsx("div",{className:"absolute top-16 right-[25%] w-2 h-2 bg-emerald-400/60 rounded-full animate-pulse delay-300"})]}),Z_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx(Ai,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),r.jsx(Ai,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),r.jsx(Ai,{className:"absolute top-4 left-[40%] w-2.5 h-2.5 text-rose-400/40 fill-rose-400/20 animate-pulse delay-300"}),r.jsx(Ai,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),Y_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx(Fy,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),r.jsx(bn,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),r.jsx(Vn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),X_t=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx(gk,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),r.jsx(L4,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),r.jsx(gk,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),xA=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx(bn,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),r.jsx(od,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),r.jsx(bn,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),t5e=()=>r.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[r.jsx(Vn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),r.jsx(bn,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),r.jsx(Vn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),Ipe=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:r.jsx(bn,{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:r.jsx(Ai,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Thank You, ${e}!`:"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:r.jsx(Z_t,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:r.jsx(hE,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Thinking of You, ${e}`:"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:r.jsx(xA,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:r.jsx(gk,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Hey ${e}!`:"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:r.jsx(X_t,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:r.jsx(Rc,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Market Update for ${e}`:"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:r.jsx(ws,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Thank You for the Referral, ${e}!`:"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:r.jsx(xA,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:r.jsx(Yl,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Congratulations, ${e}!`:"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:r.jsx(e5e,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:r.jsx(Yi,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Welcome to the Neighborhood, ${e}!`:"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:r.jsx(t5e,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:r.jsx(L4,{className:"h-5 w-5"}),category:"general",headerText:e=>e?`Hey ${e}!`:"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:r.jsx(xA,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:r.jsx(Lm,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Birthday, ${e}!`:"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:r.jsx(U_t,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:r.jsx(Ai,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Valentine's Day, ${e}!`:"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:r.jsx(V_t,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:r.jsx(C1,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Groundhog Day, ${e}!`:"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:r.jsx(q_t,{})},{id:"new_years",name:"New Year's Day",description:"Ring in the new year",icon:r.jsx(Dn,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy New Year, ${e}!`:"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:r.jsx(F_t,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:r.jsx(k4,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Easter, ${e}!`:"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:r.jsx(L_t,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:r.jsx(Kp,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Mother's Day, ${e}!`:"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:r.jsx(I_t,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:r.jsx(Yl,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Father's Day, ${e}!`:"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:r.jsx(P_t,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:r.jsx(zy,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Memorial Day, ${e}`:"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:r.jsx(A_t,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:r.jsx(Om,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy 4th of July, ${e}!`:"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:r.jsx(E_t,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:r.jsx(Yl,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Labor Day, ${e}!`:"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:r.jsx($_t,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:r.jsx(vk,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Halloween, ${e}!`:"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:r.jsx(D_t,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:r.jsx(Ai,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Thanksgiving, ${e}!`:"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:r.jsx(R_t,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:r.jsx(M1,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Merry Christmas, ${e}!`:"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:r.jsx(O_t,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:r.jsx(bn,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy Hanukkah, ${e}!`:"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:r.jsx(z_t,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:r.jsx(My,{className:"h-5 w-5"}),category:"holidays",headerText:e=>e?`Happy St. Patrick's Day, ${e}!`:"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:r.jsx(B_t,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:r.jsx(Vn,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Happy Home Anniversary, ${e}!`:"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:r.jsx(H_t,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:r.jsx(od,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Congratulations, ${e}!`:"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:r.jsx(W_t,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:r.jsx(An,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Exciting News, ${e}!`:"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:r.jsx(t5e,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:r.jsx(Sd,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Congratulations, ${e}!`:"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:r.jsx(xA,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:r.jsx(Tk,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Great News, ${e}!`:"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:r.jsx(Fy,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`You're Invited, ${e}!`:"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:r.jsx(Y_t,{})},{id:"closing_day",name:"Closing Day",description:"Celebrate their closing day",icon:r.jsx(Rm,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Congratulations, ${e}!`:"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:r.jsx(G_t,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:r.jsx(Vn,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Welcome Home, ${e}!`:"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:r.jsx(K_t,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:r.jsx(Cd,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Amazing News, ${e}!`:"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:r.jsx(xA,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:r.jsx(Yl,{className:"h-5 w-5"}),category:"transactional",headerText:e=>e?`Congratulations, ${e}!`:"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:r.jsx(e5e,{})}],Q_t=[{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 J_t(e){return Ipe.filter(t=>t.category===e)}function K4(e){return Ipe.find(t=>t.id===e)||Ipe[0]}function ebt(){const{shareToken:e}=Bl(),[t,s]=A.useState(null),[n,a]=A.useState(null),[o,l]=A.useState(null),[i,d]=A.useState(!0),[m,p]=A.useState(null),[g,v]=A.useState(!0);A.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(K=>{document.querySelectorAll(K).forEach(re=>{re.style.display="none"})})};B();const $=[setTimeout(B,500),setTimeout(B,1500),setTimeout(B,3e3)],q=new MutationObserver(B);return q.observe(document.body,{childList:!0,subtree:!0}),()=>{$.forEach(clearTimeout),q.disconnect()}},[]),A.useEffect(()=>{(async()=>{if(!e){p("Invalid share link"),d(!1);return}const{data:$,error:q}=await Y.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",e).eq("is_deleted",!1).single();if(q||!$){p("Video not found or has been removed"),d(!1);return}s($);try{await Y.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 Y.from("profiles").select("id, name, email, phone").eq("id",$.owner_user_id).single();if(W){a(W);try{const{data:K}=await Y.storage.from("avatars").list(`${$.owner_user_id}`);if(K&&K.length>0){const{data:re}=Y.storage.from("avatars").getPublicUrl(`${$.owner_user_id}/${K[0].name}`);l(re.publicUrl)}}catch{}}}d(!1)})()},[e]);const _=B=>{if(!B)return"0:00";const $=Math.floor(B/60),q=B%60;return`${$}:${q.toString().padStart(2,"0")}`},k=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()},S=K4((t==null?void 0:t.page_template)||"default"),T=(t==null?void 0:t.recipient_name)||null,C=S.headerText(T),R=`https://dashboard.relevelup.com/share/video/${e}`;if(i)return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-primary"})});if(m||!t)return r.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:r.jsx(ze,{className:"max-w-md w-full",children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(ma,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Video Not Found"}),r.jsx("p",{className:"text-muted-foreground",children:m||"This video is no longer available."})]})})});const D=S.id!=="default";return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsx("title",{children:C}),r.jsx("meta",{name:"description",content:S.subText}),r.jsx("meta",{property:"og:title",content:C}),r.jsx("meta",{property:"og:description",content:S.subText}),r.jsx("meta",{property:"og:type",content:"video.other"}),r.jsx("meta",{property:"og:url",content:R}),t.preview_url&&r.jsx("meta",{property:"og:image",content:t.preview_url}),!t.preview_url&&t.thumbnail_url&&r.jsx("meta",{property:"og:image",content:t.thumbnail_url}),t.playback_url&&r.jsxs(r.Fragment,{children:[r.jsx("meta",{property:"og:video",content:t.playback_url}),r.jsx("meta",{property:"og:video:type",content:"text/html"}),r.jsx("meta",{property:"og:video:width",content:"1280"}),r.jsx("meta",{property:"og:video:height",content:"720"})]}),r.jsx("meta",{name:"twitter:card",content:"player"}),r.jsx("meta",{name:"twitter:title",content:C}),r.jsx("meta",{name:"twitter:description",content:S.subText}),t.preview_url&&r.jsx("meta",{name:"twitter:image",content:t.preview_url}),t.playback_url&&r.jsxs(r.Fragment,{children:[r.jsx("meta",{name:"twitter:player",content:t.playback_url}),r.jsx("meta",{name:"twitter:player:width",content:"1280"}),r.jsx("meta",{name:"twitter:player:height",content:"720"})]})]}),r.jsxs("div",{className:Vt("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",S.gradientClasses),children:[D&&S.decorativeElement,r.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[D&&r.jsxs("div",{className:"text-center py-4 animate-fade-in",children:[r.jsx("div",{className:"flex justify-center mb-3",children:r.jsx("div",{className:Vt("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",S.accentColor==="primary"&&"bg-primary/10 text-primary",S.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",S.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",S.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",S.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",S.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",S.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",S.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",S.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",S.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",S.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",S.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",S.accentColor==="sky"&&"bg-sky-100 text-sky-600 dark:bg-sky-900/50 dark:text-sky-400"),children:r.jsx("div",{className:"scale-150",children:S.icon})})}),r.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:C}),r.jsx("p",{className:"text-muted-foreground",children:S.subText})]}),n&&r.jsxs("div",{className:"flex items-center gap-4 p-4 bg-card/90 backdrop-blur-sm rounded-lg border shadow-sm",children:[r.jsxs(cn,{className:"h-14 w-14 border-2 border-primary/20",children:[r.jsx(xa,{src:o||void 0,alt:n.name||"Agent"}),r.jsx(dn,{className:"bg-primary/10 text-primary font-semibold",children:w(n.name)})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:D?"A special video from":"A personal video from"}),r.jsx("h2",{className:"text-lg font-semibold truncate",children:n.name||"Your Agent"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Your Real Estate Professional"})]}),r.jsxs("div",{className:"flex gap-2 shrink-0",children:[n.phone&&r.jsx(X,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:r.jsx("a",{href:`tel:${n.phone}`,"aria-label":"Call agent",children:r.jsx(fi,{className:"h-4 w-4"})})}),n.email&&r.jsx(X,{variant:"outline",size:"icon",asChild:!0,className:"h-10 w-10",children:r.jsx("a",{href:`mailto:${n.email}`,"aria-label":"Email agent",children:r.jsx(Vs,{className:"h-4 w-4"})})})]})]}),r.jsx(ze,{className:"overflow-hidden shadow-lg",children:g&&t.playback_url?r.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:r.jsx("iframe",{src:k(t.playback_url),title:t.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})}):r.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>v(!0),children:[t.preview_url||t.thumbnail_url?r.jsx("img",{src:t.preview_url||t.thumbnail_url||"",alt:t.title?`${t.title} video preview`:"Video message preview",className:"w-full h-full object-cover",onError:B=>{var q;B.currentTarget.style.display="none";const $=(q=B.currentTarget.parentElement)==null?void 0:q.querySelector(".video-fallback");$&&($.style.display="flex")}}):null,r.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:t.preview_url||t.thumbnail_url?"none":"flex"},children:r.jsx(ma,{className:"h-16 w-16 text-primary/50"})}),r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 group-hover:bg-black/40 transition-colors",children:r.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:r.jsx(tc,{className:"h-10 w-10 text-primary ml-1"})})}),t.duration_seconds&&r.jsx("div",{className:"absolute bottom-3 right-3 bg-black/70 text-white text-sm px-2 py-1 rounded",children:_(t.duration_seconds)})]})}),!D&&r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold",children:t.title||"Video Message"}),r.jsx("p",{className:"text-muted-foreground mt-2",children:g?"Enjoy the video!":"Click to play the video"})]}),!g&&r.jsx("div",{className:"flex justify-center",children:r.jsxs(X,{size:"lg",onClick:()=>v(!0),className:"gap-2",children:[r.jsx(tc,{className:"h-5 w-5"}),"Watch Video"]})}),r.jsx(T_t,{shareToken:e,agentName:(n==null?void 0:n.name)||null,hasContact:!!t.contact_id})]})]})]})}function tbt(){return A.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),r.jsx(nct,{})}function rbt(){const{token:e}=Bl();return A.useEffect(()=>{if(!e)return;const t=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/video-og-image?token=${e}`;window.location.replace(t)},[e]),r.jsx("main",{className:"min-h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[r.jsx($r,{className:"h-5 w-5 animate-spin"}),r.jsx("span",{children:"Loading video preview…"})]})})}const sbt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},nbt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},wC={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function abt(){var se,pe,ie,de;const{slugOrId:e}=Bl(),[t]=Cc(),{data:s,isLoading:n}=e7e(e||""),a=t7e(),o=Xpt(),l=t.get("ref"),[i,d]=A.useState(""),[m,p]=A.useState(""),[g,v]=A.useState(""),[_,k]=A.useState(""),[w,S]=A.useState(!1),[T,C]=A.useState(!1),[I,R]=A.useState(null),[D,B]=A.useState(!1);A.useEffect(()=>{l&&o.mutate(l)},[l]);const $=ce=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ce),q=async ce=>{if(ce.preventDefault(),!(!i.trim()||!g.trim()||!s)){S(!0);try{await a.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:i.trim(),lastName:m.trim(),email:g.trim(),phone:_.trim(),shareToken:l}),C(!0),we.success("Thanks! The agent will be in touch soon.")}catch(ge){console.error("Lead submission error:",ge),we.error(`Failed to submit: ${ge.message||"Please try again"}`)}finally{S(!1)}}},W=(s==null?void 0:s.photos)||[],K=W.find(ce=>ce.is_primary)||W[0],re=()=>{I!==null&&R(I===0?W.length-1:I-1)},ae=()=>{I!==null&&R(I===W.length-1?0:I+1)};if(n)return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"border-b bg-card",children:r.jsx("div",{className:"container mx-auto px-4 py-4",children:r.jsx(pr,{className:"h-8 w-32"})})}),r.jsxs("div",{className:"container mx-auto px-4 py-8",children:[r.jsx(pr,{className:"h-10 w-48 mb-6"}),r.jsx(pr,{className:"aspect-video mb-6"}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"md:col-span-2 space-y-4",children:[r.jsx(pr,{className:"h-12 w-48"}),r.jsx(pr,{className:"h-6 w-full"}),r.jsx(pr,{className:"h-6 w-3/4"})]}),r.jsx(pr,{className:"h-64"})]})]})]});if(!s)return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"border-b bg-card",children:r.jsx("div",{className:"container mx-auto px-4 py-4",children:r.jsx(vo,{to:"/public/listings",className:"flex items-center gap-2",children:r.jsx("img",{src:dse,alt:"LevelUp",className:"h-8"})})})}),r.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[r.jsx(Vn,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Listing Not Found"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing may no longer be available."}),r.jsx(X,{asChild:!0,children:r.jsx(vo,{to:"/public/listings",children:"Browse All Listings"})})]})]});const oe=s.property_address?`${s.property_address} - ${s.city}, ${s.state}`:`${s.city}, ${s.state} Home for Sale`;return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsxs("title",{children:[oe," | LevelUp Listings"]}),r.jsx("meta",{name:"description",content:`${$(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${wC[s.property_type]} in ${s.city}, ${s.state}. ${((se=s.description)==null?void 0:se.slice(0,150))||""}`}),r.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${s.slug||s.id}`}),r.jsx("meta",{property:"og:title",content:oe}),r.jsx("meta",{property:"og:description",content:`${$(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${wC[s.property_type]} in ${s.city}, ${s.state}. View photos, details, and contact the listing agent.`}),r.jsx("meta",{property:"og:type",content:"website"}),r.jsx("meta",{property:"og:url",content:`https://listings.relevelup.com/${s.slug||s.id}`}),K&&r.jsx("meta",{property:"og:image",content:K.photo_url}),K&&r.jsx("meta",{property:"og:image:alt",content:`${s.property_address||s.city} - ${wC[s.property_type]} for sale`}),r.jsx("meta",{property:"og:site_name",content:"LevelUp Listings"}),r.jsx("meta",{property:"og:locale",content:"en_US"}),r.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),r.jsx("meta",{name:"twitter:title",content:oe}),r.jsx("meta",{name:"twitter:description",content:`${$(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),K&&r.jsx("meta",{name:"twitter:image",content:K.photo_url}),r.jsx("meta",{name:"robots",content:"index, follow"}),r.jsx("meta",{name:"geo.region",content:`US-${s.state}`}),r.jsx("meta",{name:"geo.placename",content:s.city}),r.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"RealEstateListing",name:s.property_address||`${s.city}, ${s.state} Home`,description:s.description||`${wC[s.property_type]} for sale in ${s.city}, ${s.state}`,url:`https://listings.relevelup.com/${s.slug||s.id}`,datePosted:s.created_at,image:W.map(ce=>ce.photo_url),address:{"@type":"PostalAddress",streetAddress:s.property_address||void 0,addressLocality:s.city,addressRegion:s.state,addressCountry:"US"},geo:s.neighborhood?{"@type":"GeoCoordinates",name:s.neighborhood}:void 0,offers:{"@type":"Offer",price:s.price,priceCurrency:"USD",availability:s.status==="sold"?"https://schema.org/SoldOut":s.status==="under_contract"?"https://schema.org/LimitedAvailability":"https://schema.org/InStock"},numberOfRooms:s.bedrooms||void 0,numberOfBathroomsTotal:s.bathrooms||void 0,floorSize:s.square_footage?{"@type":"QuantitativeValue",value:s.square_footage,unitCode:"FTK"}:void 0,yearBuilt:s.year_built||void 0,broker:s.agent?{"@type":"RealEstateAgent",name:s.agent.name,email:s.agent.email,worksFor:(pe=s.agent.brokerage)!=null&&pe.name?{"@type":"RealEstateAgent",name:s.agent.brokerage.name}:void 0}:void 0})})]}),r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"border-b bg-card sticky top-0 z-50",children:r.jsx("div",{className:"container mx-auto px-4 py-4",children:r.jsx("div",{className:"flex items-center justify-between",children:r.jsx(vo,{to:"/public/listings",className:"flex items-center gap-2",children:r.jsx("img",{src:dse,alt:"LevelUp",className:"h-8"})})})})}),r.jsxs("div",{className:"container mx-auto px-4 py-6",children:[r.jsxs(vo,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),W.length>0&&r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>R(0),children:r.jsx("img",{src:K==null?void 0:K.photo_url,alt:`${s.property_address||s.city+", "+s.state} - ${wC[s.property_type]} main photo`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"})})}),r.jsx("div",{className:"grid grid-cols-2 gap-2",children:W.slice(1,5).map((ce,ge)=>r.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>R(ge+1),children:[r.jsx("img",{src:ce.photo_url,alt:`${s.property_address||s.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&&r.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))})]}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-8",children:[r.jsxs("div",{className:"md:col-span-2 space-y-6",children:[r.jsxs("div",{children:[r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsx(_t,{className:`${sbt[s.status]} text-white border-0`,children:nbt[s.status]})}),r.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:$(s.price)}),s.property_address&&r.jsx("p",{className:"text-xl font-medium",children:s.property_address}),r.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[r.jsx(Yi,{className:"h-4 w-4"}),s.city,", ",s.state,s.neighborhood&&` • ${s.neighborhood}`]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[s.bedrooms&&r.jsxs("div",{className:"text-center",children:[r.jsx(x1,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:s.bedrooms}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Beds"})]}),s.bathrooms&&r.jsxs("div",{className:"text-center",children:[r.jsx(g1,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:s.bathrooms}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Baths"})]}),s.square_footage&&r.jsxs("div",{className:"text-center",children:[r.jsx(fx,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:s.square_footage.toLocaleString()}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Sq Ft"})]}),s.year_built&&r.jsxs("div",{className:"text-center",children:[r.jsx(An,{className:"h-6 w-6 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"text-xl font-semibold",children:s.year_built}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Built"})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(_t,{variant:"secondary",children:[r.jsx(Ni,{className:"h-3 w-3 mr-1"}),wC[s.property_type]]}),s.lot_size&&r.jsxs(_t,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&r.jsx(_t,{variant:"secondary",children:"HOA"})]}),s.description&&r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold mb-2",children:"About This Property"}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})]}),s.agent_notes&&s.agent_notes_public&&r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Agent Notes"}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.agent_notes})]}),s.mls_link&&r.jsx(X,{variant:"outline",asChild:!0,children:r.jsxs("a",{href:s.mls_link,target:"_blank",rel:"noopener noreferrer",children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),r.jsxs("div",{className:"space-y-6",children:[s.video&&s.video.playback_url&&r.jsx(ze,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:r.jsxs(qe,{className:"p-0",children:[r.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>B(!0),children:[s.video.thumbnail_url?r.jsx("img",{src:s.video.thumbnail_url,alt:"Video thumbnail",className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gradient-to-br from-primary/20 to-primary/30",children:r.jsx(ma,{className:"h-12 w-12 text-primary"})}),r.jsx("div",{className:"absolute inset-0 bg-black/30 group-hover:bg-black/40 transition-colors flex items-center justify-center",children:r.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:r.jsx(tc,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),r.jsxs("div",{className:"p-4",children:[r.jsxs(X,{onClick:()=>B(!0),className:"w-full gap-2",size:"lg",children:[r.jsx(tc,{className:"h-4 w-4"}),"Watch Video Tour"]}),s.video.title&&r.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center truncate",children:s.video.title})]})]})}),s.agent&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:[r.jsx(Fl,{className:"h-5 w-5"}),"Listing Agent"]})}),r.jsxs(qe,{children:[r.jsx("p",{className:"font-semibold text-lg",children:s.agent.name}),((ie=s.agent.brokerage)==null?void 0:ie.name)&&r.jsx("p",{className:"text-sm text-muted-foreground",children:s.agent.brokerage.name})]})]}),r.jsxs(ze,{className:"border-primary",children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Interested in this property?"})}),r.jsx(qe,{children:T?r.jsxs("div",{className:"text-center py-4",children:[r.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:r.jsx(Vs,{className:"h-6 w-6 text-primary"})}),r.jsx("p",{className:"font-medium",children:"Thanks for your interest!"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"The listing agent will contact you soon."})]}):r.jsxs("form",{onSubmit:q,className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"firstName",children:"First Name *"}),r.jsx(Ye,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:ce=>d(ce.target.value),required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"lastName",children:"Last Name"}),r.jsx(Ye,{id:"lastName",type:"text",placeholder:"Doe",value:m,onChange:ce=>p(ce.target.value)})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"email",children:"Email *"}),r.jsx(Ye,{id:"email",type:"email",placeholder:"you@example.com",value:g,onChange:ce=>v(ce.target.value),required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"phone",children:"Phone"}),r.jsx(Ye,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:_,onChange:ce=>k(ce.target.value)})]}),r.jsx(X,{type:"submit",className:"w-full",disabled:w,children:w?"Submitting...":"Get More Info"}),r.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"The listing agent will reach out to you directly."})]})})]})]})]})]}),r.jsx(Ir,{open:I!==null,onOpenChange:()=>R(null),children:r.jsxs(Er,{className:"max-w-5xl p-0 bg-black/95",children:[r.jsx(zr,{className:"sr-only",children:r.jsx(Fr,{children:"Photo Gallery"})}),r.jsx("button",{onClick:()=>R(null),className:"absolute right-4 top-4 z-50 rounded-full bg-black/50 p-2 text-white hover:bg-black/70",children:r.jsx(Xs,{className:"h-5 w-5"})}),I!==null&&W[I]&&r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:W[I].photo_url,alt:`Photo ${I+1}`,className:"w-full max-h-[80vh] object-contain"}),W.length>1&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:re,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:r.jsx(jc,{className:"h-6 w-6"})}),r.jsx("button",{onClick:ae,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:r.jsx(Zi,{className:"h-6 w-6"})}),r.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:[I+1," / ",W.length]})]})]})]})}),r.jsx(Ir,{open:D,onOpenChange:B,children:r.jsxs(Er,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[r.jsx(zr,{className:"sr-only",children:r.jsx(Fr,{children:"Video Tour"})}),r.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:r.jsx(Xs,{className:"h-5 w-5"})}),((de=s==null?void 0:s.video)==null?void 0:de.playback_url)&&r.jsx("div",{className:"aspect-video w-full",children:r.jsx("iframe",{src:s.video.playback_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]})}),r.jsx("footer",{className:"border-t py-8 mt-16",children:r.jsxs("div",{className:"container mx-auto px-4 text-center text-sm text-muted-foreground",children:[r.jsxs("p",{children:["© ",new Date().getFullYear()," LevelUp. All rights reserved."]}),r.jsx("p",{className:"mt-2",children:r.jsx("a",{href:"https://relevelup.com",target:"_blank",rel:"noopener noreferrer",className:"hover:text-foreground",children:"relevelup.com"})})]})})]})]})}function ibt(){var o;const{slug:e}=Bl(),{data:t,isLoading:s,error:n}=a7e(e);if(A.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),A.useEffect(()=>{t!=null&&t.id&&Gi(t.id,"card_view")},[t==null?void 0:t.id]),s)return r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center",children:r.jsxs("div",{className:"w-full max-w-md mx-auto p-6 space-y-6",children:[r.jsxs("div",{className:"flex flex-col items-center gap-4",children:[r.jsx(pr,{className:"h-28 w-28 rounded-full"}),r.jsx(pr,{className:"h-6 w-48"}),r.jsx(pr,{className:"h-4 w-36"})]}),r.jsx(pr,{className:"h-12 w-full"}),r.jsx(pr,{className:"h-12 w-full"})]})});if(n||!t)return r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Card Not Found"}),r.jsx("p",{className:"text-slate-500",children:"This agent card doesn't exist or isn't published yet."})]})});const a=((o=t.profile)==null?void 0:o.name)||"Agent";return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsxs("title",{children:[a," | Real Estate Agent"]}),r.jsx("meta",{name:"description",content:t.positioning_statement||`Connect with ${a}, your trusted real estate professional.`}),r.jsx("meta",{property:"og:title",content:`${a} | Real Estate Agent`}),r.jsx("meta",{property:"og:description",content:t.positioning_statement||`Connect with ${a}`}),t.avatar_url&&r.jsx("meta",{property:"og:image",content:t.avatar_url})]}),r.jsx(Sve,{card:t})]})}function yA({banners:e,autoPlayInterval:t=5e3,className:s}){const[n,a]=A.useState(0),[o,l]=A.useState(!1),i=A.useCallback(()=>{a(g=>(g+1)%e.length)},[e.length]),d=A.useCallback(()=>{a(g=>(g-1+e.length)%e.length)},[e.length]),m=A.useCallback(g=>{a(g)},[]);if(A.useEffect(()=>{if(e.length<=1||o)return;const g=setInterval(i,t);return()=>clearInterval(g)},[e.length,o,t,i]),!e||e.length===0)return null;const p=e[n];return r.jsxs("div",{className:Vt("relative w-full overflow-hidden rounded-xl",s),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[r.jsxs("div",{className:"relative aspect-[21/9] md:aspect-[3/1] w-full",children:[r.jsxs("div",{className:"absolute inset-0 transition-opacity duration-500",children:[r.jsx("img",{src:p.image_url,alt:p.title,className:"w-full h-full object-cover"}),r.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/20 to-transparent"})]}),r.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-6 md:p-8 text-white",children:[r.jsx("h2",{className:"text-xl md:text-3xl font-bold mb-2 drop-shadow-lg",children:p.title}),p.description&&r.jsx("p",{className:"text-sm md:text-base text-white/90 mb-4 max-w-2xl drop-shadow",children:p.description}),p.link_url&&r.jsx("a",{href:p.link_url,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:r.jsx(X,{variant:"secondary",className:"bg-white/90 hover:bg-white text-foreground font-semibold",children:p.link_text||"Learn More"})})]}),e.length>1&&r.jsxs(r.Fragment,{children:[r.jsx(X,{variant:"ghost",size:"icon",className:Vt("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:r.jsx(jc,{className:"h-6 w-6"})}),r.jsx(X,{variant:"ghost",size:"icon",className:Vt("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:r.jsx(Zi,{className:"h-6 w-6"})})]})]}),e.length>1&&r.jsx("div",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex gap-2",children:e.map((g,v)=>r.jsx("button",{onClick:()=>m(v),className:Vt("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 obt(e){return"EST"}function JI(e){const s=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(e),n=obt();return`${s} ${n}`}function Z4(e){const t=new Date,s=new Date(e),n=l4e(s,-15),a=l4e(s,30);return t>a?"ended":p4e(t,{start:s,end:a})?"live":p4e(t,{start:n,end:s})?"starting_soon":"upcoming"}function o1e(e){const t=Z4(e);return t==="starting_soon"||t==="live"}const r5e=o1e,lbt=({events:e,registrations:t,onNavigateToEvents:s})=>{const[n,a]=A.useState(new Date);A.useEffect(()=>{const _=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(_)},[]);const o=e.filter(_=>o1e(_.event_date));if(o.length===0)return null;const l=o[0],i=Z4(l.event_date),d=t.find(_=>_.event_id===l.id),m=(d==null?void 0:d.zoom_join_url)||l.zoom_link,p=!!d,g=i==="live",v=g?{container:"from-red-500/10 via-red-500/5 to-primary/10 border-red-500/30",pulse:"from-red-500/5",indicator:"bg-red-500",text:"text-red-500",button:"bg-red-500 hover:bg-red-600",outlineButton:"border-red-500/50 text-red-500 hover:bg-red-500/10"}:{container:"from-amber-500/10 via-amber-500/5 to-primary/10 border-amber-500/30",pulse:"from-amber-500/5",indicator:"bg-amber-500",text:"text-amber-500",button:"bg-amber-500 hover:bg-amber-600",outlineButton:"border-amber-500/50 text-amber-500 hover:bg-amber-500/10"};return r.jsxs("div",{className:`relative mb-8 overflow-hidden rounded-xl bg-gradient-to-r ${v.container} border`,children:[r.jsx("div",{className:`absolute inset-0 bg-gradient-to-r ${v.pulse} to-transparent animate-pulse`}),r.jsx("div",{className:"relative p-4 sm:p-6",children:r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative flex items-center justify-center",children:[r.jsx("span",{className:`absolute inline-flex h-full w-full animate-ping rounded-full ${v.indicator} opacity-75`}),r.jsx("span",{className:`relative flex h-3 w-3 rounded-full ${v.indicator}`})]}),r.jsx("div",{className:`flex items-center gap-2 ${v.text} font-bold text-sm uppercase tracking-wider`,children:g?r.jsxs(r.Fragment,{children:[r.jsx(Ck,{className:"h-4 w-4"}),"Live Now"]}):r.jsxs(r.Fragment,{children:[r.jsx(Pa,{className:"h-4 w-4"}),"Starting Soon"]})})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"font-semibold text-lg text-foreground line-clamp-1",children:l.title}),r.jsx("p",{className:"text-sm text-muted-foreground",children:g?`Started at ${JI(new Date(l.event_date))}`:`Starts at ${JI(new Date(l.event_date))}`})]}),r.jsx("div",{className:"flex items-center gap-2",children:p?r.jsxs(X,{onClick:()=>window.open(m,"_blank"),className:`${v.button} text-white gap-2`,children:[r.jsx(jn,{className:"h-4 w-4"}),g?"Join Now":"Join When Live"]}):r.jsxs(X,{variant:"outline",onClick:s,className:`${v.outlineButton} gap-2`,children:[r.jsx(ws,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var l1e="Progress",c1e=100,[cbt]=Sc(l1e),[dbt,ubt]=cbt(l1e),XBe=A.forwardRef((e,t)=>{const{__scopeProgress:s,value:n=null,max:a,getValueLabel:o=hbt,...l}=e;(a||a===0)&&!s5e(a)&&console.error(mbt(`${a}`,"Progress"));const i=s5e(a)?a:c1e;n!==null&&!n5e(n,i)&&console.error(fbt(`${n}`,"Progress"));const d=n5e(n,i)?n:null,m=Sse(d)?o(d,i):void 0;return r.jsx(dbt,{scope:s,value:d,max:i,children:r.jsx(Hs.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Sse(d)?d:void 0,"aria-valuetext":m,role:"progressbar","data-state":e9e(d,i),"data-value":d??void 0,"data-max":i,...l,ref:t})})});XBe.displayName=l1e;var QBe="ProgressIndicator",JBe=A.forwardRef((e,t)=>{const{__scopeProgress:s,...n}=e,a=ubt(QBe,s);return r.jsx(Hs.div,{"data-state":e9e(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:t})});JBe.displayName=QBe;function hbt(e,t){return`${Math.round(e/t*100)}%`}function e9e(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Sse(e){return typeof e=="number"}function s5e(e){return Sse(e)&&!isNaN(e)&&e>0}function n5e(e,t){return Sse(e)&&!isNaN(e)&&e<=t&&e>=0}function mbt(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${c1e}\`.`}function fbt(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. 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 t9e=XBe,pbt=JBe;const zl=A.forwardRef(({className:e,value:t,...s},n)=>r.jsx(t9e,{ref:n,className:Vt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...s,children:r.jsx(pbt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));zl.displayName=t9e.displayName;function gbt(){const{user:e,isBrokerageManager:t}=Gr(),[s,n]=A.useState([]),[a,o]=A.useState([]),[l,i]=A.useState(!1),[d,m]=A.useState(!0),p=t?"brokerage_manager":"agent";A.useEffect(()=>{if(!(e!=null&&e.id)){m(!1);return}g()},[e==null?void 0:e.id,p]);const g=async()=>{if(e!=null&&e.id)try{const{data:R,error:D}=await Y.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(D)throw D;const{data:B,error:$}=await Y.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",e.id);if($)throw $;const{data:q,error:W}=await Y.from("onboarding_checklist_dismissed").select("id").eq("user_id",e.id).maybeSingle();if(W)throw W;n(R||[]),o(B||[]),i(!!q),R&&R.length>0&&await v(R,B||[])}catch(R){console.error("Error fetching checklist data:",R)}finally{m(!1)}},v=async(R,D)=>{var Ve,Ie;if(!(e!=null&&e.id))return;const B=D.map(We=>We.item_id),$=R.filter(We=>!B.includes(We.id));if($.length===0)return;const[q,W,K,re,ae,oe,se,pe,ie,de,ce,ge,Te,_e,ve]=await Promise.all([Y.from("profiles").select("brokerage_id").eq("id",e.id).maybeSingle(),Y.from("resource_shares").select("id",{count:"exact",head:!0}).eq("sender_id",e.id),Y.from("community_posts").select("id",{count:"exact",head:!0}).eq("user_id",e.id),Y.from("event_registrations").select("id",{count:"exact",head:!0}).eq("user_id",e.id),Y.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",e.id).eq("resource_type","template"),Y.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",e.id).eq("resource_type","academy_video"),Y.from("content_engagement_logs").select("id",{count:"exact",head:!0}).eq("user_id",e.id).eq("resource_type","toolbox"),Y.from("activity_logs").select("id",{count:"exact",head:!0}).eq("user_id",e.id),Y.from("innercircle_contacts").select("id",{count:"exact",head:!0}).eq("owner_user_id",e.id),Y.from("agent_videos").select("id",{count:"exact",head:!0}).eq("owner_user_id",e.id),Y.from("contact_touch_logs").select("id",{count:"exact",head:!0}).eq("owner_user_id",e.id),Y.from("scorecard_transactions").select("id",{count:"exact",head:!0}).eq("owner_user_id",e.id),Y.from("listings").select("id",{count:"exact",head:!0}).eq("agent_id",e.id),Y.from("innercircle_contacts").select("id").eq("owner_user_id",e.id),Y.from("deal_pipeline").select("id",{count:"exact",head:!0}).eq("owner_user_id",e.id)]),Me={},Ze=(Ve=q.data)==null?void 0:Ve.brokerage_id;Me.share_resource=(W.count||0)>0,Me.post_community=(K.count||0)>0,Me.register_event=(re.count||0)>0,Me.view_template=(ae.count||0)>0,Me.watch_academy=(oe.count||0)>0,Me.use_toolbox=(se.count||0)>0,Me.launch_app=(pe.count||0)>0,Me.add_contact=(ie.count||0)>0,Me.create_video=(de.count||0)>0,Me.complete_touch=(ce.count||0)>0,Me.add_transaction=(ge.count||0)>0,Me.add_listing=(Te.count||0)>0,Me.add_deal=(ve.count||0)>0;const Ae=((Ie=_e.data)==null?void 0:Ie.map(We=>We.id))||[],Le=[];Ze?Le.push(Y.from("profiles").select("id").eq("brokerage_id",Ze).neq("id",e.id).then(We=>{var wt;Me.add_agent=(((wt=We.data)==null?void 0:wt.length)||0)>0})):Me.add_agent=!1,Ae.length>0?(Le.push(Y.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Ae).then(We=>{Me.add_plan=(We.count||0)>0})),Le.push(Y.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Ae).then(We=>{Me.schedule_popby=(We.count||0)>0}))):(Me.add_plan=!1,Me.schedule_popby=!1),await Promise.all(Le);const Ue=$.filter(We=>Me[We.action_type]);if(Ue.length>0){const We=Ue.map(Pe=>({user_id:e.id,item_id:Pe.id})),{error:wt}=await Y.from("onboarding_checklist_progress").upsert(We,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!wt){const Pe=Ue.map(st=>({item_id:st.id,completed_at:new Date().toISOString()}));o(st=>[...st,...Pe])}}},_=async R=>{if(e!=null&&e.id)try{const{error:D}=await Y.from("onboarding_checklist_progress").insert({user_id:e.id,item_id:R});if(D)throw D;o(B=>[...B,{item_id:R,completed_at:new Date().toISOString()}])}catch(D){console.error("Error marking item complete:",D)}},k=async()=>{if(e!=null&&e.id)try{const{error:R}=await Y.from("onboarding_checklist_dismissed").insert({user_id:e.id});if(R)throw R;i(!0)}catch(R){console.error("Error dismissing checklist:",R)}},w=a.length,S=s.length,T=S>0&&w>=S,C=S>0?w/S*100:0;return{items:s,progress:a,isDismissed:l,loading:d,completedCount:w,totalCount:S,isComplete:T,progressPercentage:C,isItemComplete:R=>a.some(D=>D.item_id===R),markComplete:_,dismiss:k,refetch:g}}const xbt={add_agent:r.jsx(ws,{className:"h-4 w-4"}),share_resource:r.jsx(Uc,{className:"h-4 w-4"}),post_community:r.jsx(Vo,{className:"h-4 w-4"}),register_event:r.jsx(An,{className:"h-4 w-4"}),view_template:r.jsx(wv,{className:"h-4 w-4"}),watch_academy:r.jsx(w1,{className:"h-4 w-4"}),use_toolbox:r.jsx(Hy,{className:"h-4 w-4"}),launch_app:r.jsx(cE,{className:"h-4 w-4"}),add_deal:r.jsx(By,{className:"h-4 w-4"}),add_listing:r.jsx(Vn,{className:"h-4 w-4"})},ybt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function vbt(){const{items:e,isDismissed:t,loading:s,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:d,dismiss:m}=gbt(),p=Ks(),[g,v]=A.useState(!0);return s||t||a===0||o?null:r.jsxs(ze,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[r.jsxs(Wt,{className:"pb-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(hx,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-lg",children:"Get Started with LevelUp"}),r.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Complete these steps to make the most of your membership"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>v(!g),className:"h-8 w-8 p-0",children:g?r.jsx(cx,{className:"h-4 w-4"}):r.jsx(ad,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",children:r.jsx(Xs,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"mt-4",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm mb-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Progress"}),r.jsxs("span",{className:"font-medium",children:[n," of ",a," complete"]})]}),r.jsx(zl,{value:l,className:"h-2"})]})]}),g&&r.jsx(qe,{className:"pt-0",children:r.jsx("div",{className:"space-y-3",children:e.map(_=>{const k=i(_.id);return r.jsxs("div",{className:Vt("flex items-start gap-3 p-3 rounded-lg transition-colors",k?"bg-muted/50":"bg-background hover:bg-muted/30 cursor-pointer"),onClick:()=>{if(k)return;const w=ybt[_.action_type];w?p(w):d(_.id)},children:[r.jsx("div",{className:"mt-0.5",children:k?r.jsx(Ri,{className:"h-5 w-5 text-primary"}):r.jsx(vh,{className:"h-5 w-5 text-muted-foreground"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-muted-foreground",children:xbt[_.action_type]||r.jsx(vh,{className:"h-4 w-4"})}),r.jsx("span",{className:Vt("font-medium",k&&"line-through text-muted-foreground"),children:_.title})]}),_.description&&r.jsx("p",{className:Vt("text-sm text-muted-foreground mt-1",k&&"line-through"),children:_.description})]})]},_.id)})})})]})}const gg=()=>Ht({queryKey:["relationship-types"],queryFn:async()=>{const{data:e,error:t}=await Y.from("relationship_types").select("*").order("sort_order");if(t)throw t;return e}}),Xf=e=>{const t=fl(),s=1e3,n=async a=>{const o=[];let l=0;for(;;){const{data:i,error:d}=await a.range(l,l+s-1);if(d)throw d;const m=i??[];if(o.push(...m),m.length{let a=Y.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:!!t})},_bt=e=>Ht({queryKey:["innercircle-contact",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("innercircle_contacts").select(` *, tags:innercircle_contact_tags( id, contact_id, relationship_type_id, relationship_type:relationship_types(*) ) `).eq("id",e).maybeSingle();if(s)throw s;return t},enabled:!!e}),r9e=()=>{const e=fl();return Ht({queryKey:["innercircle-contact-counts",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(s)throw s;const n={};return t==null||t.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:!!e})},d1e=()=>{const e=Rr(),t=fl();return Qt({mutationFn:async s=>{const{tagIds:n,...a}=s,o={...a,birthday:a.birthday||null,home_anniversary:a.home_anniversary||null,owner_user_id:t},{data:l,error:i}=await Y.from("innercircle_contacts").insert(o).select().single();if(i)throw i;if(n&&n.length>0){const{error:d}=await Y.from("innercircle_contact_tags").insert(n.map(m=>({contact_id:l.id,relationship_type_id:m})));if(d)throw d}return l},onSuccess:()=>{e.invalidateQueries({queryKey:["innercircle-contacts"]}),e.invalidateQueries({queryKey:["innercircle-contact-counts"]}),ta({title:"Contact created successfully"})},onError:s=>{ta({title:"Error creating contact",description:s.message,variant:"destructive"})}})},s9e=()=>{const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{tagIds:n,tags:a,...o}=s,l={...o,birthday:o.birthday||null,home_anniversary:o.home_anniversary||null},{data:i,error:d}=await Y.from("innercircle_contacts").update(l).eq("id",t).select().single();if(d)throw d;if(n!==void 0&&(await Y.from("innercircle_contact_tags").delete().eq("contact_id",t),n.length>0)){const{error:m}=await Y.from("innercircle_contact_tags").insert(n.map(p=>({contact_id:t,relationship_type_id:p})));if(m)throw m}return i},onSuccess:()=>{e.invalidateQueries({queryKey:["innercircle-contacts"]}),e.invalidateQueries({queryKey:["innercircle-contact"]}),e.invalidateQueries({queryKey:["innercircle-contact-counts"]}),ta({title:"Contact updated successfully"})},onError:t=>{ta({title:"Error updating contact",description:t.message,variant:"destructive"})}})},u1e=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("innercircle_contacts").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["innercircle-contacts"]}),e.invalidateQueries({queryKey:["innercircle-contact-counts"]}),ta({title:"Contact deleted successfully"})},onError:t=>{ta({title:"Error deleting contact",description:t.message,variant:"destructive"})}})},h1e=()=>Ht({queryKey:["action-types"],queryFn:async()=>{const{data:e,error:t}=await Y.from("action_types").select("*").order("sort_order");if(t)throw t;return e}}),bbt=e=>Ht({queryKey:["action-scripts",e],queryFn:async()=>{let t=Y.from("action_scripts").select("*, action_type:action_types(*)");const{data:s,error:n}=await t;if(n)throw n;return s}}),wbt=()=>Ht({queryKey:["touchpoint-plans"],queryFn:async()=>{const{data:e,error:t}=await Y.from("touchpoint_plans").select(` *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) `).order("name");if(t)throw t;return e}}),jbt=()=>{const e=Rr(),t=fl();return Qt({mutationFn:async({name:s,description:n})=>{const{data:a,error:o}=await Y.from("touchpoint_plans").insert({name:s,description:n,owner_user_id:t,active:!0,is_template:!1}).select().single();if(o)throw o;return a},onSuccess:()=>{e.invalidateQueries({queryKey:["touchpoint-plans"]}),ta({title:"Plan created successfully"})},onError:s=>{ta({title:"Error creating plan",description:s.message,variant:"destructive"})}})},kbt=()=>{const e=Rr(),t=fl();return Qt({mutationFn:async({sourcePlanId:s,newName:n})=>{const{data:a,error:o}=await Y.from("touchpoint_plans").select(` *, items:touchpoint_plan_items(*) `).eq("id",s).single();if(o)throw o;if(!a)throw new Error("Source plan not found");const{data:l,error:i}=await Y.from("touchpoint_plans").insert({name:n,description:a.description,owner_user_id:t,active:!0,is_template:!1}).select().single();if(i)throw i;if(a.items&&a.items.length>0){const d=a.items.map(p=>({plan_id:l.id,month_number:p.month_number,action_type_id:p.action_type_id,default_script_id:p.default_script_id,notes:p.notes})),{error:m}=await Y.from("touchpoint_plan_items").insert(d);if(m)throw m}return l},onSuccess:()=>{e.invalidateQueries({queryKey:["touchpoint-plans"]}),ta({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:s=>{ta({title:"Error duplicating plan",description:s.message,variant:"destructive"})}})},Nbt=()=>{const e=Rr();return Qt({mutationFn:async({id:t,name:s,description:n})=>{const{data:a,error:o}=await Y.from("touchpoint_plans").update({name:s,description:n}).eq("id",t).select().single();if(o)throw o;return a},onSuccess:()=>{e.invalidateQueries({queryKey:["touchpoint-plans"]}),ta({title:"Plan updated successfully"})}})},Sbt=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("touchpoint_plans").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["touchpoint-plans"]}),ta({title:"Plan deleted successfully"})}})},Cbt=()=>{const e=Rr();return Qt({mutationFn:async({planId:t,items:s})=>{if(await Y.from("touchpoint_plan_items").delete().eq("plan_id",t),s.length>0){const{error:n}=await Y.from("touchpoint_plan_items").insert(s.map(a=>({plan_id:t,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:()=>{e.invalidateQueries({queryKey:["touchpoint-plans"]}),ta({title:"Plan schedule updated"})}})},Mbt=()=>{const e=Rr();return Qt({mutationFn:async({actionTypeId:t,title:s,scriptBody:n,emailSubject:a,tone:o})=>{const{data:{user:l}}=await Y.auth.getUser(),{data:i,error:d}=await Y.from("action_scripts").insert({action_type_id:t,title:s,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:()=>{e.invalidateQueries({queryKey:["action-scripts"]}),ta({title:"Script created successfully"})},onError:t=>{ta({title:"Error creating script",description:t.message,variant:"destructive"})}})},Tbt=()=>{const e=fl();return Ht({queryKey:["user-plan-enrollments",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("user_plan_enrollments").select(` *, plan:touchpoint_plans(*), relationship_type:relationship_types(*) `);if(s)throw s;return t},enabled:!!e})},Abt=()=>{const e=Rr(),t=fl();return Qt({mutationFn:async({planId:s,relationshipTypeId:n,active:a})=>{const{data:o}=await Y.from("user_plan_enrollments").select("id").eq("plan_id",s).eq("relationship_type_id",n).maybeSingle();if(o){const{error:l}=await Y.from("user_plan_enrollments").update({active:a}).eq("id",o.id);if(l)throw l}else if(a){const{error:l}=await Y.from("user_plan_enrollments").insert({owner_user_id:t,plan_id:s,relationship_type_id:n,active:!0,start_date:new Date().toISOString().split("T")[0]});if(l)throw l}},onSuccess:()=>{e.invalidateQueries({queryKey:["user-plan-enrollments"]}),ta({title:"Plan enrollment updated"})}})},$ie=(e=7)=>{const t=fl();return Ht({queryKey:["contact-touch-logs",t,e],queryFn:async()=>{const s=new Date;s.setDate(s.getDate()-e);const{data:n,error:a}=await Y.from("contact_touch_logs").select(` *, contact:innercircle_contacts(*), action_type:action_types(*) `).gte("completed_at",s.toISOString()).order("completed_at",{ascending:!1});if(a)throw a;return n},enabled:!!t})},n9e=()=>{const e=fl();return Ht({queryKey:["contacts-last-touch",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("contact_touch_logs").select("contact_id, completed_at").order("completed_at",{ascending:!1});if(s)throw s;const n={};return t==null||t.forEach(a=>{n[a.contact_id]||(n[a.contact_id]=a.completed_at)}),n},enabled:!!e})},Ebt=(e=90)=>{const{data:t}=Xf(),{data:s}=n9e();if(!t||!s)return{contacts:[],count:0};const n=new Date;n.setDate(n.getDate()-e);const a=t.filter(o=>{const l=s[o.id];return l?new Date(l){const e=Rr(),t=fl();return Qt({mutationFn:async({contactId:s,actionTypeId:n,scriptUsedId:a,notes:o})=>{const{data:l,error:i}=await Y.from("contact_touch_logs").insert({owner_user_id:t,contact_id:s,action_type_id:n,script_used_id:a,notes:o,completed_at:new Date().toISOString()}).select().single();if(i)throw i;return l},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-touch-logs"]}),e.invalidateQueries({queryKey:["contacts-last-touch"]}),e.invalidateQueries({queryKey:["today-actions"]}),ta({title:"Action completed!"})}})},i9e="agentos_weekly_touch_goal",a5e=20,Cse=()=>{if(typeof window>"u")return a5e;const e=localStorage.getItem(i9e);if(e){const t=parseInt(e,10);if(!isNaN(t)&&t>0)return t}return a5e},o9e=e=>{localStorage.setItem(i9e,e.toString())},l9e=()=>{const{data:e}=$ie(7),t=new Date;t.setHours(0,0,0,0);const s=new Date(t);s.setDate(t.getDate()-t.getDay());const n=(e==null?void 0:e.filter(l=>new Date(l.completed_at)>=s).length)||0;let a=0;if(e&&e.length>0){const l=new Set(e.map(d=>new Date(d.completed_at).toDateString()));let i=new Date(t);for(;l.has(i.toDateString());)a++,i.setDate(i.getDate()-1)}const o=Cse();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},Ibt=()=>{const e=fl();return Ht({queryKey:["contact-plan-cycles",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("contact_plan_cycles").select(` *, contact:innercircle_contacts(*), plan:touchpoint_plans( *, items:touchpoint_plan_items( *, action_type:action_types(*), default_script:action_scripts(*) ) ) `);if(s)throw s;return t},enabled:!!e})},Pbt=()=>{const e=Rr();return fl(),Qt({mutationFn:async()=>{const{data:t}=await Y.from("user_plan_enrollments").select("*").eq("active",!0);if(!t||t.length===0)return;const{data:s}=await Y.from("innercircle_contacts").select(` id, tags:innercircle_contact_tags(relationship_type_id) `);if(!s)return;const{data:n}=await Y.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 s)for(const i of l.tags||[]){const d=t.find(m=>m.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 Y.from("contact_plan_cycles").insert(o);if(l)throw l}return o.length},onSuccess:t=>{e.invalidateQueries({queryKey:["contact-plan-cycles"]}),t&&t>0&&ta({title:`${t} contact(s) enrolled in plans`})}})},c9e=()=>{const e=fl(),{data:t}=Ibt(),{data:s}=$ie(30);return Ht({queryKey:["today-actions",e,t==null?void 0:t.length,s==null?void 0:s.length],queryFn:async()=>{var k;if(!t||t.length===0)return[];const{data:n}=await Y.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((s==null?void 0:s.filter(w=>new Date(w.completed_at)>=i).map(w=>`${w.contact_id}-${w.action_type_id}`))||[]);for(const w of t){if(!((k=w.plan)!=null&&k.items)||w.plan.items.length===0||!w.contact||a.has(w.contact_id))continue;const S=new Date(w.cycle_start_date),C=Math.floor((o.getTime()-S.getTime())/(30.44*24*60*60*1e3))%12+1,I=w.plan.items.find(R=>R.month_number===C);if(I&&I.action_type){const R=`${w.contact_id}-${I.action_type_id}`;if(!d.has(R)){const{data:D}=await Y.from("relationship_types").select("name").eq("id",w.relationship_type_id).single();l.push({contact:w.contact,actionType:I.action_type,script:I.default_script||void 0,planName:w.plan.name,relationshipTypeName:(D==null?void 0:D.name)||"",monthNumber:C})}}}const m=5,p=o.getDate(),g=l.sort((w,S)=>w.contact.first_name.localeCompare(S.contact.first_name)),v=(p-1)%Math.max(1,g.length);return[...g.slice(v),...g.slice(0,v)].slice(0,m)},enabled:!!e&&!!t})};function Lbt(){const e=Ks(),{data:t,isLoading:s}=c9e(),{data:n}=Xf(),a=l9e(),[o,l]=A.useState(Cse()),[i,d]=A.useState(""),[m,p]=A.useState(!1);A.useEffect(()=>{l(Cse())},[]);const g=()=>{const B=parseInt(i,10);if(isNaN(B)||B<1){ta({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(B),o9e(B),p(!1),ta({title:"Goal updated",description:`Weekly touch goal set to ${B}`})},v=()=>{d(o.toString()),p(!0)},_=Wm(new Date),k=dc(_,7),w=B=>{if(!B)return null;const $=B.split(/[-/T]/);if($.length<3)return null;const q=parseInt($[1],10)-1,W=parseInt($[2],10);return isNaN(q)||isNaN(W)?null:new Date(_.getFullYear(),q,W)},S=(n==null?void 0:n.map(B=>{const $=w(B.birthday),q=w(B.home_anniversary),W=[];return $&&$>=_&&$<=k&&W.push({contact:B,type:"birthday",date:$,isToday:Xl($,_)}),q&&q>=_&&q<=k&&W.push({contact:B,type:"anniversary",date:q,isToday:Xl(q,_)}),W}).flat().sort((B,$)=>B.date.getTime()-$.date.getTime()).slice(0,3))||[],T=(n==null?void 0:n.filter(B=>{const $=w(B.birthday),q=w(B.home_anniversary);return $&&Xl($,_)||q&&Xl(q,_)}).length)||0,C=(t==null?void 0:t.length)||0,I=T+C,R=(a==null?void 0:a.actionsThisWeek)||0,D=(a==null?void 0:a.streak)||0;return s?r.jsx(ze,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[r.jsx("div",{className:"h-12 w-12 bg-primary/20 rounded-lg"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-primary/20 rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-primary/10 rounded w-1/2"})]})]})})}):r.jsxs(ze,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[r.jsxs(Wt,{className:"pb-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),r.jsx("div",{className:"flex items-center gap-2",children:D>0&&r.jsxs(_t,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[r.jsx(Om,{className:"h-3 w-3"}),D," day streak"]})})]}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:[I>0?r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"text-primary font-medium",children:[I," tasks"]})," for today"]}):"No tasks for today",R>0&&r.jsxs("span",{className:"ml-2",children:["• ",r.jsx("span",{className:"text-emerald-600 font-medium",children:R})," touches this week"]})]})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(X,{size:"sm",variant:"outline",className:"gap-1.5",onClick:B=>{B.stopPropagation(),e("/mission-control/contacts?new=true")},children:[r.jsx(Kd,{className:"h-3.5 w-3.5"}),"Add Contact"]}),r.jsxs(X,{size:"sm",variant:"outline",className:"gap-1.5",onClick:B=>{B.stopPropagation(),e("/mission-control")},children:[r.jsx(fi,{className:"h-3.5 w-3.5"}),"Log Touch"]}),r.jsxs(X,{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(),e("/mission-control/video/record")},children:[r.jsx(ma,{className:"h-3.5 w-3.5"}),"Quick Video"]}),r.jsxs(X,{size:"sm",variant:"outline",className:"gap-1.5",onClick:B=>{B.stopPropagation(),e("/mission-control/popbys")},children:[r.jsx(Yi,{className:"h-3.5 w-3.5"}),"Pop-by Map"]}),r.jsxs(X,{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(),e("/mission-control/pipeline")},children:[r.jsx(By,{className:"h-3.5 w-3.5"}),"Pipeline"]})]}),r.jsxs("div",{className:"pt-3 border-t border-border/50",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Bf,{className:"h-4 w-4 text-primary"}),r.jsx("span",{className:"text-sm font-medium",children:"Weekly Goal"}),r.jsxs(Ir,{open:m,onOpenChange:p,children:[r.jsx(Qi,{asChild:!0,children:r.jsx("button",{onClick:v,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:r.jsx(ld,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),r.jsxs(Er,{className:"sm:max-w-[360px]",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Set Weekly Goal"}),r.jsx(Zs,{children:"How many touches do you want to complete each week?"})]}),r.jsxs("div",{className:"space-y-4 pt-2",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),r.jsx(Ye,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:B=>d(B.target.value),placeholder:"20",onKeyDown:B=>{B.key==="Enter"&&g()}})]}),r.jsx(X,{onClick:g,className:"w-full",children:"Save Goal"})]})]})]})]}),r.jsxs("span",{className:"text-sm",children:[r.jsx("span",{className:"font-medium text-primary",children:R}),r.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),r.jsx(zl,{value:Math.min(R/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),R>=o&&r.jsxs("p",{className:"text-xs text-emerald-600 mt-1.5 flex items-center gap-1",children:[r.jsx("span",{children:"🎉"})," Goal achieved! Keep the momentum going."]}),R0&&r.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-R," more to hit your weekly goal"]})]}),S.length>0&&r.jsxs("div",{className:"pt-3 border-t border-border/50",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Lm,{className:"h-4 w-4 text-pink-500"}),r.jsx("span",{className:"text-sm font-medium",children:"Upcoming Milestones"})]}),r.jsx("div",{className:"space-y-2",children:S.map((B,$)=>r.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:q=>{q.stopPropagation(),e(`/mission-control/contacts/${B.contact.id}`)},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[B.type==="birthday"?r.jsx(Lm,{className:"h-3.5 w-3.5 text-pink-500"}):r.jsx(Vn,{className:"h-3.5 w-3.5 text-blue-500"}),r.jsxs("span",{className:"text-sm",children:[B.contact.first_name," ",B.contact.last_name]}),B.isToday&&r.jsx(_t,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-pink-500/20 text-pink-600",children:"Today!"})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:B.isToday?B.type==="birthday"?"🎂":"🏠":Xr(B.date,"EEE, MMM d")}),r.jsx(Zi,{className:"h-3 w-3"})]})]},`${B.contact.id}-${B.type}-${$}`))})]}),r.jsxs(X,{variant:"ghost",size:"sm",className:"w-full gap-1 text-muted-foreground hover:text-primary",onClick:()=>e("/mission-control"),children:["Open Agent OS",r.jsx(Ki,{className:"h-4 w-4"})]})]})]})}const d9e=()=>Ht({queryKey:["listing-exchange-enabled"],queryFn:async()=>{const{data:e,error:t}=await Y.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").maybeSingle();if(t)throw t;return(e==null?void 0:e.enabled)??!1}}),u9e=e=>{const{user:t,brokerageId:s}=Gr();return Ht({queryKey:["listings",e,s],queryFn:async()=>{let n=Y.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);e!=null&&e.status&&(n=n.eq("status",e.status)),e!=null&&e.propertyType&&(n=n.eq("property_type",e.propertyType)),e!=null&&e.city&&(n=n.ilike("city",`%${e.city}%`)),e!=null&&e.minPrice&&(n=n.gte("price",e.minPrice)),e!=null&&e.maxPrice&&(n=n.lte("price",e.maxPrice)),e!=null&&e.openToReferrals&&(n=n.eq("open_to_referrals",!0));const{data:a,error:o}=await n;if(o)throw o;let l=a||[];if(s){const{data:i}=await Y.from("profiles").select("id").eq("brokerage_id",s);if(i&&i.length>0){const d=i.map(g=>g.id);let m=Y.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);e!=null&&e.status&&(m=m.eq("status",e.status)),e!=null&&e.propertyType&&(m=m.eq("property_type",e.propertyType)),e!=null&&e.city&&(m=m.ilike("city",`%${e.city}%`)),e!=null&&e.minPrice&&(m=m.gte("price",e.minPrice)),e!=null&&e.maxPrice&&(m=m.lte("price",e.maxPrice)),e!=null&&e.openToReferrals&&(m=m.eq("open_to_referrals",!0));const{data:p}=await m;if(p){const g=new Set(l.map(_=>_.id)),v=p.filter(_=>!g.has(_.id));l=[...l,...v]}}}switch(e==null?void 0:e.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}})},h9e=()=>{const{user:e}=Gr();return Ht({queryKey:["my-listings",e==null?void 0:e.id],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("listings").select(` *, photos:listing_photos(*) `).eq("agent_id",e.id).order("created_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})},m9e=e=>{const{user:t}=Gr();return Ht({queryKey:["listing",e],queryFn:async()=>{const{data:s,error:n}=await Y.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",e).single();if(n)throw n;return t&&await Y.from("listing_views").insert({listing_id:e,viewer_id:t.id}),s},enabled:!!e})},Dbt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{if(!t)throw new Error("Not authenticated");const{data:n,error:a}=await Y.from("listings").insert({...s,agent_id:t.id}).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["listings"]}),e.invalidateQueries({queryKey:["my-listings"]})}})},Obt=()=>{const e=Rr();return Qt({mutationFn:async({agentId:t,...s})=>{const{data:n,error:a}=await Y.from("listings").insert({...s,agent_id:t}).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["listings"]}),e.invalidateQueries({queryKey:["my-listings"]}),e.invalidateQueries({queryKey:["brokerage-listings"]})}})},Rbt=()=>{const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("listings").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:t=>{e.invalidateQueries({queryKey:["listings"]}),e.invalidateQueries({queryKey:["my-listings"]}),e.invalidateQueries({queryKey:["listing",t.id]})}})},f9e=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("listings").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["listings"]}),e.invalidateQueries({queryKey:["my-listings"]})}})},Fbt=()=>{const e=Rr();return Qt({mutationFn:async({listingId:t,photoUrl:s,isPrimary:n=!1})=>{const{data:a,error:o}=await Y.from("listing_photos").insert({listing_id:t,photo_url:s,is_primary:n}).select().single();if(o)throw o;return a},onSuccess:t=>{e.invalidateQueries({queryKey:["listing",t.listing_id]}),e.invalidateQueries({queryKey:["my-listings"]})}})},zbt=()=>{const e=Rr();return Qt({mutationFn:async({photoId:t,listingId:s})=>{const{error:n}=await Y.from("listing_photos").delete().eq("id",t);if(n)throw n;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["listing",t]}),e.invalidateQueries({queryKey:["my-listings"]})}})},Bbt=()=>{const{user:e}=Gr();return Ht({queryKey:["saved-listings",e==null?void 0:e.id],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("listing_saves").select(` *, listing:listings( *, photos:listing_photos(*), agent:profiles!listings_agent_id_fkey(id, name, email, brokerage_id) ) `).eq("agent_id",e.id);if(s)throw s;return t},enabled:!!e})},p9e=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{if(!t)throw new Error("Not authenticated");const{data:n}=await Y.from("listing_saves").select("id").eq("listing_id",s).eq("agent_id",t.id).maybeSingle();return n?(await Y.from("listing_saves").delete().eq("id",n.id),{saved:!1}):(await Y.from("listing_saves").insert({listing_id:s,agent_id:t.id}),{saved:!0})},onSuccess:()=>{e.invalidateQueries({queryKey:["saved-listings"]}),e.invalidateQueries({queryKey:["listings"]})}})},g9e=e=>{const{user:t}=Gr();return Ht({queryKey:["listing-saved",e,t==null?void 0:t.id],queryFn:async()=>{if(!t)return!1;const{data:s}=await Y.from("listing_saves").select("id").eq("listing_id",e).eq("agent_id",t.id).maybeSingle();return!!s},enabled:!!t&&!!e})},$bt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{if(!t)throw new Error("Not authenticated");const{data:n}=await Y.from("listing_follows").select("id").eq("listing_id",s).eq("agent_id",t.id).maybeSingle();return n?(await Y.from("listing_follows").delete().eq("id",n.id),{following:!1}):(await Y.from("listing_follows").insert({listing_id:s,agent_id:t.id}),{following:!0})},onSuccess:()=>{e.invalidateQueries({queryKey:["listing-following"]})}})},Ubt=e=>{const{user:t}=Gr();return Ht({queryKey:["listing-following",e,t==null?void 0:t.id],queryFn:async()=>{if(!t)return!1;const{data:s}=await Y.from("listing_follows").select("id").eq("listing_id",e).eq("agent_id",t.id).maybeSingle();return!!s},enabled:!!t&&!!e})},Vbt=()=>{const{user:e}=Gr();return Qt({mutationFn:async({listingId:t,shareType:s})=>{if(!e)throw new Error("Not authenticated");const{error:n}=await Y.from("listing_shares").insert({listing_id:t,sharing_agent_id:e.id,share_type:s});if(n)throw n}})},qbt=()=>{const{user:e}=Gr();return Ht({queryKey:["my-referrals",e==null?void 0:e.id],queryFn:async()=>{if(!e)return{sent:[],received:[]};const[t,s]=await Promise.all([Y.from("listing_referrals").select(` *, listing:listings(*,photos:listing_photos(*)) `).eq("sender_agent_id",e.id).order("created_at",{ascending:!1}),Y.from("listing_referrals").select(` *, sender:profiles!listing_referrals_sender_agent_id_fkey(id, name, email), listing:listings(*,photos:listing_photos(*)) `).eq("listing_agent_id",e.id).order("created_at",{ascending:!1})]);return{sent:t.data||[],received:s.data||[]}},enabled:!!e})},Hbt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async({listingId:s,listingAgentId:n,buyerName:a,buyerType:o,notes:l})=>{if(!t)throw new Error("Not authenticated");const{data:i,error:d}=await Y.from("listing_referrals").insert({listing_id:s,sender_agent_id:t.id,listing_agent_id:n,buyer_name:a,buyer_type:o,notes:l}).select().single();if(d)throw d;return i},onSuccess:()=>{e.invalidateQueries({queryKey:["my-referrals"]})}})},Wbt=()=>Ht({queryKey:["listing-leaderboard"],queryFn:async()=>{const{data:e}=await Y.from("listing_shares").select("sharing_agent_id, profiles!listing_shares_agent_id_fkey(name)").order("created_at",{ascending:!1}),t=new Map;e==null||e.forEach(l=>{var m;const i=l.sharing_agent_id;if(!i)return;const d=t.get(i);d?d.count++:t.set(i,{name:((m=l.profiles)==null?void 0:m.name)||"Unknown",count:1})});const s=Array.from(t.entries()).map(([l,i])=>({agentId:l,...i})).sort((l,i)=>i.count-l.count).slice(0,10),{data:n}=await Y.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:s,topListers:o}}}),Gbt=()=>{const{user:e,brokerageId:t}=Gr();return Ht({queryKey:["brokerage-listings",t],queryFn:async()=>{if(!e||!t)return[];const{data:s}=await Y.from("profiles").select("id").eq("brokerage_id",t);if(!s||s.length===0)return[];const n=s.map(l=>l.id),{data:a,error:o}=await Y.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:!!e&&!!t})},m1e=({className:e,variant:t="default"})=>r.jsx(_t,{variant:"outline",className:Vt("text-[10px] font-semibold uppercase tracking-wide px-1.5 py-0 h-4",t==="default"?"border-amber-500 text-amber-600 dark:text-amber-400 bg-amber-500/10":"border-muted-foreground/30 text-muted-foreground",e),children:"Beta"}),Kbt={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"},Zbt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function Ybt(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:`$${(e/1e3).toFixed(0)}K`}function Xbt(){const e=Ks(),{data:t,isLoading:s}=d9e(),{data:n,isLoading:a}=u9e({status:void 0,propertyType:void 0,sortBy:"newest"}),o=(n==null?void 0:n.filter(p=>p.is_approved&&p.is_public))||[],l=o.filter(p=>p.is_featured),i=o.filter(p=>!p.is_featured),d=[...l,...i].slice(0,6),m=s||a;return!m&&!t?null:m?r.jsx(ze,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"animate-pulse flex items-center gap-4",children:[r.jsx("div",{className:"h-12 w-12 bg-emerald-500/20 rounded-lg"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx("div",{className:"h-4 bg-emerald-500/20 rounded w-1/3"}),r.jsx("div",{className:"h-3 bg-emerald-500/10 rounded w-1/2"})]})]})})}):r.jsxs("section",{className:"mb-10",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Listing Exchange"}),r.jsx(m1e,{})]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>e("/mission-control/listings"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",r.jsx(Ki,{className:"h-4 w-4"})]})]}),d.length===0?r.jsx(ze,{className:"bg-muted/30 border-dashed",children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx(Vn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"No listings available yet"}),r.jsx(X,{variant:"link",size:"sm",onClick:()=>e("/mission-control/listings/new"),className:"mt-2",children:"Add the first listing"})]})})}):r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:d.map(p=>{var v,_;const g=((v=p.photos)==null?void 0:v.find(k=>k.is_primary))||((_=p.photos)==null?void 0:_[0]);return r.jsxs("div",{onClick:()=>e(`/mission-control/listings/${p.id}`),className:"group cursor-pointer bg-card rounded-xl border border-border overflow-hidden transition-all duration-200 hover:shadow-lg hover:border-primary/30",children:[r.jsxs("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden relative",children:[g!=null&&g.photo_url?r.jsx("img",{src:g.photo_url,alt:`${p.city}, ${p.state}`,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(Vn,{className:"h-8 w-8 text-muted-foreground/50"})}),p.is_featured&&r.jsx("div",{className:"absolute top-1.5 left-1.5",children:r.jsxs(_t,{className:"gap-1 bg-amber-500 text-white border-0 text-[10px] px-1.5 py-0.5",children:[r.jsx(Dn,{className:"h-2.5 w-2.5 fill-current"}),"Featured"]})}),r.jsx("div",{className:"absolute top-1.5 right-1.5",children:r.jsx(_t,{className:`text-[10px] px-1.5 py-0.5 ${Kbt[p.status]}`,children:Zbt[p.status]})})]}),r.jsxs("div",{className:"p-2",children:[r.jsx("p",{className:"font-bold text-sm text-foreground",children:Ybt(p.price)}),r.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[p.city,", ",p.state]}),(p.bedrooms||p.bathrooms)&&r.jsxs("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:[p.bedrooms&&`${p.bedrooms} bed`,p.bedrooms&&p.bathrooms&&" · ",p.bathrooms&&`${p.bathrooms} bath`]})]})]},p.id)})})]})}function x9e(e=10,t){return Ht({queryKey:["event-leaderboard",e,t],queryFn:async()=>{const{data:s}=await Y.from("user_roles").select("user_id").eq("role","admin"),n=new Set((s==null?void 0:s.map(v=>v.user_id))||[]);let a=null;if(t){const{data:v}=await Y.from("profiles").select("id").eq("brokerage_id",t);a=new Set((v==null?void 0:v.map(_=>_.id))||[])}const{data:o,error:l}=await Y.from("agent_attendance_stats").select("user_id, total_points, total_events_attended, current_streak").order("total_points",{ascending:!1}).limit(e+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,e),m=d.map(v=>v.user_id),{data:p}=await Y.from("profiles").select("id, name").in("id",m),g=new Map((p==null?void 0:p.map(v=>[v.id,{name:v.name}]))||[]);return d.map(v=>({user_id:v.user_id,total_points:v.total_points,total_events_attended:v.total_events_attended,current_streak:v.current_streak,profile:g.get(v.user_id)||null}))}})}function y9e(e){return Ht({queryKey:["user-attendance-stats",e],queryFn:async()=>{if(!e)return null;const{data:t,error:s}=await Y.from("agent_attendance_stats").select("*").eq("user_id",e).single();if(s&&s.code!=="PGRST116")throw s;return t},enabled:!!e})}function v9e(e){return Ht({queryKey:["user-badges",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("agent_badges").select("*").eq("user_id",e).order("earned_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function _9e(e,t){return Ht({queryKey:["user-rank",e,t],queryFn:async()=>{if(!e)return null;const{data:s}=await Y.from("agent_attendance_stats").select("total_points").eq("user_id",e).single();if(!s)return null;const{data:n}=await Y.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 Y.from("agent_attendance_stats").select("user_id, total_points").gt("total_points",s.total_points);if(l)throw l;let i=(o==null?void 0:o.filter(d=>!a.has(d.user_id)))||[];if(t){const{data:d}=await Y.from("profiles").select("id").eq("brokerage_id",t),m=new Set((d==null?void 0:d.map(p=>p.id))||[]);i=i.filter(p=>m.has(p.user_id))}return i.length+1},enabled:!!e})}function Qbt(){const{user:e,brokerageId:t,isAdmin:s}=Gr();Ks();const n=!!t,[a,o]=A.useState("brokerage"),l=()=>{if(s)return null;if(n)return a==="global"?null:t},{data:i,isLoading:d}=x9e(5,l()),{data:m}=y9e(e==null?void 0:e.id),{data:p}=_9e(e==null?void 0:e.id,l()),{data:g}=v9e(e==null?void 0:e.id),v=s||n,_=()=>s?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(d)return r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx(go,{className:"h-4 w-4 text-yellow-500"}),_()]})}),r.jsx(qe,{children:r.jsx("div",{className:"space-y-2",children:[...Array(v?5:3)].map((w,S)=>r.jsx(pr,{className:"h-10 w-full"},S))})})]});const k=w=>w===0?r.jsx(go,{className:"h-4 w-4 text-yellow-500 mx-auto"}):w===1?r.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):w===2?r.jsx("span",{className:"text-sm font-medium text-amber-600",children:"3"}):r.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 r.jsxs(ze,{children:[r.jsxs(Wt,{className:"pb-2",children:[r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx(go,{className:"h-4 w-4 text-yellow-500"}),_()]}),!s&&n&&r.jsxs("div",{className:"flex gap-1 mt-2",children:[r.jsx(X,{variant:a==="brokerage"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("brokerage"),children:"My Brokerage"}),r.jsx(X,{variant:a==="global"?"default":"outline",size:"sm",className:"text-xs h-7 flex-1",onClick:()=>o("global"),children:"All LevelUp"})]})]}),r.jsxs(qe,{children:[!s&&m&&r.jsx("div",{className:"mb-3 p-2 rounded-lg bg-primary/5 border border-primary/10",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:"Your Rank:"}),r.jsxs("span",{className:"font-bold text-primary",children:["#",p||"-"]})]}),r.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[r.jsxs("span",{children:[r.jsx("strong",{className:"text-primary",children:m.total_points})," pts"]}),r.jsxs("span",{children:[r.jsx("strong",{children:m.total_events_attended})," events"]})]})]})}),r.jsxs("div",{className:"space-y-2",children:[w.map((S,T)=>{var C,I,R;return r.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${S.user_id===(e==null?void 0:e.id)?"bg-primary/10 border border-primary/20":T===0?"bg-yellow-500/10":""}`,children:[r.jsx("div",{className:"w-5 text-center",children:k(T)}),r.jsx(cn,{className:"h-6 w-6",children:r.jsx(dn,{className:"text-xs",children:((I=(C=S.profile)==null?void 0:C.name)==null?void 0:I.charAt(0))||"?"})}),r.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((R=S.profile)==null?void 0:R.name)||"Unknown"}),r.jsx("span",{className:"text-sm font-bold text-primary",children:S.total_points})]},S.user_id)}),w.length===0&&r.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),r.jsxs(vo,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[r.jsx(po,{className:"h-4 w-4"}),"Spend Points in Reward Store",r.jsx(Zi,{className:"h-4 w-4"})]})]})]})}return r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx(go,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),r.jsx(qe,{children:m?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"p-3 rounded-lg bg-primary/5 border border-primary/10 text-center",children:[r.jsx("div",{className:"text-2xl font-bold text-primary",children:m.total_points}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Points"})]}),r.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:m.total_events_attended}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Events Attended"})]})]}),r.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Om,{className:"h-4 w-4 text-orange-500"}),r.jsx("span",{className:"text-sm font-medium",children:"Current Streak"})]}),r.jsxs("span",{className:"font-bold text-orange-500",children:[m.current_streak," 🔥"]})]}),g&&g.length>0&&r.jsxs("div",{className:"pt-2 border-t",children:[r.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[r.jsx(Yl,{className:"h-3 w-3 text-muted-foreground"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Badges"})]}),r.jsxs("div",{className:"flex flex-wrap gap-1",children:[g.slice(0,4).map(w=>r.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&&r.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",g.length-4," more"]})]})]}),r.jsxs(vo,{to:"/reward-store",className:"mt-3 flex items-center justify-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[r.jsx(po,{className:"h-4 w-4"}),"Spend Points in Reward Store",r.jsx(Zi,{className:"h-4 w-4"})]})]}):r.jsxs("div",{className:"text-center text-muted-foreground py-4 text-sm",children:[r.jsx(Dn,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/50"}),r.jsx("p",{children:"Attend events to earn points!"}),r.jsxs(vo,{to:"/reward-store",className:"mt-3 inline-flex items-center gap-2 p-2 rounded-lg bg-primary/5 hover:bg-primary/10 transition-colors text-sm font-medium text-primary",children:[r.jsx(po,{className:"h-4 w-4"}),"Visit Reward Store",r.jsx(Zi,{className:"h-4 w-4"})]})]})})]})}const Uie=()=>Ht({queryKey:["lead-sources"],queryFn:async()=>{const{data:e,error:t}=await Y.from("lead_sources").select("*").eq("is_active",!0).order("sort_order");if(t)throw t;return e}}),Jbt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{data:n,error:a}=await Y.from("lead_sources").insert({name:s,owner_user_id:t==null?void 0:t.id,sort_order:100}).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["lead-sources"]}),we.success("Lead source added")},onError:s=>{we.error("Failed to add lead source"),console.error(s)}})},f1e=(e,t)=>{const{user:s,isAdmin:n}=Gr(),a=n&&t?t:s==null?void 0:s.id;return Ht({queryKey:["scorecard-transactions",e,a],queryFn:async()=>{let o=Y.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});e&&(o=o.gte("close_date",`${e}-01-01`).lte("close_date",`${e}-12-31`));const{data:l,error:i}=await o;if(i)throw i;return l},enabled:!!a})},b9e=e=>{const{user:t,isAdmin:s}=Gr(),n=s&&e?e:t==null?void 0:t.id;return Ht({queryKey:["scorecard-transactions-all",n],queryFn:async()=>{const{data:a,error:o}=await Y.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})},Vie=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{data:n,error:a}=await Y.from("scorecard_transactions").insert({...s,owner_user_id:t.id}).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["scorecard-transactions"]}),e.invalidateQueries({queryKey:["scorecard-transactions-all"]}),we.success("Transaction added")},onError:s=>{we.error("Failed to add transaction"),console.error(s)}})},ewt=()=>{const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("scorecard_transactions").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["scorecard-transactions"]}),e.invalidateQueries({queryKey:["scorecard-transactions-all"]}),we.success("Transaction updated")},onError:t=>{we.error("Failed to update transaction"),console.error(t)}})},twt=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("scorecard_transactions").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["scorecard-transactions"]}),e.invalidateQueries({queryKey:["scorecard-transactions-all"]}),we.success("Transaction deleted")},onError:t=>{we.error("Failed to delete transaction"),console.error(t)}})},w9e=(e,t)=>{const{user:s,isAdmin:n}=Gr(),a=n&&t?t:s==null?void 0:s.id;return Ht({queryKey:["scorecard-goals",e,a],queryFn:async()=>{const{data:o,error:l}=await Y.from("scorecard_goals").select("*").eq("owner_user_id",a).eq("year",e).maybeSingle();if(l)throw l;return o},enabled:!!a})},rwt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{data:n,error:a}=await Y.from("scorecard_goals").upsert({...s,owner_user_id:t.id},{onConflict:"owner_user_id,year"}).select().single();if(a)throw a;return n},onSuccess:(s,n)=>{e.invalidateQueries({queryKey:["scorecard-goals",n.year]}),we.success("Goals saved")},onError:s=>{we.error("Failed to save goals"),console.error(s)}})},qie=()=>{const{user:e}=Gr();return Ht({queryKey:["scorecard-settings",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("scorecard_settings").select("*").eq("user_id",e.id).maybeSingle();if(s)throw s;return t},enabled:!!(e!=null&&e.id)})},swt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{data:n,error:a}=await Y.from("scorecard_settings").upsert({...s,user_id:t.id},{onConflict:"user_id"}).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["scorecard-settings"]}),we.success("Settings saved")},onError:s=>{we.error("Failed to save settings"),console.error(s)}})},j9e=(e,t)=>{const{data:s,isLoading:n}=f1e(e,t),{data:a,isLoading:o}=b9e(t),{data:l}=qie(),i=(l==null?void 0:l.show_commission)??!0,d=m=>{if(!m||m.length===0)return{totalTransactions:0,buyerCount:0,sellerCount:0,totalVolume:0,averagePrice:0,totalCommission:0,topLeadSource:null,transactionsByMonth:[],leadSourceBreakdown:[]};const p=m.filter(R=>R.transaction_type==="buyer").length,g=m.filter(R=>R.transaction_type==="seller").length,v=m.reduce((R,D)=>R+Number(D.sale_price),0),_=m.reduce((R,D)=>R+(Number(D.commission_amount)||0),0),k={};m.forEach(R=>{var B;const D=((B=R.lead_source)==null?void 0:B.name)||"Unknown";k[D]=(k[D]||0)+1});const w=Object.entries(k).map(([R,D])=>({name:R,count:D})).sort((R,D)=>D.count-R.count),S=w[0]||null,T={};m.forEach(R=>{const D=new Date(R.close_date).toLocaleString("default",{month:"short"});T[D]=(T[D]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(R=>({month:R,count:T[R]||0}));return{totalTransactions:m.length,buyerCount:p,sellerCount:g,totalVolume:v,averagePrice:m.length>0?v/m.length:0,totalCommission:i?_:0,topLeadSource:S,transactionsByMonth:I,leadSourceBreakdown:w}};return{yearStats:d(s),lifetimeStats:d(a),isLoading:n||o,showCommission:i}},nwt=()=>{const{isAdmin:e}=Gr();return Ht({queryKey:["agents-with-transactions"],queryFn:async()=>{const{data:t,error:s}=await Y.from("scorecard_transactions").select("owner_user_id").order("owner_user_id");if(s)throw s;const n=[...new Set(t.map(l=>l.owner_user_id))],{data:a,error:o}=await Y.from("profiles").select("id, name, email").in("id",n);if(o)throw o;return a},enabled:e})},Cv={recency:40,touchpoints:30,transactions:20},i5e={warm:70,cooling:40};function awt(e){return e===null?0:e<=14?Cv.recency:e<=30?Cv.recency*.85:e<=60?Cv.recency*.65:e<=90?Cv.recency*.4:e<=180?Cv.recency*.2:Cv.recency*.05}function iwt(e){const t=Math.min(e/12,1);return Math.round(Cv.touchpoints*t)}function owt(e){return e?Cv.transactions:0}function lwt(){return 0}function cwt(e){return e>=i5e.warm?"warm":e>=i5e.cooling?"cooling":"at-risk"}function p1e(){const{data:e,isLoading:t}=Xf(),{data:s}=n9e(),{data:n}=$ie(365),{data:a}=b9e(),o=A.useMemo(()=>{if(!e)return[];const i=new Date,d=Xyt(i),m={};n==null||n.forEach(g=>{new Date(g.completed_at)>=d&&(m[g.contact_id]=(m[g.contact_id]||0)+1)});const p=new Set((a==null?void 0:a.filter(g=>g.contact_id).map(g=>g.contact_id))||[]);return e.map(g=>{const v=(s==null?void 0:s[g.id])||null,_=v?jx(i,new Date(v)):null,k=m[g.id]||0,w=p.has(g.id),S=awt(_),T=iwt(k),C=owt(w),I=lwt(),R=Math.round(S+T+C+I),D={score:R,status:cwt(R),breakdown:{recency:Math.round(S),touchpoints:Math.round(T),transactions:Math.round(C),referrals:Math.round(I)},lastTouchDate:v,daysSinceTouch:_,touchCountLast12Months:k,hasTransaction:w};return{...g,relationshipScore:D}})},[e,s,n,a]),l=A.useMemo(()=>{const i=o.filter(v=>v.relationshipScore.status==="warm").length,d=o.filter(v=>v.relationshipScore.status==="cooling").length,m=o.filter(v=>v.relationshipScore.status==="at-risk").length,p=o.length,g=p>0?Math.round(o.reduce((v,_)=>v+_.relationshipScore.score,0)/p):0;return{warm:i,cooling:d,atRisk:m,total:p,averageScore:g}},[o]);return{contactsWithScores:o,stats:l,isLoading:t}}function k9e(){const e=Ks(),{stats:t,contactsWithScores:s,isLoading:n}=p1e();if(n)return r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(pr,{className:"h-5 w-40"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsx(pr,{className:"h-20 w-full"}),r.jsx(pr,{className:"h-16 w-full"})]})]});if(t.total===0)return r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"Relationship Health"]})}),r.jsxs(qe,{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Add contacts to see your relationship health scores."}),r.jsx(X,{variant:"outline",size:"sm",className:"mt-3",onClick:()=>e("/mission-control/contacts?new=true"),children:"Add Your First Contact"})]})]});const a=Math.round(t.warm/t.total*100),o=Math.round(t.cooling/t.total*100),l=Math.round(t.atRisk/t.total*100),i=s.filter(d=>d.relationshipScore.status==="at-risk").sort((d,m)=>d.relationshipScore.score-m.relationshipScore.score).slice(0,3);return r.jsxs(ze,{children:[r.jsxs(Wt,{className:"pb-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:[r.jsx(pu,{className:"h-5 w-5 text-emerald-500"}),"Relationship Health"]}),r.jsx("span",{className:"text-2xl font-bold",children:t.averageScore})]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Average score across ",t.total," contacts"]})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-500"}),r.jsx("span",{children:"Warm"})]}),r.jsxs("span",{className:"font-medium",children:[t.warm," (",a,"%)"]})]}),r.jsx(zl,{value:a,className:"h-2 bg-muted [&>div]:bg-emerald-500"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-amber-500"}),r.jsx("span",{children:"Cooling Off"})]}),r.jsxs("span",{className:"font-medium",children:[t.cooling," (",o,"%)"]})]}),r.jsx(zl,{value:o,className:"h-2 bg-muted [&>div]:bg-amber-500"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500"}),r.jsx("span",{children:"At Risk"})]}),r.jsxs("span",{className:"font-medium",children:[t.atRisk," (",l,"%)"]})]}),r.jsx(zl,{value:l,className:"h-2 bg-muted [&>div]:bg-red-500"})]})]}),i.length>0&&r.jsxs("div",{className:"pt-3 border-t",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(Tk,{className:"h-4 w-4 text-red-500"}),r.jsx("span",{className:"text-sm font-medium",children:"Needs Attention"})]}),r.jsx("div",{className:"space-y-2",children:i.map(d=>r.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:()=>e(`/mission-control/contacts/${d.id}`),children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),r.jsxs("span",{className:"text-sm",children:[d.first_name," ",d.last_name]})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:d.relationshipScore.daysSinceTouch===null?"Never":`${d.relationshipScore.daysSinceTouch}d`}),r.jsx(Zi,{className:"h-3 w-3"})]})]},d.id))})]}),r.jsxs(X,{variant:"outline",size:"sm",className:"w-full",onClick:()=>e("/mission-control/contacts?filter=at-risk"),children:["View All At-Risk Contacts",r.jsx(Zi,{className:"h-4 w-4 ml-1"})]})]})]})}const dwt=()=>{var ie;const{user:e,isAdmin:t}=Gr(),s=Ks(),[n,a]=A.useState([]),[o,l]=A.useState([]),[i,d]=A.useState([]),[m,p]=A.useState([]),[g,v]=A.useState([]),[_,k]=A.useState([]),[w,S]=A.useState(new Set),[T,C]=A.useState([]),[I,R]=A.useState([]),[D,B]=A.useState([]),[$,q]=A.useState(null),[W,K]=A.useState(!0);A.useEffect(()=>{re()},[e]);const re=async()=>{var de,ce,ge,Te,_e;try{const[ve,Me,Ze,Ae,Le,Ue,Ve,Ie,We,wt,Pe]=await Promise.all([Y.from("user_tags").select("tag").eq("user_id",e==null?void 0:e.id),Y.from("app_tiles").select("*").order("name"),Y.from("user_favorites").select("app_id").eq("user_id",e==null?void 0:e.id),Y.from("events").select("*").order("event_date",{ascending:!0}),Y.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",e==null?void 0:e.id),Y.from("canva_templates").select("id, name, preview_image_url, publish_date").order("publish_date",{ascending:!1}).limit(4),Y.from("resource_kits").select("id, name, description, featured_image_url, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),Y.from("academy_videos").select("id, title, description, thumbnail_url, duration, publish_date").eq("is_published",!0).order("publish_date",{ascending:!1}).limit(4),Y.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),Y.from("dashboard_banners").select("id, title, description, image_url, link_url, link_text, placement, section_after").eq("is_active",!0).order("sort_order"),Y.from("profiles").select("name").eq("id",e==null?void 0:e.id).single()]);(de=Pe.data)!=null&&de.name&&q(Pe.data.name);const st=((ce=ve.data)==null?void 0:ce.map(it=>it.tag))||[],ue=new Set(((ge=Ze.data)==null?void 0:ge.map(it=>it.app_id))||[]);S(ue);const tt=(((Te=Me.data)==null?void 0:Te.filter(it=>!it.required_tags||it.required_tags.length===0?!0:it.required_tags.some(Se=>st.includes(Se))))||[]).sort((it,Se)=>it.name==="LevelUp Members Portal"?-1:Se.name==="LevelUp Members Portal"?1:0);a(tt.slice(0,6));const rt=((_e=Ae.data)==null?void 0:_e.filter(it=>Z4(it.event_date)!=="ended"))||[];l(rt.slice(0,4)),C(Le.data||[]),d(Ue.data||[]),p(Ve.data||[]),v(Ie.data||[]),k(We.data||[]);const je=wt.data||[];R(je.filter(it=>it.placement==="top")),B(je.filter(it=>it.placement==="between"))}catch(ve){console.error("Error loading dashboard:",ve),we.error("Failed to load dashboard data")}finally{K(!1)}},ae=async de=>{var ge;const ce=window.open("about:blank","_blank");try{await Y.from("activity_logs").insert({user_id:e==null?void 0:e.id,app_id:de.app_id,app_name:de.name,user_agent:navigator.userAgent});const{data:Te,error:_e}=await Y.functions.invoke("sso-launch",{body:{app_id:de.app_id}});if(_e)throw _e;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(),we.error("Launch link unavailable"))}catch(Te){ce==null||ce.close(),console.error("Error launching app:",Te),we.error("Failed to launch app")}},oe=de=>T==null?void 0:T.some(ce=>ce.event_id===de),se=de=>{const ce=T==null?void 0:T.find(ge=>ge.event_id===de);return ce==null?void 0:ce.zoom_join_url};if(W)return r.jsx(Ur,{title:"Dashboard",children:r.jsx("div",{className:"flex items-center justify-center py-16",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"Loading your dashboard..."})]})})});const pe=de=>D.filter(ce=>ce.section_after===de);return r.jsxs(Ur,{title:"Dashboard",children:[r.jsx(lbt,{events:o,registrations:T,onNavigateToEvents:()=>s("/events")}),I.length>0&&r.jsx("div",{className:"mb-8",children:r.jsx(yA,{banners:I})}),r.jsx(vbt,{}),r.jsxs("div",{className:"mb-6",children:[r.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",($||((ie=e==null?void 0:e.user_metadata)==null?void 0:ie.name)||"there").split(" ")[0],"!"]}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Are you ready to LevelUp today?"})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4 mb-8",children:[r.jsx(Lbt,{}),r.jsx(k9e,{}),r.jsx(Qbt,{})]}),r.jsxs("section",{className:"mb-10",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Upcoming Events"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>s("/events"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",r.jsx(Ki,{className:"h-4 w-4"})]})]}),o.length===0?r.jsx(ze,{className:"bg-muted/30 border-dashed",children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx(An,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]})})}):r.jsx("div",{className:"bg-card rounded-xl border border-border overflow-hidden divide-y divide-border max-w-full",children:o.map(de=>{const ce=oe(de.id),ge=se(de.id)||de.zoom_link;return r.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 ${r5e(de.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>s("/events"),children:[r5e(de.event_date)?r.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:[r.jsx("span",{className:"absolute inline-flex h-3 w-3 top-1 right-1 animate-ping rounded-full bg-red-500 opacity-75"}),r.jsx(Ck,{className:"h-5 w-5 text-red-500"}),r.jsx("span",{className:"text-[10px] font-bold text-red-500 uppercase mt-0.5",children:"Live"})]}):r.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:[r.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(de.event_date))}),r.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(de.event_date))})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"font-medium text-sm sm:text-base text-foreground group-hover:text-primary transition-colors line-clamp-2 sm:truncate",children:de.title}),r.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(de.event_date))," at ",JI(new Date(de.event_date))]})]}),r.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:ce?r.jsxs(X,{size:"sm",variant:"default",className:"gap-1",onClick:Te=>{Te.stopPropagation(),window.open(ge,"_blank")},children:[r.jsx(jn,{className:"h-3.5 w-3.5"}),"Join"]}):r.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground group-hover:text-primary transition-colors",children:[r.jsx("span",{className:"text-sm",children:"Register"}),r.jsx(Zi,{className:"h-4 w-4"})]})})]},de.id)})})]}),pe("events").length>0&&r.jsx("div",{className:"mb-10",children:r.jsx(yA,{banners:pe("events")})}),r.jsxs("section",{className:"mb-10",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Academy Videos"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>s("/academy"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",r.jsx(Ki,{className:"h-4 w-4"})]})]}),g.length===0?r.jsx(ze,{className:"bg-muted/30 border-dashed",children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx(kf,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"No academy videos available"})]})})}):r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:g.map(de=>r.jsxs("div",{onClick:()=>s(`/academy/${de.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:[r.jsxs("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden relative",children:[de.thumbnail_url?r.jsx("img",{src:de.thumbnail_url,alt:de.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(kf,{className:"h-8 w-8 text-muted-foreground/50"})}),de.duration&&r.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:de.duration})]}),r.jsx("div",{className:"p-3",children:r.jsx("h4",{className:"font-medium text-sm text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:de.title})})]},de.id))})]}),pe("academy").length>0&&r.jsx("div",{className:"mb-10",children:r.jsx(yA,{banners:pe("academy")})}),r.jsxs("section",{className:"mb-10",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Resource Kits"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>s("/toolbox"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",r.jsx(Ki,{className:"h-4 w-4"})]})]}),m.length===0?r.jsx(ze,{className:"bg-muted/30 border-dashed",children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx(Jh,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"No resource kits available"})]})})}):r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:m.map(de=>r.jsxs("div",{onClick:()=>s(`/toolbox/${de.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:[r.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:de.featured_image_url?r.jsx("img",{src:de.featured_image_url,alt:de.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(Jh,{className:"h-8 w-8 text-muted-foreground/50"})})}),r.jsx("div",{className:"p-3",children:r.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:de.name})})]},de.id))})]}),pe("toolbox").length>0&&r.jsx("div",{className:"mb-10",children:r.jsx(yA,{banners:pe("toolbox")})}),r.jsxs("section",{className:"mb-10",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"New Templates"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>s("/templates"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",r.jsx(Ki,{className:"h-4 w-4"})]})]}),i.length===0?r.jsx(ze,{className:"bg-muted/30 border-dashed",children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx(v1,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"No templates available"})]})})}):r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map(de=>r.jsxs("div",{onClick:()=>s("/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:[r.jsx("div",{className:"aspect-[3/2] bg-muted/50 overflow-hidden",children:de.preview_image_url?r.jsx("img",{src:de.preview_image_url,alt:de.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(v1,{className:"h-8 w-8 text-muted-foreground/50"})})}),r.jsx("div",{className:"p-3",children:r.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:de.name})})]},de.id))})]}),pe("templates").length>0&&r.jsx("div",{className:"mb-10",children:r.jsx(yA,{banners:pe("templates")})}),r.jsx("div",{className:"mb-10",children:r.jsx(Xbt,{})}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Your Apps"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>s("/apps"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",r.jsx(Ki,{className:"h-4 w-4"})]})]}),n.length===0?r.jsx(ze,{className:"bg-muted/30 border-dashed",children:r.jsx(qe,{className:"flex items-center justify-center py-12",children:r.jsxs("div",{className:"text-center",children:[r.jsx(rg,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"No apps available"})]})})}):r.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:n.map(de=>{const ce=w.has(de.id);return r.jsxs("div",{onClick:()=>ae(de),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:[r.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:de.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:de.name}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:de.description})]}),ce&&r.jsx(rg,{className:"h-5 w-5 text-primary fill-current flex-shrink-0"})]},de.id)})})]}),r.jsxs("section",{className:"mt-10",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Additional Services"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>s("/additional-services"),className:"gap-1 text-muted-foreground hover:text-foreground",children:["View All ",r.jsx(Ki,{className:"h-4 w-4"})]})]}),_.length===0?r.jsx(ze,{className:"bg-muted/30 border-dashed",children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx(bn,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"No additional services available"})]})})}):r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:_.map(de=>r.jsxs("div",{onClick:()=>window.open(de.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:[r.jsx("div",{className:"aspect-[4/3] bg-muted/50 overflow-hidden",children:de.preview_image_url?r.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"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(bn,{className:"h-8 w-8 text-muted-foreground/50"})})}),r.jsxs("div",{className:"p-3",children:[r.jsx("h4",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:de.name}),de.description&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:de.description})]})]},de.id))})]})]})};var Hie="Switch",[uwt]=Sc(Hie),[hwt,mwt]=uwt(Hie),N9e=A.forwardRef((e,t)=>{const{__scopeSwitch:s,name:n,checked:a,defaultChecked:o,required:l,disabled:i,value:d="on",onCheckedChange:m,form:p,...g}=e,[v,_]=A.useState(null),k=va(t,I=>_(I)),w=A.useRef(!1),S=v?p||!!v.closest("form"):!0,[T,C]=bh({prop:a,defaultProp:o??!1,onChange:m,caller:Hie});return r.jsxs(hwt,{scope:s,checked:T,disabled:i,children:[r.jsx(Hs.button,{type:"button",role:"switch","aria-checked":T,"aria-required":l,"data-state":T9e(T),"data-disabled":i?"":void 0,disabled:i,value:d,...g,ref:k,onClick:bs(e.onClick,I=>{C(R=>!R),S&&(w.current=I.isPropagationStopped(),w.current||I.stopPropagation())})}),S&&r.jsx(M9e,{control:v,bubbles:!w.current,name:n,value:d,checked:T,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});N9e.displayName=Hie;var S9e="SwitchThumb",C9e=A.forwardRef((e,t)=>{const{__scopeSwitch:s,...n}=e,a=mwt(S9e,s);return r.jsx(Hs.span,{"data-state":T9e(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:t})});C9e.displayName=S9e;var fwt="SwitchBubbleInput",M9e=A.forwardRef(({__scopeSwitch:e,control:t,checked:s,bubbles:n=!0,...a},o)=>{const l=A.useRef(null),i=va(l,o),d=C6(s),m=p6(t);return A.useEffect(()=>{const p=l.current;if(!p)return;const g=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(g,"checked").set;if(d!==s&&_){const k=new Event("click",{bubbles:n});_.call(p,s),p.dispatchEvent(k)}},[d,s,n]),r.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:s,...a,tabIndex:-1,ref:i,style:{...a.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});M9e.displayName=fwt;function T9e(e){return e?"checked":"unchecked"}var A9e=N9e,pwt=C9e;const fn=A.forwardRef(({className:e,...t},s)=>r.jsx(A9e,{className:Vt("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",e),...t,ref:s,children:r.jsx(pwt,{className:Vt("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")})}));fn.displayName=A9e.displayName;var E9e="AlertDialog",[gwt]=Sc(E9e,[XFe]),x0=XFe(),I9e=e=>{const{__scopeAlertDialog:t,...s}=e,n=x0(t);return r.jsx(hie,{...n,...s,modal:!0})};I9e.displayName=E9e;var xwt="AlertDialogTrigger",P9e=A.forwardRef((e,t)=>{const{__scopeAlertDialog:s,...n}=e,a=x0(s);return r.jsx(jve,{...a,...n,ref:t})});P9e.displayName=xwt;var ywt="AlertDialogPortal",L9e=e=>{const{__scopeAlertDialog:t,...s}=e,n=x0(t);return r.jsx(mie,{...n,...s})};L9e.displayName=ywt;var vwt="AlertDialogOverlay",D9e=A.forwardRef((e,t)=>{const{__scopeAlertDialog:s,...n}=e,a=x0(s);return r.jsx(I3,{...a,...n,ref:t})});D9e.displayName=vwt;var Y4="AlertDialogContent",[_wt,bwt]=gwt(Y4),wwt=PDe("AlertDialogContent"),O9e=A.forwardRef((e,t)=>{const{__scopeAlertDialog:s,children:n,...a}=e,o=x0(s),l=A.useRef(null),i=va(t,l),d=A.useRef(null);return r.jsx(cpt,{contentName:Y4,titleName:R9e,docsSlug:"alert-dialog",children:r.jsx(_wt,{scope:s,cancelRef:d,children:r.jsxs(P3,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:bs(a.onOpenAutoFocus,m=>{var p;m.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:m=>m.preventDefault(),onInteractOutside:m=>m.preventDefault(),children:[r.jsx(wwt,{children:n}),r.jsx(kwt,{contentRef:l})]})})})});O9e.displayName=Y4;var R9e="AlertDialogTitle",F9e=A.forwardRef((e,t)=>{const{__scopeAlertDialog:s,...n}=e,a=x0(s);return r.jsx(N6,{...a,...n,ref:t})});F9e.displayName=R9e;var z9e="AlertDialogDescription",B9e=A.forwardRef((e,t)=>{const{__scopeAlertDialog:s,...n}=e,a=x0(s);return r.jsx(S6,{...a,...n,ref:t})});B9e.displayName=z9e;var jwt="AlertDialogAction",$9e=A.forwardRef((e,t)=>{const{__scopeAlertDialog:s,...n}=e,a=x0(s);return r.jsx(fie,{...a,...n,ref:t})});$9e.displayName=jwt;var U9e="AlertDialogCancel",V9e=A.forwardRef((e,t)=>{const{__scopeAlertDialog:s,...n}=e,{cancelRef:a}=bwt(U9e,s),o=x0(s),l=va(t,a);return r.jsx(fie,{...o,...n,ref:l})});V9e.displayName=U9e;var kwt=({contentRef:e})=>{const t=`\`${Y4}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${Y4}\` by passing a \`${z9e}\` 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 \`${Y4}\`. 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 A.useEffect(()=>{var n;document.getElementById((n=e.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Nwt=I9e,Swt=P9e,Cwt=L9e,q9e=D9e,H9e=O9e,W9e=$9e,G9e=V9e,K9e=F9e,Z9e=B9e;const $c=Nwt,Im=Swt,Mwt=Cwt,Y9e=A.forwardRef(({className:e,...t},s)=>r.jsx(q9e,{className:Vt("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",e),...t,ref:s}));Y9e.displayName=q9e.displayName;const xc=A.forwardRef(({className:e,...t},s)=>r.jsxs(Mwt,{children:[r.jsx(Y9e,{}),r.jsx(H9e,{ref:s,className:Vt("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",e),...t})]}));xc.displayName=H9e.displayName;const yc=({className:e,...t})=>r.jsx("div",{className:Vt("flex flex-col space-y-2 text-center sm:text-left",e),...t});yc.displayName="AlertDialogHeader";const vc=({className:e,...t})=>r.jsx("div",{className:Vt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});vc.displayName="AlertDialogFooter";const _c=A.forwardRef(({className:e,...t},s)=>r.jsx(K9e,{ref:s,className:Vt("text-lg font-semibold",e),...t}));_c.displayName=K9e.displayName;const bc=A.forwardRef(({className:e,...t},s)=>r.jsx(Z9e,{ref:s,className:Vt("text-sm text-muted-foreground",e),...t}));bc.displayName=Z9e.displayName;const Ql=A.forwardRef(({className:e,...t},s)=>r.jsx(W9e,{ref:s,className:Vt(GI(),e),...t}));Ql.displayName=W9e.displayName;const wc=A.forwardRef(({className:e,...t},s)=>r.jsx(G9e,{ref:s,className:Vt(GI({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));wc.displayName=G9e.displayName;const Twt=[{key:"contacts",label:"Contacts",icon:fi,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:bk,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Jh,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:ma,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Vn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:fE,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Yi,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:Dm,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:Oy,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Ff,description:"Create and manage smart presentations"}];function Awt(){var $;const{user:e}=Gr(),[t,s]=A.useState([]),[n,a]=A.useState(!0),[o,l]=A.useState(!1),[i,d]=A.useState(!1),[m,p]=A.useState(null),[g,v]=A.useState({email:"",name:"",password:""}),[_,k]=A.useState("create"),[w,S]=A.useState(!1),[T,C]=A.useState(null);A.useEffect(()=>{e&&I()},[e]);const I=async()=>{if(e){a(!0);try{const{data:q,error:W}=await Y.from("agent_assistant_assignments").select("id, assistant_id, permissions, created_at").eq("agent_id",e.id);if(W)throw W;if(q&&q.length>0){const K=q.map(oe=>oe.assistant_id),{data:re}=await Y.from("profiles").select("id, name, email").in("id",K),ae=q.map(oe=>{const se=re==null?void 0:re.find(pe=>pe.id===oe.assistant_id);return{...oe,permissions:oe.permissions,assistant_profile:se?{name:se.name||"",email:se.email||""}:void 0}});s(ae)}else s([])}catch(q){console.error("Error loading assistants:",q)}finally{a(!1)}}},R=async()=>{if(e){if(_==="link"){if(!g.email.trim()){we.error("Please enter the assistant's email");return}S(!0);try{const{data:{session:q}}=await Y.auth.getSession();if(!q)throw new Error("Not authenticated");const{data:W,error:K}=await Y.from("profiles").select("id, name, email").eq("email",g.email.trim().toLowerCase()).single();if(K||!W){we.error("No account found with that email. Try creating a new assistant instead.");return}const{data:re}=await Y.from("agent_assistant_assignments").select("id").eq("agent_id",e.id).eq("assistant_id",W.id);if(re&&re.length>0){we.error("This assistant is already assigned to you");return}const ae=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:W.id,role:"assistant",action:"add",agentId:e.id})}),oe=await ae.json();if(!ae.ok)throw new Error(oe.error||"Failed to assign assistant role");const{error:se}=await Y.from("agent_assistant_assignments").insert({agent_id:e.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(se)throw se;we.success(`${W.name||W.email} linked as your assistant`),l(!1),v({email:"",name:"",password:""}),I()}catch(q){console.error("Error linking assistant:",q),we.error(q.message||"Failed to link assistant")}finally{S(!1)}return}if(!g.email.trim()||!g.name.trim()||!g.password.trim()){we.error("Please fill in all fields");return}if(g.password.length<6){we.error("Password must be at least 6 characters");return}S(!0);try{const{data:{session:q}}=await Y.auth.getSession();if(!q)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 ${q.access_token}`},body:JSON.stringify({email:g.email.trim(),password:g.password,name:g.name.trim(),purpose:"assistant"})}),K=await W.json();if(!W.ok)throw new Error(K.error||"Failed to create assistant account");const re=K.userId||K.id;if(!re)throw new Error("No user ID returned");const ae=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:re,role:"assistant",action:"add",agentId:e.id})}),oe=await ae.json();if(!ae.ok)throw new Error(oe.error||"Failed to assign assistant role");const{error:se}=await Y.from("agent_assistant_assignments").insert({agent_id:e.id,assistant_id:re,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(se)throw se;we.success(`Assistant account created for ${g.name.trim()}`),l(!1),v({email:"",name:"",password:""}),I()}catch(q){console.error("Error adding assistant:",q),we.error(q.message||"Failed to add assistant")}finally{S(!1)}}},D=async()=>{if(!(!m||!e))try{const{data:{session:q}}=await Y.auth.getSession();if(!q)throw new Error("Not authenticated");const{error:W}=await Y.from("agent_assistant_assignments").delete().eq("id",m.id);if(W)throw W;const{data:K}=await Y.from("agent_assistant_assignments").select("id").eq("assistant_id",m.assistant_id);(!K||K.length===0)&&await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${q.access_token}`},body:JSON.stringify({userId:m.assistant_id,role:"assistant",action:"remove"})}),we.success("Assistant removed"),d(!1),p(null),I()}catch(q){console.error("Error removing assistant:",q),we.error(q.message||"Failed to remove assistant")}},B=async(q,W,K)=>{C(q);try{const re=t.find(se=>se.id===q);if(!re)return;const ae={...re.permissions,[W]:K},{error:oe}=await Y.from("agent_assistant_assignments").update({permissions:ae}).eq("id",q);if(oe)throw oe;s(se=>se.map(pe=>pe.id===q?{...pe,permissions:ae}:pe))}catch(re){console.error("Error updating permissions:",re),we.error("Failed to update permissions")}finally{C(null)}};return n?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"My Assistants"]})}),r.jsx(qe,{children:r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"My Assistants"]}),r.jsx(Cs,{children:"Add assistants to help manage your Agent OS"})]}),r.jsxs(X,{size:"sm",onClick:()=>{k("create"),l(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Assistant"]})]})}),r.jsx(qe,{children:t.length===0?r.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."}):r.jsx("div",{className:"space-y-4",children:t.map(q=>{var W,K,re,ae;return r.jsxs("div",{className:"border rounded-lg p-4 space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(cn,{className:"h-10 w-10",children:r.jsx(dn,{children:((K=(W=q.assistant_profile)==null?void 0:W.name)==null?void 0:K.split(" ").map(oe=>oe[0]).join("").toUpperCase())||"A"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:((re=q.assistant_profile)==null?void 0:re.name)||"Unknown"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:((ae=q.assistant_profile)==null?void 0:ae.email)||""})]}),r.jsxs(_t,{variant:"secondary",className:"ml-2",children:[r.jsx(Ou,{className:"h-3 w-3 mr-1"}),"Assistant"]})]}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>{p(q),d(!0)},children:r.jsx(Os,{className:"h-4 w-4"})})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium mb-3",children:"Permissions"}),r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Twt.map(oe=>{const se=oe.icon;return r.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(se,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",children:oe.label}),r.jsx("p",{className:"text-xs text-muted-foreground",children:oe.description})]})]}),r.jsx(fn,{checked:q.permissions[oe.key]||!1,onCheckedChange:pe=>B(q.id,oe.key,pe),disabled:T===q.id})]},oe.key)})})]})]},q.id)})})})]}),r.jsx(Ir,{open:o,onOpenChange:l,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Add Assistant"}),r.jsx(Zs,{children:_==="create"?"Create a new account for your assistant.":"Link an existing assistant account by their email."})]}),r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsxs(X,{variant:_==="create"?"default":"outline",size:"sm",onClick:()=>k("create"),children:[r.jsx(gs,{className:"h-3 w-3 mr-1"}),"Create New"]}),r.jsxs(X,{variant:_==="link"?"default":"outline",size:"sm",onClick:()=>k("link"),children:[r.jsx(Lo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),r.jsxs("div",{className:"space-y-4 py-2",children:[_==="create"&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"assistant-name",children:"Name"}),r.jsx(Ye,{id:"assistant-name",value:g.name,onChange:q=>v({...g,name:q.target.value}),placeholder:"Assistant's full name"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"assistant-email",children:"Email"}),r.jsx(Ye,{id:"assistant-email",type:"email",value:g.email,onChange:q=>v({...g,email:q.target.value}),placeholder:"assistant@email.com"})]}),_==="create"&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"assistant-password",children:"Temporary Password"}),r.jsx(Ye,{id:"assistant-password",type:"password",value:g.password,onChange:q=>v({...g,password:q.target.value}),placeholder:"Min 6 characters"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Your assistant can change this after their first login."})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),r.jsxs(X,{onClick:R,disabled:w,children:[w&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),_==="create"?"Create Assistant":"Link Assistant"]})]})]})}),r.jsx($c,{open:i,onOpenChange:d,children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Remove Assistant?"}),r.jsxs(bc,{children:["This will remove ",($=m==null?void 0:m.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."]})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:D,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function lu(e){this.content=e}lu.prototype={constructor:lu,find:function(e){for(var t=0;t>1}};lu.from=function(e){if(e instanceof lu)return e;var t=[];if(e)for(var s in e)t.push(s,e[s]);return new lu(t)};function X9e(e,t,s){for(let n=0;;n++){if(n==e.childCount||n==t.childCount)return e.childCount==t.childCount?null:s;let a=e.child(n),o=t.child(n);if(a==o){s+=a.nodeSize;continue}if(!a.sameMarkup(o))return s;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)s++;return s}if(a.content.size||o.content.size){let l=X9e(a.content,o.content,s+1);if(l!=null)return l}s+=a.nodeSize}}function Q9e(e,t,s,n){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:s,b:n};let l=e.child(--a),i=t.child(--o),d=l.nodeSize;if(l==i){s-=d,n-=d;continue}if(!l.sameMarkup(i))return{a:s,b:n};if(l.isText&&l.text!=i.text){let m=0,p=Math.min(l.text.length,i.text.length);for(;mt&&n(d,a+i,o||null,l)!==!1&&d.content.size){let p=i+1;d.nodesBetween(Math.max(0,t-p),Math.min(d.content.size,s-p),n,a+p)}i=m}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,s,n,a){let o="",l=!0;return this.nodesBetween(t,s,(i,d)=>{let m=i.isText?i.text.slice(Math.max(t,d)-d,s-d):i.isLeaf?a?typeof a=="function"?a(i):a:i.type.spec.leafText?i.type.spec.leafText(i):"":"";i.isBlock&&(i.isLeaf&&m||i.isTextblock)&&n&&(l?l=!1:o+=n),o+=m},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let s=this.lastChild,n=t.firstChild,a=this.content.slice(),o=0;for(s.isText&&s.sameMarkup(n)&&(a[a.length-1]=s.withText(s.text+n.text),o=1);ot)for(let o=0,l=0;lt&&((ls)&&(i.isText?i=i.cut(Math.max(0,t-l),Math.min(i.text.length,s-l)):i=i.cut(Math.max(0,t-l-1),Math.min(i.content.size,s-l-1))),n.push(i),a+=i.nodeSize),l=d}return new _s(n,a)}cutByIndex(t,s){return t==s?_s.empty:t==0&&s==this.content.length?this:new _s(this.content.slice(t,s))}replaceChild(t,s){let n=this.content[t];if(n==s)return this;let a=this.content.slice(),o=this.size+s.nodeSize-n.nodeSize;return a[t]=s,new _s(a,o)}addToStart(t){return new _s([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new _s(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let s=0;sthis.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let s=0,n=0;;s++){let a=this.child(s),o=n+a.nodeSize;if(o>=t)return o==t?EO(s+1,o):EO(s,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,s){if(!s)return _s.empty;if(!Array.isArray(s))throw new RangeError("Invalid input for Fragment.fromJSON");return new _s(s.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return _s.empty;let s,n=0;for(let a=0;athis.type.rank&&(s||(s=t.slice(0,a)),s.push(this),n=!0),s&&s.push(o)}}return s||(s=t.slice()),n||s.push(this),s}removeFromSet(t){for(let s=0;sn.type.rank-a.type.rank),s}};Xo.none=[];class Tse extends Error{}class nn{constructor(t,s,n){this.content=t,this.openStart=s,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,s){let n=e$e(this.content,t+this.openStart,s);return n&&new nn(n,this.openStart,this.openEnd)}removeBetween(t,s){return new nn(J9e(this.content,t+this.openStart,s+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,s){if(!s)return nn.empty;let n=s.openStart||0,a=s.openEnd||0;if(typeof n!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new nn(_s.fromJSON(t,s.content),n,a)}static maxOpen(t,s=!0){let n=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(s||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=t.lastChild;o&&!o.isLeaf&&(s||!o.type.spec.isolating);o=o.lastChild)a++;return new nn(t,n,a)}}nn.empty=new nn(_s.empty,0,0);function J9e(e,t,s){let{index:n,offset:a}=e.findIndex(t),o=e.maybeChild(n),{index:l,offset:i}=e.findIndex(s);if(a==t||o.isText){if(i!=s&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(s))}if(n!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(n,o.copy(J9e(o.content,t-a-1,s-a-1)))}function e$e(e,t,s,n){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return n&&!n.canReplace(a,a,s)?null:e.cut(0,t).append(s).append(e.cut(t));let i=e$e(l.content,t-o-1,s,l);return i&&e.replaceChild(a,l.copy(i))}function Ewt(e,t,s){if(s.openStart>e.depth)throw new Tse("Inserted content deeper than insertion position");if(e.depth-s.openStart!=t.depth-s.openEnd)throw new Tse("Inconsistent open depths");return t$e(e,t,s,0)}function t$e(e,t,s,n){let a=e.index(n),o=e.node(n);if(a==t.index(n)&&n=0&&e.isText&&e.sameMarkup(t[s])?t[s]=e.withText(t[s].text+e.text):t.push(e)}function XE(e,t,s,n){let a=(t||e).node(s),o=0,l=t?t.index(s):a.childCount;e&&(o=e.index(s),e.depth>s?o++:e.textOffset&&(Lk(e.nodeAfter,n),o++));for(let i=o;ia&&Lpe(e,t,a+1),l=n.depth>a&&Lpe(s,n,a+1),i=[];return XE(null,e,a,i),o&&l&&t.index(a)==s.index(a)?(r$e(o,l),Lk(Dk(o,s$e(e,t,s,n,a+1)),i)):(o&&Lk(Dk(o,Ase(e,t,a+1)),i),XE(t,s,a,i),l&&Lk(Dk(l,Ase(s,n,a+1)),i)),XE(n,null,a,i),new _s(i)}function Ase(e,t,s){let n=[];if(XE(null,e,s,n),e.depth>s){let a=Lpe(e,t,s+1);Lk(Dk(a,Ase(e,t,s+1)),n)}return XE(t,null,s,n),new _s(n)}function Iwt(e,t){let s=t.depth-e.openStart,a=t.node(s).copy(e.content);for(let o=s-1;o>=0;o--)a=t.node(o).copy(_s.from(a));return{start:a.resolveNoCache(e.openStart+s),end:a.resolveNoCache(a.content.size-e.openEnd-s)}}class eP{constructor(t,s,n){this.pos=t,this.path=s,this.parentOffset=n,this.depth=s.length/3-1}resolveDepth(t){return t==null?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,s=this.index(this.depth);if(s==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],a=t.child(s);return n?t.child(s).cut(n):a}get nodeBefore(){let t=this.index(this.depth),s=this.pos-this.path[this.path.length-1];return s?this.parent.child(t).cut(0,s):t==0?null:this.parent.child(t-1)}posAtIndex(t,s){s=this.resolveDepth(s);let n=this.path[s*3],a=s==0?0:this.path[s*3-1]+1;for(let o=0;o0;s--)if(this.start(s)<=t&&this.end(s)>=t)return s;return 0}blockRange(t=this,s){if(t.pos=0;n--)if(t.pos<=this.end(n)&&(!s||s(this.node(n))))return new Ese(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos=0&&s<=t.content.size))throw new RangeError("Position "+s+" out of range");let n=[],a=0,o=s;for(let l=t;;){let{index:i,offset:d}=l.content.findIndex(o),m=o-d;if(n.push(l,i,a+d),!m||(l=l.child(i),l.isText))break;o=m-1,a+=d+1}return new eP(s,n,o)}static resolveCached(t,s){let n=o5e.get(t);if(n)for(let o=0;ot&&this.nodesBetween(t,s,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 t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),n$e(this.marks,t)}contentMatchAt(t){let s=this.type.contentMatch.matchFragment(this.content,0,t);if(!s)throw new Error("Called contentMatchAt on a node with invalid content");return s}canReplace(t,s,n=_s.empty,a=0,o=n.childCount){let l=this.contentMatchAt(t).matchFragment(n,a,o),i=l&&l.matchFragment(this.content,s);if(!i||!i.validEnd)return!1;for(let d=a;ds.type.name)}`);this.content.forEach(s=>s.check())}toJSON(){let t={type:this.type.name};for(let s in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map(s=>s.toJSON())),t}static fromJSON(t,s){if(!s)throw new RangeError("Invalid input for Node.fromJSON");let n;if(s.marks){if(!Array.isArray(s.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=s.marks.map(t.markFromJSON)}if(s.type=="text"){if(typeof s.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(s.text,n)}let a=_s.fromJSON(t,s.content),o=t.nodeType(s.type).create(s.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};P1.prototype.text=void 0;class Ise extends P1{constructor(t,s,n,a){if(super(t,s,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):n$e(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,s){return this.text.slice(t,s)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new Ise(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new Ise(this.type,this.attrs,t,this.marks)}cut(t=0,s=this.text.length){return t==0&&s==this.text.length?this:this.withText(this.text.slice(t,s))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function n$e(e,t){for(let s=e.length-1;s>=0;s--)t=e[s].type.name+"("+t+")";return t}class rN{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,s){let n=new Owt(t,s);if(n.next==null)return rN.empty;let a=a$e(n);n.next&&n.err("Unexpected trailing text");let o=Vwt(Uwt(a));return qwt(o,n),o}matchType(t){for(let s=0;sm.createAndFill()));for(let m=0;m=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function s(n){t.push(n);for(let a=0;a{let o=a+(n.validEnd?"*":" ")+" ";for(let l=0;l"+t.indexOf(n.next[l].next);return o}).join(` `)}}rN.empty=new rN(!0);class Owt{constructor(t,s){this.string=t,this.nodeTypes=s,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function a$e(e){let t=[];do t.push(Rwt(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function Rwt(e){let t=[];do t.push(Fwt(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function Fwt(e){let t=$wt(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=zwt(e,t);else break;return t}function l5e(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function zwt(e,t){let s=l5e(e),n=s;return e.eat(",")&&(e.next!="}"?n=l5e(e):n=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:s,max:n,expr:t}}function Bwt(e,t){let s=e.nodeTypes,n=s[t];if(n)return[n];let a=[];for(let o in s){let l=s[o];l.isInGroup(t)&&a.push(l)}return a.length==0&&e.err("No node type or group '"+t+"' found"),a}function $wt(e){if(e.eat("(")){let t=a$e(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=Bwt(e,e.next).map(s=>(e.inline==null?e.inline=s.isInline:e.inline!=s.isInline&&e.err("Mixing inline and block content"),{type:"name",value:s}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function Uwt(e){let t=[[]];return a(o(e,0),s()),t;function s(){return t.push([])-1}function n(l,i,d){let m={term:d,to:i};return t[l].push(m),m}function a(l,i){l.forEach(d=>d.to=i)}function o(l,i){if(l.type=="choice")return l.exprs.reduce((d,m)=>d.concat(o(m,i)),[]);if(l.type=="seq")for(let d=0;;d++){let m=o(l.exprs[d],i);if(d==l.exprs.length-1)return m;a(m,i=s())}else if(l.type=="star"){let d=s();return n(i,d),a(o(l.expr,d),d),[n(d)]}else if(l.type=="plus"){let d=s();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 m=0;m{e[l].forEach(({term:i,to:d})=>{if(!i)return;let m;for(let p=0;p{m||a.push([i,m=[]]),m.indexOf(p)==-1&&m.push(p)})})});let o=t[n.join(",")]=new rN(n.indexOf(e.length-1)>-1);for(let l=0;l-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:l$e(this.attrs,t)}create(t=null,s,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new P1(this,this.computeAttrs(t),_s.from(s),Xo.setFrom(n))}createChecked(t=null,s,n){return s=_s.from(s),this.checkContent(s),new P1(this,this.computeAttrs(t),s,Xo.setFrom(n))}createAndFill(t=null,s,n){if(t=this.computeAttrs(t),s=_s.from(s),s.size){let l=this.contentMatch.fillBefore(s);if(!l)return null;s=l.append(s)}let a=this.contentMatch.matchFragment(s),o=a&&a.fillBefore(_s.empty,!0);return o?new P1(this,t,s.append(o),Xo.setFrom(n)):null}validContent(t){let s=this.contentMatch.matchFragment(t);if(!s||!s.validEnd)return!1;for(let n=0;n-1}allowsMarks(t){if(this.markSet==null)return!0;for(let s=0;sn[o]=new u$e(o,s,l));let a=s.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 Hwt(e,t,s){let n=s.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 ${t} on type ${e}, got ${o}`)}}class Wwt{constructor(t,s,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?Hwt(t,s,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Wie{constructor(t,s,n,a){this.name=t,this.rank=s,this.schema=n,this.spec=a,this.attrs=d$e(t,a.attrs),this.excluded=null;let o=o$e(this.attrs);this.instance=o?new Xo(this,o):null}create(t=null){return!t&&this.instance?this.instance:new Xo(this,l$e(this.attrs,t))}static compile(t,s){let n=Object.create(null),a=0;return t.forEach((o,l)=>n[o]=new Wie(o,a++,s,l)),n}removeFromSet(t){for(var s=0;s-1}}class h$e{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let s=this.spec={};for(let a in t)s[a]=t[a];s.nodes=lu.from(t.nodes),s.marks=lu.from(t.marks||{}),this.nodes=d5e.compile(this.spec.nodes,this),this.marks=Wie.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]=rN.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?u5e(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==""?[]:u5e(this,l.split(" "))}this.nodeFromJSON=a=>P1.fromJSON(this,a),this.markFromJSON=a=>Xo.fromJSON(this,a),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,s=null,n,a){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof d5e){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(s,n,a)}text(t,s){let n=this.nodes.text;return new Ise(n,n.defaultAttrs,t,Xo.setFrom(s))}mark(t,s){return typeof t=="string"&&(t=this.marks[t]),t.create(s)}nodeType(t){let s=this.nodes[t];if(!s)throw new RangeError("Unknown node type: "+t);return s}}function u5e(e,t){let s=[];for(let n=0;n-1)&&s.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return s}function Gwt(e){return e.tag!=null}function Kwt(e){return e.style!=null}let QE=class Ope{constructor(t,s){this.schema=t,this.rules=s,this.tags=[],this.styles=[];let n=this.matchedStyles=[];s.forEach(a=>{if(Gwt(a))this.tags.push(a);else if(Kwt(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=t.nodes[a.node];return o.contentMatch.matchType(o)})}parse(t,s={}){let n=new m5e(this,s,!1);return n.addAll(t,Xo.none,s.from,s.to),n.finish()}parseSlice(t,s={}){let n=new m5e(this,s,!0);return n.addAll(t,Xo.none,s.from,s.to),nn.maxOpen(n.finish())}matchTag(t,s,n){for(let a=n?this.tags.indexOf(n)+1:0;at.length&&(i.charCodeAt(t.length)!=61||i.slice(t.length+1)!=s))){if(l.getAttrs){let d=l.getAttrs(s);if(d===!1)continue;l.attrs=d||void 0}return l}}}static schemaRules(t){let s=[];function n(a){let o=a.priority==null?50:a.priority,l=0;for(;l{n(l=f5e(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in t.nodes){let o=t.nodes[a].spec.parseDOM;o&&o.forEach(l=>{n(l=f5e(l)),l.node||l.ignore||l.mark||(l.node=a)})}return s}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Ope(t,Ope.schemaRules(t)))}};const m$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},Zwt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},f$e={ol:!0,ul:!0},tP=1,Rpe=2,JE=4;function h5e(e,t,s){return t!=null?(t?tP:0)|(t==="full"?Rpe:0):e&&e.whitespace=="pre"?tP|Rpe:s&~JE}class IO{constructor(t,s,n,a,o,l){this.type=t,this.attrs=s,this.marks=n,this.solid=a,this.options=l,this.content=[],this.activeMarks=Xo.none,this.match=o||(l&JE?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let s=this.type.contentMatch.fillBefore(_s.from(t));if(s)this.match=this.type.contentMatch.matchFragment(s);else{let n=this.type.contentMatch,a;return(a=n.findWrapping(t.type))?(this.match=n,a):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&tP)){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 s=_s.from(this.content);return!t&&this.match&&(s=s.append(this.match.fillBefore(_s.empty,!0))),this.type?this.type.create(this.attrs,s,this.marks):s}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!m$e.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class m5e{constructor(t,s,n){this.parser=t,this.options=s,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let a=s.topNode,o,l=h5e(null,s.preserveWhitespace,0)|(n?JE:0);a?o=new IO(a.type,a.attrs,Xo.none,!0,s.topMatch||a.type.contentMatch,l):n?o=new IO(null,null,Xo.none,!0,null,l):o=new IO(t.schema.topNodeType,null,Xo.none,!0,null,l),this.nodes=[o],this.find=s.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,s){t.nodeType==3?this.addTextNode(t,s):t.nodeType==1&&this.addElement(t,s)}addTextNode(t,s){let n=t.nodeValue,a=this.top,o=a.options&Rpe?"full":this.localPreserveWS||(a.options&tP)>0,{schema:l}=this.parser;if(o==="full"||a.inlineContext(t)||/[^ \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(m)):s=s.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)i=d;else break}}return s}addElementByRule(t,s,n,a){let o,l;if(s.node)if(l=this.parser.schema.nodes[s.node],l.isLeaf)this.insertNode(l.create(s.attrs),n,t.nodeName=="BR")||this.leafFallback(t,n);else{let d=this.enter(l,s.attrs||null,n,s.preserveWhitespace);d&&(o=!0,n=d)}else{let d=this.parser.schema.marks[s.mark];n=n.concat(d.create(s.attrs))}let i=this.top;if(l&&l.isLeaf)this.findInside(t);else if(a)this.addElement(t,n,a);else if(s.getContent)this.findInside(t),s.getContent(t,this.parser.schema).forEach(d=>this.insertNode(d,n,!1));else{let d=t;typeof s.contentElement=="string"?d=t.querySelector(s.contentElement):typeof s.contentElement=="function"?d=s.contentElement(t):s.contentElement&&(d=s.contentElement),this.findAround(t,d,!0),this.addAll(d,n),this.findAround(t,d,!1)}o&&this.sync(i)&&this.open--}addAll(t,s,n,a){let o=n||0;for(let l=n?t.childNodes[n]:t.firstChild,i=a==null?null:t.childNodes[a];l!=i;l=l.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(l,s);this.findAtPoint(t,o)}findPlace(t,s,n){let a,o;for(let l=this.open,i=0;l>=0;l--){let d=this.nodes[l],m=d.findWrapping(t);if(m&&(!a||a.length>m.length+i)&&(a=m,o=d,!m.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(m.type):p5e(m.type,t))?(d=m.addToSet(d),!1):!0),this.nodes.push(new IO(t,s,d,a,null,i)),this.open++,n}closeExtra(t=!1){let s=this.nodes.length-1;if(s>this.open){for(;s>this.open;s--)this.nodes[s-1].content.push(this.nodes[s].finish(t));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(t){for(let s=this.open;s>=0;s--){if(this.nodes[s]==t)return this.open=s,!0;this.localPreserveWS&&(this.nodes[s].options|=tP)}return!1}get currentPos(){this.closeExtra();let t=0;for(let s=this.open;s>=0;s--){let n=this.nodes[s].content;for(let a=n.length-1;a>=0;a--)t+=n[a].nodeSize;s&&t++}return t}findAtPoint(t,s){if(this.find)for(let n=0;n-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let s=t.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 m=s[i];if(m==""){if(i==s.length-1||i==0)continue;for(;d>=o;d--)if(l(i-1,d))return!0;return!1}else{let p=d>0||d==0&&a?this.nodes[d].type:n&&d>=o?n.node(d-o).type:null;if(!p||p.name!=m&&!p.isInGroup(m))return!1;d--}}return!0};return l(s.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let s=t.depth;s>=0;s--){let n=t.node(s).contentMatchAt(t.indexAfter(s)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let s in this.parser.schema.nodes){let n=this.parser.schema.nodes[s];if(n.isTextblock&&n.defaultAttrs)return n}}}function Ywt(e){for(let t=e.firstChild,s=null;t;t=t.nextSibling){let n=t.nodeType==1?t.nodeName.toLowerCase():null;n&&f$e.hasOwnProperty(n)&&s?(s.appendChild(t),t=s):n=="li"?s=t:n&&(s=null)}}function Xwt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function f5e(e){let t={};for(let s in e)t[s]=e[s];return t}function p5e(e,t){let s=t.schema.nodes;for(let n in s){let a=s[n];if(!a.allowsMarkType(e))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(t.marks[a],t.isInline,s);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(t,s,n={}){let a=this.marks[t.type.name];return a&&ore(Lue(n),a(t,s),null,t.attrs)}static renderSpec(t,s,n=null,a){return ore(t,s,n,a)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new wN(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let s=g5e(t.nodes);return s.text||(s.text=n=>n.text),s}static marksFromSchema(t){return g5e(t.marks)}}function g5e(e){let t={};for(let s in e){let n=e[s].spec.toDOM;n&&(t[s]=n)}return t}function Lue(e){return e.document||window.document}const x5e=new WeakMap;function Qwt(e){let t=x5e.get(e);return t===void 0&&x5e.set(e,t=Jwt(e)),t}function Jwt(e){let t=null;function s(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")t||(t=[]),t.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&&(s=a.slice(0,l),a=a.slice(l+1));let i,d=s?e.createElementNS(s,a):e.createElement(a),m=t[1],p=1;if(m&&typeof m=="object"&&m.nodeType==null&&!Array.isArray(m)){p=2;for(let g in m)if(m[g]!=null){let v=g.indexOf(" ");v>0?d.setAttributeNS(g.slice(0,v),g.slice(v+1),m[g]):g=="style"&&d.style?d.style.cssText=m[g]:d.setAttribute(g,m[g])}}for(let g=p;gp)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:_,contentDOM:k}=ore(e,v,s,n);if(d.appendChild(_),k){if(i)throw new RangeError("Multiple content holes");i=k}}}return{dom:d,contentDOM:i}}const p$e=65535,g$e=Math.pow(2,16);function e2t(e,t){return e+t*g$e}function y5e(e){return e&p$e}function t2t(e){return(e-(e&p$e))/g$e}const x$e=1,y$e=2,lre=4,v$e=8;class Fpe{constructor(t,s,n){this.pos=t,this.delInfo=s,this.recover=n}get deleted(){return(this.delInfo&v$e)>0}get deletedBefore(){return(this.delInfo&(x$e|lre))>0}get deletedAfter(){return(this.delInfo&(y$e|lre))>0}get deletedAcross(){return(this.delInfo&lre)>0}}class Mm{constructor(t,s=!1){if(this.ranges=t,this.inverted=s,!t.length&&Mm.empty)return Mm.empty}recover(t){let s=0,n=y5e(t);if(!this.inverted)for(let a=0;at)break;let m=this.ranges[i+o],p=this.ranges[i+l],g=d+m;if(t<=g){let v=m?t==d?-1:t==g?1:s:s,_=d+a+(v<0?0:p);if(n)return _;let k=t==(s<0?d:g)?null:e2t(i/3,t-d),w=t==d?y$e:t==g?x$e:lre;return(s<0?t!=d:t!=g)&&(w|=v$e),new Fpe(_,w,k)}a+=p-m}return n?t+a:new Fpe(t+a,0,null)}touches(t,s){let n=0,a=y5e(s),o=this.inverted?2:1,l=this.inverted?1:2;for(let i=0;it)break;let m=this.ranges[i+o],p=d+m;if(t<=p&&i==a*3)return!0;n+=this.ranges[i+l]-m}return!1}forEach(t){let s=this.inverted?2:1,n=this.inverted?1:2;for(let a=0,o=0;a=0;s--){let a=t.getMirror(s);this.appendMap(t._maps[s].invert(),a!=null&&a>s?n-a-1:void 0)}}invert(){let t=new rP;return t.appendMappingInverted(this),t}map(t,s=1){if(this.mirror)return this._map(t,s,!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),s.openStart,s.openEnd);return nd.fromReplace(t,this.from,this.to,o)}invert(){return new nx(this.from,this.to,this.mark)}map(t){let s=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return s.deleted&&n.deleted||s.pos>=n.pos?null:new s1(s.pos,n.pos,this.mark)}merge(t){return t instanceof s1&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new s1(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,s){if(typeof s.from!="number"||typeof s.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new s1(s.from,s.to,t.markFromJSON(s.mark))}}Uu.jsonID("addMark",s1);class nx extends Uu{constructor(t,s,n){super(),this.from=t,this.to=s,this.mark=n}apply(t){let s=t.slice(this.from,this.to),n=new nn(g1e(s.content,a=>a.mark(this.mark.removeFromSet(a.marks)),t),s.openStart,s.openEnd);return nd.fromReplace(t,this.from,this.to,n)}invert(){return new s1(this.from,this.to,this.mark)}map(t){let s=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return s.deleted&&n.deleted||s.pos>=n.pos?null:new nx(s.pos,n.pos,this.mark)}merge(t){return t instanceof nx&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new nx(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,s){if(typeof s.from!="number"||typeof s.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new nx(s.from,s.to,t.markFromJSON(s.mark))}}Uu.jsonID("removeMark",nx);class n1 extends Uu{constructor(t,s){super(),this.pos=t,this.mark=s}apply(t){let s=t.nodeAt(this.pos);if(!s)return nd.fail("No node at mark step's position");let n=s.type.create(s.attrs,null,this.mark.addToSet(s.marks));return nd.fromReplace(t,this.pos,this.pos+1,new nn(_s.from(n),0,s.isLeaf?0:1))}invert(t){let s=t.nodeAt(this.pos);if(s){let n=this.mark.addToSet(s.marks);if(n.length==s.marks.length){for(let a=0;an.pos?null:new Zd(s.pos,n.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,s){if(typeof s.from!="number"||typeof s.to!="number"||typeof s.gapFrom!="number"||typeof s.gapTo!="number"||typeof s.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Zd(s.from,s.to,s.gapFrom,s.gapTo,nn.fromJSON(t,s.slice),s.insert,!!s.structure)}}Uu.jsonID("replaceAround",Zd);function zpe(e,t,s){let n=e.resolve(t),a=s-t,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 r2t(e,t,s,n){let a=[],o=[],l,i;e.doc.nodesBetween(t,s,(d,m,p)=>{if(!d.isInline)return;let g=d.marks;if(!n.isInSet(g)&&p.type.allowsMarkType(n.type)){let v=Math.max(m,t),_=Math.min(m+d.nodeSize,s),k=n.addToSet(g);for(let w=0;we.step(d)),o.forEach(d=>e.step(d))}function s2t(e,t,s,n){let a=[],o=0;e.doc.nodesBetween(t,s,(l,i)=>{if(!l.isInline)return;o++;let d=null;if(n instanceof Wie){let m=l.marks,p;for(;p=n.isInSet(m);)(d||(d=[])).push(p),m=p.removeFromSet(m)}else n?n.isInSet(l.marks)&&(d=[n]):d=l.marks;if(d&&d.length){let m=Math.min(i+l.nodeSize,s);for(let p=0;pe.step(new nx(l.from,l.to,l.style)))}function x1e(e,t,s,n=s.contentMatch,a=!0){let o=e.doc.nodeAt(t),l=[],i=t+1;for(let d=0;d=0;d--)e.step(l[d])}function n2t(e,t,s){return(t==0||e.canReplace(t,e.childCount))&&(s==e.childCount||e.canReplace(0,s))}function D3(e){let s=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,a=0,o=0;;--n){let l=e.$from.node(n),i=e.$from.index(n)+a,d=e.$to.indexAfter(n)-o;if(ns;k--)w||n.index(k)>0?(w=!0,p=_s.from(n.node(k).copy(p)),g++):d--;let v=_s.empty,_=0;for(let k=o,w=!1;k>s;k--)w||a.after(k+1)=0;l--){if(n.size){let i=s[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=_s.from(s[l].type.create(s[l].attrs,n))}let a=t.start,o=t.end;e.step(new Zd(a,o,a,o,new nn(n,0,0),s.length,!0))}function c2t(e,t,s,n,a){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=e.steps.length;e.doc.nodesBetween(t,s,(l,i)=>{let d=typeof a=="function"?a(l):a;if(l.isTextblock&&!l.hasMarkup(n,d)&&d2t(e.doc,e.mapping.slice(o).map(i),n)){let m=null;if(n.schema.linebreakReplacement){let _=n.whitespace=="pre",k=!!n.contentMatch.matchType(n.schema.linebreakReplacement);_&&!k?m=!1:!_&&k&&(m=!0)}m===!1&&b$e(e,l,i,o),x1e(e,e.mapping.slice(o).map(i,1),n,void 0,m===null);let p=e.mapping.slice(o),g=p.map(i,1),v=p.map(i+l.nodeSize,1);return e.step(new Zd(g,v,g+1,v-1,new nn(_s.from(n.create(d,null,l.marks)),0,0),1,!0)),m===!0&&_$e(e,l,i,o),!1}})}function _$e(e,t,s,n){t.forEach((a,o)=>{if(a.isText){let l,i=/\r?\n|\r/g;for(;l=i.exec(a.text);){let d=e.mapping.slice(n).map(s+1+o+l.index);e.replaceWith(d,d+1,t.type.schema.linebreakReplacement.create())}}})}function b$e(e,t,s,n){t.forEach((a,o)=>{if(a.type==a.type.schema.linebreakReplacement){let l=e.mapping.slice(n).map(s+1+o);e.replaceWith(l,l+1,t.type.schema.text(` `))}})}function d2t(e,t,s){let n=e.resolve(t),a=n.index();return n.parent.canReplaceWith(a,a+1,s)}function u2t(e,t,s,n,a){let o=e.doc.nodeAt(t);if(!o)throw new RangeError("No node at given position");s||(s=o.type);let l=s.create(n,null,a||o.marks);if(o.isLeaf)return e.replaceWith(t,t+o.nodeSize,l);if(!s.validContent(o.content))throw new RangeError("Invalid content for node type "+s.name);e.step(new Zd(t,t+o.nodeSize,t+1,t+o.nodeSize-1,new nn(_s.from(l),0,0),1,!0))}function Wy(e,t,s=1,n){let a=e.resolve(t),o=a.depth-s,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 m=a.depth-1,p=s-2;m>o;m--,p--){let g=a.node(m),v=a.index(m);if(g.type.spec.isolating)return!1;let _=g.content.cutByIndex(v,g.childCount),k=n&&n[p+1];k&&(_=_.replaceChild(0,k.type.create(k.attrs)));let w=n&&n[p]||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 h2t(e,t,s=1,n){let a=e.doc.resolve(t),o=_s.empty,l=_s.empty;for(let i=a.depth,d=a.depth-s,m=s-1;i>d;i--,m--){o=_s.from(a.node(i).copy(o));let p=n&&n[m];l=_s.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}e.step(new qd(t,t,new nn(o.append(l),s,s),!0))}function l_(e,t){let s=e.resolve(t),n=s.index();return w$e(s.nodeBefore,s.nodeAfter)&&s.parent.canReplace(n,n+1)}function m2t(e,t){t.content.size||e.type.compatibleContent(t.type);let s=e.contentMatchAt(e.childCount),{linebreakReplacement:n}=e.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 t;if(a==0)break;t=s<0?n.before(a):n.after(a)}}function f2t(e,t,s){let n=null,{linebreakReplacement:a}=e.doc.type.schema,o=e.doc.resolve(t-s),l=o.node().type;if(a&&l.inlineContent){let p=l.whitespace=="pre",g=!!l.contentMatch.matchType(a);p&&!g?n=!1:!p&&g&&(n=!0)}let i=e.steps.length;if(n===!1){let p=e.doc.resolve(t+s);b$e(e,p.node(),p.before(),i)}l.inlineContent&&x1e(e,t+s-1,l,o.node().contentMatchAt(o.index()),n==null);let d=e.mapping.slice(i),m=d.map(t-s);if(e.step(new qd(m,d.map(t+s,-1),nn.empty,!0)),n===!0){let p=e.doc.resolve(m);_$e(e,p.node(),p.before(),e.steps.length)}return e}function p2t(e,t,s){let n=e.resolve(t);if(n.parent.canReplaceWith(n.index(),n.index(),s))return t;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,s))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,s))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),m=n.node(l),p=!1;if(o==1)p=m.canReplace(d,d,a);else{let g=m.contentMatchAt(d).findWrapping(a.firstChild.type);p=g&&m.canReplaceWith(d,d,g[0])}if(p)return i==0?n.pos:i<0?n.before(l+1):n.after(l+1)}return null}function Kie(e,t,s=t,n=nn.empty){if(t==s&&!n.size)return null;let a=e.resolve(t),o=e.resolve(s);return k$e(a,o,n)?new qd(t,s,n):new g2t(a,o,n).fit()}function k$e(e,t,s){return!s.openStart&&!s.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),s.content)}class g2t{constructor(t,s,n){this.$from=t,this.$to=s,this.unplaced=n,this.frontier=[],this.placed=_s.empty;for(let a=0;a<=t.depth;a++){let o=t.node(a);this.frontier.push({type:o.type,match:o.contentMatchAt(t.indexAfter(a))})}for(let a=t.depth;a>0;a--)this.placed=_s.from(t.node(a).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let m=this.findFittable();m?this.placeNodes(m):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),s=this.placed.size-this.depth-this.$from.depth,n=this.$from,a=this.close(t<0?this.$to:n.doc.resolve(t));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 nn(o,l,i);return t>-1?new Zd(n.pos,t,this.$to.pos,this.$to.end(),d,s):d.size||n.pos!=this.$to.pos?new qd(n.pos,a.pos,d):null}findFittable(){let t=this.unplaced.openStart;for(let s=this.unplaced.content,n=0,a=this.unplaced.openEnd;n1&&(a=0),o.type.spec.isolating&&a<=n){t=n;break}s=o.content}for(let s=1;s<=2;s++)for(let n=s==1?t:this.unplaced.openStart;n>=0;n--){let a,o=null;n?(o=Oue(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:m}=this.frontier[i],p,g=null;if(s==1&&(l?m.matchType(l.type)||(g=m.fillBefore(_s.from(l),!1)):o&&d.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:i,parent:o,inject:g};if(s==2&&l&&(p=m.findWrapping(l.type)))return{sliceDepth:n,frontierDepth:i,parent:o,wrap:p};if(o&&m.matchType(o.type))break}}}openMore(){let{content:t,openStart:s,openEnd:n}=this.unplaced,a=Oue(t,s);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new nn(t,s+1,Math.max(n,a.size+s>=t.size-n?s+1:0)),!0)}dropNode(){let{content:t,openStart:s,openEnd:n}=this.unplaced,a=Oue(t,s);if(a.childCount<=1&&s>0){let o=t.size-s<=s+a.size;this.unplaced=new nn(WA(t,s-1,1),s-1,o?s-1:n)}else this.unplaced=new nn(WA(t,s,1),s,n)}placeNodes({sliceDepth:t,frontierDepth:s,parent:n,inject:a,wrap:o}){for(;this.depth>s;)this.closeFrontierNode();if(o)for(let w=0;w1||d==0||w.content.size)&&(g=S,p.push(N$e(w.mark(v.allowedMarks(w.marks)),m==1?d:0,m==i.childCount?_:-1)))}let k=m==i.childCount;k||(_=-1),this.placed=GA(this.placed,s,_s.from(p)),this.frontier[s].match=g,k&&_<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,S=i;w<_;w++){let T=S.lastChild;this.frontier.push({type:T.type,match:T.contentMatchAt(T.childCount)}),S=T.content}this.unplaced=k?t==0?nn.empty:new nn(WA(l.content,t-1,1),t-1,_<0?l.openEnd:t-1):new nn(WA(l.content,t,m),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t=this.frontier[this.depth],s;if(!t.type.isTextblock||!Rue(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(s=this.findCloseLevel(this.$to))&&s.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(t){e:for(let s=Math.min(this.depth,t.depth);s>=0;s--){let{match:n,type:a}=this.frontier[s],o=s=0;i--){let{match:d,type:m}=this.frontier[i],p=Rue(t,i,m,d,!0);if(!p||p.childCount)continue e}return{depth:s,fit:l,move:o?t.doc.resolve(t.after(s+1)):t}}}}close(t){let s=this.findCloseLevel(t);if(!s)return null;for(;this.depth>s.depth;)this.closeFrontierNode();s.fit.childCount&&(this.placed=GA(this.placed,s.depth,s.fit)),t=s.move;for(let n=s.depth+1;n<=t.depth;n++){let a=t.node(n),o=a.type.contentMatch.fillBefore(a.content,!0,t.index(n));this.openFrontierNode(a.type,a.attrs,o)}return t}openFrontierNode(t,s=null,n){let a=this.frontier[this.depth];a.match=a.match.matchType(t),this.placed=GA(this.placed,this.depth,_s.from(t.create(s,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let s=this.frontier.pop().match.fillBefore(_s.empty,!0);s.childCount&&(this.placed=GA(this.placed,this.frontier.length,s))}}function WA(e,t,s){return t==0?e.cutByIndex(s,e.childCount):e.replaceChild(0,e.firstChild.copy(WA(e.firstChild.content,t-1,s)))}function GA(e,t,s){return t==0?e.append(s):e.replaceChild(e.childCount-1,e.lastChild.copy(GA(e.lastChild.content,t-1,s)))}function Oue(e,t){for(let s=0;s1&&(n=n.replaceChild(0,N$e(n.firstChild,t-1,n.childCount==1?s-1:0))),t>0&&(n=e.type.contentMatch.fillBefore(n).append(n),s<=0&&(n=n.append(e.type.contentMatch.matchFragment(n).fillBefore(_s.empty,!0)))),e.copy(n)}function Rue(e,t,s,n,a){let o=e.node(t),l=a?e.indexAfter(t):e.index(t);if(l==o.childCount&&!s.compatibleContent(o.type))return null;let i=n.fillBefore(o.content,!0,l);return i&&!x2t(s,o.content,l)?i:null}function x2t(e,t,s){for(let n=s;n0;v--,_--){let k=a.node(v).type.spec;if(k.defining||k.definingAsContext||k.isolating)break;l.indexOf(v)>-1?i=v:a.before(v)==_&&l.splice(1,0,-v)}let d=l.indexOf(i),m=[],p=n.openStart;for(let v=n.content,_=0;;_++){let k=v.firstChild;if(m.push(k),_==n.openStart)break;v=k.content}for(let v=p-1;v>=0;v--){let _=m[v],k=y2t(_.type);if(k&&!_.sameMarkup(a.node(Math.abs(i)-1)))p=v;else if(k||!_.type.isTextblock)break}for(let v=n.openStart;v>=0;v--){let _=(v+p+1)%(n.openStart+1),k=m[_];if(k)for(let w=0;w=0&&(e.replace(t,s,n),!(e.steps.length>g));v--){let _=l[v];_<0||(t=a.before(_),s=o.after(_))}}function S$e(e,t,s,n,a){if(tn){let o=a.contentMatchAt(0),l=o.fillBefore(e).append(e);e=l.append(o.matchFragment(l).fillBefore(_s.empty,!0))}return e}function _2t(e,t,s,n){if(!n.isInline&&t==s&&e.doc.resolve(t).parent.content.size){let a=p2t(e.doc,t,n.type);a!=null&&(t=s=a)}e.replaceRange(t,s,new nn(_s.from(n),0,0))}function b2t(e,t,s){let n=e.doc.resolve(t),a=e.doc.resolve(s),o=C$e(n,a);for(let l=0;l0&&(d||n.node(i-1).canReplace(n.index(i-1),a.indexAfter(i-1))))return e.delete(n.before(i),a.after(i))}for(let l=1;l<=n.depth&&l<=a.depth;l++)if(t-n.start(l)==n.depth-l&&s>n.end(l)&&a.end(l)-s!=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 e.delete(n.before(l),s);e.delete(t,s)}function C$e(e,t){let s=[],n=Math.min(e.depth,t.depth);for(let a=n;a>=0;a--){let o=e.start(a);if(ot.pos+(t.depth-a)||e.node(a).type.spec.isolating||t.node(a).type.spec.isolating)break;(o==t.start(a)||a==e.depth&&a==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&a&&t.start(a-1)==o-1)&&s.push(a)}return s}class X4 extends Uu{constructor(t,s,n){super(),this.pos=t,this.attr=s,this.value=n}apply(t){let s=t.nodeAt(this.pos);if(!s)return nd.fail("No node at attribute step's position");let n=Object.create(null);for(let o in s.attrs)n[o]=s.attrs[o];n[this.attr]=this.value;let a=s.type.create(n,null,s.marks);return nd.fromReplace(t,this.pos,this.pos+1,new nn(_s.from(a),0,s.isLeaf?0:1))}getMap(){return Mm.empty}invert(t){return new X4(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let s=t.mapResult(this.pos,1);return s.deletedAfter?null:new X4(s.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,s){if(typeof s.pos!="number"||typeof s.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new X4(s.pos,s.attr,s.value)}}Uu.jsonID("attr",X4);class sP extends Uu{constructor(t,s){super(),this.attr=t,this.value=s}apply(t){let s=Object.create(null);for(let a in t.attrs)s[a]=t.attrs[a];s[this.attr]=this.value;let n=t.type.create(s,t.content,t.marks);return nd.ok(n)}getMap(){return Mm.empty}invert(t){return new sP(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,s){if(typeof s.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new sP(s.attr,s.value)}}Uu.jsonID("docAttr",sP);let z5=class extends Error{};z5=function e(t){let s=Error.call(this,t);return s.__proto__=e.prototype,s};z5.prototype=Object.create(Error.prototype);z5.prototype.constructor=z5;z5.prototype.name="TransformError";class v1e{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new rP}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let s=this.maybeStep(t);if(s.failed)throw new z5(s.failed);return this}maybeStep(t){let s=t.apply(this.doc);return s.failed||this.addStep(t,s.doc),s}get docChanged(){return this.steps.length>0}addStep(t,s){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=s}replace(t,s=t,n=nn.empty){let a=Kie(this.doc,t,s,n);return a&&this.step(a),this}replaceWith(t,s,n){return this.replace(t,s,new nn(_s.from(n),0,0))}delete(t,s){return this.replace(t,s,nn.empty)}insert(t,s){return this.replaceWith(t,t,s)}replaceRange(t,s,n){return v2t(this,t,s,n),this}replaceRangeWith(t,s,n){return _2t(this,t,s,n),this}deleteRange(t,s){return b2t(this,t,s),this}lift(t,s){return a2t(this,t,s),this}join(t,s=1){return f2t(this,t,s),this}wrap(t,s){return l2t(this,t,s),this}setBlockType(t,s=t,n,a=null){return c2t(this,t,s,n,a),this}setNodeMarkup(t,s,n=null,a){return u2t(this,t,s,n,a),this}setNodeAttribute(t,s,n){return this.step(new X4(t,s,n)),this}setDocAttribute(t,s){return this.step(new sP(t,s)),this}addNodeMark(t,s){return this.step(new n1(t,s)),this}removeNodeMark(t,s){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(s instanceof Xo)s.isInSet(n.marks)&&this.step(new sN(t,s));else{let a=n.marks,o,l=[];for(;o=s.isInSet(a);)l.push(new sN(t,o)),a=o.removeFromSet(a);for(let i=l.length-1;i>=0;i--)this.step(l[i])}return this}split(t,s=1,n){return h2t(this,t,s,n),this}addMark(t,s,n){return r2t(this,t,s,n),this}removeMark(t,s,n){return s2t(this,t,s,n),this}clearIncompatible(t,s,n){return x1e(this,t,s,n),this}}const Fue=Object.create(null);class Va{constructor(t,s,n){this.$anchor=t,this.$head=s,this.ranges=n||[new M$e(t.min(s),t.max(s))]}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 t=this.ranges;for(let s=0;s=0;o--){let l=s<0?OC(t.node(0),t.node(o),t.before(o+1),t.index(o),s,n):OC(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,s,n);if(l)return l}return null}static near(t,s=1){return this.findFrom(t,s)||this.findFrom(t,-s)||new Um(t.node(0))}static atStart(t){return OC(t,t,0,0,1)||new Um(t)}static atEnd(t){return OC(t,t,t.content.size,t.childCount,-1)||new Um(t)}static fromJSON(t,s){if(!s||!s.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Fue[s.type];if(!n)throw new RangeError(`No selection type ${s.type} defined`);return n.fromJSON(t,s)}static jsonID(t,s){if(t in Fue)throw new RangeError("Duplicate use of selection JSON ID "+t);return Fue[t]=s,s.prototype.jsonID=t,s}getBookmark(){return Ca.between(this.$anchor,this.$head).getBookmark()}}Va.prototype.visible=!0;class M$e{constructor(t,s){this.$from=t,this.$to=s}}let _5e=!1;function b5e(e){!_5e&&!e.parent.inlineContent&&(_5e=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Ca extends Va{constructor(t,s=t){b5e(t),b5e(s),super(t,s)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,s){let n=t.resolve(s.map(this.head));if(!n.parent.inlineContent)return Va.near(n);let a=t.resolve(s.map(this.anchor));return new Ca(a.parent.inlineContent?a:n,n)}replace(t,s=nn.empty){if(super.replace(t,s),s==nn.empty){let n=this.$from.marksAcross(this.$to);n&&t.ensureMarks(n)}}eq(t){return t instanceof Ca&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Zie(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,s){if(typeof s.anchor!="number"||typeof s.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ca(t.resolve(s.anchor),t.resolve(s.head))}static create(t,s,n=s){let a=t.resolve(s);return new this(a,n==s?a:t.resolve(n))}static between(t,s,n){let a=t.pos-s.pos;if((!n||a)&&(n=a>=0?1:-1),!s.parent.inlineContent){let o=Va.findFrom(s,n,!0)||Va.findFrom(s,-n,!0);if(o)s=o.$head;else return Va.near(s,n)}return t.parent.inlineContent||(a==0?t=s:(t=(Va.findFrom(t,-n,!0)||Va.findFrom(t,n,!0)).$anchor,t.pos0?0:1);a>0?l=0;l+=a){let i=t.child(l);if(i.isAtom){if(!o&&ba.isSelectable(i))return ba.create(e,s-(a<0?i.nodeSize:0))}else{let d=OC(e,i,s+a,a<0?i.childCount:0,a,o);if(d)return d}s+=i.nodeSize*a}return null}function w5e(e,t,s){let n=e.steps.length-1;if(n{l==null&&(l=p)}),e.setSelection(Va.near(e.doc.resolve(l),s))}const j5e=1,PO=2,k5e=4;class j2t extends v1e{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(t){return this.storedMarks=t,this.updated|=PO,this}ensureMarks(t){return Xo.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&PO)>0}addStep(t,s){super.addStep(t,s),this.updated=this.updated&~PO,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,s=!0){let n=this.selection;return s&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Xo.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,s,n){let a=this.doc.type.schema;if(s==null)return t?this.replaceSelectionWith(a.text(t),!0):this.deleteSelection();{if(n==null&&(n=s),!t)return this.deleteRange(s,n);let o=this.storedMarks;if(!o){let l=this.doc.resolve(s);o=n==s?l.marks():l.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(s,n,a.text(t,o)),!this.selection.empty&&this.selection.to==s+t.length&&this.setSelection(Va.near(this.selection.$to)),this}}setMeta(t,s){return this.meta[typeof t=="string"?t:t.key]=s,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=k5e,this}get scrolledIntoView(){return(this.updated&k5e)>0}}function N5e(e,t){return!t||!e?e:e.bind(t)}class KA{constructor(t,s,n){this.name=t,this.init=N5e(s.init,n),this.apply=N5e(s.apply,n)}}const k2t=[new KA("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new KA("selection",{init(e,t){return e.selection||Va.atStart(t.doc)},apply(e){return e.selection}}),new KA("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,s,n){return n.selection.$cursor?e.storedMarks:null}}),new KA("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class zue{constructor(t,s){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=k2t.slice(),s&&s.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 KA(n.key,n.spec.state,n))})}}class QC{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,s=-1){for(let n=0;nn.toJSON())),t&&typeof t=="object")for(let n in t){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let a=t[n],o=a.spec.state;o&&o.toJSON&&(s[n]=o.toJSON.call(a,this[a.key]))}return s}static fromJSON(t,s,n){if(!s)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let a=new zue(t.schema,t.plugins),o=new QC(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=P1.fromJSON(t.schema,s.doc);else if(l.name=="selection")o.selection=Va.fromJSON(o.doc,s.selection);else if(l.name=="storedMarks")s.storedMarks&&(o.storedMarks=s.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let d=n[i],m=d.spec.state;if(d.key==l.name&&m&&m.fromJSON&&Object.prototype.hasOwnProperty.call(s,i)){o[l.name]=m.fromJSON.call(d,t,s[i],o);return}}o[l.name]=l.init(t,o)}}),o}}function T$e(e,t,s){for(let n in e){let a=e[n];a instanceof Function?a=a.bind(t):n=="handleDOMEvents"&&(a=T$e(a,t,{})),s[n]=a}return s}class Td{constructor(t){this.spec=t,this.props={},t.props&&T$e(t.props,this,this.props),this.key=t.key?t.key.key:A$e("plugin")}getState(t){return t[this.key]}}const Bue=Object.create(null);function A$e(e){return e in Bue?e+"$"+ ++Bue[e]:(Bue[e]=0,e+"$")}class Vu{constructor(t="key"){this.key=A$e(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const uu=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},B5=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let Bpe=null;const yy=function(e,t,s){let n=Bpe||(Bpe=document.createRange());return n.setEnd(e,s??e.nodeValue.length),n.setStart(e,t||0),n},N2t=function(){Bpe=null},nN=function(e,t,s,n){return s&&(S5e(e,t,s,n,-1)||S5e(e,t,s,n,1))},S2t=/^(img|br|input|textarea|hr)$/i;function S5e(e,t,s,n,a){for(var o;;){if(e==s&&t==n)return!0;if(t==(a<0?0:Cf(e))){let l=e.parentNode;if(!l||l.nodeType!=1||E6(e)||S2t.test(e.nodeName)||e.contentEditable=="false")return!1;t=uu(e)+(a<0?0:1),e=l}else if(e.nodeType==1){let l=e.childNodes[t+(a<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((o=l.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)t+=a;else return!1;else e=l,t=a<0?Cf(e):0}else return!1}}function Cf(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function C2t(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable=="false")return null;e=e.childNodes[t-1],t=Cf(e)}else if(e.parentNode&&!E6(e))t=uu(e),e=e.parentNode;else return null}}function M2t(e,t){for(;;){if(e.nodeType==3&&t2),_f=$5||(Nx?/Mac/.test(Nx.platform):!1),P$e=Nx?/Win/.test(Nx.platform):!1,Ty=/Android \d/.test(c_),I6=!!C5e&&"webkitFontSmoothing"in C5e.documentElement.style,I2t=I6?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function P2t(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function ly(e,t){return typeof e=="number"?e:e[t]}function L2t(e){let t=e.getBoundingClientRect(),s=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*s,top:t.top,bottom:t.top+e.clientHeight*n}}function M5e(e,t,s){let n=e.someProp("scrollThreshold")||0,a=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let l=s||e.dom;l;){if(l.nodeType!=1){l=B5(l);continue}let i=l,d=i==o.body,m=d?P2t(o):L2t(i),p=0,g=0;if(t.topm.bottom-ly(n,"bottom")&&(g=t.bottom-t.top>m.bottom-m.top?t.top+ly(a,"top")-m.top:t.bottom-m.bottom+ly(a,"bottom")),t.leftm.right-ly(n,"right")&&(p=t.right-m.right+ly(a,"right")),p||g)if(d)o.defaultView.scrollBy(p,g);else{let _=i.scrollLeft,k=i.scrollTop;g&&(i.scrollTop+=g),p&&(i.scrollLeft+=p);let w=i.scrollLeft-_,S=i.scrollTop-k;t={left:t.left-w,top:t.top-S,right:t.right-w,bottom:t.bottom-S}}let v=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(v))break;l=v=="absolute"?l.offsetParent:B5(l)}}function D2t(e){let t=e.dom.getBoundingClientRect(),s=Math.max(0,t.top),n,a;for(let o=(t.left+t.right)/2,l=s+1;l=s-20){n=i,a=d.top;break}}return{refDOM:n,refTop:a,stack:L$e(e.dom)}}function L$e(e){let t=[],s=e.ownerDocument;for(let n=e;n&&(t.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),e!=s);n=B5(n));return t}function O2t({refDOM:e,refTop:t,stack:s}){let n=e?e.getBoundingClientRect().top:0;D$e(s,n==0?0:n-t)}function D$e(e,t){for(let s=0;s=i){l=Math.max(k.bottom,l),i=Math.min(k.top,i);let w=k.left>t.left?k.left-t.left:k.right=(k.left+k.right)/2?1:0));continue}}else k.top>t.top&&!d&&k.left<=t.left&&k.right>=t.left&&(d=p,m={left:Math.max(k.left,Math.min(k.right,t.left)),top:k.top});!s&&(t.left>=k.right&&t.top>=k.top||t.left>=k.left&&t.top>=k.bottom)&&(o=g+1)}}return!s&&d&&(s=d,a=m,n=0),s&&s.nodeType==3?F2t(s,a):!s||n&&s.nodeType==1?{node:e,offset:o}:O$e(s,a)}function F2t(e,t){let s=e.nodeValue.length,n=document.createRange(),a;for(let o=0;o=(l.left+l.right)/2?1:0)};break}}return n.detach(),a||{node:e,offset:0}}function b1e(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function z2t(e,t){let s=e.parentNode;return s&&/^li$/i.test(s.nodeName)&&t.left(l.left+l.right)/2?1:-1}return e.docView.posFromDOM(n,a,o)}function $2t(e,t,s,n){let a=-1;for(let o=t,l=!1;o!=e.dom;){let i=e.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:e.docView.posFromDOM(t,s,-1)}function R$e(e,t,s){let n=e.childNodes.length;if(n&&s.topt.top&&a++}let m;I6&&a&&n.nodeType==1&&(m=n.childNodes[a-1]).nodeType==1&&m.contentEditable=="false"&&m.getBoundingClientRect().top>=t.top&&a--,n==e.dom&&a==n.childNodes.length-1&&n.lastChild.nodeType==1&&t.top>n.lastChild.getBoundingClientRect().bottom?i=e.state.doc.content.size:(a==0||n.nodeType!=1||n.childNodes[a-1].nodeName!="BR")&&(i=$2t(e,n,a,t))}i==null&&(i=B2t(e,l,t));let d=e.docView.nearestDesc(l,!0);return{pos:i,inside:d?d.posAtStart-d.border:-1}}function T5e(e){return e.top=0&&a==n.nodeValue.length?(d--,p=1):s<0?d--:m++,vA(gv(yy(n,d,m),p),p<0)}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(o==null&&a&&(s<0||a==Cf(n))){let d=n.childNodes[a-1];if(d.nodeType==1)return $ue(d.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(s<0||a==Cf(n))){let d=n.childNodes[a-1],m=d.nodeType==3?yy(d,Cf(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(m)return vA(gv(m,1),!1)}if(o==null&&a=0)}function vA(e,t){if(e.width==0)return e;let s=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:s,right:s}}function $ue(e,t){if(e.height==0)return e;let s=t?e.top:e.bottom;return{top:s,bottom:s,left:e.left,right:e.right}}function z$e(e,t,s){let n=e.state,a=e.root.activeElement;n!=t&&e.updateState(t),a!=e.dom&&e.focus();try{return s()}finally{n!=t&&e.updateState(n),a!=e.dom&&a&&a.focus()}}function q2t(e,t,s){let n=t.selection,a=s=="up"?n.$from:n.$to;return z$e(e,t,()=>{let{node:o}=e.docView.domFromPos(a.pos,s=="up"?-1:1);for(;;){let i=e.docView.nearestDesc(o,!0);if(!i)break;if(i.node.isBlock){o=i.contentDOM||i.dom;break}o=i.dom.parentNode}let l=F$e(e,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=yy(i,0,i.nodeValue.length).getClientRects();else continue;for(let m=0;mp.top+1&&(s=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const H2t=/[\u0590-\u08ac]/;function W2t(e,t,s){let{$head:n}=t.selection;if(!n.parent.isTextblock)return!1;let a=n.parentOffset,o=!a,l=a==n.parent.content.size,i=e.domSelection();return i?!H2t.test(n.parent.textContent)||!i.modify?s=="left"||s=="backward"?o:l:z$e(e,t,()=>{let{focusNode:d,focusOffset:m,anchorNode:p,anchorOffset:g}=e.domSelectionRange(),v=i.caretBidiLevel;i.modify("move",s,"character");let _=n.depth?e.docView.domAfterPos(n.before()):e.dom,{focusNode:k,focusOffset:w}=e.domSelectionRange(),S=k&&!_.contains(k.nodeType==1?k:k.parentNode)||d==k&&m==w;try{i.collapse(p,g),d&&(d!=p||m!=g)&&i.extend&&i.extend(d,m)}catch{}return v!=null&&(i.caretBidiLevel=v),S}):n.pos==n.start()||n.pos==n.end()}let A5e=null,E5e=null,I5e=!1;function G2t(e,t,s){return A5e==t&&E5e==s?I5e:(A5e=t,E5e=s,I5e=s=="up"||s=="down"?q2t(e,t,s):W2t(e,t,s))}const Vf=0,P5e=1,Hj=2,Sx=3;class P6{constructor(t,s,n,a){this.parent=t,this.children=s,this.dom=n,this.contentDOM=a,this.dirty=Vf,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,s,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let s=0;suu(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))a=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(s==0)for(let o=t;;o=o.parentNode){if(o==this.dom){a=!1;break}if(o.previousSibling)break}if(a==null&&s==t.childNodes.length)for(let o=t;;o=o.parentNode){if(o==this.dom){a=!0;break}if(o.nextSibling)break}}return a??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,s=!1){for(let n=!0,a=t;a;a=a.parentNode){let o=this.getDesc(a),l;if(o&&(!s||o.node))if(n&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(t.nodeType==1?t:t.parentNode):l==t))n=!1;else return o}}getDesc(t){let s=t.pmViewDesc;for(let n=s;n;n=n.parent)if(n==this)return s}posFromDOM(t,s,n){for(let a=t;a;a=a.parentNode){let o=this.getDesc(a);if(o)return o.localPosFromDOM(t,s,n)}return-1}descAt(t){for(let s=0,n=0;st||l instanceof $$e){a=t-o;break}o=i}if(a)return this.children[n].domFromPos(a-this.children[n].border,s);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof B$e&&o.side>=0;n--);if(s<=0){let o,l=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,l=!1);return o&&s&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,s):{node:this.contentDOM,offset:o?uu(o.dom)+1:0}}else{let o,l=!0;for(;o=n=p&&s<=m-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(t,s,p);t=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=uu(v.dom)+1;break}t-=v.size}a==-1&&(a=0)}if(a>-1&&(m>s||i==this.children.length-1)){s=m;for(let p=i+1;pk&&ls){let k=i;i=d,d=k}let _=document.createRange();_.setEnd(d.node,d.offset),_.setStart(i.node,i.offset),m.removeAllRanges(),m.addRange(_)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,s){for(let n=0,a=0;a=n:tn){let i=n+o.border,d=l-o.border;if(t>=i&&s<=d){this.dirty=t==n||s==l?Hj:P5e,t==i&&s==d&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Sx:o.markDirty(t-i,s-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Hj:Sx}n=l}this.dirty=Hj}markParentsDirty(){let t=1;for(let s=this.parent;s;s=s.parent,t++){let n=t==1?Hj:P5e;s.dirty{if(!o)return a;if(o.parent)return o.parent.posBeforeChild(o)})),!s.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(t,[],l,null),this.widget=s,this.widget=s,o=this}matchesWidget(t){return this.dirty==Vf&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let s=this.widget.spec.stopEvent;return s?s(t):!1}ignoreMutation(t){return t.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 K2t extends P6{constructor(t,s,n,a){super(t,[],s,null),this.textDOM=n,this.text=a}get size(){return this.text.length}localPosFromDOM(t,s){return t!=this.textDOM?this.posAtStart+(s?this.size:0):this.posAtStart+s}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class aN extends P6{constructor(t,s,n,a,o){super(t,[],n,a),this.mark=s,this.spec=o}static create(t,s,n,a){let o=a.nodeViews[s.type.name],l=o&&o(s,a,n);return(!l||!l.dom)&&(l=wN.renderSpec(document,s.type.spec.toDOM(s,n),null,s.attrs)),new aN(t,s,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&Sx||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Sx&&this.mark.eq(t)}markDirty(t,s){if(super.markDirty(t,s),this.dirty!=Vf){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=Hpe(o,0,t,n));for(let i=0;i{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},n,a),p=m&&m.dom,g=m&&m.contentDOM;if(s.isText){if(!p)p=document.createTextNode(s.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:g}=wN.renderSpec(document,s.type.spec.toDOM(s),null,s.attrs));!g&&!s.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),s.type.spec.draggable&&(p.draggable=!0));let v=p;return p=q$e(p,n,s),m?d=new Z2t(t,s,n,a,p,g||null,v,m,o,l+1):s.isText?new Xie(t,s,n,a,p,v,o):new D1(t,s,n,a,p,g||null,v,o,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let s=this.children.length-1;s>=0;s--){let n=this.children[s];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>_s.empty)}return t}matchesNode(t,s,n){return this.dirty==Vf&&t.eq(this.node)&&Pse(s,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,s){let n=this.node.inlineContent,a=s,o=t.composing?this.localCompositionInfo(t,s):null,l=o&&o.pos>-1?o:null,i=o&&o.pos<0,d=new X2t(this,l&&l.node,t);ejt(this.node,this.innerDeco,(m,p,g)=>{m.spec.marks?d.syncToMarks(m.spec.marks,n,t):m.type.side>=0&&!g&&d.syncToMarks(p==this.node.childCount?Xo.none:this.node.child(p).marks,n,t),d.placeWidget(m,t,a)},(m,p,g,v)=>{d.syncToMarks(m.marks,n,t);let _;d.findNodeMatch(m,p,g,v)||i&&t.state.selection.from>a&&t.state.selection.to-1&&d.updateNodeAt(m,p,g,_,t)||d.updateNextNode(m,p,g,t,v,a)||d.addNode(m,p,g,t,a),a+=m.nodeSize}),d.syncToMarks([],n,t),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==Hj)&&(l&&this.protectLocalComposition(t,l),U$e(this.contentDOM,this.children,t),$5&&tjt(this.dom))}localCompositionInfo(t,s){let{from:n,to:a}=t.state.selection;if(!(t.state.selection instanceof Ca)||ns+this.node.content.size)return null;let o=t.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,i=rjt(this.node.content,l,n-s,a-s);return i<0?null:{node:o,pos:i,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(t,{node:s,pos:n,text:a}){if(this.getDesc(s))return;let o=s;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 K2t(this,o,s,a);t.input.compositionNodes.push(l),this.children=Hpe(this.children,n,n+a.length,t,l)}update(t,s,n,a){return this.dirty==Sx||!t.sameMarkup(this.node)?!1:(this.updateInner(t,s,n,a),!0)}updateInner(t,s,n,a){this.updateOuterDeco(s),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(a,this.posAtStart),this.dirty=Vf}updateOuterDeco(t){if(Pse(t,this.outerDeco))return;let s=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=V$e(this.dom,this.nodeDOM,qpe(this.outerDeco,this.node,s),qpe(t,this.node,s)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}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 L5e(e,t,s,n,a){q$e(n,t,e);let o=new D1(void 0,e,t,s,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class Xie extends D1{constructor(t,s,n,a,o,l,i){super(t,s,n,a,o,null,l,i,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,s,n,a){return this.dirty==Sx||this.dirty!=Vf&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(s),(this.dirty!=Vf||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,a.trackWrites==this.nodeDOM&&(a.trackWrites=null)),this.node=t,this.dirty=Vf,!0)}inParent(){let t=this.parent.contentDOM;for(let s=this.nodeDOM;s;s=s.parentNode)if(s==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,s,n){return t==this.nodeDOM?this.posAtStart+Math.min(s,this.node.text.length):super.localPosFromDOM(t,s,n)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,s,n){let a=this.node.cut(t,s),o=document.createTextNode(a.text);return new Xie(this.parent,a,this.outerDeco,this.innerDeco,o,o,n)}markDirty(t,s){super.markDirty(t,s),this.dom!=this.nodeDOM&&(t==0||s==this.nodeDOM.nodeValue.length)&&(this.dirty=Sx)}get domAtom(){return!1}isText(t){return this.node.text==t}}class $$e extends P6{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==Vf&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Z2t extends D1{constructor(t,s,n,a,o,l,i,d,m,p){super(t,s,n,a,o,l,i,m,p),this.spec=d}update(t,s,n,a){if(this.dirty==Sx)return!1;if(this.spec.update&&(this.node.type==t.type||this.spec.multiType)){let o=this.spec.update(t,s,n);return o&&this.updateInner(t,s,n,a),o}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,s,n,a)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,s,n,a){this.spec.setSelection?this.spec.setSelection(t,s,n.root):super.setSelection(t,s,n,a)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function U$e(e,t,s){let n=e.firstChild,a=!1;for(let o=0;o>1,l=Math.min(o,t.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=aN.create(this.top,t[o],s,n);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(t,s,n,a){let o=-1,l;if(a>=this.preMatch.index&&(l=this.preMatch.matches[a-this.preMatch.index]).parent==this.top&&l.matchesNode(t,s,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 m=s.children[n-1];if(m instanceof aN)s=m,n=m.children.length;else{i=m,n--;break}}else{if(s==t)break e;n=s.parent.children.indexOf(s),s=s.parent}let d=i.node;if(d){if(d!=e.child(a-1))break;--a,o.set(i,a),l.push(i)}}return{index:a,matched:o,matches:l.reverse()}}function J2t(e,t){return e.type.side-t.type.side}function ejt(e,t,s,n){let a=t.locals(e),o=0;if(a.length==0){for(let m=0;mo;)i.push(a[l++]);let k=o+v.nodeSize;if(v.isText){let S=k;l!S.inline):i.slice();n(v,w,t.forChild(o,v),_),o=k}}function tjt(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function rjt(e,t,s,n){for(let a=0,o=0;a=s){if(o>=n&&d.slice(n-t.length-i,n-i)==t)return n-t.length;let m=i=0&&m+t.length+i>=s)return i+m;if(s==n&&d.length>=n+t.length-i&&d.slice(n-i,n-i+t.length)==t)return n}}return-1}function Hpe(e,t,s,n,a){let o=[];for(let l=0,i=0;l=s||p<=t?o.push(d):(ms&&o.push(d.slice(s-m,d.size,n)))}return o}function w1e(e,t=null){let s=e.domSelectionRange(),n=e.state.doc;if(!s.focusNode)return null;let a=e.docView.nearestDesc(s.focusNode),o=a&&a.size==0,l=e.docView.posFromDOM(s.focusNode,s.focusOffset,1);if(l<0)return null;let i=n.resolve(l),d,m;if(Yie(s)){for(d=l;a&&!a.node;)a=a.parent;let g=a.node;if(a&&g.isAtom&&ba.isSelectable(g)&&a.parent&&!(g.isInline&&T2t(s.focusNode,s.focusOffset,a.dom))){let v=a.posBefore;m=new ba(l==v?i:n.resolve(v))}}else{if(s instanceof e.dom.ownerDocument.defaultView.Selection&&s.rangeCount>1){let g=l,v=l;for(let _=0;_{(s.anchorNode!=n||s.anchorOffset!=a)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!H$e(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function njt(e){let t=e.domSelection();if(!t)return;let s=e.cursorWrapper.dom,n=s.nodeName=="IMG";n?t.collapse(s.parentNode,uu(s)+1):t.collapse(s,0),!n&&!e.state.selection.visible&&tm&&L1<=11&&(s.disabled=!0,s.disabled=!1)}function W$e(e,t){if(t instanceof ba){let s=e.docView.descAt(t.from);s!=e.lastSelectedViewDesc&&(z5e(e),s&&s.selectNode(),e.lastSelectedViewDesc=s)}else z5e(e)}function z5e(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function j1e(e,t,s,n){return e.someProp("createSelectionBetween",a=>a(e,t,s))||Ca.between(t,s,n)}function B5e(e){return e.editable&&!e.hasFocus()?!1:G$e(e)}function G$e(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function ajt(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),s=e.domSelectionRange();return nN(t.node,t.offset,s.anchorNode,s.anchorOffset)}function Wpe(e,t){let{$anchor:s,$head:n}=e.selection,a=t>0?s.max(n):s.min(n),o=a.parent.inlineContent?a.depth?e.doc.resolve(t>0?a.after():a.before()):null:a;return o&&Va.findFrom(o,t)}function Mv(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function $5e(e,t,s){let n=e.state.selection;if(n instanceof Ca)if(s.indexOf("s")>-1){let{$head:a}=n,o=a.textOffset?null:t<0?a.nodeBefore:a.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let l=e.state.doc.resolve(a.pos+o.nodeSize*(t<0?-1:1));return Mv(e,new Ca(n.$anchor,l))}else if(n.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let a=Wpe(e.state,t);return a&&a instanceof ba?Mv(e,a):!1}else if(!(_f&&s.indexOf("m")>-1)){let a=n.$head,o=a.textOffset?null:t<0?a.nodeBefore:a.nodeAfter,l;if(!o||o.isText)return!1;let i=t<0?a.pos-o.nodeSize:a.pos;return o.isAtom||(l=e.docView.descAt(i))&&!l.contentDOM?ba.isSelectable(o)?Mv(e,new ba(t<0?e.state.doc.resolve(a.pos-o.nodeSize):a)):I6?Mv(e,new Ca(e.state.doc.resolve(t<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof ba&&n.node.isInline)return Mv(e,new Ca(t>0?n.$to:n.$from));{let a=Wpe(e.state,t);return a?Mv(e,a):!1}}}function Lse(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function tI(e,t){let s=e.pmViewDesc;return s&&s.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function kC(e,t){return t<0?ijt(e):ojt(e)}function ijt(e){let t=e.domSelectionRange(),s=t.focusNode,n=t.focusOffset;if(!s)return;let a,o,l=!1;for(Uf&&s.nodeType==1&&n0){if(s.nodeType!=1)break;{let i=s.childNodes[n-1];if(tI(i,-1))a=s,o=--n;else if(i.nodeType==3)s=i,n=s.nodeValue.length;else break}}else{if(K$e(s))break;{let i=s.previousSibling;for(;i&&tI(i,-1);)a=s.parentNode,o=uu(i),i=i.previousSibling;if(i)s=i,n=Lse(s);else{if(s=s.parentNode,s==e.dom)break;n=0}}}l?Gpe(e,s,n):a&&Gpe(e,a,o)}function ojt(e){let t=e.domSelectionRange(),s=t.focusNode,n=t.focusOffset;if(!s)return;let a=Lse(s),o,l;for(;;)if(n{e.state==a&&Gy(e)},50)}function U5e(e,t){let s=e.state.doc.resolve(t);if(!(Wd||P$e)&&s.parent.inlineContent){let a=e.coordsAtPos(t);if(t>s.start()){let o=e.coordsAtPos(t-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(e.dom).direction=="rtl"?"rtl":"ltr"}function V5e(e,t,s){let n=e.state.selection;if(n instanceof Ca&&!n.empty||s.indexOf("s")>-1||_f&&s.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let l=Wpe(e.state,t);if(l&&l instanceof ba)return Mv(e,l)}if(!a.parent.inlineContent){let l=t<0?a:o,i=n instanceof Um?Va.near(l,t):Va.findFrom(l,t);return i?Mv(e,i):!1}return!1}function q5e(e,t){if(!(e.state.selection instanceof Ca))return!0;let{$head:s,$anchor:n,empty:a}=e.state.selection;if(!s.sameParent(n))return!0;if(!a)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let o=!s.textOffset&&(t<0?s.nodeBefore:s.nodeAfter);if(o&&!o.isText){let l=e.state.tr;return t<0?l.delete(s.pos-o.nodeSize,s.pos):l.delete(s.pos,s.pos+o.nodeSize),e.dispatch(l),!0}return!1}function H5e(e,t,s){e.domObserver.stop(),t.contentEditable=s,e.domObserver.start()}function djt(e){if(!Fu||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:s}=e.domSelectionRange();if(t&&t.nodeType==1&&s==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let n=t.firstChild;H5e(e,n,"true"),setTimeout(()=>H5e(e,n,"false"),20)}return!1}function ujt(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function hjt(e,t){let s=t.keyCode,n=ujt(t);if(s==8||_f&&s==72&&n=="c")return q5e(e,-1)||kC(e,-1);if(s==46&&!t.shiftKey||_f&&s==68&&n=="c")return q5e(e,1)||kC(e,1);if(s==13||s==27)return!0;if(s==37||_f&&s==66&&n=="c"){let a=s==37?U5e(e,e.state.selection.from)=="ltr"?-1:1:-1;return $5e(e,a,n)||kC(e,a)}else if(s==39||_f&&s==70&&n=="c"){let a=s==39?U5e(e,e.state.selection.from)=="ltr"?1:-1:1;return $5e(e,a,n)||kC(e,a)}else{if(s==38||_f&&s==80&&n=="c")return V5e(e,-1,n)||kC(e,-1);if(s==40||_f&&s==78&&n=="c")return djt(e)||V5e(e,1,n)||kC(e,1);if(n==(_f?"m":"c")&&(s==66||s==73||s==89||s==90))return!0}return!1}function k1e(e,t){e.someProp("transformCopied",_=>{t=_(t,e)});let s=[],{content:n,openStart:a,openEnd:o}=t;for(;a>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){a--,o--;let _=n.firstChild;s.push(_.type.name,_.attrs!=_.type.defaultAttrs?_.attrs:null),n=_.content}let l=e.someProp("clipboardSerializer")||wN.fromSchema(e.state.schema),i=eUe(),d=i.createElement("div");d.appendChild(l.serializeFragment(n,{document:i}));let m=d.firstChild,p,g=0;for(;m&&m.nodeType==1&&(p=J$e[m.nodeName.toLowerCase()]);){for(let _=p.length-1;_>=0;_--){let k=i.createElement(p[_]);for(;d.firstChild;)k.appendChild(d.firstChild);d.appendChild(k),g++}m=d.firstChild}m&&m.nodeType==1&&m.setAttribute("data-pm-slice",`${a} ${o}${g?` -${g}`:""} ${JSON.stringify(s)}`);let v=e.someProp("clipboardTextSerializer",_=>_(t,e))||t.content.textBetween(0,t.content.size,` `);return{dom:d,text:v,slice:t}}function Z$e(e,t,s,n,a){let o=a.parent.type.spec.code,l,i;if(!s&&!t)return null;let d=!!t&&(n||o||!s);if(d){if(e.someProp("transformPastedText",v=>{t=v(t,o||n,e)}),o)return i=new nn(_s.from(e.state.schema.text(t.replace(/\r\n?/g,` `))),0,0),e.someProp("transformPasted",v=>{i=v(i,e,!0)}),i;let g=e.someProp("clipboardTextParser",v=>v(t,a,n,e));if(g)i=g;else{let v=a.marks(),{schema:_}=e.state,k=wN.fromSchema(_);l=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(w=>{let S=l.appendChild(document.createElement("p"));w&&S.appendChild(k.serializeNode(_.text(w,v)))})}}else e.someProp("transformPastedHTML",g=>{s=g(s,e)}),l=gjt(s),I6&&xjt(l);let m=l&&l.querySelector("[data-pm-slice]"),p=m&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(m.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let g=+p[3];g>0;g--){let v=l.firstChild;for(;v&&v.nodeType!=1;)v=v.nextSibling;if(!v)break;l=v}if(i||(i=(e.someProp("clipboardParser")||e.someProp("domParser")||QE.fromSchema(e.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:a,ruleFromNode(v){return v.nodeName=="BR"&&!v.nextSibling&&v.parentNode&&!mjt.test(v.parentNode.nodeName)?{ignore:!0}:null}})),p)i=yjt(W5e(i,+p[1],+p[2]),p[4]);else if(i=nn.maxOpen(fjt(i.content,a),!0),i.openStart||i.openEnd){let g=0,v=0;for(let _=i.content.firstChild;g{i=g(i,e,d)}),i}const mjt=/^(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 fjt(e,t){if(e.childCount<2)return e;for(let s=t.depth;s>=0;s--){let a=t.node(s).contentMatchAt(t.index(s)),o,l=[];if(e.forEach(i=>{if(!l)return;let d=a.findWrapping(i.type),m;if(!d)return l=null;if(m=l.length&&o.length&&X$e(d,o,i,l[l.length-1],0))l[l.length-1]=m;else{l.length&&(l[l.length-1]=Q$e(l[l.length-1],o.length));let p=Y$e(i,d);l.push(p),a=a.matchType(p.type),o=d}}),l)return _s.from(l)}return e}function Y$e(e,t,s=0){for(let n=t.length-1;n>=s;n--)e=t[n].create(null,_s.from(e));return e}function X$e(e,t,s,n,a){if(a1&&(o=0),a=s&&(i=t<0?l.contentMatchAt(0).fillBefore(i,o<=a).append(i):i.append(l.contentMatchAt(l.childCount).fillBefore(_s.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(i))}function W5e(e,t,s){return ts})),Vue.createHTML(e)):e}function gjt(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let s=eUe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(e),a;if((a=n&&J$e[n[1].toLowerCase()])&&(e=a.map(o=>"<"+o+">").join("")+e+a.map(o=>"").reverse().join("")),s.innerHTML=pjt(e),a)for(let o=0;o=0;i-=2){let d=s.nodes[n[i]];if(!d||d.hasRequiredAttrs())break;a=_s.from(d.create(n[i+1],a)),o++,l++}return new nn(a,o,l)}const wh={},jh={},vjt={touchstart:!0,touchmove:!0};class _jt{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 bjt(e){for(let t in wh){let s=wh[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=n=>{jjt(e,n)&&!N1e(e,n)&&(e.editable||!(n.type in jh))&&s(e,n)},vjt[t]?{passive:!0}:void 0)}Fu&&e.dom.addEventListener("input",()=>null),Zpe(e)}function a1(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function wjt(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function Zpe(e){e.someProp("handleDOMEvents",t=>{for(let s in t)e.input.eventHandlers[s]||e.dom.addEventListener(s,e.input.eventHandlers[s]=n=>N1e(e,n))})}function N1e(e,t){return e.someProp("handleDOMEvents",s=>{let n=s[t.type];return n?n(e,t)||t.defaultPrevented:!1})}function jjt(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let s=t.target;s!=e.dom;s=s.parentNode)if(!s||s.nodeType==11||s.pmViewDesc&&s.pmViewDesc.stopEvent(t))return!1;return!0}function kjt(e,t){!N1e(e,t)&&wh[t.type]&&(e.editable||!(t.type in jh))&&wh[t.type](e,t)}jh.keydown=(e,t)=>{let s=t;if(e.input.shiftKey=s.keyCode==16||s.shiftKey,!rUe(e,s)&&(e.input.lastKeyCode=s.keyCode,e.input.lastKeyCodeTime=Date.now(),!(Ty&&Wd&&s.keyCode==13)))if(s.keyCode!=229&&e.domObserver.forceFlush(),$5&&s.keyCode==13&&!s.ctrlKey&&!s.altKey&&!s.metaKey){let n=Date.now();e.input.lastIOSEnter=n,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==n&&(e.someProp("handleKeyDown",a=>a(e,Oj(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",n=>n(e,s))||hjt(e,s)?s.preventDefault():a1(e,"key")};jh.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};jh.keypress=(e,t)=>{let s=t;if(rUe(e,s)||!s.charCode||s.ctrlKey&&!s.altKey||_f&&s.metaKey)return;if(e.someProp("handleKeyPress",a=>a(e,s))){s.preventDefault();return}let n=e.state.selection;if(!(n instanceof Ca)||!n.$from.sameParent(n.$to)){let a=String.fromCharCode(s.charCode),o=()=>e.state.tr.insertText(a).scrollIntoView();!/[\r\n]/.test(a)&&!e.someProp("handleTextInput",l=>l(e,n.$from.pos,n.$to.pos,a,o))&&e.dispatch(o()),s.preventDefault()}};function Qie(e){return{left:e.clientX,top:e.clientY}}function Njt(e,t){let s=t.x-e.clientX,n=t.y-e.clientY;return s*s+n*n<100}function S1e(e,t,s,n,a){if(n==-1)return!1;let o=e.state.doc.resolve(n);for(let l=o.depth+1;l>0;l--)if(e.someProp(t,i=>l>o.depth?i(e,s,o.nodeAfter,o.before(l),a,!0):i(e,s,o.node(l),o.before(l),a,!1)))return!0;return!1}function Q4(e,t,s){if(e.focused||e.focus(),e.state.selection.eq(t))return;let n=e.state.tr.setSelection(t);n.setMeta("pointer",!0),e.dispatch(n)}function Sjt(e,t){if(t==-1)return!1;let s=e.state.doc.resolve(t),n=s.nodeAfter;return n&&n.isAtom&&ba.isSelectable(n)?(Q4(e,new ba(s)),!0):!1}function Cjt(e,t){if(t==-1)return!1;let s=e.state.selection,n,a;s instanceof ba&&(n=s.node);let o=e.state.doc.resolve(t);for(let l=o.depth+1;l>0;l--){let i=l>o.depth?o.nodeAfter:o.node(l);if(ba.isSelectable(i)){n&&s.$from.depth>0&&l>=s.$from.depth&&o.before(s.$from.depth+1)==s.$from.pos?a=o.before(s.$from.depth):a=o.before(l);break}}return a!=null?(Q4(e,ba.create(e.state.doc,a)),!0):!1}function Mjt(e,t,s,n,a){return S1e(e,"handleClickOn",t,s,n)||e.someProp("handleClick",o=>o(e,t,n))||(a?Cjt(e,s):Sjt(e,s))}function Tjt(e,t,s,n){return S1e(e,"handleDoubleClickOn",t,s,n)||e.someProp("handleDoubleClick",a=>a(e,t,n))}function Ajt(e,t,s,n){return S1e(e,"handleTripleClickOn",t,s,n)||e.someProp("handleTripleClick",a=>a(e,t,n))||Ejt(e,s,n)}function Ejt(e,t,s){if(s.button!=0)return!1;let n=e.state.doc;if(t==-1)return n.inlineContent?(Q4(e,Ca.create(n,0,n.content.size)),!0):!1;let a=n.resolve(t);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)Q4(e,Ca.create(n,i+1,i+1+l.content.size));else if(ba.isSelectable(l))Q4(e,ba.create(n,i));else continue;return!0}}function C1e(e){return Dse(e)}const tUe=_f?"metaKey":"ctrlKey";wh.mousedown=(e,t)=>{let s=t;e.input.shiftKey=s.shiftKey;let n=C1e(e),a=Date.now(),o="singleClick";a-e.input.lastClick.time<500&&Njt(s,e.input.lastClick)&&!s[tUe]&&e.input.lastClick.button==s.button&&(e.input.lastClick.type=="singleClick"?o="doubleClick":e.input.lastClick.type=="doubleClick"&&(o="tripleClick")),e.input.lastClick={time:a,x:s.clientX,y:s.clientY,type:o,button:s.button};let l=e.posAtCoords(Qie(s));l&&(o=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Ijt(e,l,s,!!n)):(o=="doubleClick"?Tjt:Ajt)(e,l.pos,l.inside,s)?s.preventDefault():a1(e,"pointer"))};class Ijt{constructor(t,s,n,a){this.view=t,this.pos=s,this.event=n,this.flushed=a,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[tUe],this.allowDefault=n.shiftKey;let o,l;if(s.inside>-1)o=t.state.doc.nodeAt(s.inside),l=s.inside;else{let p=t.state.doc.resolve(s.pos);o=p.parent,l=p.depth?p.before():0}const i=a?null:n.target,d=i?t.docView.nearestDesc(i,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:m}=t.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||m instanceof ba&&m.from<=l&&m.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Uf&&!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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),a1(t,"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(()=>Gy(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let s=this.pos;this.view.state.doc!=this.startDoc&&(s=this.view.posAtCoords(Qie(t))),this.updateAllowDefault(t),this.allowDefault||!s?a1(this.view,"pointer"):Mjt(this.view,s.pos,s.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Fu&&this.mightDrag&&!this.mightDrag.node.isAtom||Wd&&!this.view.state.selection.visible&&Math.min(Math.abs(s.pos-this.view.state.selection.from),Math.abs(s.pos-this.view.state.selection.to))<=2)?(Q4(this.view,Va.near(this.view.state.doc.resolve(s.pos))),t.preventDefault()):a1(this.view,"pointer")}move(t){this.updateAllowDefault(t),a1(this.view,"pointer"),t.buttons==0&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}wh.touchstart=e=>{e.input.lastTouch=Date.now(),C1e(e),a1(e,"pointer")};wh.touchmove=e=>{e.input.lastTouch=Date.now(),a1(e,"pointer")};wh.contextmenu=e=>C1e(e);function rUe(e,t){return e.composing?!0:Fu&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const Pjt=Ty?5e3:-1;jh.compositionstart=jh.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,s=t.selection.$to;if(t.selection instanceof Ca&&(t.storedMarks||!s.textOffset&&s.parentOffset&&s.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Wd&&P$e&&Ljt(e)))e.markCursor=e.state.storedMarks||s.marks(),Dse(e,!0),e.markCursor=null;else if(Dse(e,!t.selection.empty),Uf&&t.selection.empty&&s.parentOffset&&!s.textOffset&&s.nodeBefore.marks.length){let n=e.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=e.domSelection();i&&i.collapse(l,l.nodeValue.length);break}else a=l,o=-1}}e.input.composing=!0}sUe(e,Pjt)};function Ljt(e){let{focusNode:t,focusOffset:s}=e.domSelectionRange();if(!t||t.nodeType!=1||s>=t.childNodes.length)return!1;let n=t.childNodes[s];return n.nodeType==1&&n.contentEditable=="false"}jh.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,sUe(e,20))};function sUe(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Dse(e),t))}function nUe(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Ojt());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Djt(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let s=C2t(t.focusNode,t.focusOffset),n=M2t(t.focusNode,t.focusOffset);if(s&&n&&s!=n){let a=n.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(s==o||n==o)return o;if(!a||!a.isText(n.nodeValue))return n;if(e.input.compositionNode==n){let l=s.pmViewDesc;if(!(!l||!l.isText(s.nodeValue)))return n}}return s||n}function Ojt(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Dse(e,t=!1){if(!(Ty&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),nUe(e),t||e.docView&&e.docView.dirty){let s=w1e(e),n=e.state.selection;return s&&!s.eq(n)?e.dispatch(e.state.tr.setSelection(s)):(e.markCursor||t)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Rjt(e,t){if(!e.dom.parentNode)return;let s=e.dom.parentNode.appendChild(document.createElement("div"));s.appendChild(t),s.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),a=document.createRange();a.selectNodeContents(t),e.dom.blur(),n.removeAllRanges(),n.addRange(a),setTimeout(()=>{s.parentNode&&s.parentNode.removeChild(s),e.focus()},50)}const nP=tm&&L1<15||$5&&I2t<604;wh.copy=jh.cut=(e,t)=>{let s=t,n=e.state.selection,a=s.type=="cut";if(n.empty)return;let o=nP?null:s.clipboardData,l=n.content(),{dom:i,text:d}=k1e(e,l);o?(s.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",d)):Rjt(e,i),a&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fjt(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function zjt(e,t){if(!e.dom.parentNode)return;let s=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,n=e.dom.parentNode.appendChild(document.createElement(s?"textarea":"div"));s||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let a=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),n.parentNode&&n.parentNode.removeChild(n),s?aP(e,n.value,null,a,t):aP(e,n.textContent,n.innerHTML,a,t)},50)}function aP(e,t,s,n,a){let o=Z$e(e,t,s,n,e.state.selection.$from);if(e.someProp("handlePaste",d=>d(e,a,o||nn.empty)))return!0;if(!o)return!1;let l=Fjt(o),i=l?e.state.tr.replaceSelectionWith(l,n):e.state.tr.replaceSelection(o);return e.dispatch(i.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function aUe(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let s=e.getData("text/uri-list");return s?s.replace(/\r?\n/g," "):""}jh.paste=(e,t)=>{let s=t;if(e.composing&&!Ty)return;let n=nP?null:s.clipboardData,a=e.input.shiftKey&&e.input.lastKeyCode!=45;n&&aP(e,aUe(n),n.getData("text/html"),a,s)?s.preventDefault():zjt(e,s)};class iUe{constructor(t,s,n){this.slice=t,this.move=s,this.node=n}}const Bjt=_f?"altKey":"ctrlKey";function oUe(e,t){let s=e.someProp("dragCopies",n=>!n(t));return s??!t[Bjt]}wh.dragstart=(e,t)=>{let s=t,n=e.input.mouseDown;if(n&&n.done(),!s.dataTransfer)return;let a=e.state.selection,o=a.empty?null:e.posAtCoords(Qie(s)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof ba?a.to-1:a.to))){if(n&&n.mightDrag)l=ba.create(e.state.doc,n.mightDrag.pos);else if(s.target&&s.target.nodeType==1){let g=e.docView.nearestDesc(s.target,!0);g&&g.node.type.spec.draggable&&g!=e.docView&&(l=ba.create(e.state.doc,g.posBefore))}}let i=(l||e.state.selection).content(),{dom:d,text:m,slice:p}=k1e(e,i);(!s.dataTransfer.files.length||!Wd||I$e>120)&&s.dataTransfer.clearData(),s.dataTransfer.setData(nP?"Text":"text/html",d.innerHTML),s.dataTransfer.effectAllowed="copyMove",nP||s.dataTransfer.setData("text/plain",m),e.dragging=new iUe(p,oUe(e,s),l)};wh.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};jh.dragover=jh.dragenter=(e,t)=>t.preventDefault();jh.drop=(e,t)=>{try{$jt(e,t,e.dragging)}finally{e.dragging=null}};function $jt(e,t,s){if(!t.dataTransfer)return;let n=e.posAtCoords(Qie(t));if(!n)return;let a=e.state.doc.resolve(n.pos),o=s&&s.slice;o?e.someProp("transformPasted",_=>{o=_(o,e,!1)}):o=Z$e(e,aUe(t.dataTransfer),nP?null:t.dataTransfer.getData("text/html"),!1,a);let l=!!(s&&oUe(e,t));if(e.someProp("handleDrop",_=>_(e,t,o||nn.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let i=o?j$e(e.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let d=e.state.tr;if(l){let{node:_}=s;_?_.replace(d):d.deleteSelection()}let m=d.mapping.map(i),p=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,g=d.doc;if(p?d.replaceRangeWith(m,m,o.content.firstChild):d.replaceRange(m,m,o),d.doc.eq(g))return;let v=d.doc.resolve(m);if(p&&ba.isSelectable(o.content.firstChild)&&v.nodeAfter&&v.nodeAfter.sameMarkup(o.content.firstChild))d.setSelection(new ba(v));else{let _=d.mapping.map(i);d.mapping.maps[d.mapping.maps.length-1].forEach((k,w,S,T)=>_=T),d.setSelection(j1e(e,v,d.doc.resolve(_)))}e.focus(),e.dispatch(d.setMeta("uiEvent","drop"))}wh.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Gy(e)},20))};wh.blur=(e,t)=>{let s=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),s.relatedTarget&&e.dom.contains(s.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};wh.beforeinput=(e,t)=>{if(Wd&&Ty&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:n}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=n||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",o=>o(e,Oj(8,"Backspace")))))return;let{$cursor:a}=e.state.selection;a&&a.pos>0&&e.dispatch(e.state.tr.delete(a.pos-1,a.pos).scrollIntoView())},50)}};for(let e in jh)wh[e]=jh[e];function iP(e,t){if(e==t)return!0;for(let s in e)if(e[s]!==t[s])return!1;for(let s in t)if(!(s in e))return!1;return!0}class Ose{constructor(t,s){this.toDOM=t,this.spec=s||Ok,this.side=this.spec.side||0}map(t,s,n,a){let{pos:o,deleted:l}=t.mapResult(s.from+a,this.side<0?-1:1);return l?null:new hh(o-n,o-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Ose&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&iP(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class O1{constructor(t,s){this.attrs=t,this.spec=s||Ok}map(t,s,n,a){let o=t.map(s.from+a,this.spec.inclusiveStart?-1:1)-n,l=t.map(s.to+a,this.spec.inclusiveEnd?1:-1)-n;return o>=l?null:new hh(o,l,this)}valid(t,s){return s.from=t&&(!o||o(i.spec))&&n.push(i.copy(i.from+a,i.to+a))}for(let l=0;lt){let i=this.children[l]+1;this.children[l+2].findInner(t-i,s-i,n,a+i,o)}}map(t,s,n){return this==Cu||t.maps.length==0?this:this.mapInner(t,s,0,0,n||Ok)}mapInner(t,s,n,a,o){let l;for(let i=0;i{let m=d+n,p;if(p=cUe(s,i,m)){for(a||(a=this.children.slice());oi&&g.to=t){this.children[i]==t&&(n=this.children[i+2]);break}let o=t+1,l=o+s.content.size;for(let i=0;io&&d.type instanceof O1){let m=Math.max(o,d.from)-o,p=Math.min(l,d.to)-o;ma.map(t,s,Ok));return Fv.from(n)}forChild(t,s){if(s.isLeaf)return hc.empty;let n=[];for(let a=0;as instanceof hc)?t:t.reduce((s,n)=>s.concat(n instanceof hc?n:n.members),[]))}}forEachSet(t){for(let s=0;s{let S=w-k-(_-v);for(let T=0;TC+p-g)continue;let I=i[T]+p-g;_>=I?i[T+1]=v<=I?-2:-1:v>=p&&S&&(i[T]+=S,i[T+1]+=S)}g+=S}),p=s.maps[m].map(p,-1)}let d=!1;for(let m=0;m=n.content.size){d=!0;continue}let v=s.map(e[m+1]+o,-1),_=v-a,{index:k,offset:w}=n.content.findIndex(g),S=n.maybeChild(k);if(S&&w==g&&w+S.nodeSize==_){let T=i[m+2].mapInner(s,S,p+1,e[m]+o+1,l);T!=Cu?(i[m]=g,i[m+1]=_,i[m+2]=T):(i[m+1]=-2,d=!0)}else d=!0}if(d){let m=Vjt(i,e,t,s,a,o,l),p=Rse(m,n,0,l);t=p.local;for(let g=0;gs&&l.to{let m=cUe(e,i,d+s);if(m){o=!0;let p=Rse(m,i,s+d+1,n);p!=Cu&&a.push(d,d+i.nodeSize,p)}});let l=lUe(o?dUe(e):e,-s).sort(Rk);for(let i=0;i0;)t++;e.splice(t,0,s)}function que(e){let t=[];return e.someProp("decorations",s=>{let n=s(e.state);n&&n!=Cu&&t.push(n)}),e.cursorWrapper&&t.push(hc.create(e.state.doc,[e.cursorWrapper.deco])),Fv.from(t)}const qjt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Hjt=tm&&L1<=11;class Wjt{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class Gjt{constructor(t,s){this.view=t,this.handleDOMChange=s,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Wjt,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()}),Hjt&&(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,qjt)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let s=0;sthis.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(B5e(this.view)){if(this.suppressingSelectionUpdates)return Gy(this.view);if(tm&&L1<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&nN(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let s=new Set,n;for(let o=t.focusNode;o;o=B5(o))s.add(o);for(let o=t.anchorNode;o;o=B5(o))if(s.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 t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let s=this.pendingRecords();s.length&&(this.queue=[]);let n=t.domSelectionRange(),a=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&B5e(t)&&!this.ignoreSelectionChange(n),o=-1,l=-1,i=!1,d=[];if(t.editable)for(let p=0;pg.nodeName=="BR");if(p.length==2){let[g,v]=p;g.parentNode&&g.parentNode.parentNode==v.parentNode?v.remove():g.remove()}else{let{focusNode:g}=this.currentSelection;for(let v of p){let _=v.parentNode;_&&_.nodeName=="LI"&&(!g||Yjt(t,g)!=_)&&v.remove()}}}else if((Wd||Fu)&&d.some(p=>p.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46)){for(let p of d)if(p.nodeName=="BR"&&p.parentNode){let g=p.nextSibling;g&&g.nodeType==1&&g.contentEditable=="false"&&p.parentNode.removeChild(p)}}let m=null;o<0&&a&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)-1||a)&&(o>-1&&(t.docView.markDirty(o,l),Kjt(t)),this.handleDOMChange(o,l,i,d),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||Gy(t),this.currentSelection.set(n))}registerMutation(t,s){if(s.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let p=0;pa;S--){let T=n.childNodes[S-1],C=T.pmViewDesc;if(T.nodeName=="BR"&&!C){o=S;break}if(!C||C.size)break}let g=e.state.doc,v=e.someProp("domParser")||QE.fromSchema(e.state.schema),_=g.resolve(l),k=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:m,ruleFromNode:Qjt,context:_});if(m&&m[0].pos!=null){let S=m[0].pos,T=m[1]&&m[1].pos;T==null&&(T=S),k={anchor:S+l,head:T+l}}return{doc:w,sel:k,from:l,to:i}}function Qjt(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName=="BR"&&e.parentNode){if(Fu&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let s=document.createElement("div");return s.appendChild(document.createElement("li")),{skip:s}}else if(e.parentNode.lastChild==e||Fu&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Jjt=/^(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 ekt(e,t,s,n,a){let o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let $=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,q=w1e(e,$);if(q&&!e.state.selection.eq(q)){if(Wd&&Ty&&e.input.lastKeyCode===13&&Date.now()-100K(e,Oj(13,"Enter"))))return;let W=e.state.tr.setSelection(q);$=="pointer"?W.setMeta("pointer",!0):$=="key"&&W.scrollIntoView(),o&&W.setMeta("composition",o),e.dispatch(W)}return}let l=e.state.doc.resolve(t),i=l.sharedDepth(s);t=l.before(i+1),s=e.state.doc.resolve(s).after(i+1);let d=e.state.selection,m=Xjt(e,t,s),p=e.state.doc,g=p.slice(m.from,m.to),v,_;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Ty)&&a.some($=>$.nodeType==1&&!Jjt.test($.nodeName))&&(!k||k.endA>=k.endB)&&e.someProp("handleKeyDown",$=>$(e,Oj(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!k)if(n&&d instanceof Ca&&!d.empty&&d.$head.sameParent(d.$anchor)&&!e.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))k={start:d.from,endA:d.to,endB:d.to};else{if(m.sel){let $=Q5e(e,e.state.doc,m.sel);if($&&!$.eq(e.state.selection)){let q=e.state.tr.setSelection($);o&&q.setMeta("composition",o),e.dispatch(q)}}return}e.state.selection.frome.state.selection.from&&k.start<=e.state.selection.from+2&&e.state.selection.from>=m.from?k.start=e.state.selection.from:k.endA=e.state.selection.to-2&&e.state.selection.to<=m.to&&(k.endB+=e.state.selection.to-k.endA,k.endA=e.state.selection.to)),tm&&L1<=11&&k.endB==k.start+1&&k.endA==k.start&&k.start>m.from&&m.doc.textBetween(k.start-m.from-1,k.start-m.from+1)=="  "&&(k.start--,k.endA--,k.endB--);let w=m.doc.resolveNoCache(k.start-m.from),S=m.doc.resolveNoCache(k.endB-m.from),T=p.resolve(k.start),C=w.sameParent(S)&&w.parent.inlineContent&&T.end()>=k.endA;if(($5&&e.input.lastIOSEnter>Date.now()-225&&(!C||a.some($=>$.nodeName=="DIV"||$.nodeName=="P"))||!C&&w.pos$(e,Oj(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>k.start&&rkt(p,k.start,k.endA,w,S)&&e.someProp("handleKeyDown",$=>$(e,Oj(8,"Backspace")))){Ty&&Wd&&e.domObserver.suppressSelectionUpdates();return}Wd&&k.endB==k.start&&(e.input.lastChromeDelete=Date.now()),Ty&&!C&&w.start()!=S.start()&&S.parentOffset==0&&w.depth==S.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==k.endA&&(k.endB-=2,S=m.doc.resolveNoCache(k.endB-m.from),setTimeout(()=>{e.someProp("handleKeyDown",function($){return $(e,Oj(13,"Enter"))})},20));let I=k.start,R=k.endA,D=$=>{let q=$||e.state.tr.replace(I,R,m.doc.slice(k.start-m.from,k.endB-m.from));if(m.sel){let W=Q5e(e,q.doc,m.sel);W&&!(Wd&&e.composing&&W.empty&&(k.start!=k.endB||e.input.lastChromeDeleteGy(e),20));let $=D(e.state.tr.delete(I,R)),q=p.resolve(k.start).marksAcross(p.resolve(k.endA));q&&$.ensureMarks(q),e.dispatch($)}else if(k.endA==k.endB&&(B=tkt(w.parent.content.cut(w.parentOffset,S.parentOffset),T.parent.content.cut(T.parentOffset,k.endA-T.start())))){let $=D(e.state.tr);B.type=="add"?$.addMark(I,R,B.mark):$.removeMark(I,R,B.mark),e.dispatch($)}else if(w.parent.child(w.index()).isText&&w.index()==S.index()-(S.textOffset?0:1)){let $=w.parent.textBetween(w.parentOffset,S.parentOffset),q=()=>D(e.state.tr.insertText($,I,R));e.someProp("handleTextInput",W=>W(e,I,R,$,q))||e.dispatch(q())}else e.dispatch(D());else e.dispatch(D())}function Q5e(e,t,s){return Math.max(s.anchor,s.head)>t.content.size?null:j1e(e,t.resolve(s.anchor),t.resolve(s.head))}function tkt(e,t){let s=e.firstChild.marks,n=t.firstChild.marks,a=s,o=n,l,i,d;for(let p=0;pp.mark(i.addToSet(p.marks));else if(a.length==0&&o.length==1)i=o[0],l="remove",d=p=>p.mark(i.removeFromSet(p.marks));else return null;let m=[];for(let p=0;ps||Hue(l,!0,!1)0&&(t||e.indexAfter(n)==e.node(n).childCount);)n--,a++,t=!1;if(s){let o=e.node(n).maybeChild(e.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,a++}return a}function skt(e,t,s,n,a){let o=e.findDiffStart(t,s);if(o==null)return null;let{a:l,b:i}=e.findDiffEnd(t,s+e.size,s+t.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&&t<=57343&&s>=55296&&s<=56319}class uUe{constructor(t,s){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 _jt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=s,this.state=s.state,this.directPlugins=s.plugins||[],this.directPlugins.forEach(n3e),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):typeof t=="function"?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=r3e(this),t3e(this),this.nodeViews=s3e(this),this.docView=L5e(this.state.doc,e3e(this),que(this),this.dom,this),this.domObserver=new Gjt(this,(n,a,o,l)=>ekt(this,n,a,o,l)),this.domObserver.start(),bjt(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let s in t)this._props[s]=t[s];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&Zpe(this);let s=this._props;this._props=t,t.plugins&&(t.plugins.forEach(n3e),this.directPlugins=t.plugins),this.updateStateInner(t.state,s)}setProps(t){let s={};for(let n in this._props)s[n]=this._props[n];s.state=this.state;for(let n in t)s[n]=t[n];this.update(s)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,s){var n;let a=this.state,o=!1,l=!1;t.storedMarks&&this.composing&&(nUe(this),l=!0),this.state=t;let i=a.plugins!=t.plugins||this._props.plugins!=s.plugins;if(i||this._props.plugins!=s.plugins||this._props.nodeViews!=s.nodeViews){let _=s3e(this);akt(_,this.nodeViews)&&(this.nodeViews=_,o=!0)}(i||s.handleDOMEvents!=this._props.handleDOMEvents)&&Zpe(this),this.editable=r3e(this),t3e(this);let d=que(this),m=e3e(this),p=a.plugins!=t.plugins&&!a.doc.eq(t.doc)?"reset":t.scrollToSelection>a.scrollToSelection?"to selection":"preserve",g=o||!this.docView.matchesNode(t.doc,m,d);(g||!t.selection.eq(a.selection))&&(l=!0);let v=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&D2t(this);if(l){this.domObserver.stop();let _=g&&(tm||Wd)&&!this.composing&&!a.selection.empty&&!t.selection.empty&&nkt(a.selection,t.selection);if(g){let k=Wd?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Djt(this)),(o||!this.docView.update(t.doc,m,d,this))&&(this.docView.updateOuterDeco(m),this.docView.destroy(),this.docView=L5e(t.doc,m,d,this.dom,this)),k&&!this.trackWrites&&(_=!0)}_||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ajt(this))?Gy(this,_):(W$e(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(a),!((n=this.dragging)===null||n===void 0)&&n.node&&!a.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,a),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():v&&O2t(v)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!(!t||!this.dom.contains(t.nodeType==1?t:t.parentNode))){if(!this.someProp("handleScrollToSelection",s=>s(this)))if(this.state.selection instanceof ba){let s=this.docView.domAfterPos(this.state.selection.from);s.nodeType==1&&M5e(this,s.getBoundingClientRect(),t)}else M5e(this,this.coordsAtPos(this.state.selection.head,1),t)}}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(!t||t.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let s=0;s0&&this.state.doc.nodeAt(o))==n.node&&(a=o)}this.dragging=new iUe(t.slice,t.move,a<0?void 0:ba.create(this.state.doc,a))}someProp(t,s){let n=this._props&&this._props[t],a;if(n!=null&&(a=s?s(n):n))return a;for(let l=0;ls.ownerDocument.getSelection()),this._root=s}return t||document}updateRoot(){this._root=null}posAtCoords(t){return U2t(this,t)}coordsAtPos(t,s=1){return F$e(this,t,s)}domAtPos(t,s=0){return this.docView.domFromPos(t,s)}nodeDOM(t){let s=this.docView.descAt(t);return s?s.nodeDOM:null}posAtDOM(t,s,n=-1){let a=this.docView.posFromDOM(t,s,n);if(a==null)throw new RangeError("DOM position not inside the editor");return a}endOfTextblock(t,s){return G2t(this,s||this.state,t)}pasteHTML(t,s){return aP(this,"",t,!1,s||new ClipboardEvent("paste"))}pasteText(t,s){return aP(this,t,null,!0,s||new ClipboardEvent("paste"))}serializeForClipboard(t){return k1e(this,t)}destroy(){this.docView&&(wjt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],que(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,N2t())}get isDestroyed(){return this.docView==null}dispatchEvent(t){return kjt(this,t)}domSelectionRange(){let t=this.domSelection();return t?Fu&&this.root.nodeType===11&&A2t(this.dom.ownerDocument)==this.dom&&Zjt(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}uUe.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function e3e(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",s=>{if(typeof s=="function"&&(s=s(e.state)),s)for(let n in s)n=="class"?t.class+=" "+s[n]:n=="style"?t.style=(t.style?t.style+";":"")+s[n]:!t[n]&&n!="contenteditable"&&n!="nodeName"&&(t[n]=String(s[n]))}),t.translate||(t.translate="no"),[hh.node(0,e.state.doc.content.size,t)]}function t3e(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:hh.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function r3e(e){return!e.someProp("editable",t=>t(e.state)===!1)}function nkt(e,t){let s=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(s)!=t.$anchor.start(s)}function s3e(e){let t=Object.create(null);function s(n){for(let a in n)Object.prototype.hasOwnProperty.call(t,a)||(t[a]=n[a])}return e.someProp("nodeViews",s),e.someProp("markViews",s),t}function akt(e,t){let s=0,n=0;for(let a in e){if(e[a]!=t[a])return!0;s++}for(let a in t)n++;return s!=n}function n3e(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var K1={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:"'"},Fse={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ikt=typeof navigator<"u"&&/Mac/.test(navigator.platform),okt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var hu=0;hu<10;hu++)K1[48+hu]=K1[96+hu]=String(hu);for(var hu=1;hu<=24;hu++)K1[hu+111]="F"+hu;for(var hu=65;hu<=90;hu++)K1[hu]=String.fromCharCode(hu+32),Fse[hu]=String.fromCharCode(hu);for(var Wue in K1)Fse.hasOwnProperty(Wue)||(Fse[Wue]=K1[Wue]);function lkt(e){var t=ikt&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||okt&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",s=!t&&e.key||(e.shiftKey?Fse:K1)[e.keyCode]||e.key||"Unidentified";return s=="Esc"&&(s="Escape"),s=="Del"&&(s="Delete"),s=="Left"&&(s="ArrowLeft"),s=="Up"&&(s="ArrowUp"),s=="Right"&&(s="ArrowRight"),s=="Down"&&(s="ArrowDown"),s}const ckt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),dkt=typeof navigator<"u"&&/Win/.test(navigator.platform);function ukt(e){let t=e.split(/-(?!$)/),s=t[t.length-1];s=="Space"&&(s=" ");let n,a,o,l;for(let i=0;ie.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function hUe(e,t){let{$cursor:s}=e.selection;return!s||(t?!t.endOfTextblock("backward",e):s.parentOffset>0)?null:s}const mUe=(e,t,s)=>{let n=hUe(e,s);if(!n)return!1;let a=I1e(n);if(!a){let l=n.blockRange(),i=l&&D3(l);return i==null?!1:(t&&t(e.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(wUe(e,a,t,-1))return!0;if(n.parent.content.size==0&&(U5(o,"end")||ba.isSelectable(o)))for(let l=n.depth;;l--){let i=Kie(e.doc,n.before(l),n.after(l),nn.empty);if(i&&i.slice.size1)break}return o.isAtom&&a.depth==n.depth-1?(t&&t(e.tr.delete(a.pos-o.nodeSize,a.pos).scrollIntoView()),!0):!1},fkt=(e,t,s)=>{let n=hUe(e,s);if(!n)return!1;let a=I1e(n);return a?fUe(e,a,t):!1},pkt=(e,t,s)=>{let n=gUe(e,s);if(!n)return!1;let a=P1e(n);return a?fUe(e,a,t):!1};function fUe(e,t,s){let n=t.nodeBefore,a=n,o=t.pos-1;for(;!a.isTextblock;o--){if(a.type.spec.isolating)return!1;let p=a.lastChild;if(!p)return!1;a=p}let l=t.nodeAfter,i=l,d=t.pos+1;for(;!i.isTextblock;d++){if(i.type.spec.isolating)return!1;let p=i.firstChild;if(!p)return!1;i=p}let m=Kie(e.doc,o,d,nn.empty);if(!m||m.from!=o||m instanceof qd&&m.slice.size>=d-o)return!1;if(s){let p=e.tr.step(m);p.setSelection(Ca.create(p.doc,o)),s(p.scrollIntoView())}return!0}function U5(e,t,s=!1){for(let n=e;n;n=t=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(s&&n.childCount!=1)return!1}return!1}const pUe=(e,t,s)=>{let{$head:n,empty:a}=e.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(s?!s.endOfTextblock("backward",e):n.parentOffset>0)return!1;o=I1e(n)}let l=o&&o.nodeBefore;return!l||!ba.isSelectable(l)?!1:(t&&t(e.tr.setSelection(ba.create(e.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function I1e(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function gUe(e,t){let{$cursor:s}=e.selection;return!s||(t?!t.endOfTextblock("forward",e):s.parentOffset{let n=gUe(e,s);if(!n)return!1;let a=P1e(n);if(!a)return!1;let o=a.nodeAfter;if(wUe(e,a,t,1))return!0;if(n.parent.content.size==0&&(U5(o,"start")||ba.isSelectable(o))){let l=Kie(e.doc,n.before(),n.after(),nn.empty);if(l&&l.slice.size{let{$head:n,empty:a}=e.selection,o=n;if(!a)return!1;if(n.parent.isTextblock){if(s?!s.endOfTextblock("forward",e):n.parentOffset=0;t--){let s=e.node(t);if(e.index(t)+1{let s=e.selection,n=s instanceof ba,a;if(n){if(s.node.isTextblock||!l_(e.doc,s.from))return!1;a=s.from}else if(a=Gie(e.doc,s.from,-1),a==null)return!1;if(t){let o=e.tr.join(a);n&&o.setSelection(ba.create(o.doc,a-e.doc.resolve(a).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0},xkt=(e,t)=>{let s=e.selection,n;if(s instanceof ba){if(s.node.isTextblock||!l_(e.doc,s.to))return!1;n=s.to}else if(n=Gie(e.doc,s.to,1),n==null)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},ykt=(e,t)=>{let{$from:s,$to:n}=e.selection,a=s.blockRange(n),o=a&&D3(a);return o==null?!1:(t&&t(e.tr.lift(a,o).scrollIntoView()),!0)},vUe=(e,t)=>{let{$head:s,$anchor:n}=e.selection;return!s.parent.type.spec.code||!s.sameParent(n)?!1:(t&&t(e.tr.insertText(` `).scrollIntoView()),!0)};function L1e(e){for(let t=0;t{let{$head:s,$anchor:n}=e.selection;if(!s.parent.type.spec.code||!s.sameParent(n))return!1;let a=s.node(-1),o=s.indexAfter(-1),l=L1e(a.contentMatchAt(o));if(!l||!a.canReplaceWith(o,o,l))return!1;if(t){let i=s.after(),d=e.tr.replaceWith(i,i,l.createAndFill());d.setSelection(Va.near(d.doc.resolve(i),1)),t(d.scrollIntoView())}return!0},_Ue=(e,t)=>{let s=e.selection,{$from:n,$to:a}=s;if(s instanceof Um||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=L1e(a.parent.contentMatchAt(a.indexAfter()));if(!o||!o.isTextblock)return!1;if(t){let l=(!n.parentOffset&&a.index(){let{$cursor:s}=e.selection;if(!s||s.parent.content.size)return!1;if(s.depth>1&&s.after()!=s.end(-1)){let o=s.before();if(Wy(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let n=s.blockRange(),a=n&&D3(n);return a==null?!1:(t&&t(e.tr.lift(n,a).scrollIntoView()),!0)};function _kt(e){return(t,s)=>{let{$from:n,$to:a}=t.selection;if(t.selection instanceof ba&&t.selection.node.isBlock)return!n.parentOffset||!Wy(t.doc,n.pos)?!1:(s&&s(t.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],l,i,d=!1,m=!1;for(let _=n.depth;;_--)if(n.node(_).isBlock){d=n.end(_)==n.pos+(n.depth-_),m=n.start(_)==n.pos-(n.depth-_),i=L1e(n.node(_-1).contentMatchAt(n.indexAfter(_-1))),o.unshift(d&&i?{type:i}:null),l=_;break}else{if(_==1)return!1;o.unshift(null)}let p=t.tr;(t.selection instanceof Ca||t.selection instanceof Um)&&p.deleteSelection();let g=p.mapping.map(n.pos),v=Wy(p.doc,g,o.length,o);if(v||(o[0]=i?{type:i}:null,v=Wy(p.doc,g,o.length,o)),!v)return!1;if(p.split(g,o.length,o),!d&&m&&n.node(l).type!=i){let _=p.mapping.map(n.before(l)),k=p.doc.resolve(_);i&&n.node(l-1).canReplaceWith(k.index(),k.index()+1,i)&&p.setNodeMarkup(p.mapping.map(n.before(l)),i)}return s&&s(p.scrollIntoView()),!0}}const bkt=_kt(),wkt=(e,t)=>{let{$from:s,to:n}=e.selection,a,o=s.sharedDepth(n);return o==0?!1:(a=s.before(o),t&&t(e.tr.setSelection(ba.create(e.doc,a))),!0)};function jkt(e,t,s){let n=t.nodeBefore,a=t.nodeAfter,o=t.index();return!n||!a||!n.type.compatibleContent(a.type)?!1:!n.content.size&&t.parent.canReplace(o-1,o)?(s&&s(e.tr.delete(t.pos-n.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(o,o+1)||!(a.isTextblock||l_(e.doc,t.pos))?!1:(s&&s(e.tr.join(t.pos).scrollIntoView()),!0)}function wUe(e,t,s,n){let a=t.nodeBefore,o=t.nodeAfter,l,i,d=a.type.spec.isolating||o.type.spec.isolating;if(!d&&jkt(e,t,s))return!0;let m=!d&&t.parent.canReplace(t.index(),t.index()+1);if(m&&(l=(i=a.contentMatchAt(a.childCount)).findWrapping(o.type))&&i.matchType(l[0]||o.type).validEnd){if(s){let _=t.pos+o.nodeSize,k=_s.empty;for(let T=l.length-1;T>=0;T--)k=_s.from(l[T].create(null,k));k=_s.from(a.copy(k));let w=e.tr.step(new Zd(t.pos-1,_,t.pos,_,new nn(k,1,0),l.length,!0)),S=w.doc.resolve(_+2*l.length);S.nodeAfter&&S.nodeAfter.type==a.type&&l_(w.doc,S.pos)&&w.join(S.pos),s(w.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&d?null:Va.findFrom(t,1),g=p&&p.$from.blockRange(p.$to),v=g&&D3(g);if(v!=null&&v>=t.depth)return s&&s(e.tr.lift(g,v).scrollIntoView()),!0;if(m&&U5(o,"start",!0)&&U5(a,"end")){let _=a,k=[];for(;k.push(_),!_.isTextblock;)_=_.lastChild;let w=o,S=1;for(;!w.isTextblock;w=w.firstChild)S++;if(_.canReplace(_.childCount,_.childCount,w.content)){if(s){let T=_s.empty;for(let I=k.length-1;I>=0;I--)T=_s.from(k[I].copy(T));let C=e.tr.step(new Zd(t.pos-k.length,t.pos+o.nodeSize,t.pos+S,t.pos+o.nodeSize-S,new nn(T,k.length,0),0,!0));s(C.scrollIntoView())}return!0}}return!1}function jUe(e){return function(t,s){let n=t.selection,a=e<0?n.$from:n.$to,o=a.depth;for(;a.node(o).isInline;){if(!o)return!1;o--}return a.node(o).isTextblock?(s&&s(t.tr.setSelection(Ca.create(t.doc,e<0?a.start(o):a.end(o)))),!0):!1}}const kkt=jUe(-1),Nkt=jUe(1);function Skt(e,t=null){return function(s,n){let{$from:a,$to:o}=s.selection,l=a.blockRange(o),i=l&&y1e(l,e,t);return i?(n&&n(s.tr.wrap(l,i).scrollIntoView()),!0):!1}}function a3e(e,t=null){return function(s,n){let a=!1;for(let o=0;o{if(a)return!1;if(!(!d.isTextblock||d.hasMarkup(e,t)))if(d.type==e)a=!0;else{let p=s.doc.resolve(m),g=p.index();a=p.parent.canReplaceWith(g,g+1,e)}})}if(!a)return!1;if(n){let o=s.tr;for(let l=0;l=2&&t.$from.node(t.depth-1).type.compatibleContent(s)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let d=l.resolve(t.start-2);o=new Ese(d,d,t.depth),t.endIndex=0;p--)o=_s.from(s[p].type.create(s[p].attrs,o));e.step(new Zd(t.start-(n?2:0),t.end,t.start,t.end,new nn(o,0,0),s.length,!0));let l=0;for(let p=0;pl.childCount>0&&l.firstChild.type==e);return o?s?n.node(o.depth-1).type==e?Ekt(t,s,e,o):Ikt(t,s,o):!0:!1}}function Ekt(e,t,s,n){let a=e.tr,o=n.end,l=n.$to.end(n.depth);ow;k--)_-=a.child(k).nodeSize,n.delete(_-1,_+1);let o=n.doc.resolve(s.start),l=o.nodeAfter;if(n.mapping.map(s.end)!=s.start+o.nodeAfter.nodeSize)return!1;let i=s.startIndex==0,d=s.endIndex==a.childCount,m=o.node(-1),p=o.index(-1);if(!m.canReplace(p+(i?0:1),p+1,l.content.append(d?_s.empty:_s.from(a))))return!1;let g=o.pos,v=g+l.nodeSize;return n.step(new Zd(g-(i?1:0),v+(d?1:0),g+1,v-1,new nn((i?_s.empty:_s.from(a.copy(_s.empty))).append(d?_s.empty:_s.from(a.copy(_s.empty))),i?0:1,d?0:1),i?0:1)),t(n.scrollIntoView()),!0}function Pkt(e){return function(t,s){let{$from:n,$to:a}=t.selection,o=n.blockRange(a,m=>m.childCount>0&&m.firstChild.type==e);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!=e)return!1;if(s){let m=d.lastChild&&d.lastChild.type==i.type,p=_s.from(m?e.create():null),g=new nn(_s.from(e.create(null,_s.from(i.type.create(null,p)))),m?3:1,0),v=o.start,_=o.end;s(t.tr.step(new Zd(v-(m?3:1),_,v,_,g,1,!0)).scrollIntoView())}return!0}}function Jie(e){const{state:t,transaction:s}=e;let{selection:n}=s,{doc:a}=s,{storedMarks:o}=s;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return n},get doc(){return a},get tr(){return n=s.selection,a=s.doc,o=s.storedMarks,s}}}class eoe{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:s,state:n}=this,{view:a}=s,{tr:o}=n,l=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([i,d])=>[i,(...p)=>{const g=d(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),g}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,s=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i=[],d=!!t,m=t||o.tr,p=()=>(!d&&s&&!m.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(m),i.every(v=>v===!0)),g={...Object.fromEntries(Object.entries(n).map(([v,_])=>[v,(...w)=>{const S=this.buildProps(m,s),T=_(...w)(S);return i.push(T),g}])),run:p};return g}createCan(t){const{rawCommands:s,state:n}=this,a=!1,o=t||n.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(s).map(([d,m])=>[d,(...p)=>m(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(t,s=!0){const{rawCommands:n,editor:a,state:o}=this,{view:l}=a,i={tr:t,editor:a,view:l,state:Jie({state:o,transaction:t}),dispatch:s?()=>{}:void 0,chain:()=>this.createChain(t,s),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([d,m])=>[d,(...p)=>m(...p)(i)]))}};return i}}let Lkt=class{constructor(){this.callbacks={}}on(t,s){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(s),this}emit(t,...s){const n=this.callbacks[t];return n&&n.forEach(a=>a.apply(this,s)),this}off(t,s){const n=this.callbacks[t];return n&&(s?this.callbacks[t]=n.filter(a=>a!==s):delete this.callbacks[t]),this}once(t,s){const n=(...a)=>{this.off(t,n),s.apply(this,a)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function Un(e,t,s){return e.config[t]===void 0&&e.parent?Un(e.parent,t,s):typeof e.config[t]=="function"?e.config[t].bind({...s,parent:e.parent?Un(e.parent,t,s):null}):e.config[t]}function toe(e){const t=e.filter(a=>a.type==="extension"),s=e.filter(a=>a.type==="node"),n=e.filter(a=>a.type==="mark");return{baseExtensions:t,nodeExtensions:s,markExtensions:n}}function kUe(e){const t=[],{nodeExtensions:s,markExtensions:n}=toe(e),a=[...s,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage,extensions:a},d=Un(l,"addGlobalAttributes",i);if(!d)return;d().forEach(p=>{p.types.forEach(g=>{Object.entries(p.attributes).forEach(([v,_])=>{t.push({type:g,name:v,attribute:{...o,..._}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},d=Un(l,"addAttributes",i);if(!d)return;const m=d();Object.entries(m).forEach(([p,g])=>{const v={...o,...g};typeof(v==null?void 0:v.default)=="function"&&(v.default=v.default()),v!=null&&v.isRequired&&(v==null?void 0:v.default)===void 0&&delete v.default,t.push({type:l.name,name:p,attribute:v})})}),t}function Xd(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function sc(...e){return e.filter(t=>!!t).reduce((t,s)=>{const n={...t};return Object.entries(s).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(" "):[],m=i.filter(p=>!d.includes(p));n[a]=[...d,...m].join(" ")}else if(a==="style"){const i=o?o.split(";").map(p=>p.trim()).filter(Boolean):[],d=n[a]?n[a].split(";").map(p=>p.trim()).filter(Boolean):[],m=new Map;d.forEach(p=>{const[g,v]=p.split(":").map(_=>_.trim());m.set(g,v)}),i.forEach(p=>{const[g,v]=p.split(":").map(_=>_.trim());m.set(g,v)}),n[a]=Array.from(m.entries()).map(([p,g])=>`${p}: ${g}`).join("; ")}else n[a]=o}),n},{})}function Ype(e,t){return t.filter(s=>s.type===e.type.name).filter(s=>s.attribute.rendered).map(s=>s.attribute.renderHTML?s.attribute.renderHTML(e.attrs)||{}:{[s.name]:e.attrs[s.name]}).reduce((s,n)=>sc(s,n),{})}function NUe(e){return typeof e=="function"}function Ti(e,t=void 0,...s){return NUe(e)?t?e.bind(t)(...s):e(...s):e}function Dkt(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Okt(e){return typeof e!="string"?e:e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e==="true"?!0:e==="false"?!1:e}function i3e(e,t){return"style"in e?e:{...e,getAttrs:s=>{const n=e.getAttrs?e.getAttrs(s):e.attrs;if(n===!1)return!1;const a=t.reduce((o,l)=>{const i=l.attribute.parseHTML?l.attribute.parseHTML(s):Okt(s.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function o3e(e){return Object.fromEntries(Object.entries(e).filter(([t,s])=>t==="attrs"&&Dkt(s)?!1:s!=null))}function Rkt(e,t){var s;const n=kUe(e),{nodeExtensions:a,markExtensions:o}=toe(e),l=(s=a.find(m=>Un(m,"topNode")))===null||s===void 0?void 0:s.name,i=Object.fromEntries(a.map(m=>{const p=n.filter(T=>T.type===m.name),g={name:m.name,options:m.options,storage:m.storage,editor:t},v=e.reduce((T,C)=>{const I=Un(C,"extendNodeSchema",g);return{...T,...I?I(m):{}}},{}),_=o3e({...v,content:Ti(Un(m,"content",g)),marks:Ti(Un(m,"marks",g)),group:Ti(Un(m,"group",g)),inline:Ti(Un(m,"inline",g)),atom:Ti(Un(m,"atom",g)),selectable:Ti(Un(m,"selectable",g)),draggable:Ti(Un(m,"draggable",g)),code:Ti(Un(m,"code",g)),whitespace:Ti(Un(m,"whitespace",g)),linebreakReplacement:Ti(Un(m,"linebreakReplacement",g)),defining:Ti(Un(m,"defining",g)),isolating:Ti(Un(m,"isolating",g)),attrs:Object.fromEntries(p.map(T=>{var C;return[T.name,{default:(C=T==null?void 0:T.attribute)===null||C===void 0?void 0:C.default}]}))}),k=Ti(Un(m,"parseHTML",g));k&&(_.parseDOM=k.map(T=>i3e(T,p)));const w=Un(m,"renderHTML",g);w&&(_.toDOM=T=>w({node:T,HTMLAttributes:Ype(T,p)}));const S=Un(m,"renderText",g);return S&&(_.toText=S),[m.name,_]})),d=Object.fromEntries(o.map(m=>{const p=n.filter(S=>S.type===m.name),g={name:m.name,options:m.options,storage:m.storage,editor:t},v=e.reduce((S,T)=>{const C=Un(T,"extendMarkSchema",g);return{...S,...C?C(m):{}}},{}),_=o3e({...v,inclusive:Ti(Un(m,"inclusive",g)),excludes:Ti(Un(m,"excludes",g)),group:Ti(Un(m,"group",g)),spanning:Ti(Un(m,"spanning",g)),code:Ti(Un(m,"code",g)),attrs:Object.fromEntries(p.map(S=>{var T;return[S.name,{default:(T=S==null?void 0:S.attribute)===null||T===void 0?void 0:T.default}]}))}),k=Ti(Un(m,"parseHTML",g));k&&(_.parseDOM=k.map(S=>i3e(S,p)));const w=Un(m,"renderHTML",g);return w&&(_.toDOM=S=>w({mark:S,HTMLAttributes:Ype(S,p)})),[m.name,_]}));return new h$e({topNode:l,nodes:i,marks:d})}function Kue(e,t){return t.nodes[e]||t.marks[e]||null}function l3e(e,t){return Array.isArray(t)?t.some(s=>(typeof s=="string"?s:s.name)===e.name):t}function O1e(e,t){const s=wN.fromSchema(t).serializeFragment(e),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(s),a.innerHTML}const Fkt=(e,t=500)=>{let s="";const n=e.parentOffset;return e.parent.nodesBetween(Math.max(0,n-t),n,(a,o,l,i)=>{var d,m;const p=((m=(d=a.type.spec).toText)===null||m===void 0?void 0:m.call(d,{node:a,pos:o,parent:l,index:i}))||a.textContent||"%leaf%";s+=a.isAtom&&!a.isText?p:p.slice(0,Math.max(0,n-o))}),s};function R1e(e){return Object.prototype.toString.call(e)==="[object RegExp]"}class roe{constructor(t){this.find=t.find,this.handler=t.handler}}const zkt=(e,t)=>{if(R1e(t))return t.exec(e);const s=t(e);if(!s)return null;const n=[s.text];return n.index=s.index,n.input=e,n.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(s.replaceWith)),n};function LO(e){var t;const{editor:s,from:n,to:a,text:o,rules:l,plugin:i}=e,{view:d}=s;if(d.composing)return!1;const m=d.state.doc.resolve(n);if(m.parent.type.spec.code||!((t=m.nodeBefore||m.nodeAfter)===null||t===void 0)&&t.marks.find(v=>v.type.spec.code))return!1;let p=!1;const g=Fkt(m)+o;return l.forEach(v=>{if(p)return;const _=zkt(g,v.find);if(!_)return;const k=d.state.tr,w=Jie({state:d.state,transaction:k}),S={from:n-(_[0].length-o.length),to:a},{commands:T,chain:C,can:I}=new eoe({editor:s,state:w});v.handler({state:w,range:S,match:_,commands:T,chain:C,can:I})===null||!k.steps.length||(k.setMeta(i,{transform:k,from:n,to:a,text:o}),d.dispatch(k),p=!0)}),p}function Bkt(e){const{editor:t,rules:s}=e,n=new Td({state:{init(){return null},apply(a,o,l){const i=a.getMeta(n);if(i)return i;const d=a.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:p}=d;typeof p=="string"?p=p:p=O1e(_s.from(p),l.schema);const{from:g}=d,v=g+p.length;LO({editor:t,from:g,to:v,text:p,rules:s,plugin:n})}),a.selectionSet||a.docChanged?null:o}},props:{handleTextInput(a,o,l,i){return LO({editor:t,from:o,to:l,text:i,rules:s,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&LO({editor:t,from:o.pos,to:o.pos,text:"",rules:s,plugin:n})}),!1)},handleKeyDown(a,o){if(o.key!=="Enter")return!1;const{$cursor:l}=a.state.selection;return l?LO({editor:t,from:l.pos,to:l.pos,text:` `,rules:s,plugin:n}):!1}},isInputRules:!0});return n}function $kt(e){return Object.prototype.toString.call(e).slice(8,-1)}function DO(e){return $kt(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function soe(e,t){const s={...e};return DO(e)&&DO(t)&&Object.keys(t).forEach(n=>{DO(t[n])&&DO(e[n])?s[n]=soe(e[n],t[n]):s[n]=t[n]}),s}class Cx{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.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=Ti(Un(this,"addOptions",{name:this.name}))),this.storage=Ti(Un(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Cx(t)}configure(t={}){const s=this.extend({...this.config,addOptions:()=>soe(this.options,t)});return s.name=this.name,s.parent=this.parent,s}extend(t={}){const s=new Cx(t);return s.parent=this,this.child=s,s.name=t.name?t.name:s.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${s.name}".`),s.options=Ti(Un(s,"addOptions",{name:s.name})),s.storage=Ti(Un(s,"addStorage",{name:s.name,options:s.options})),s}static handleExit({editor:t,mark:s}){const{tr:n}=t.state,a=t.state.selection.$from;if(a.pos===a.end()){const l=a.marks();if(!!!l.find(m=>(m==null?void 0:m.type.name)===s.name))return!1;const d=l.find(m=>(m==null?void 0:m.type.name)===s.name);return d&&n.removeStoredMark(d),n.insertText(" ",a.pos),t.view.dispatch(n),!0}return!1}}function Ukt(e){return typeof e=="number"}class Vkt{constructor(t){this.find=t.find,this.handler=t.handler}}const qkt=(e,t,s)=>{if(R1e(t))return[...e.matchAll(t)];const n=t(e,s);return n?n.map(a=>{const o=[a.text];return o.index=a.index,o.input=e,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 Hkt(e){const{editor:t,state:s,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=e,{commands:d,chain:m,can:p}=new eoe({editor:t,state:s}),g=[];return s.doc.nodesBetween(n,a,(_,k)=>{if(!_.isTextblock||_.type.spec.code)return;const w=Math.max(n,k),S=Math.min(a,k+_.content.size),T=_.textBetween(w-k,S-k,void 0,"");qkt(T,o.find,l).forEach(I=>{if(I.index===void 0)return;const R=w+I.index+1,D=R+I[0].length,B={from:s.tr.mapping.map(R),to:s.tr.mapping.map(D)},$=o.handler({state:s,range:B,match:I,commands:d,chain:m,can:p,pasteEvent:l,dropEvent:i});g.push($)})}),g.every(_=>_!==null)}let OO=null;const Wkt=e=>{var t;const s=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(t=s.clipboardData)===null||t===void 0||t.setData("text/html",e),s};function Gkt(e){const{editor:t,rules:s}=e;let n=null,a=!1,o=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,i;try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}const d=({state:p,from:g,to:v,rule:_,pasteEvt:k})=>{const w=p.tr,S=Jie({state:p,transaction:w});if(!(!Hkt({editor:t,state:S,from:Math.max(g-1,0),to:v.b-1,rule:_,pasteEvent:k,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 s.map(p=>new Td({view(g){const v=k=>{var w;n=!((w=g.dom.parentElement)===null||w===void 0)&&w.contains(k.target)?g.dom.parentElement:null,n&&(OO=t)},_=()=>{OO&&(OO=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 _=OO;_!=null&&_.isEditable&&setTimeout(()=>{const k=_.state.selection;k&&_.commands.deleteRange({from:k.from,to:k.to})},10)}return!1},paste:(g,v)=>{var _;const k=(_=v.clipboardData)===null||_===void 0?void 0:_.getData("text/html");return l=v,a=!!(k!=null&&k.includes("data-pm-slice")),!1}}},appendTransaction:(g,v,_)=>{const k=g[0],w=k.getMeta("uiEvent")==="paste"&&!a,S=k.getMeta("uiEvent")==="drop"&&!o,T=k.getMeta("applyPasteRules"),C=!!T;if(!w&&!S&&!C)return;if(C){let{text:D}=T;typeof D=="string"?D=D:D=O1e(_s.from(D),_.schema);const{from:B}=T,$=B+D.length,q=Wkt(D);return d({rule:p,state:_,from:B,to:{b:$},pasteEvt:q})}const I=v.doc.content.findDiffStart(_.doc.content),R=v.doc.content.findDiffEnd(_.doc.content);if(!(!Ukt(I)||!R||I===R.b))return d({rule:p,state:_,from:I,to:R,pasteEvt:l})}}))}function Kkt(e){const t=e.filter((s,n)=>e.indexOf(s)!==n);return Array.from(new Set(t))}class JC{constructor(t,s){this.splittableMarks=[],this.editor=s,this.extensions=JC.resolve(t),this.schema=Rkt(this.extensions,s),this.setupExtensions()}static resolve(t){const s=JC.sort(JC.flatten(t)),n=Kkt(s.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.`),s}static flatten(t){return t.map(s=>{const n={name:s.name,options:s.options,storage:s.storage},a=Un(s,"addExtensions",n);return a?[s,...this.flatten(a())]:s}).flat(10)}static sort(t){return t.sort((n,a)=>{const o=Un(n,"priority")||100,l=Un(a,"priority")||100;return o>l?-1:o{const n={name:s.name,options:s.options,storage:s.storage,editor:this.editor,type:Kue(s.name,this.schema)},a=Un(s,"addCommands",n);return a?{...t,...a()}:t},{})}get plugins(){const{editor:t}=this,s=JC.sort([...this.extensions].reverse()),n=[],a=[],o=s.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:t,type:Kue(l.name,this.schema)},d=[],m=Un(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&Un(l,"exitable",i)&&(p.ArrowRight=()=>Cx.handleExit({editor:t,mark:l})),m){const w=Object.fromEntries(Object.entries(m()).map(([S,T])=>[S,()=>T({editor:t})]));p={...p,...w}}const g=mkt(p);d.push(g);const v=Un(l,"addInputRules",i);l3e(l,t.options.enableInputRules)&&v&&n.push(...v());const _=Un(l,"addPasteRules",i);l3e(l,t.options.enablePasteRules)&&_&&a.push(..._());const k=Un(l,"addProseMirrorPlugins",i);if(k){const w=k();d.push(...w)}return d}).flat();return[Bkt({editor:t,rules:n}),...Gkt({editor:t,rules:a}),...o]}get attributes(){return kUe(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:s}=toe(this.extensions);return Object.fromEntries(s.filter(n=>!!Un(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:t,type:Xd(n.name,this.schema)},l=Un(n,"addNodeView",o);if(!l)return[];const i=(d,m,p,g,v)=>{const _=Ype(d,a);return l()({node:d,view:m,getPos:p,decorations:g,innerDecorations:v,editor:t,extension:n,HTMLAttributes:_})};return[n.name,i]}))}setupExtensions(){this.extensions.forEach(t=>{var s;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Kue(t.name,this.schema)};t.type==="mark"&&(!((s=Ti(Un(t,"keepOnSplit",n)))!==null&&s!==void 0)||s)&&this.splittableMarks.push(t.name);const a=Un(t,"onBeforeCreate",n),o=Un(t,"onCreate",n),l=Un(t,"onUpdate",n),i=Un(t,"onSelectionUpdate",n),d=Un(t,"onTransaction",n),m=Un(t,"onFocus",n),p=Un(t,"onBlur",n),g=Un(t,"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),m&&this.editor.on("focus",m),p&&this.editor.on("blur",p),g&&this.editor.on("destroy",g)})}}class yu{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.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=Ti(Un(this,"addOptions",{name:this.name}))),this.storage=Ti(Un(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new yu(t)}configure(t={}){const s=this.extend({...this.config,addOptions:()=>soe(this.options,t)});return s.name=this.name,s.parent=this.parent,s}extend(t={}){const s=new yu({...this.config,...t});return s.parent=this,this.child=s,s.name=t.name?t.name:s.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${s.name}".`),s.options=Ti(Un(s,"addOptions",{name:s.name})),s.storage=Ti(Un(s,"addStorage",{name:s.name,options:s.options})),s}}function SUe(e,t,s){const{from:n,to:a}=t,{blockSeparator:o=` `,textSerializers:l={}}=s||{};let i="";return e.nodesBetween(n,a,(d,m,p,g)=>{var v;d.isBlock&&m>n&&(i+=o);const _=l==null?void 0:l[d.type.name];if(_)return p&&(i+=_({node:d,pos:m,parent:p,index:g,range:t})),!1;d.isText&&(i+=(v=d==null?void 0:d.text)===null||v===void 0?void 0:v.slice(Math.max(n,m)-m,a-m))}),i}function CUe(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,s])=>[t,s.spec.toText]))}const Zkt=yu.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Td({key:new Vu("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:s}=e,{doc:n,selection:a}=t,{ranges:o}=a,l=Math.min(...o.map(p=>p.$from.pos)),i=Math.max(...o.map(p=>p.$to.pos)),d=CUe(s);return SUe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),Ykt=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var s;e.isDestroyed||(t.dom.blur(),(s=window==null?void 0:window.getSelection())===null||s===void 0||s.removeAllRanges())}),!0),Xkt=(e=!1)=>({commands:t})=>t.setContent("",e),Qkt=()=>({state:e,tr:t,dispatch:s})=>{const{selection:n}=t,{ranges:a}=n;return s&&a.forEach(({$from:o,$to:l})=>{e.doc.nodesBetween(o.pos,l.pos,(i,d)=>{if(i.type.isText)return;const{doc:m,mapping:p}=t,g=m.resolve(p.map(d)),v=m.resolve(p.map(d+i.nodeSize)),_=g.blockRange(v);if(!_)return;const k=D3(_);if(i.type.isTextblock){const{defaultType:w}=g.parent.contentMatchAt(g.index());t.setNodeMarkup(_.start,w)}(k||k===0)&&t.lift(_,k)})}),!0},Jkt=e=>t=>e(t),eNt=()=>({state:e,dispatch:t})=>_Ue(e,t),tNt=(e,t)=>({editor:s,tr:n})=>{const{state:a}=s,o=a.doc.slice(e.from,e.to);n.deleteRange(e.from,e.to);const l=n.mapping.map(t);return n.insert(l,o.content),n.setSelection(new Ca(n.doc.resolve(Math.max(l-1,0)))),!0},rNt=()=>({tr:e,dispatch:t})=>{const{selection:s}=e,n=s.$anchor.node();if(n.content.size>0)return!1;const a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===n.type){if(t){const i=a.before(o),d=a.after(o);e.delete(i,d).scrollIntoView()}return!0}return!1},sNt=e=>({tr:t,state:s,dispatch:n})=>{const a=Xd(e,s.schema),o=t.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===a){if(n){const d=o.before(l),m=o.after(l);t.delete(d,m).scrollIntoView()}return!0}return!1},nNt=e=>({tr:t,dispatch:s})=>{const{from:n,to:a}=e;return s&&t.delete(n,a),!0},aNt=()=>({state:e,dispatch:t})=>E1e(e,t),iNt=()=>({commands:e})=>e.keyboardShortcut("Enter"),oNt=()=>({state:e,dispatch:t})=>vkt(e,t);function zse(e,t,s={strict:!0}){const n=Object.keys(t);return n.length?n.every(a=>s.strict?t[a]===e[a]:R1e(t[a])?t[a].test(e[a]):t[a]===e[a]):!0}function MUe(e,t,s={}){return e.find(n=>n.type===t&&zse(Object.fromEntries(Object.keys(s).map(a=>[a,n.attrs[a]])),s))}function c3e(e,t,s={}){return!!MUe(e,t,s)}function F1e(e,t,s){var n;if(!e||!t)return;let a=e.parent.childAfter(e.parentOffset);if((!a.node||!a.node.marks.some(p=>p.type===t))&&(a=e.parent.childBefore(e.parentOffset)),!a.node||!a.node.marks.some(p=>p.type===t)||(s=s||((n=a.node.marks[0])===null||n===void 0?void 0:n.attrs),!MUe([...a.node.marks],t,s)))return;let l=a.index,i=e.start()+a.offset,d=l+1,m=i+a.node.nodeSize;for(;l>0&&c3e([...e.parent.child(l-1).marks],t,s);)l-=1,i-=e.parent.child(l).nodeSize;for(;d({tr:s,state:n,dispatch:a})=>{const o=d_(e,n.schema),{doc:l,selection:i}=s,{$from:d,from:m,to:p}=i;if(a){const g=F1e(d,o,t);if(g&&g.from<=m&&g.to>=p){const v=Ca.create(l,g.from,g.to);s.setSelection(v)}}return!0},cNt=e=>t=>{const s=typeof e=="function"?e(t):e;for(let n=0;n({editor:s,view:n,tr:a,dispatch:o})=>{t={scrollIntoView:!0,...t};const l=()=>{(z1e()||dNt())&&n.dom.focus(),requestAnimationFrame(()=>{s.isDestroyed||(n.focus(),t!=null&&t.scrollIntoView&&s.commands.scrollIntoView())})};if(n.hasFocus()&&e===null||e===!1)return!0;if(o&&e===null&&!TUe(s.state.selection))return l(),!0;const i=AUe(a.doc,e)||s.state.selection,d=s.state.selection.eq(i);return o&&(d||a.setSelection(i),d&&a.storedMarks&&a.setStoredMarks(a.storedMarks),l()),!0},hNt=(e,t)=>s=>e.every((n,a)=>t(n,{...s,index:a})),mNt=(e,t)=>({tr:s,commands:n})=>n.insertContentAt({from:s.selection.from,to:s.selection.to},e,t),EUe=e=>{const t=e.childNodes;for(let s=t.length-1;s>=0;s-=1){const n=t[s];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?e.removeChild(n):n.nodeType===1&&EUe(n)}return e};function RO(e){const t=`${e}`,s=new window.DOMParser().parseFromString(t,"text/html").body;return EUe(s)}function oP(e,t,s){if(e instanceof P1||e instanceof _s)return e;s={slice:!0,parseOptions:{},...s};const n=typeof e=="object"&&e!==null,a=typeof e=="string";if(n)try{if(Array.isArray(e)&&e.length>0)return _s.fromArray(e.map(i=>t.nodeFromJSON(i)));const l=t.nodeFromJSON(e);return s.errorOnInvalidContent&&l.check(),l}catch(o){if(s.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",o),oP("",t,s)}if(a){if(s.errorOnInvalidContent){let l=!1,i="";const d=new h$e({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:m=>(l=!0,i=typeof m=="string"?m:m.outerHTML,null)}]}})});if(s.slice?QE.fromSchema(d).parseSlice(RO(e),s.parseOptions):QE.fromSchema(d).parse(RO(e),s.parseOptions),s.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=QE.fromSchema(t);return s.slice?o.parseSlice(RO(e),s.parseOptions).content:o.parse(RO(e),s.parseOptions)}return oP("",t,s)}function fNt(e,t,s){const n=e.steps.length-1;if(n{l===0&&(l=p)}),e.setSelection(Va.near(e.doc.resolve(l),s))}const pNt=e=>!("type"in e),gNt=(e,t,s)=>({tr:n,dispatch:a,editor:o})=>{var l;if(a){s={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...s};let i;const d=S=>{o.emit("contentError",{editor:o,error:S,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},m={preserveWhitespace:"full",...s.parseOptions};if(!s.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{oP(t,o.schema,{parseOptions:m,errorOnInvalidContent:!0})}catch(S){d(S)}try{i=oP(t,o.schema,{parseOptions:m,errorOnInvalidContent:(l=s.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(S){return d(S),!1}let{from:p,to:g}=typeof e=="number"?{from:e,to:e}:{from:e.from,to:e.to},v=!0,_=!0;if((pNt(i)?i:[i]).forEach(S=>{S.check(),v=v?S.isText&&S.marks.length===0:!1,_=_?S.isBlock:!1}),p===g&&_){const{parent:S}=n.doc.resolve(p);S.isTextblock&&!S.type.spec.code&&!S.childCount&&(p-=1,g+=1)}let w;if(v){if(Array.isArray(t))w=t.map(S=>S.text||"").join("");else if(t instanceof _s){let S="";t.forEach(T=>{T.text&&(S+=T.text)}),w=S}else typeof t=="object"&&t&&t.text?w=t.text:w=t;n.insertText(w,p,g)}else w=i,n.replaceWith(p,g,w);s.updateSelection&&fNt(n,n.steps.length-1,-1),s.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:w}),s.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:w})}return!0},xNt=()=>({state:e,dispatch:t})=>gkt(e,t),yNt=()=>({state:e,dispatch:t})=>xkt(e,t),vNt=()=>({state:e,dispatch:t})=>mUe(e,t),_Nt=()=>({state:e,dispatch:t})=>xUe(e,t),bNt=()=>({state:e,dispatch:t,tr:s})=>{try{const n=Gie(e.doc,e.selection.$from.pos,-1);return n==null?!1:(s.join(n,2),t&&t(s),!0)}catch{return!1}},wNt=()=>({state:e,dispatch:t,tr:s})=>{try{const n=Gie(e.doc,e.selection.$from.pos,1);return n==null?!1:(s.join(n,2),t&&t(s),!0)}catch{return!1}},jNt=()=>({state:e,dispatch:t})=>fkt(e,t),kNt=()=>({state:e,dispatch:t})=>pkt(e,t);function IUe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function NNt(e){const t=e.split(/-(?!$)/);let s=t[t.length-1];s==="Space"&&(s=" ");let n,a,o,l;for(let i=0;i({editor:t,view:s,tr:n,dispatch:a})=>{const o=NNt(e).split(/-(?!$)/),l=o.find(m=>!["Alt","Ctrl","Meta","Shift"].includes(m)),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=t.captureTransaction(()=>{s.someProp("handleKeyDown",m=>m(s,i))});return d==null||d.steps.forEach(m=>{const p=m.map(n.mapping);p&&a&&n.maybeStep(p)}),!0};function lP(e,t,s={}){const{from:n,to:a,empty:o}=e.selection,l=t?Xd(t,e.schema):null,i=[];e.doc.nodesBetween(n,a,(g,v)=>{if(g.isText)return;const _=Math.max(n,v),k=Math.min(a,v+g.nodeSize);i.push({node:g,from:_,to:k})});const d=a-n,m=i.filter(g=>l?l.name===g.node.type.name:!0).filter(g=>zse(g.node.attrs,s,{strict:!1}));return o?!!m.length:m.reduce((g,v)=>g+v.to-v.from,0)>=d}const CNt=(e,t={})=>({state:s,dispatch:n})=>{const a=Xd(e,s.schema);return lP(s,a,t)?ykt(s,n):!1},MNt=()=>({state:e,dispatch:t})=>bUe(e,t),TNt=e=>({state:t,dispatch:s})=>{const n=Xd(e,t.schema);return Akt(n)(t,s)},ANt=()=>({state:e,dispatch:t})=>vUe(e,t);function noe(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function d3e(e,t){const s=typeof t=="string"?[t]:t;return Object.keys(e).reduce((n,a)=>(s.includes(a)||(n[a]=e[a]),n),{})}const ENt=(e,t)=>({tr:s,state:n,dispatch:a})=>{let o=null,l=null;const i=noe(typeof e=="string"?e:e.name,n.schema);return i?(i==="node"&&(o=Xd(e,n.schema)),i==="mark"&&(l=d_(e,n.schema)),a&&s.selection.ranges.forEach(d=>{n.doc.nodesBetween(d.$from.pos,d.$to.pos,(m,p)=>{o&&o===m.type&&s.setNodeMarkup(p,void 0,d3e(m.attrs,t)),l&&m.marks.length&&m.marks.forEach(g=>{l===g.type&&s.addMark(p,p+m.nodeSize,l.create(d3e(g.attrs,t)))})})}),!0):!1},INt=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),PNt=()=>({tr:e,dispatch:t})=>{if(t){const s=new Um(e.doc);e.setSelection(s)}return!0},LNt=()=>({state:e,dispatch:t})=>pUe(e,t),DNt=()=>({state:e,dispatch:t})=>yUe(e,t),ONt=()=>({state:e,dispatch:t})=>wkt(e,t),RNt=()=>({state:e,dispatch:t})=>Nkt(e,t),FNt=()=>({state:e,dispatch:t})=>kkt(e,t);function Xpe(e,t,s={},n={}){return oP(e,t,{slice:!1,parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent})}const zNt=(e,t=!1,s={},n={})=>({editor:a,tr:o,dispatch:l,commands:i})=>{var d,m;const{doc:p}=o;if(s.preserveWhitespace!=="full"){const g=Xpe(e,a.schema,s,{errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:a.options.enableContentCheck});return l&&o.replaceWith(0,p.content.size,g).setMeta("preventUpdate",!t),!0}return l&&o.setMeta("preventUpdate",!t),i.insertContentAt({from:0,to:p.content.size},e,{parseOptions:s,errorOnInvalidContent:(m=n.errorOnInvalidContent)!==null&&m!==void 0?m:a.options.enableContentCheck})};function PUe(e,t){const s=d_(t,e.schema),{from:n,to:a,empty:o}=e.selection,l=[];o?(e.storedMarks&&l.push(...e.storedMarks),l.push(...e.selection.$head.marks())):e.doc.nodesBetween(n,a,d=>{l.push(...d.marks)});const i=l.find(d=>d.type.name===s.name);return i?{...i.attrs}:{}}function BNt(e,t){const s=new v1e(e);return t.forEach(n=>{n.steps.forEach(a=>{s.step(a)})}),s}function $Nt(e){for(let t=0;t{s(a)&&n.push({node:a,pos:o})}),n}function LUe(e,t){for(let s=e.depth;s>0;s-=1){const n=e.node(s);if(t(n))return{pos:s>0?e.before(s):0,start:e.start(s),depth:s,node:n}}}function B1e(e){return t=>LUe(t.$from,e)}function VNt(e,t){const s={from:0,to:e.content.size};return SUe(e,s,t)}function qNt(e,t){const s=Xd(t,e.schema),{from:n,to:a}=e.selection,o=[];e.doc.nodesBetween(n,a,i=>{o.push(i)});const l=o.reverse().find(i=>i.type.name===s.name);return l?{...l.attrs}:{}}function DUe(e,t){const s=noe(typeof t=="string"?t:t.name,e.schema);return s==="node"?qNt(e,t):s==="mark"?PUe(e,t):{}}function HNt(e,t=JSON.stringify){const s={};return e.filter(n=>{const a=t(n);return Object.prototype.hasOwnProperty.call(s,a)?!1:s[a]=!0})}function WNt(e){const t=HNt(e);return t.length===1?t:t.filter((s,n)=>!t.filter((o,l)=>l!==n).some(o=>s.oldRange.from>=o.oldRange.from&&s.oldRange.to<=o.oldRange.to&&s.newRange.from>=o.newRange.from&&s.newRange.to<=o.newRange.to))}function GNt(e){const{mapping:t,steps:s}=e,n=[];return t.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}=s[o];if(i===void 0||d===void 0)return;l.push({from:i,to:d})}l.forEach(({from:i,to:d})=>{const m=t.slice(o).map(i,-1),p=t.slice(o).map(d),g=t.invert().map(m,-1),v=t.invert().map(p);n.push({oldRange:{from:g,to:v},newRange:{from:m,to:p}})})}),WNt(n)}function $1e(e,t,s){const n=[];return e===t?s.resolve(e).marks().forEach(a=>{const o=s.resolve(e),l=F1e(o,a.type);l&&n.push({mark:a,...l})}):s.nodesBetween(e,t,(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 cre(e,t,s){return Object.fromEntries(Object.entries(s).filter(([n])=>{const a=e.find(o=>o.type===t&&o.name===n);return a?a.attribute.keepOnSplit:!1}))}function Qpe(e,t,s={}){const{empty:n,ranges:a}=e.selection,o=t?d_(t,e.schema):null;if(n)return!!(e.storedMarks||e.selection.$from.marks()).filter(g=>o?o.name===g.type.name:!0).find(g=>zse(g.attrs,s,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:g,$to:v})=>{const _=g.pos,k=v.pos;e.doc.nodesBetween(_,k,(w,S)=>{if(!w.isText&&!w.marks.length)return;const T=Math.max(_,S),C=Math.min(k,S+w.nodeSize),I=C-T;l+=I,i.push(...w.marks.map(R=>({mark:R,from:T,to:C})))})}),l===0)return!1;const d=i.filter(g=>o?o.name===g.mark.type.name:!0).filter(g=>zse(g.mark.attrs,s,{strict:!1})).reduce((g,v)=>g+v.to-v.from,0),m=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+m:d)>=l}function KNt(e,t,s={}){if(!t)return lP(e,null,s)||Qpe(e,null,s);const n=noe(t,e.schema);return n==="node"?lP(e,t,s):n==="mark"?Qpe(e,t,s):!1}function u3e(e,t){const{nodeExtensions:s}=toe(t),n=s.find(l=>l.name===e);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=Ti(Un(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function U1e(e,{checkChildren:t=!0,ignoreWhitespace:s=!1}={}){var n;if(s){if(e.type.name==="hardBreak")return!0;if(e.isText)return/^\s*$/m.test((n=e.text)!==null&&n!==void 0?n:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let a=!0;return e.content.forEach(o=>{a!==!1&&(U1e(o,{ignoreWhitespace:s,checkChildren:t})||(a=!1))}),a}return!1}function ZNt(e){return e instanceof ba}function YNt(e,t,s){var n;const{selection:a}=t;let o=null;if(TUe(a)&&(o=a.$cursor),o){const i=(n=e.storedMarks)!==null&&n!==void 0?n:o.marks();return!!s.isInSet(i)||!i.some(d=>d.type.excludes(s))}const{ranges:l}=a;return l.some(({$from:i,$to:d})=>{let m=i.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(s):!1;return e.doc.nodesBetween(i.pos,d.pos,(p,g,v)=>{if(m)return!1;if(p.isInline){const _=!v||v.type.allowsMarkType(s),k=!!s.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(s));m=_&&k}return!m}),m})}const XNt=(e,t={})=>({tr:s,state:n,dispatch:a})=>{const{selection:o}=s,{empty:l,ranges:i}=o,d=d_(e,n.schema);if(a)if(l){const m=PUe(n,d);s.addStoredMark(d.create({...m,...t}))}else i.forEach(m=>{const p=m.$from.pos,g=m.$to.pos;n.doc.nodesBetween(p,g,(v,_)=>{const k=Math.max(_,p),w=Math.min(_+v.nodeSize,g);v.marks.find(T=>T.type===d)?v.marks.forEach(T=>{d===T.type&&s.addMark(k,w,d.create({...T.attrs,...t}))}):s.addMark(k,w,d.create(t))})});return YNt(n,s,d)},QNt=(e,t)=>({tr:s})=>(s.setMeta(e,t),!0),JNt=(e,t={})=>({state:s,dispatch:n,chain:a})=>{const o=Xd(e,s.schema);let l;return s.selection.$anchor.sameParent(s.selection.$head)&&(l=s.selection.$anchor.parent.attrs),o.isTextblock?a().command(({commands:i})=>a3e(o,{...l,...t})(s)?!0:i.clearNodes()).command(({state:i})=>a3e(o,{...l,...t})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},eSt=e=>({tr:t,dispatch:s})=>{if(s){const{doc:n}=t,a=Gj(e,0,n.content.size),o=ba.create(n,a);t.setSelection(o)}return!0},tSt=e=>({tr:t,dispatch:s})=>{if(s){const{doc:n}=t,{from:a,to:o}=typeof e=="number"?{from:e,to:e}:e,l=Ca.atStart(n).from,i=Ca.atEnd(n).to,d=Gj(a,l,i),m=Gj(o,l,i),p=Ca.create(n,d,m);t.setSelection(p)}return!0},rSt=e=>({state:t,dispatch:s})=>{const n=Xd(e,t.schema);return Pkt(n)(t,s)};function h3e(e,t){const s=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(s){const n=s.filter(a=>t==null?void 0:t.includes(a.type.name));e.tr.ensureMarks(n)}}const sSt=({keepMarks:e=!0}={})=>({tr:t,state:s,dispatch:n,editor:a})=>{const{selection:o,doc:l}=t,{$from:i,$to:d}=o,m=a.extensionManager.attributes,p=cre(m,i.node().type.name,i.node().attrs);if(o instanceof ba&&o.node.isBlock)return!i.parentOffset||!Wy(l,i.pos)?!1:(n&&(e&&h3e(s,a.extensionManager.splittableMarks),t.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:$Nt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let _=g&&v?[{type:v,attrs:p}]:void 0,k=Wy(t.doc,t.mapping.map(i.pos),1,_);if(!_&&!k&&Wy(t.doc,t.mapping.map(i.pos),1,v?[{type:v}]:void 0)&&(k=!0,_=v?[{type:v,attrs:p}]:void 0),n){if(k&&(o instanceof Ca&&t.deleteSelection(),t.split(t.mapping.map(i.pos),1,_),v&&!g&&!i.parentOffset&&i.parent.type!==v)){const w=t.mapping.map(i.before()),S=t.doc.resolve(w);i.node(-1).canReplaceWith(S.index(),S.index()+1,v)&&t.setNodeMarkup(t.mapping.map(i.before()),v)}e&&h3e(s,a.extensionManager.splittableMarks),t.scrollIntoView()}return k},nSt=(e,t={})=>({tr:s,state:n,dispatch:a,editor:o})=>{var l;const i=Xd(e,n.schema),{$from:d,$to:m}=n.selection,p=n.selection.node;if(p&&p.isBlock||d.depth<2||!d.sameParent(m))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 T=_s.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let q=d.depth-C;q>=d.depth-3;q-=1)T=_s.from(d.node(q).copy(T));const I=d.indexAfter(-1){if($>-1)return!1;q.isTextblock&&q.content.size===0&&($=W+1)}),$>-1&&s.setSelection(Ca.near(s.doc.resolve($))),s.scrollIntoView()}return!0}const _=m.pos===d.end()?g.contentMatchAt(0).defaultType:null,k={...cre(v,g.type.name,g.attrs),...t},w={...cre(v,d.node().type.name,d.node().attrs),...t};s.delete(d.pos,m.pos);const S=_?[{type:i,attrs:k},{type:_,attrs:w}]:[{type:i,attrs:k}];if(!Wy(s.doc,d.pos,2))return!1;if(a){const{selection:T,storedMarks:C}=n,{splittableMarks:I}=o.extensionManager,R=C||T.$to.parentOffset&&T.$from.marks();if(s.split(d.pos,2,S).scrollIntoView(),!R||!a)return!0;const D=R.filter(B=>I.includes(B.type.name));s.ensureMarks(D)}return!0},Zue=(e,t)=>{const s=B1e(l=>l.type===t)(e.selection);if(!s)return!0;const n=e.doc.resolve(Math.max(0,s.pos-1)).before(s.depth);if(n===void 0)return!0;const a=e.doc.nodeAt(n);return s.node.type===(a==null?void 0:a.type)&&l_(e.doc,s.pos)&&e.join(s.pos),!0},Yue=(e,t)=>{const s=B1e(l=>l.type===t)(e.selection);if(!s)return!0;const n=e.doc.resolve(s.start).after(s.depth);if(n===void 0)return!0;const a=e.doc.nodeAt(n);return s.node.type===(a==null?void 0:a.type)&&l_(e.doc,n)&&e.join(n),!0},aSt=(e,t,s,n={})=>({editor:a,tr:o,state:l,dispatch:i,chain:d,commands:m,can:p})=>{const{extensions:g,splittableMarks:v}=a.extensionManager,_=Xd(e,l.schema),k=Xd(t,l.schema),{selection:w,storedMarks:S}=l,{$from:T,$to:C}=w,I=T.blockRange(C),R=S||w.$to.parentOffset&&w.$from.marks();if(!I)return!1;const D=B1e(B=>u3e(B.type.name,g))(w);if(I.depth>=1&&D&&I.depth-D.depth<=1){if(D.node.type===_)return m.liftListItem(k);if(u3e(D.node.type.name,g)&&_.validContent(D.node.content)&&i)return d().command(()=>(o.setNodeMarkup(D.pos,_),!0)).command(()=>Zue(o,_)).command(()=>Yue(o,_)).run()}return!s||!R||!i?d().command(()=>p().wrapInList(_,n)?!0:m.clearNodes()).wrapInList(_,n).command(()=>Zue(o,_)).command(()=>Yue(o,_)).run():d().command(()=>{const B=p().wrapInList(_,n),$=R.filter(q=>v.includes(q.type.name));return o.ensureMarks($),B?!0:m.clearNodes()}).wrapInList(_,n).command(()=>Zue(o,_)).command(()=>Yue(o,_)).run()},iSt=(e,t={},s={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=s,l=d_(e,n.schema);return Qpe(n,l,t)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,t)},oSt=(e,t,s={})=>({state:n,commands:a})=>{const o=Xd(e,n.schema),l=Xd(t,n.schema),i=lP(n,o,s);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,...s})},lSt=(e,t={})=>({state:s,commands:n})=>{const a=Xd(e,s.schema);return lP(s,a,t)?n.lift(a):n.wrapIn(a,t)},cSt=()=>({state:e,dispatch:t})=>{const s=e.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,e.schema.text(o.text,d))}else l.delete(o.from,o.to)}return!0}}return!1},dSt=()=>({tr:e,dispatch:t})=>{const{selection:s}=e,{empty:n,ranges:a}=s;return n||t&&a.forEach(o=>{e.removeMark(o.$from.pos,o.$to.pos)}),!0},uSt=(e,t={})=>({tr:s,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=t,{selection:i}=s,d=d_(e,n.schema),{$from:m,empty:p,ranges:g}=i;if(!a)return!0;if(p&&l){let{from:v,to:_}=i;const k=(o=m.marks().find(S=>S.type===d))===null||o===void 0?void 0:o.attrs,w=F1e(m,d,k);w&&(v=w.from,_=w.to),s.removeMark(v,_,d)}else g.forEach(v=>{s.removeMark(v.$from.pos,v.$to.pos,d)});return s.removeStoredMark(d),!0},hSt=(e,t={})=>({tr:s,state:n,dispatch:a})=>{let o=null,l=null;const i=noe(typeof e=="string"?e:e.name,n.schema);return i?(i==="node"&&(o=Xd(e,n.schema)),i==="mark"&&(l=d_(e,n.schema)),a&&s.selection.ranges.forEach(d=>{const m=d.$from.pos,p=d.$to.pos;let g,v,_,k;s.selection.empty?n.doc.nodesBetween(m,p,(w,S)=>{o&&o===w.type&&(_=Math.max(S,m),k=Math.min(S+w.nodeSize,p),g=S,v=w)}):n.doc.nodesBetween(m,p,(w,S)=>{S=m&&S<=p&&(o&&o===w.type&&s.setNodeMarkup(S,void 0,{...w.attrs,...t}),l&&w.marks.length&&w.marks.forEach(T=>{if(l===T.type){const C=Math.max(S,m),I=Math.min(S+w.nodeSize,p);s.addMark(C,I,l.create({...T.attrs,...t}))}}))}),v&&(g!==void 0&&s.setNodeMarkup(g,void 0,{...v.attrs,...t}),l&&v.marks.length&&v.marks.forEach(w=>{l===w.type&&s.addMark(_,k,l.create({...w.attrs,...t}))}))}),!0):!1},mSt=(e,t={})=>({state:s,dispatch:n})=>{const a=Xd(e,s.schema);return Skt(a,t)(s,n)},fSt=(e,t={})=>({state:s,dispatch:n})=>{const a=Xd(e,s.schema);return Ckt(a,t)(s,n)};var pSt=Object.freeze({__proto__:null,blur:Ykt,clearContent:Xkt,clearNodes:Qkt,command:Jkt,createParagraphNear:eNt,cut:tNt,deleteCurrentNode:rNt,deleteNode:sNt,deleteRange:nNt,deleteSelection:aNt,enter:iNt,exitCode:oNt,extendMarkRange:lNt,first:cNt,focus:uNt,forEach:hNt,insertContent:mNt,insertContentAt:gNt,joinBackward:vNt,joinDown:yNt,joinForward:_Nt,joinItemBackward:bNt,joinItemForward:wNt,joinTextblockBackward:jNt,joinTextblockForward:kNt,joinUp:xNt,keyboardShortcut:SNt,lift:CNt,liftEmptyBlock:MNt,liftListItem:TNt,newlineInCode:ANt,resetAttributes:ENt,scrollIntoView:INt,selectAll:PNt,selectNodeBackward:LNt,selectNodeForward:DNt,selectParentNode:ONt,selectTextblockEnd:RNt,selectTextblockStart:FNt,setContent:zNt,setMark:XNt,setMeta:QNt,setNode:JNt,setNodeSelection:eSt,setTextSelection:tSt,sinkListItem:rSt,splitBlock:sSt,splitListItem:nSt,toggleList:aSt,toggleMark:iSt,toggleNode:oSt,toggleWrap:lSt,undoInputRule:cSt,unsetAllMarks:dSt,unsetMark:uSt,updateAttributes:hSt,wrapIn:mSt,wrapInList:fSt});const gSt=yu.create({name:"commands",addCommands(){return{...pSt}}}),xSt=yu.create({name:"drop",addProseMirrorPlugins(){return[new Td({key:new Vu("tiptapDrop"),props:{handleDrop:(e,t,s,n)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:s,moved:n})}}})]}}),ySt=yu.create({name:"editable",addProseMirrorPlugins(){return[new Td({key:new Vu("editable"),props:{editable:()=>this.editor.options.editable}})]}}),vSt=new Vu("focusEvents"),_St=yu.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new Td({key:vSt,props:{handleDOMEvents:{focus:(t,s)=>{e.isFocused=!0;const n=e.state.tr.setMeta("focus",{event:s}).setMeta("addToHistory",!1);return t.dispatch(n),!1},blur:(t,s)=>{e.isFocused=!1;const n=e.state.tr.setMeta("blur",{event:s}).setMeta("addToHistory",!1);return t.dispatch(n),!1}}}})]}}),bSt=yu.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:i})=>{const{selection:d,doc:m}=i,{empty:p,$anchor:g}=d,{pos:v,parent:_}=g,k=g.parent.isTextblock&&v>0?i.doc.resolve(v-1):g,w=k.parent.type.spec.isolating,S=g.pos-g.parentOffset,T=w&&k.parent.childCount===1?S===g.pos:Va.atStart(m).from===v;return!p||!_.type.isTextblock||_.textContent.length||!T||T&&g.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),t=()=>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:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},a={...n},o={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return z1e()||IUe()?o:a},addProseMirrorPlugins(){return[new Td({key:new Vu("clearDocument"),appendTransaction:(e,t,s)=>{if(e.some(w=>w.getMeta("composition")))return;const n=e.some(w=>w.docChanged)&&!t.doc.eq(s.doc),a=e.some(w=>w.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=t.selection,d=Va.atStart(t.doc).from,m=Va.atEnd(t.doc).to;if(o||!(l===d&&i===m)||!U1e(s.doc))return;const v=s.tr,_=Jie({state:s,transaction:v}),{commands:k}=new eoe({editor:this.editor,state:_});if(k.clearNodes(),!!v.steps.length)return v}})]}}),wSt=yu.create({name:"paste",addProseMirrorPlugins(){return[new Td({key:new Vu("tiptapPaste"),props:{handlePaste:(e,t,s)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:s})}}})]}}),jSt=yu.create({name:"tabindex",addProseMirrorPlugins(){return[new Td({key:new Vu("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Rj{get name(){return this.node.type.name}constructor(t,s,n=!1,a=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=s,this.currentNode=a}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return(t=this.actualDepth)!==null&&t!==void 0?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let s=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}s=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:s,to:n},t)}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 t=this.resolvedPos.start(this.resolvedPos.depth-1),s=this.resolvedPos.doc.resolve(t);return new Rj(s,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new Rj(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new Rj(t,this.editor)}get children(){const t=[];return this.node.content.forEach((s,n)=>{const a=s.isBlock&&!s.isTextblock,o=s.isAtom&&!s.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 Rj(i,this.editor,a,a?s:null);a&&(d.actualDepth=this.depth+1),t.push(new Rj(i,this.editor,a,a?s:null))}),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,s={}){let n=null,a=this.parent;for(;a&&!n;){if(a.node.type.name===t)if(Object.keys(s).length>0){const o=a.node.attrs,l=Object.keys(s);for(let i=0;i{n&&a.length>0||(l.node.type.name===t&&o.every(d=>s[d]===l.node.attrs[d])&&a.push(l),!(n&&a.length>0)&&(a=a.concat(l.querySelectorAll(t,s,n))))}),a}setAttribute(t){const{tr:s}=this.editor.state;s.setNodeMarkup(this.from,void 0,{...this.node.attrs,...t}),this.editor.view.dispatch(s)}}const kSt=`.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 NSt(e,t,s){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const a=document.createElement("style");return t&&a.setAttribute("nonce",t),a.setAttribute("data-tiptap-style",""),a.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(a),a}class SSt extends Lkt{constructor(t={}){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:s})=>{throw s},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),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:s,slice:n,moved:a})=>this.options.onDrop(s,n,a)),this.on("paste",({event:s,slice:n})=>this.options.onPaste(s,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=NSt(kSt,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,s=!0){this.setOptions({editable:t}),s&&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(t,s){const n=NUe(s)?s(t,[...this.state.plugins]):[...this.state.plugins,t],a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}unregisterPlugin(t){if(this.isDestroyed)return;const s=this.state.plugins;let n=s;if([].concat(t).forEach(o=>{const l=typeof o=="string"?`${o}$`:o.key;n=n.filter(i=>!i.key.startsWith(l))}),s.length===n.length)return;const a=this.state.reconfigure({plugins:n});return this.view.updateState(a),a}createExtensionManager(){var t,s;const a=[...this.options.enableCoreExtensions?[ySt,Zkt.configure({blockSeparator:(s=(t=this.options.coreExtensionOptions)===null||t===void 0?void 0:t.clipboardTextSerializer)===null||s===void 0?void 0:s.blockSeparator}),gSt,_St,bSt,jSt,xSt,wSt].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 JC(a,this)}createCommandManager(){this.commandManager=new eoe({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var t;let s;try{s=Xpe(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()}}),s=Xpe(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=AUe(s,this.options.autofocus);this.view=new uUe(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(t=this.options.editorProps)===null||t===void 0?void 0:t.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:QC.create({doc:s,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(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const s=this.capturedTransaction;return this.capturedTransaction=null,s}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(l=>{var i;return(i=this.capturedTransaction)===null||i===void 0?void 0:i.step(l)});return}const s=this.state.apply(t),n=!this.state.selection.eq(s.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:s}),this.view.updateState(s),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const a=t.getMeta("focus"),o=t.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:t}),o&&this.emit("blur",{editor:this,event:o.event,transaction:t}),!(!t.docChanged||t.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return DUe(this.state,t)}isActive(t,s){const n=typeof t=="string"?t:null,a=typeof t=="string"?s:t;return KNt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return O1e(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:s=` `,textSerializers:n={}}=t||{};return VNt(this.state.doc,{blockSeparator:s,textSerializers:{...CUe(this.schema),...n}})}get isEmpty(){return U1e(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 t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(!((t=this.view)===null||t===void 0)&&t.docView)}$node(t,s){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(t,s))||null}$nodes(t,s){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(t,s))||null}$pos(t){const s=this.state.doc.resolve(t);return new Rj(s,this)}get $doc(){return this.$pos(0)}}function V5(e){return new roe({find:e.find,handler:({state:t,range:s,match:n})=>{const a=Ti(e.getAttributes,void 0,n);if(a===!1||a===null)return null;const{tr:o}=t,l=n[n.length-1],i=n[0];if(l){const d=i.search(/\S/),m=s.from+i.indexOf(l),p=m+l.length;if($1e(s.from,s.to,t.doc).filter(_=>_.mark.type.excluded.find(w=>w===e.type&&w!==_.mark.type)).filter(_=>_.to>m).length)return null;ps.from&&o.delete(s.from+d,m);const v=s.from+d+l.length;o.addMark(s.from+d,v,e.type.create(a||{})),o.removeStoredMark(e.type)}}})}function OUe(e){return new roe({find:e.find,handler:({state:t,range:s,match:n})=>{const a=Ti(e.getAttributes,void 0,n)||{},{tr:o}=t,l=s.from;let i=s.to;const d=e.type.create(a);if(n[1]){const m=n[0].lastIndexOf(n[1]);let p=l+m;p>i?p=i:i=p+n[1].length;const g=n[0][n[0].length-1];o.insertText(g,l+n[0].length-1),o.replaceWith(p,i,d)}else if(n[0]){const m=e.type.isInline?l:l-1;o.insert(m,e.type.create(a)).delete(o.mapping.map(l),o.mapping.map(i))}o.scrollIntoView()}})}function Jpe(e){return new roe({find:e.find,handler:({state:t,range:s,match:n})=>{const a=t.doc.resolve(s.from),o=Ti(e.getAttributes,void 0,n)||{};if(!a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),e.type))return null;t.tr.delete(s.from,s.to).setBlockType(s.from,s.from,e.type,o)}})}function cP(e){return new roe({find:e.find,handler:({state:t,range:s,match:n,chain:a})=>{const o=Ti(e.getAttributes,void 0,n)||{},l=t.tr.delete(s.from,s.to),d=l.doc.resolve(s.from).blockRange(),m=d&&y1e(d,e.type,o);if(!m)return null;if(l.wrap(d,m),e.keepMarks&&e.editor){const{selection:g,storedMarks:v}=t,{splittableMarks:_}=e.editor.extensionManager,k=v||g.$to.parentOffset&&g.$from.marks();if(k){const w=k.filter(S=>_.includes(S.type.name));l.ensureMarks(w)}}if(e.keepAttributes){const g=e.type.name==="bulletList"||e.type.name==="orderedList"?"listItem":"taskList";a().updateAttributes(g,o).run()}const p=l.doc.resolve(s.from-1).nodeBefore;p&&p.type===e.type&&l_(l.doc,s.from-1)&&(!e.joinPredicate||e.joinPredicate(n,p))&&l.join(s.from-1)}})}let qu=class ege{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.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=Ti(Un(this,"addOptions",{name:this.name}))),this.storage=Ti(Un(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ege(t)}configure(t={}){const s=this.extend({...this.config,addOptions:()=>soe(this.options,t)});return s.name=this.name,s.parent=this.parent,s}extend(t={}){const s=new ege(t);return s.parent=this,this.child=s,s.name=t.name?t.name:s.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${s.name}".`),s.options=Ti(Un(s,"addOptions",{name:s.name})),s.storage=Ti(Un(s,"addStorage",{name:s.name,options:s.options})),s}};function iN(e){return new Vkt({find:e.find,handler:({state:t,range:s,match:n,pasteEvent:a})=>{const o=Ti(e.getAttributes,void 0,n,a);if(o===!1||o===null)return null;const{tr:l}=t,i=n[n.length-1],d=n[0];let m=s.to;if(i){const p=d.search(/\S/),g=s.from+d.indexOf(i),v=g+i.length;if($1e(s.from,s.to,t.doc).filter(k=>k.mark.type.excluded.find(S=>S===e.type&&S!==k.mark.type)).filter(k=>k.to>g).length)return null;vs.from&&l.delete(s.from+p,g),m=s.from+p+i.length,l.addMark(s.from+p,m,e.type.create(o||{})),l.removeStoredMark(e.type)}}})}function CSt(e,t){const{selection:s}=e,{$from:n}=s;if(s instanceof ba){const o=n.index();return n.parent.canReplaceWith(o,o+1,t)}let a=n.depth;for(;a>=0;){const o=n.index(a);if(n.node(a).contentMatchAt(o).matchType(t))return!0;a-=1}return!1}function MSt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var RUe={exports:{}},Xue={};/** * @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 m3e;function TSt(){if(m3e)return Xue;m3e=1;var e=lt;function t(g,v){return g===v&&(g!==0||1/g===1/v)||g!==g&&v!==v}var s=typeof Object.is=="function"?Object.is:t,n=e.useState,a=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function i(g,v){var _=v(),k=n({inst:{value:_,getSnapshot:v}}),w=k[0].inst,S=k[1];return o(function(){w.value=_,w.getSnapshot=v,d(w)&&S({inst:w})},[g,_,v]),a(function(){return d(w)&&S({inst:w}),g(function(){d(w)&&S({inst:w})})},[g]),l(_),_}function d(g){var v=g.getSnapshot;g=g.value;try{var _=v();return!s(g,_)}catch{return!0}}function m(g,v){return v()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?m:i;return Xue.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Xue}RUe.exports=TSt();var V1e=RUe.exports;const ASt=(...e)=>t=>{e.forEach(s=>{typeof s=="function"?s(t):s&&(s.current=t)})},ESt=({contentComponent:e})=>{const t=V1e.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return lt.createElement(lt.Fragment,null,Object.values(t))};function ISt(){const e=new Set;let t={};return{subscribe(s){return e.add(s),()=>{e.delete(s)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(s,n){t={...t,[s]:N0e.createPortal(n.reactElement,n.element,s)},e.forEach(a=>a())},removeRenderer(s){const n={...t};delete n[s],t=n,e.forEach(a=>a())}}}class PSt extends lt.Component{constructor(t){var s;super(t),this.editorContentRef=lt.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((s=t.editor)===null||s===void 0)&&s.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const s=this.editorContentRef.current;s.append(...t.options.element.childNodes),t.setOptions({element:s}),t.contentComponent=ISt(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t||(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild))return;const s=document.createElement("div");s.append(...t.options.element.childNodes),t.setOptions({element:s})}render(){const{editor:t,innerRef:s,...n}=this.props;return lt.createElement(lt.Fragment,null,lt.createElement("div",{ref:ASt(s,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&<.createElement(ESt,{contentComponent:t.contentComponent}))}}const LSt=A.forwardRef((e,t)=>{const s=lt.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return lt.createElement(PSt,{key:s,innerRef:t,...e})}),FUe=lt.memo(LSt);var DSt=function e(t,s){if(t===s)return!0;if(t&&s&&typeof t=="object"&&typeof s=="object"){if(t.constructor!==s.constructor)return!1;var n,a,o;if(Array.isArray(t)){if(n=t.length,n!=s.length)return!1;for(a=n;a--!==0;)if(!e(t[a],s[a]))return!1;return!0}if(t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(a of t.entries())if(!s.has(a[0]))return!1;for(a of t.entries())if(!e(a[1],s.get(a[0])))return!1;return!0}if(t instanceof Set&&s instanceof Set){if(t.size!==s.size)return!1;for(a of t.entries())if(!s.has(a[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(s)){if(n=t.length,n!=s.length)return!1;for(a=n;a--!==0;)if(t[a]!==s[a])return!1;return!0}if(t.constructor===RegExp)return t.source===s.source&&t.flags===s.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===s.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===s.toString();if(o=Object.keys(t),n=o.length,n!==Object.keys(s).length)return!1;for(a=n;a--!==0;)if(!Object.prototype.hasOwnProperty.call(s,o[a]))return!1;for(a=n;a--!==0;){var l=o[a];if(!(l==="_owner"&&t.$$typeof)&&!e(t[l],s[l]))return!1}return!0}return t!==t&&s!==s},OSt=MSt(DSt),zUe={exports:{}},Que={};/** * @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 f3e;function RSt(){if(f3e)return Que;f3e=1;var e=lt,t=V1e;function s(m,p){return m===p&&(m!==0||1/m===1/p)||m!==m&&p!==p}var n=typeof Object.is=="function"?Object.is:s,a=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,i=e.useMemo,d=e.useDebugValue;return Que.useSyncExternalStoreWithSelector=function(m,p,g,v,_){var k=o(null);if(k.current===null){var w={hasValue:!1,value:null};k.current=w}else w=k.current;k=i(function(){function T(B){if(!C){if(C=!0,I=B,B=v(B),_!==void 0&&w.hasValue){var $=w.value;if(_($,B))return R=$}return R=B}if($=R,n(I,B))return $;var q=v(B);return _!==void 0&&_($,q)?$:(I=B,R=q)}var C=!1,I,R,D=g===void 0?null:g;return[function(){return T(p())},D===null?void 0:function(){return T(D())}]},[p,g,v,_]);var S=a(m,k[0],k[1]);return l(function(){w.hasValue=!0,w.value=S},[S]),d(S),S},Que}zUe.exports=RSt();var FSt=zUe.exports;const zSt=typeof window<"u"?A.useLayoutEffect:A.useEffect;class BSt{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,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(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const s=()=>{this.transactionNumber+=1,this.subscribers.forEach(a=>a())},n=this.editor;return n.on("transaction",s),()=>{n.off("transaction",s)}}}}function $St(e){var t;const[s]=A.useState(()=>new BSt(e.editor)),n=FSt.useSyncExternalStoreWithSelector(s.subscribe,s.getSnapshot,s.getServerSnapshot,e.selector,(t=e.equalityFn)!==null&&t!==void 0?t:OSt);return zSt(()=>s.watch(e.editor),[e.editor,s]),A.useDebugValue(n),n}const USt=!1,tge=typeof window>"u",VSt=tge||!!(typeof window<"u"&&window.next);class q1e{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,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(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(s=>s())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?tge||VSt?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const t={...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 SSt(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}static compareOptions(t,s){return Object.keys(t).every(n=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)?!0:n==="extensions"&&t.extensions&&s.extensions?t.extensions.length!==s.extensions.length?!1:t.extensions.every((a,o)=>{var l;return a===((l=s.extensions)===null||l===void 0?void 0:l[o])}):t[n]===s[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?q1e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=t;return}if(this.previousDeps.length===t.length&&this.previousDeps.every((n,a)=>n===t[a]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,s=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===t){s&&s.setOptions(this.options.current);return}s&&!s.isDestroyed&&(s.destroy(),this.instanceId===t&&this.setEditor(null))},1)}}function BUe(e={},t=[]){const s=A.useRef(e);s.current=e;const[n]=A.useState(()=>new q1e(s)),a=V1e.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return A.useDebugValue(a),A.useEffect(n.onRender(t)),$St({editor:a,selector:({transactionNumber:o})=>e.shouldRerenderOnTransaction===!1?null:e.immediatelyRender&&o===0?0:o+1}),a}const qSt=A.createContext({editor:null});qSt.Consumer;const HSt=A.createContext({onDragStart:void 0}),WSt=()=>A.useContext(HSt);lt.forwardRef((e,t)=>{const{onDragStart:s}=WSt(),n=e.as||"div";return lt.createElement(n,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:s,style:{whiteSpace:"normal",...e.style}})});const GSt=/^\s*>\s$/,KSt=qu.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:e}){return["blockquote",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[cP({find:GSt,type:this.type})]}}),ZSt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,YSt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,XSt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,QSt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,JSt=Cx.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[V5({find:ZSt,type:this.type}),V5({find:XSt,type:this.type})]},addPasteRules(){return[iN({find:YSt,type:this.type}),iN({find:QSt,type:this.type})]}}),eCt="listItem",p3e="textStyle",g3e=/^\s*([-+*])\s$/,tCt=qu.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:e}){return["ul",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(eCt,this.editor.getAttributes(p3e)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=cP({find:g3e,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=cP({find:g3e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(p3e),editor:this.editor})),[e]}}),rCt=/(^|[^`])`([^`]+)`(?!`)/,sCt=/(^|[^`])`([^`]+)`(?!`)/g,nCt=Cx.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:e}){return["code",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[V5({find:rCt,type:this.type})]},addPasteRules(){return[iN({find:sCt,type:this.type})]}}),aCt=/^```([a-z]+)?[\s\n]$/,iCt=/^~~~([a-z]+)?[\s\n]$/,oCt=qu.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:e=>{var t;const{languageClassPrefix:s}=this.options,o=[...((t=e.firstElementChild)===null||t===void 0?void 0:t.classList)||[]].filter(l=>l.startsWith(s)).map(l=>l.replace(s,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:e,HTMLAttributes:t}){return["pre",sc(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:e,$anchor:t}=this.editor.state.selection,s=t.pos===1;return!e||t.parent.type.name!==this.name?!1:s||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:t}=e,{selection:s}=t,{$from:n,empty:a}=s;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:e.chain().command(({tr:i})=>(i.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;const{state:t}=e,{selection:s,doc:n}=t,{$from:a,empty:o}=s;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)?e.commands.command(({tr:m})=>(m.setSelection(Va.near(n.resolve(i))),!0)):e.commands.exitCode()}}},addInputRules(){return[Jpe({find:aCt,type:this.type,getAttributes:e=>({language:e[1]})}),Jpe({find:iCt,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Td({key:new Vu("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;const s=t.clipboardData.getData("text/plain"),n=t.clipboardData.getData("vscode-editor-data"),a=n?JSON.parse(n):void 0,o=a==null?void 0:a.mode;if(!s||!o)return!1;const{tr:l,schema:i}=e.state,d=i.text(s.replace(/\r\n?/g,` `));return l.replaceSelectionWith(this.type.create({language:o},d)),l.selection.$from.parent.type!==this.type&&l.setSelection(Ca.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),e.dispatch(l),!0}}})]}}),lCt=qu.create({name:"doc",topNode:!0,content:"block+"});function cCt(e={}){return new Td({view(t){return new dCt(t,e)}})}class dCt{constructor(t,s){var n;this.editorView=t,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=s.width)!==null&&n!==void 0?n:1,this.color=s.color===!1?void 0:s.color||"black",this.class=s.class,this.handlers=["dragover","dragend","drop","dragleave"].map(a=>{let o=l=>{this[a](l)};return t.dom.addEventListener(a,o),{name:a,handler:o}})}destroy(){this.handlers.forEach(({name:t,handler:s})=>this.editorView.dom.removeEventListener(t,s))}update(t,s){this.cursorPos!=null&&s.doc!=t.state.doc&&(this.cursorPos>t.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(t){t!=this.cursorPos&&(this.cursorPos=t,t==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let t=this.editorView.state.doc.resolve(this.cursorPos),s=!t.parent.inlineContent,n,a=this.editorView.dom,o=a.getBoundingClientRect(),l=o.width/a.offsetWidth,i=o.height/a.offsetHeight;if(s){let g=t.nodeBefore,v=t.nodeAfter;if(g||v){let _=this.editorView.nodeDOM(this.cursorPos-(g?g.nodeSize:0));if(_){let k=_.getBoundingClientRect(),w=g?k.bottom:k.top;g&&v&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let S=this.width/2*i;n={left:k.left,right:k.right,top:w-S,bottom:w+S}}}}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",s),this.element.classList.toggle("prosemirror-dropcursor-inline",!s);let m,p;if(!d||d==document.body&&getComputedStyle(d).position=="static")m=-pageXOffset,p=-pageYOffset;else{let g=d.getBoundingClientRect(),v=g.width/d.offsetWidth,_=g.height/d.offsetHeight;m=g.left-d.scrollLeft*v,p=g.top-d.scrollTop*_}this.element.style.left=(n.left-m)/l+"px",this.element.style.top=(n.top-p)/i+"px",this.element.style.width=(n.right-n.left)/l+"px",this.element.style.height=(n.bottom-n.top)/i+"px"}scheduleRemoval(t){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),t)}dragover(t){if(!this.editorView.editable)return;let s=this.editorView.posAtCoords({left:t.clientX,top:t.clientY}),n=s&&s.inside>=0&&this.editorView.state.doc.nodeAt(s.inside),a=n&&n.type.spec.disableDropCursor,o=typeof a=="function"?a(this.editorView,s,t):a;if(s&&!o){let l=s.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let i=j$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(t){this.editorView.dom.contains(t.relatedTarget)||this.setCursor(null)}}const uCt=yu.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[cCt(this.options)]}});class mc extends Va{constructor(t){super(t,t)}map(t,s){let n=t.resolve(s.map(this.head));return mc.valid(n)?new mc(n):Va.near(n)}content(){return nn.empty}eq(t){return t instanceof mc&&t.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(t,s){if(typeof s.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new mc(t.resolve(s.pos))}getBookmark(){return new H1e(this.anchor)}static valid(t){let s=t.parent;if(s.isTextblock||!hCt(t)||!mCt(t))return!1;let n=s.type.spec.allowGapCursor;if(n!=null)return n;let a=s.contentMatchAt(t.index()).defaultType;return a&&a.isTextblock}static findGapCursorFrom(t,s,n=!1){e:for(;;){if(!n&&mc.valid(t))return t;let a=t.pos,o=null;for(let l=t.depth;;l--){let i=t.node(l);if(s>0?t.indexAfter(l)0){o=i.child(s>0?t.indexAfter(l):t.index(l)-1);break}else if(l==0)return null;a+=s;let d=t.doc.resolve(a);if(mc.valid(d))return d}for(;;){let l=s>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!ba.isSelectable(o)){t=t.doc.resolve(a+o.nodeSize*s),n=!1;continue e}break}o=l,a+=s;let i=t.doc.resolve(a);if(mc.valid(i))return i}return null}}}mc.prototype.visible=!1;mc.findFrom=mc.findGapCursorFrom;Va.jsonID("gapcursor",mc);class H1e{constructor(t){this.pos=t}map(t){return new H1e(t.map(this.pos))}resolve(t){let s=t.resolve(this.pos);return mc.valid(s)?new mc(s):Va.near(s)}}function $Ue(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function hCt(e){for(let t=e.depth;t>=0;t--){let s=e.index(t),n=e.node(t);if(s==0){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(s-1);;a=a.lastChild){if(a.childCount==0&&!a.inlineContent||$Ue(a.type))return!0;if(a.inlineContent)return!1}}return!0}function mCt(e){for(let t=e.depth;t>=0;t--){let s=e.indexAfter(t),n=e.node(t);if(s==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let a=n.child(s);;a=a.firstChild){if(a.childCount==0&&!a.inlineContent||$Ue(a.type))return!0;if(a.inlineContent)return!1}}return!0}function fCt(){return new Td({props:{decorations:yCt,createSelectionBetween(e,t,s){return t.pos==s.pos&&mc.valid(s)?new mc(s):null},handleClick:gCt,handleKeyDown:pCt,handleDOMEvents:{beforeinput:xCt}}})}const pCt=A1e({ArrowLeft:FO("horiz",-1),ArrowRight:FO("horiz",1),ArrowUp:FO("vert",-1),ArrowDown:FO("vert",1)});function FO(e,t){const s=e=="vert"?t>0?"down":"up":t>0?"right":"left";return function(n,a,o){let l=n.selection,i=t>0?l.$to:l.$from,d=l.empty;if(l instanceof Ca){if(!o.endOfTextblock(s)||i.depth==0)return!1;d=!1,i=n.doc.resolve(t>0?i.after():i.before())}let m=mc.findGapCursorFrom(i,t,d);return m?(a&&a(n.tr.setSelection(new mc(m))),!0):!1}}function gCt(e,t,s){if(!e||!e.editable)return!1;let n=e.state.doc.resolve(t);if(!mc.valid(n))return!1;let a=e.posAtCoords({left:s.clientX,top:s.clientY});return a&&a.inside>-1&&ba.isSelectable(e.state.doc.nodeAt(a.inside))?!1:(e.dispatch(e.state.tr.setSelection(new mc(n))),!0)}function xCt(e,t){if(t.inputType!="insertCompositionText"||!(e.state.selection instanceof mc))return!1;let{$from:s}=e.state.selection,n=s.parent.contentMatchAt(s.index()).findWrapping(e.state.schema.nodes.text);if(!n)return!1;let a=_s.empty;for(let l=n.length-1;l>=0;l--)a=_s.from(n[l].createAndFill(null,a));let o=e.state.tr.replace(s.pos,s.pos,new nn(a,0,0));return o.setSelection(Ca.near(o.doc.resolve(s.pos+1))),e.dispatch(o),!1}function yCt(e){if(!(e.selection instanceof mc))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",hc.create(e.doc,[hh.widget(e.selection.head,t,{key:"gapcursor"})])}const vCt=yu.create({name:"gapCursor",addProseMirrorPlugins(){return[fCt()]},extendNodeSchema(e){var t;const s={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:(t=Ti(Un(e,"allowGapCursor",s)))!==null&&t!==void 0?t:null}}}),_Ct=qu.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:e}){return["br",sc(this.options.HTMLAttributes,e)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:s,editor:n})=>e.first([()=>e.exitCode(),()=>e.command(()=>{const{selection:a,storedMarks:o}=s;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 t().insertContent({type:this.name}).command(({tr:m,dispatch:p})=>{if(p&&d&&l){const g=d.filter(v=>i.includes(v.type.name));m.ensureMarks(g)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),bCt=qu.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(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,sc(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Jpe({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var Bse=200,Yd=function(){};Yd.prototype.append=function(t){return t.length?(t=Yd.from(t),!this.length&&t||t.length=s?Yd.empty:this.sliceInner(Math.max(0,t),Math.min(this.length,s))};Yd.prototype.get=function(t){if(!(t<0||t>=this.length))return this.getInner(t)};Yd.prototype.forEach=function(t,s,n){s===void 0&&(s=0),n===void 0&&(n=this.length),s<=n?this.forEachInner(t,s,n,0):this.forEachInvertedInner(t,s,n,0)};Yd.prototype.map=function(t,s,n){s===void 0&&(s=0),n===void 0&&(n=this.length);var a=[];return this.forEach(function(o,l){return a.push(t(o,l))},s,n),a};Yd.from=function(t){return t instanceof Yd?t:t&&t.length?new UUe(t):Yd.empty};var UUe=function(e){function t(n){e.call(this),this.values=n}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var s={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(a,o){return a==0&&o==this.length?this:new t(this.values.slice(a,o))},t.prototype.getInner=function(a){return this.values[a]},t.prototype.forEachInner=function(a,o,l,i){for(var d=o;d=l;d--)if(a(this.values[d],i+d)===!1)return!1},t.prototype.leafAppend=function(a){if(this.length+a.length<=Bse)return new t(this.values.concat(a.flatten()))},t.prototype.leafPrepend=function(a){if(this.length+a.length<=Bse)return new t(a.flatten().concat(this.values))},s.length.get=function(){return this.values.length},s.depth.get=function(){return 0},Object.defineProperties(t.prototype,s),t}(Yd);Yd.empty=new UUe([]);var wCt=function(e){function t(s,n){e.call(this),this.left=s,this.right=n,this.length=s.length+n.length,this.depth=Math.max(s.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.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},t.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))},t.prototype.leafAppend=function(n){var a=this.right.leafAppend(n);if(a)return new t(this.left,a)},t.prototype.leafPrepend=function(n){var a=this.left.leafPrepend(n);if(a)return new t(a,this.right)},t.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new t(this.left,new t(this.right,n)):new t(this,n)},t}(Yd);const jCt=500;class Wp{constructor(t,s){this.items=t,this.eventCount=s}popEvent(t,s){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;s&&(a=this.remapping(n,this.items.length),o=a.maps.length);let l=t.tr,i,d,m=[],p=[];return this.items.forEach((g,v)=>{if(!g.step){a||(a=this.remapping(n,v+1),o=a.maps.length),o--,p.push(g);return}if(a){p.push(new qg(g.map));let _=g.step.map(a.slice(o)),k;_&&l.maybeStep(_).doc&&(k=l.mapping.maps[l.mapping.maps.length-1],m.push(new qg(k,void 0,void 0,m.length+p.length))),o--,k&&a.appendMap(k,o)}else l.maybeStep(g.step);if(g.selection)return i=a?g.selection.map(a.slice(o)):g.selection,d=new Wp(this.items.slice(0,n).append(p.reverse().concat(m)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:i}}addTransform(t,s,n,a){let o=[],l=this.eventCount,i=this.items,d=!a&&i.length?i.get(i.length-1):null;for(let p=0;pNCt&&(i=kCt(i,m),l-=m),new Wp(i.append(o),l)}remapping(t,s){let n=new rP;return this.items.forEach((a,o)=>{let l=a.mirrorOffset!=null&&o-a.mirrorOffset>=t?n.maps.length-a.mirrorOffset:void 0;n.appendMap(a.map,l)},t,s),n}addMaps(t){return this.eventCount==0?this:new Wp(this.items.append(t.map(s=>new qg(s))),this.eventCount)}rebased(t,s){if(!this.eventCount)return this;let n=[],a=Math.max(0,this.items.length-s),o=t.mapping,l=t.steps.length,i=this.eventCount;this.items.forEach(v=>{v.selection&&i--},a);let d=s;this.items.forEach(v=>{let _=o.getMirror(--d);if(_==null)return;l=Math.min(l,_);let k=o.maps[_];if(v.step){let w=t.steps[_].invert(t.docs[_]),S=v.selection&&v.selection.map(o.slice(d+1,_));S&&i++,n.push(new qg(k,w,S))}else n.push(new qg(k))},a);let m=[];for(let v=s;vjCt&&(g=g.compress(this.items.length-n.length)),g}emptyItemCount(){let t=0;return this.items.forEach(s=>{s.step||t++}),t}compress(t=this.items.length){let s=this.remapping(0,t),n=s.maps.length,a=[],o=0;return this.items.forEach((l,i)=>{if(i>=t)a.push(l),l.selection&&o++;else if(l.step){let d=l.step.map(s.slice(n)),m=d&&d.getMap();if(n--,m&&s.appendMap(m,n),d){let p=l.selection&&l.selection.map(s.slice(n));p&&o++;let g=new qg(m.invert(),d,p),v,_=a.length-1;(v=a.length&&a[_].merge(g))?a[_]=v:a.push(g)}}else l.map&&n--},this.items.length,0),new Wp(Yd.from(a.reverse()),o)}}Wp.empty=new Wp(Yd.empty,0);function kCt(e,t){let s;return e.forEach((n,a)=>{if(n.selection&&t--==0)return s=a,!1}),e.slice(s)}class qg{constructor(t,s,n,a){this.map=t,this.step=s,this.selection=n,this.mirrorOffset=a}merge(t){if(this.step&&t.step&&!t.selection){let s=t.step.merge(this.step);if(s)return new qg(s.getMap().invert(),s,this.selection)}}}class Tv{constructor(t,s,n,a,o){this.done=t,this.undone=s,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const NCt=20;function SCt(e,t,s,n){let a=s.getMeta(Fk),o;if(a)return a.historyState;s.getMeta(TCt)&&(e=new Tv(e.done,e.undone,null,0,-1));let l=s.getMeta("appendedTransaction");if(s.steps.length==0)return e;if(l&&l.getMeta(Fk))return l.getMeta(Fk).redo?new Tv(e.done.addTransform(s,void 0,n,dre(t)),e.undone,x3e(s.mapping.maps),e.prevTime,e.prevComposition):new Tv(e.done,e.undone.addTransform(s,void 0,n,dre(t)),null,e.prevTime,e.prevComposition);if(s.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let i=s.getMeta("composition"),d=e.prevTime==0||!l&&e.prevComposition!=i&&(e.prevTime<(s.time||0)-n.newGroupDelay||!CCt(s,e.prevRanges)),m=l?Jue(e.prevRanges,s.mapping):x3e(s.mapping.maps);return new Tv(e.done.addTransform(s,d?t.selection.getBookmark():void 0,n,dre(t)),Wp.empty,m,s.time,i??e.prevComposition)}else return(o=s.getMeta("rebased"))?new Tv(e.done.rebased(s,o),e.undone.rebased(s,o),Jue(e.prevRanges,s.mapping),e.prevTime,e.prevComposition):new Tv(e.done.addMaps(s.mapping.maps),e.undone.addMaps(s.mapping.maps),Jue(e.prevRanges,s.mapping),e.prevTime,e.prevComposition)}function CCt(e,t){if(!t)return!1;if(!e.docChanged)return!0;let s=!1;return e.mapping.maps[0].forEach((n,a)=>{for(let o=0;o=t[o]&&(s=!0)}),s}function x3e(e){let t=[];for(let s=e.length-1;s>=0&&t.length==0;s--)e[s].forEach((n,a,o,l)=>t.push(o,l));return t}function Jue(e,t){if(!e)return null;let s=[];for(let n=0;n{let a=Fk.getState(s);if(!a||(e?a.undone:a.done).eventCount==0)return!1;if(n){let o=MCt(a,s,e);o&&n(t?o.scrollIntoView():o)}return!0}}const qUe=VUe(!1,!0),HUe=VUe(!0,!0),ECt=yu.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>qUe(e,t),redo:()=>({state:e,dispatch:t})=>HUe(e,t)}},addProseMirrorPlugins(){return[ACt(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()}}}),ICt=qu.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:e}){return["hr",sc(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!CSt(t,t.schema.nodes[this.name]))return!1;const{selection:s}=t,{$from:n,$to:a}=s,o=e();return n.parentOffset===0?o.insertContentAt({from:Math.max(n.pos-1,0),to:a.pos},{type:this.name}):ZNt(s)?o.insertContentAt(a.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:l,dispatch:i})=>{var d;if(i){const{$to:m}=l.selection,p=m.end();if(m.nodeAfter)m.nodeAfter.isTextblock?l.setSelection(Ca.create(l.doc,m.pos+1)):m.nodeAfter.isBlock?l.setSelection(ba.create(l.doc,m.pos)):l.setSelection(Ca.create(l.doc,m.pos));else{const g=(d=m.parent.type.contentMatch.defaultType)===null||d===void 0?void 0:d.create();g&&(l.insert(p,g),l.setSelection(Ca.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[OUe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),PCt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,LCt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,DCt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,OCt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,RCt=Cx.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>e.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[V5({find:PCt,type:this.type}),V5({find:DCt,type:this.type})]},addPasteRules(){return[iN({find:LCt,type:this.type}),iN({find:OCt,type:this.type})]}}),FCt=qu.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:e}){return["li",sc(this.options.HTMLAttributes,e),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)}}}),zCt="listItem",v3e="textStyle",_3e=/^(\d+)\.\s$/,BCt=qu.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:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:e}){const{start:t,...s}=e;return t===1?["ol",sc(this.options.HTMLAttributes,s),0]:["ol",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(zCt,this.editor.getAttributes(v3e)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=cP({find:_3e,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,s)=>s.childCount+s.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=cP({find:_3e,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(v3e)}),joinPredicate:(t,s)=>s.childCount+s.attrs.start===+t[1],editor:this.editor})),[e]}}),$Ct=qu.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:e}){return["p",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),UCt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,VCt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,qCt=Cx.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["s",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[V5({find:UCt,type:this.type})]},addPasteRules(){return[iN({find:VCt,type:this.type})]}}),HCt=qu.create({name:"text",group:"inline"}),WUe=yu.create({name:"starterKit",addExtensions(){const e=[];return this.options.bold!==!1&&e.push(JSt.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(KSt.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(tCt.configure(this.options.bulletList)),this.options.code!==!1&&e.push(nCt.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(oCt.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(lCt.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(uCt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(vCt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(_Ct.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(bCt.configure(this.options.heading)),this.options.history!==!1&&e.push(ECt.configure(this.options.history)),this.options.horizontalRule!==!1&&e.push(ICt.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(RCt.configure(this.options.italic)),this.options.listItem!==!1&&e.push(FCt.configure(this.options.listItem)),this.options.orderedList!==!1&&e.push(BCt.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push($Ct.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(qCt.configure(this.options.strike)),this.options.text!==!1&&e.push(HCt.configure(this.options.text)),e}}),WCt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",GCt="ελ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",rge="numeric",sge="ascii",nge="alpha",rI="asciinumeric",ZA="alphanumeric",age="domain",GUe="emoji",KCt="scheme",ZCt="slashscheme",the="whitespace";function YCt(e,t){return e in t||(t[e]=[]),t[e]}function Kj(e,t,s){t[rge]&&(t[rI]=!0,t[ZA]=!0),t[sge]&&(t[rI]=!0,t[nge]=!0),t[rI]&&(t[ZA]=!0),t[nge]&&(t[ZA]=!0),t[ZA]&&(t[age]=!0),t[GUe]&&(t[age]=!0);for(const n in t){const a=YCt(n,s);a.indexOf(e)<0&&a.push(e)}}function XCt(e,t){const s={};for(const n in t)t[n].indexOf(e)>=0&&(s[n]=!0);return s}function Vh(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Vh.groups={};Vh.prototype={accepts(){return!!this.t},go(e){const t=this,s=t.j[e];if(s)return s;for(let n=0;ne.ta(t,s,n,a),ac=(e,t,s,n,a)=>e.tr(t,s,n,a),b3e=(e,t,s,n,a)=>e.ts(t,s,n,a),Ls=(e,t,s,n,a)=>e.tt(t,s,n,a),fy="WORD",ige="UWORD",KUe="ASCIINUMERICAL",ZUe="ALPHANUMERICAL",dP="LOCALHOST",oge="TLD",lge="UTLD",ure="SCHEME",FC="SLASH_SCHEME",W1e="NUM",cge="WS",G1e="NL",sI="OPENBRACE",nI="CLOSEBRACE",$se="OPENBRACKET",Use="CLOSEBRACKET",Vse="OPENPAREN",qse="CLOSEPAREN",Hse="OPENANGLEBRACKET",Wse="CLOSEANGLEBRACKET",Gse="FULLWIDTHLEFTPAREN",Kse="FULLWIDTHRIGHTPAREN",Zse="LEFTCORNERBRACKET",Yse="RIGHTCORNERBRACKET",Xse="LEFTWHITECORNERBRACKET",Qse="RIGHTWHITECORNERBRACKET",Jse="FULLWIDTHLESSTHAN",ene="FULLWIDTHGREATERTHAN",tne="AMPERSAND",rne="APOSTROPHE",sne="ASTERISK",Av="AT",nne="BACKSLASH",ane="BACKTICK",ine="CARET",zv="COLON",K1e="COMMA",one="DOLLAR",Hg="DOT",lne="EQUALS",Z1e="EXCLAMATION",gf="HYPHEN",aI="PERCENT",cne="PIPE",dne="PLUS",une="POUND",iI="QUERY",Y1e="QUOTE",YUe="FULLWIDTHMIDDLEDOT",X1e="SEMI",Wg="SLASH",oI="TILDE",hne="UNDERSCORE",XUe="EMOJI",mne="SYM";var QUe=Object.freeze({__proto__:null,ALPHANUMERICAL:ZUe,AMPERSAND:tne,APOSTROPHE:rne,ASCIINUMERICAL:KUe,ASTERISK:sne,AT:Av,BACKSLASH:nne,BACKTICK:ane,CARET:ine,CLOSEANGLEBRACKET:Wse,CLOSEBRACE:nI,CLOSEBRACKET:Use,CLOSEPAREN:qse,COLON:zv,COMMA:K1e,DOLLAR:one,DOT:Hg,EMOJI:XUe,EQUALS:lne,EXCLAMATION:Z1e,FULLWIDTHGREATERTHAN:ene,FULLWIDTHLEFTPAREN:Gse,FULLWIDTHLESSTHAN:Jse,FULLWIDTHMIDDLEDOT:YUe,FULLWIDTHRIGHTPAREN:Kse,HYPHEN:gf,LEFTCORNERBRACKET:Zse,LEFTWHITECORNERBRACKET:Xse,LOCALHOST:dP,NL:G1e,NUM:W1e,OPENANGLEBRACKET:Hse,OPENBRACE:sI,OPENBRACKET:$se,OPENPAREN:Vse,PERCENT:aI,PIPE:cne,PLUS:dne,POUND:une,QUERY:iI,QUOTE:Y1e,RIGHTCORNERBRACKET:Yse,RIGHTWHITECORNERBRACKET:Qse,SCHEME:ure,SEMI:X1e,SLASH:Wg,SLASH_SCHEME:FC,SYM:mne,TILDE:oI,TLD:oge,UNDERSCORE:hne,UTLD:lge,UWORD:ige,WORD:fy,WS:cge});const cy=/[a-z]/,_A=new RegExp("\\p{L}","u"),rhe=new RegExp("\\p{Emoji}","u"),dy=/\d/,she=/\s/,w3e="\r",nhe=` `,QCt="️",JCt="‍",ahe="";let zO=null,BO=null;function e4t(e=[]){const t={};Vh.groups=t;const s=new Vh;zO==null&&(zO=j3e(WCt)),BO==null&&(BO=j3e(GCt)),Ls(s,"'",rne),Ls(s,"{",sI),Ls(s,"}",nI),Ls(s,"[",$se),Ls(s,"]",Use),Ls(s,"(",Vse),Ls(s,")",qse),Ls(s,"<",Hse),Ls(s,">",Wse),Ls(s,"(",Gse),Ls(s,")",Kse),Ls(s,"「",Zse),Ls(s,"」",Yse),Ls(s,"『",Xse),Ls(s,"』",Qse),Ls(s,"<",Jse),Ls(s,">",ene),Ls(s,"&",tne),Ls(s,"*",sne),Ls(s,"@",Av),Ls(s,"`",ane),Ls(s,"^",ine),Ls(s,":",zv),Ls(s,",",K1e),Ls(s,"$",one),Ls(s,".",Hg),Ls(s,"=",lne),Ls(s,"!",Z1e),Ls(s,"-",gf),Ls(s,"%",aI),Ls(s,"|",cne),Ls(s,"+",dne),Ls(s,"#",une),Ls(s,"?",iI),Ls(s,'"',Y1e),Ls(s,"/",Wg),Ls(s,";",X1e),Ls(s,"~",oI),Ls(s,"_",hne),Ls(s,"\\",nne),Ls(s,"・",YUe);const n=ac(s,dy,W1e,{[rge]:!0});ac(n,dy,n);const a=ac(n,cy,KUe,{[rI]:!0}),o=ac(n,_A,ZUe,{[ZA]:!0}),l=ac(s,cy,fy,{[sge]:!0});ac(l,dy,a),ac(l,cy,l),ac(a,dy,a),ac(a,cy,a);const i=ac(s,_A,ige,{[nge]:!0});ac(i,cy),ac(i,dy,o),ac(i,_A,i),ac(o,dy,o),ac(o,cy),ac(o,_A,o);const d=Ls(s,nhe,G1e,{[the]:!0}),m=Ls(s,w3e,cge,{[the]:!0}),p=ac(s,she,cge,{[the]:!0});Ls(s,ahe,p),Ls(m,nhe,d),Ls(m,ahe,p),ac(m,she,p),Ls(p,w3e),Ls(p,nhe),ac(p,she,p),Ls(p,ahe,p);const g=ac(s,rhe,XUe,{[GUe]:!0});Ls(g,"#"),ac(g,rhe,g),Ls(g,QCt,g);const v=Ls(g,JCt);Ls(v,"#"),ac(v,rhe,g);const _=[[cy,l],[dy,a]],k=[[cy,null],[_A,i],[dy,o]];for(let w=0;ww[0]>S[0]?1:-1);for(let w=0;w=0?C[age]=!0:cy.test(S)?dy.test(S)?C[rI]=!0:C[sge]=!0:C[rge]=!0,b3e(s,S,S,C)}return b3e(s,"localhost",dP,{ascii:!0}),s.jd=new Vh(mne),{start:s,tokens:Object.assign({groups:t},QUe)}}function JUe(e,t){const s=t4t(t.replace(/[A-Z]/g,i=>i.toLowerCase())),n=s.length,a=[];let o=0,l=0;for(;l=0&&(g+=s[l].length,v++),m+=s[l].length,o+=s[l].length,l++;o-=g,l-=v,m-=g,a.push({t:p.t,v:t.slice(o-m,o),s:o-m,e:o})}return a}function t4t(e){const t=[],s=e.length;let n=0;for(;n56319||n+1===s||(o=e.charCodeAt(n+1))<56320||o>57343?e[n]:e.slice(n,n+2);t.push(l),n+=l.length}return t}function mv(e,t,s,n,a){let o;const l=t.length;for(let i=0;i=0;)o++;if(o>0){t.push(s.join(""));for(let l=parseInt(e.substring(n,n+o),10);l>0;l--)s.pop();n+=o}else s.push(e[n]),n++}return t}const uP={defaultProtocol:"http",events:null,format:k3e,formatHref:k3e,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Q1e(e,t=null){let s=Object.assign({},uP);e&&(s=Object.assign(s,e instanceof Q1e?e.o:e));const n=s.ignoreTags,a=[];for(let o=0;os?n.substring(0,s)+"…":n},toFormattedHref(e){return e.get("formatHref",this.toHref(e.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=uP.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get("validate",this.toString(),this)},render(e){const t=this,s=this.toHref(e.get("defaultProtocol")),n=e.get("formatHref",s,this),a=e.get("tagName",s,t),o=this.toFormattedString(e),l={},i=e.get("className",s,t),d=e.get("target",s,t),m=e.get("rel",s,t),p=e.getObj("attributes",s,t),g=e.getObj("events",s,t);return l.href=n,i&&(l.class=i),d&&(l.target=d),m&&(l.rel=m),p&&Object.assign(l,p),{tagName:a,attributes:l,content:o,eventListeners:g}}};function aoe(e,t){class s extends eVe{constructor(a,o){super(a,o),this.t=e}}for(const n in t)s.prototype[n]=t[n];return s.t=e,s}const N3e=aoe("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),S3e=aoe("text"),r4t=aoe("nl"),$O=aoe("url",{isLink:!0,toHref(e=uP.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){const e=this.tk;return e.length>=2&&e[0].t!==dP&&e[1].t===zv}}),hf=e=>new Vh(e);function s4t({groups:e}){const t=e.domain.concat([tne,sne,Av,nne,ane,ine,one,lne,gf,W1e,aI,cne,dne,une,Wg,mne,oI,hne]),s=[rne,zv,K1e,Hg,Z1e,aI,iI,Y1e,X1e,Hse,Wse,sI,nI,Use,$se,Vse,qse,Gse,Kse,Zse,Yse,Xse,Qse,Jse,ene],n=[tne,rne,sne,nne,ane,ine,one,lne,gf,sI,nI,aI,cne,dne,une,iI,Wg,mne,oI,hne],a=hf(),o=Ls(a,oI);Mi(o,n,o),Mi(o,e.domain,o);const l=hf(),i=hf(),d=hf();Mi(a,e.domain,l),Mi(a,e.scheme,i),Mi(a,e.slashscheme,d),Mi(l,n,o),Mi(l,e.domain,l);const m=Ls(l,Av);Ls(o,Av,m),Ls(i,Av,m),Ls(d,Av,m);const p=Ls(o,Hg);Mi(p,n,o),Mi(p,e.domain,o);const g=hf();Mi(m,e.domain,g),Mi(g,e.domain,g);const v=Ls(g,Hg);Mi(v,e.domain,g);const _=hf(N3e);Mi(v,e.tld,_),Mi(v,e.utld,_),Ls(m,dP,_);const k=Ls(g,gf);Ls(k,gf,k),Mi(k,e.domain,g),Mi(_,e.domain,g),Ls(_,Hg,v),Ls(_,gf,k);const w=Ls(_,zv);Mi(w,e.numeric,N3e);const S=Ls(l,gf),T=Ls(l,Hg);Ls(S,gf,S),Mi(S,e.domain,l),Mi(T,n,o),Mi(T,e.domain,l);const C=hf($O);Mi(T,e.tld,C),Mi(T,e.utld,C),Mi(C,e.domain,l),Mi(C,n,o),Ls(C,Hg,T),Ls(C,gf,S),Ls(C,Av,m);const I=Ls(C,zv),R=hf($O);Mi(I,e.numeric,R);const D=hf($O),B=hf();Mi(D,t,D),Mi(D,s,B),Mi(B,t,D),Mi(B,s,B),Ls(C,Wg,D),Ls(R,Wg,D);const $=Ls(i,zv),q=Ls(d,zv),W=Ls(q,Wg),K=Ls(W,Wg);Mi(i,e.domain,l),Ls(i,Hg,T),Ls(i,gf,S),Mi(d,e.domain,l),Ls(d,Hg,T),Ls(d,gf,S),Mi($,e.domain,D),Ls($,Wg,D),Ls($,iI,D),Mi(K,e.domain,D),Mi(K,t,D),Ls(K,Wg,D);const re=[[sI,nI],[$se,Use],[Vse,qse],[Hse,Wse],[Gse,Kse],[Zse,Yse],[Xse,Qse],[Jse,ene]];for(let ae=0;ae=0&&v++,a++,p++;if(v<0)a-=p,a0&&(o.push(ihe(S3e,t,l)),l=[]),a-=v,p-=v;const _=g.t,k=s.slice(a-p,a);o.push(ihe(_,t,k))}}return l.length>0&&o.push(ihe(S3e,t,l)),o}function ihe(e,t,s){const n=s[0].s,a=s[s.length-1].e,o=t.slice(n,a);return new e(o,s)}const a4t=typeof console<"u"&&console&&console.warn||(()=>{}),i4t="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",wl={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function o4t(){return Vh.groups={},wl.scanner=null,wl.parser=null,wl.tokenQueue=[],wl.pluginQueue=[],wl.customSchemes=[],wl.initialized=!1,wl}function C3e(e,t=!1){if(wl.initialized&&a4t(`linkifyjs: already initialized - will not register custom scheme "${e}" ${i4t}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))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`);wl.customSchemes.push([e,t])}function l4t(){wl.scanner=e4t(wl.customSchemes);for(let e=0;e{const a=t.some(m=>m.docChanged)&&!s.doc.eq(n.doc),o=t.some(m=>m.getMeta("preventAutolink"));if(!a||o)return;const{tr:l}=n,i=BNt(s.doc,[...t]);if(GNt(i).forEach(({newRange:m})=>{const p=UNt(n.doc,m,_=>_.isTextblock);let g,v;if(p.length>1)g=p[0],v=n.doc.textBetween(g.pos,g.pos+g.node.nodeSize,void 0," ");else if(p.length){const _=n.doc.textBetween(m.from,m.to," "," ");if(!d4t.test(_))return;g=p[0],v=n.doc.textBetween(g.pos,m.to,void 0," ")}if(g&&v){const _=v.split(c4t).filter(Boolean);if(_.length<=0)return!1;const k=_[_.length-1],w=g.pos+v.lastIndexOf(k);if(!k)return!1;const S=J1e(k).map(T=>T.toObject(e.defaultProtocol));if(!h4t(S))return!1;S.filter(T=>T.isLink).map(T=>({...T,from:w+T.start+1,to:w+T.end+1})).filter(T=>n.schema.marks.code?!n.doc.rangeHasMark(T.from,T.to,n.schema.marks.code):!0).filter(T=>e.validate(T.value)).filter(T=>e.shouldAutoLink(T.value)).forEach(T=>{$1e(T.from,T.to,n.doc).some(C=>C.mark.type===e.type)||l.addMark(T.from,T.to,e.type.create({href:T.href}))})}}),!!l.steps.length)return l}})}function f4t(e){return new Td({key:new Vu("handleClickLink"),props:{handleClick:(t,s,n)=>{var a,o;if(n.button!==0||!t.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=DUe(t.state,e.type.name),m=n.target,p=(a=m==null?void 0:m.href)!==null&&a!==void 0?a:d.href,g=(o=m==null?void 0:m.target)!==null&&o!==void 0?o:d.target;return m&&p?(window.open(p,g),!0):!1}}})}function p4t(e){return new Td({key:new Vu("handlePasteLink"),props:{handlePaste:(t,s,n)=>{const{state:a}=t,{selection:o}=a,{empty:l}=o;if(l)return!1;let i="";n.content.forEach(m=>{i+=m.textContent});const d=tVe(i,{defaultProtocol:e.defaultProtocol}).find(m=>m.isLink&&m.value===i);return!i||!d?!1:e.editor.commands.setMark(e.type,{href:d.href})}}})}function lb(e,t){const s=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return t&&t.forEach(n=>{const a=typeof n=="string"?n:n.scheme;a&&s.push(a)}),!e||e.replace(u4t,"").match(new RegExp(`^(?:(?:${s.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const rVe=Cx.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(e=>{if(typeof e=="string"){C3e(e);return}C3e(e.scheme,e.optionalSlashes)})},onDestroy(){o4t()},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:(e,t)=>!!lb(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>!!e}},addAttributes(){return{href:{default:null,parseHTML(e){return e.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:e=>{const t=e.getAttribute("href");return!t||!this.options.isAllowedUri(t,{defaultValidate:s=>!!lb(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:t=>!!lb(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",sc(this.options.HTMLAttributes,e),0]:["a",sc(this.options.HTMLAttributes,{...e,href:""}),0]},addCommands(){return{setLink:e=>({chain:t})=>{const{href:s}=e;return this.options.isAllowedUri(s,{defaultValidate:n=>!!lb(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta("preventAutolink",!0).run():!1},toggleLink:e=>({chain:t})=>{const{href:s}=e;return this.options.isAllowedUri(s,{defaultValidate:n=>!!lb(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[iN({find:e=>{const t=[];if(e){const{protocols:s,defaultProtocol:n}=this.options,a=tVe(e).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!lb(l,s),protocols:s,defaultProtocol:n}));a.length&&a.forEach(o=>t.push({text:o.value,data:{href:o.href},index:o.start}))}return t},type:this.type,getAttributes:e=>{var t;return{href:(t=e.data)===null||t===void 0?void 0:t.href}}})]},addProseMirrorPlugins(){const e=[],{protocols:t,defaultProtocol:s}=this.options;return this.options.autolink&&e.push(m4t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!lb(a,t),protocols:t,defaultProtocol:s}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&e.push(f4t({type:this.type})),this.options.linkOnPaste&&e.push(p4t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),e}}),sVe=yu.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:e=>{const t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(s=>t.updateAttributes(s,{textAlign:e})).every(s=>s):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,"textAlign")).every(t=>t),toggleTextAlign:e=>({editor:t,commands:s})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?s.unsetTextAlign():s.setTextAlign(e):!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")}}}),g4t=e=>{if(!e.children.length)return;const t=e.querySelectorAll("span");t&&t.forEach(s=>{var n,a;const o=s.getAttribute("style"),l=(a=(n=s.parentElement)===null||n===void 0?void 0:n.closest("span"))===null||a===void 0?void 0:a.getAttribute("style");s.setAttribute("style",`${l};${o}`)})},nVe=Cx.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&g4t(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",sc(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{const{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(s,n)=>{if(s.isTextblock)return!0;s.marks.filter(a=>a.type===this.type).some(a=>Object.values(a.attrs).some(o=>!!o))||e.removeMark(n,n+s.nodeSize,this.type)}),!0}}}}),x4t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,y4t=qu.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:e}){return["img",sc(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[OUe({find:x4t,type:this.type,getAttributes:e=>{const[,,t,s,n]=e;return{src:s,alt:t,title:n}}})]}});let dge,uge;if(typeof WeakMap<"u"){let e=new WeakMap;dge=t=>e.get(t),uge=(t,s)=>(e.set(t,s),s)}else{const e=[];let s=0;dge=n=>{for(let a=0;a(s==10&&(s=0),e[s++]=n,e[s++]=a)}var pc=class{constructor(e,t,s,n){this.width=e,this.height=t,this.map=s,this.problems=n}findCell(e){for(let t=0;t=s){(o||(o=[])).push({type:"overlong_rowspan",pos:p,n:T-I});break}const R=a+I*t;for(let D=0;Dn&&(o+=m.attrs.colspan)}}for(let l=0;l1&&(s=!0)}t==-1?t=o:t!=o&&(t=Math.max(t,o))}return t}function b4t(e,t,s){e.problems||(e.problems=[]);const n={};for(let a=0;a0;t--)if(e.node(t).type.spec.tableRole=="row")return e.node(0).resolve(e.before(t+1));return null}function j4t(e){for(let t=e.depth;t>0;t--){const s=e.node(t).type.spec.tableRole;if(s==="cell"||s==="header_cell")return e.node(t)}return null}function xg(e){const t=e.selection.$head;for(let s=t.depth;s>0;s--)if(t.node(s).type.spec.tableRole=="row")return!0;return!1}function ioe(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&t.node.type.spec.tableRole=="cell")return t.$anchor;const s=O3(t.$head)||k4t(t.$head);if(s)return s;throw new RangeError(`No cell found around position ${t.head}`)}function k4t(e){for(let t=e.nodeAfter,s=e.pos;t;t=t.firstChild,s++){const n=t.type.spec.tableRole;if(n=="cell"||n=="header_cell")return e.doc.resolve(s)}for(let t=e.nodeBefore,s=e.pos;t;t=t.lastChild,s--){const n=t.type.spec.tableRole;if(n=="cell"||n=="header_cell")return e.doc.resolve(s-t.nodeSize)}}function hge(e){return e.parent.type.spec.tableRole=="row"&&!!e.nodeAfter}function N4t(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function t_e(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function aVe(e,t,s){const n=e.node(-1),a=pc.get(n),o=e.start(-1),l=a.nextCell(e.pos-o,t,s);return l==null?null:e.node(0).resolve(o+l)}function oN(e,t,s=1){const n={...e,colspan:e.colspan-s};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(t,s),n.colwidth.some(a=>a>0)||(n.colwidth=null)),n}function iVe(e,t,s=1){const n={...e,colspan:e.colspan+s};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let a=0;ap!=s.pos-o);d.unshift(s.pos-o);const m=d.map(p=>{const g=n.nodeAt(p);if(!g)throw new RangeError(`No cell with offset ${p} found`);const v=o+p+1;return new M$e(i.resolve(v),i.resolve(v+g.content.size))});super(m[0].$from,m[0].$to,m),this.$anchorCell=t,this.$headCell=s}map(t,s){const n=t.resolve(s.map(this.$anchorCell.pos)),a=t.resolve(s.map(this.$headCell.pos));if(hge(n)&&hge(a)&&t_e(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?py.rowSelection(n,a):o&&this.isColSelection()?py.colSelection(n,a):new py(n,a)}return Ca.between(n,a)}content(){const t=this.$anchorCell.node(-1),s=pc.get(t),n=this.$anchorCell.start(-1),a=s.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),o={},l=[];for(let d=a.top;d0||S>0){let T=k.attrs;if(w>0&&(T=oN(T,0,w)),S>0&&(T=oN(T,T.colspan-S,S)),_.lefta.bottom){const T={...k.attrs,rowspan:Math.min(_.bottom,a.bottom)-Math.max(_.top,a.top)};_.top0)return!1;const n=t+this.$anchorCell.nodeAfter.attrs.rowspan,a=s+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,a)==this.$headCell.node(-1).childCount}static colSelection(t,s=t){const n=t.node(-1),a=pc.get(n),o=t.start(-1),l=a.findCell(t.pos-o),i=a.findCell(s.pos-o),d=t.node(0);return l.top<=i.top?(l.top>0&&(t=d.resolve(o+a.map[l.left])),i.bottom0&&(s=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)==s.width}eq(t){return t instanceof py&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,s=t){const n=t.node(-1),a=pc.get(n),o=t.start(-1),l=a.findCell(t.pos-o),i=a.findCell(s.pos-o),d=t.node(0);return l.left<=i.left?(l.left>0&&(t=d.resolve(o+a.map[l.top*a.width])),i.right0&&(s=d.resolve(o+a.map[i.top*a.width])),l.right{t.push(hh.node(n,n+s.nodeSize,{class:"selectedCell"}))}),hc.create(e.doc,t)}function T4t({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(a+1)=0&&!(t.before(o+1)>t.start(o));o--,n--);return s==n&&/row|table/.test(e.node(a).type.spec.tableRole)}function A4t({$from:e,$to:t}){let s,n;for(let a=e.depth;a>0;a--){const o=e.node(a);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){s=o;break}}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"){n=o;break}}return s!==n&&t.parentOffset===0}function E4t(e,t,s){const n=(t||e).selection,a=(t||e).doc;let o,l;if(n instanceof ba&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=ml.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=ml.rowSelection(i,i)}else if(!s){const i=pc.get(n.node),d=n.from+1,m=d+i.map[i.width*i.height-1];o=ml.create(a,d+1,m)}}else n instanceof Ca&&T4t(n)?o=Ca.create(a,n.from):n instanceof Ca&&A4t(n)&&(o=Ca.create(a,n.$from.start(),n.$from.end()));return o&&(t||(t=e.tr)).setSelection(o),t}const I4t=new Vu("fix-tables");function lVe(e,t,s,n){const a=e.childCount,o=t.childCount;e:for(let l=0,i=0;l{a.type.spec.tableRole=="table"&&(s=P4t(e,a,o,s))};return t?t.doc!=e.doc&&lVe(t.doc,e.doc,0,n):e.doc.descendants(n),s}function P4t(e,t,s,n){const a=pc.get(t);if(!a.problems)return n;n||(n=e.tr);const o=[];for(let d=0;d0){let _="cell";p.firstChild&&(_=p.firstChild.type.spec.tableRole);const k=[];for(let S=0;S0?-1:0;S4t(t,n,a+o)&&(o=a==0||a==t.width?null:0);for(let l=0;l0&&a0&&t.map[i-1]==d||a0?-1:0;F4t(t,n,a+i)&&(i=a==0||a==t.height?null:0);for(let m=0,p=t.width*a;m0&&a0&&g==t.map[p-t.width]){const v=s.nodeAt(g).attrs;e.setNodeMarkup(e.mapping.slice(i).map(g+n),null,{...v,rowspan:v.rowspan-1}),m+=v.colspan-1}else if(a0&&s[o]==s[o-1]||n.right0&&s[a]==s[a-e]||n.bottom0){const p=d+1+m.content.size,g=M3e(m)?d+1:p;o.replaceWith(g+n.tableStart,p+n.tableStart,i)}o.setSelection(new ml(o.doc.resolve(d+n.tableStart))),t(o)}return!0}function A3e(e,t){const s=zu(e.schema);return q4t(({node:n})=>s[n.type.spec.tableRole])(e,t)}function q4t(e){return(t,s)=>{const n=t.selection;let a,o;if(n instanceof ml){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=j4t(n.$from),!a)return!1;o=(l=O3(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(s){let i=a.attrs;const d=[],m=i.colwidth;i.rowspan>1&&(i={...i,rowspan:1}),i.colspan>1&&(i={...i,colspan:1});const p=Dx(t),g=t.tr;for(let _=0;_{l.attrs[e]!==t&&o.setNodeMarkup(i,null,{...l.attrs,[e]:t})}):o.setNodeMarkup(a.pos,null,{...a.nodeAfter.attrs,[e]:t}),n(o)}return!0}}function W4t(e){return function(t,s){if(!xg(t))return!1;if(s){const n=zu(t.schema),a=Dx(t),o=t.tr,l=a.map.cellsInRect(e=="column"?{left:a.left,top:0,right:a.right,bottom:a.map.height}:e=="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,k=l.doc.nodeAt(_);k&&l.setNodeMarkup(_,g,k.attrs)}),n(l)}return!0}}hP("row",{useDeprecatedLogic:!0});hP("column",{useDeprecatedLogic:!0});const G4t=hP("cell",{useDeprecatedLogic:!0});function K4t(e,t){if(t<0){const s=e.nodeBefore;if(s)return e.pos-s.nodeSize;for(let n=e.index(-1)-1,a=e.before();n>=0;n--){const o=e.node(-1).child(n),l=o.lastChild;if(l)return a-1-l.nodeSize;a-=o.nodeSize}}else{if(e.index()0;n--)if(s.node(n).type.spec.tableRole=="table")return t&&t(e.tr.delete(s.before(n),s.after(n)).scrollIntoView()),!0;return!1}function UO(e,t){const s=e.selection;if(!(s instanceof ml))return!1;if(t){const n=e.tr,a=zu(e.schema).cell.createAndFill().content;s.forEachCell((o,l)=>{o.content.eq(a)||n.replace(n.mapping.map(l+1),n.mapping.map(l+o.nodeSize-1),new nn(a,0,0))}),n.docChanged&&t(n)}return!0}function Y4t(e){if(e.size===0)return null;let{content:t,openStart:s,openEnd:n}=e;for(;t.childCount==1&&(s>0&&n>0||t.child(0).type.spec.tableRole=="table");)s--,n--,t=t.child(0).content;const a=t.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 m=a;m=t.length&&t.push(_s.empty),s[a]n&&(v=v.type.createChecked(oN(v.attrs,v.attrs.colspan,p+v.attrs.colspan-n),v.content)),m.push(v),p+=v.attrs.colspan;for(let _=1;_a&&(g=g.type.create({...g.attrs,rowspan:Math.max(1,a-g.attrs.rowspan)},g.content)),d.push(g)}o.push(_s.from(d))}s=o,t=a}return{width:e,height:t,rows:s}}function J4t(e,t,s,n,a,o,l){const i=e.doc.type.schema,d=zu(i);let m,p;if(a>t.width)for(let g=0,v=0;gt.height){const g=[];for(let k=0,w=(t.height-1)*t.width;k=t.width?!1:s.nodeAt(t.map[w+k]).type==d.header_cell;g.push(S?p||(p=d.header_cell.createAndFill()):m||(m=d.cell.createAndFill()))}const v=d.row.create(null,_s.from(g)),_=[];for(let k=t.height;k{if(!a)return!1;const o=s.selection;if(o instanceof ml)return hre(s,n,Va.near(o.$headCell,t));if(e!="horiz"&&!o.empty)return!1;const l=hVe(a,e,t);if(l==null)return!1;if(e=="horiz")return hre(s,n,Va.near(s.doc.resolve(o.head+t),t));{const i=s.doc.resolve(l),d=aVe(i,e,t);let m;return d?m=Va.near(d,1):t<0?m=Va.near(s.doc.resolve(i.before(-1)),-1):m=Va.near(s.doc.resolve(i.after(-1)),1),hre(s,n,m)}}}function qO(e,t){return(s,n,a)=>{if(!a)return!1;const o=s.selection;let l;if(o instanceof ml)l=o;else{const d=hVe(a,e,t);if(d==null)return!1;l=new ml(s.doc.resolve(d))}const i=aVe(l.$headCell,e,t);return i?hre(s,n,new ml(l.$anchorCell,i)):!1}}function t5t(e,t){const s=e.state.doc,n=O3(s.resolve(t));return n?(e.dispatch(e.state.tr.setSelection(new ml(n))),!0):!1}function r5t(e,t,s){if(!xg(e.state))return!1;let n=Y4t(s);const a=e.state.selection;if(a instanceof ml){n||(n={width:1,height:1,rows:[_s.from(mge(zu(e.state.schema).cell,s))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=pc.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=Q4t(n,i.right-i.left,i.bottom-i.top),D3e(e.state,e.dispatch,l,i,n),!0}else if(n){const o=ioe(e.state),l=o.start(-1);return D3e(e.state,e.dispatch,l,pc.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function s5t(e,t){var s;if(t.ctrlKey||t.metaKey)return;const n=O3e(e,t.target);let a;if(t.shiftKey&&e.state.selection instanceof ml)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(a=O3(e.state.selection.$anchor))!=null&&((s=ohe(e,t))===null||s===void 0?void 0:s.pos)!=a.pos)o(a,t),t.preventDefault();else if(!n)return;function o(d,m){let p=ohe(e,m);const g=Bv.getState(e.state)==null;if(!p||!t_e(d,p))if(g)p=d;else return;const v=new ml(d,p);if(g||!e.state.selection.eq(v)){const _=e.state.tr.setSelection(v);g&&_.setMeta(Bv,d.pos),e.dispatch(_)}}function l(){e.root.removeEventListener("mouseup",l),e.root.removeEventListener("dragstart",l),e.root.removeEventListener("mousemove",i),Bv.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Bv,-1))}function i(d){const m=d,p=Bv.getState(e.state);let g;if(p!=null)g=e.state.doc.resolve(p);else if(O3e(e,m.target)!=n&&(g=ohe(e,t),!g))return l();g&&o(g,m)}e.root.addEventListener("mouseup",l),e.root.addEventListener("dragstart",l),e.root.addEventListener("mousemove",i)}function hVe(e,t,s){if(!(e.state.selection instanceof Ca))return null;const{$head:n}=e.state.selection;for(let a=n.depth-1;a>=0;a--){const o=n.node(a);if((s<0?n.index(a):n.indexAfter(a))!=(s<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=n.before(a),i=t=="vert"?s>0?"down":"up":s>0?"right":"left";return e.endOfTextblock(i)?l:null}}return null}function O3e(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName=="TD"||t.nodeName=="TH")return t;return null}function ohe(e,t){const s=e.posAtCoords({left:t.clientX,top:t.clientY});if(!s)return null;const n=s.inside>=0?s.inside:s.pos;return O3(e.state.doc.resolve(n))}var n5t=class{constructor(t,s){this.node=t,this.defaultCellMinWidth=s,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",`${s}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),fge(t,this.colgroup,this.table,s),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,fge(t,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function fge(e,t,s,n,a,o){let l=0,i=!0,d=t.firstChild;const m=e.firstChild;if(m){for(let g=0,v=0;gnew n(g,s,v)),new i5t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=Tm.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{o5t(l,i,e,a)},mouseleave:l=>{l5t(l)},mousedown:(l,i)=>{c5t(l,i,t,s)}},decorations:l=>{const i=Tm.getState(l);if(i&&i.activeHandle>-1)return f5t(l,i.activeHandle)},nodeViews:{}}});return o}var i5t=class mre{constructor(t,s){this.activeHandle=t,this.dragging=s}apply(t){const s=this,n=t.getMeta(Tm);if(n&&n.setHandle!=null)return new mre(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new mre(s.activeHandle,n.setDragging);if(s.activeHandle>-1&&t.docChanged){let a=t.mapping.map(s.activeHandle,-1);return hge(t.doc.resolve(a))||(a=-1),new mre(a,s.dragging)}return s}};function o5t(e,t,s,n){if(!e.editable)return;const a=Tm.getState(e.state);if(a&&!a.dragging){const o=u5t(t.target);let l=-1;if(o){const{left:i,right:d}=o.getBoundingClientRect();t.clientX-i<=s?l=R3e(e,t,"left",s):d-t.clientX<=s&&(l=R3e(e,t,"right",s))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=e.state.doc.resolve(l),d=i.node(-1),m=pc.get(d),p=i.start(-1);if(m.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==m.width-1)return}mVe(e,l)}}}function l5t(e){if(!e.editable)return;const t=Tm.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&mVe(e,-1)}function c5t(e,t,s,n){var a;if(!e.editable)return!1;const o=(a=e.dom.ownerDocument.defaultView)!==null&&a!==void 0?a:window,l=Tm.getState(e.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=e.state.doc.nodeAt(l.activeHandle),d=d5t(e,l.activeHandle,i.attrs);e.dispatch(e.state.tr.setMeta(Tm,{setDragging:{startX:t.clientX,startWidth:d}}));function m(g){o.removeEventListener("mouseup",m),o.removeEventListener("mousemove",p);const v=Tm.getState(e.state);v!=null&&v.dragging&&(h5t(e,v.activeHandle,F3e(v.dragging,g,s)),e.dispatch(e.state.tr.setMeta(Tm,{setDragging:null})))}function p(g){if(!g.which)return m(g);const v=Tm.getState(e.state);if(v&&v.dragging){const _=F3e(v.dragging,g,s);z3e(e,v.activeHandle,_,n)}}return z3e(e,l.activeHandle,d,n),o.addEventListener("mouseup",m),o.addEventListener("mousemove",p),t.preventDefault(),!0}function d5t(e,t,{colspan:s,colwidth:n}){const a=n&&n[n.length-1];if(a)return a;const o=e.domAtPos(t);let l=o.node.childNodes[o.offset].offsetWidth,i=s;if(n)for(let d=0;d{const n=e.nodes[s];n.spec.tableRole&&(t[n.spec.tableRole]=n)}),e.cached.tableNodeTypes=t,t}function v5t(e,t,s,n,a){const o=y5t(e),l=[],i=[];for(let m=0;m{const{selection:t}=e.state;if(!_5t(t))return!1;let s=0;const n=LUe(t.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)&&(s+=1)}),s===t.ranges.length?(e.commands.deleteTable(),!0):!1},b5t=qu.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:g5t,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:e,HTMLAttributes:t}){const{colgroup:s,tableWidth:n,tableMinWidth:a}=x5t(e,this.options.cellMinWidth),o=["table",sc(this.options.HTMLAttributes,t,{style:n?`width: ${n}`:`min-width: ${a}`}),s,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},o]:o},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:s=!0}={})=>({tr:n,dispatch:a,editor:o})=>{const l=v5t(o.schema,e,t,s);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Ca.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>L4t(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>D4t(e,t),deleteColumn:()=>({state:e,dispatch:t})=>R4t(e,t),addRowBefore:()=>({state:e,dispatch:t})=>z4t(e,t),addRowAfter:()=>({state:e,dispatch:t})=>B4t(e,t),deleteRow:()=>({state:e,dispatch:t})=>U4t(e,t),deleteTable:()=>({state:e,dispatch:t})=>Z4t(e,t),mergeCells:()=>({state:e,dispatch:t})=>T3e(e,t),splitCell:()=>({state:e,dispatch:t})=>A3e(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>hP("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>hP("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>G4t(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>T3e(e,t)?!0:A3e(e,t),setCellAttribute:(e,t)=>({state:s,dispatch:n})=>H4t(e,t)(s,n),goToNextCell:()=>({state:e,dispatch:t})=>I3e(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>I3e(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&cVe(e),!0),setCellSelection:e=>({tr:t,dispatch:s})=>{if(s){const n=ml.create(t.doc,e.anchorCell,e.headCell);t.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:HO,"Mod-Backspace":HO,Delete:HO,"Mod-Delete":HO}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[a5t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],p5t({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){const t={name:e.name,options:e.options,storage:e.storage};return{tableRole:Ti(Un(e,"tableRole",t))}}}),w5t=qu.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:e}){return["tr",sc(this.options.HTMLAttributes,e),0]}}),j5t=qu.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",sc(this.options.HTMLAttributes,e),0]}}),k5t=qu.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(n=>parseInt(n,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:e}){return["th",sc(this.options.HTMLAttributes,e),0]}});function yg({content:e,onChange:t,placeholder:s="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=A.useState(!1),[i,d]=A.useState(""),[m,p]=A.useState(!0),g=BUe({extensions:[WUe,rVe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),sVe.configure({types:["heading","paragraph"]}),nVe,y4t.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}),b5t.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}),w5t.extend({addAttributes(){var w;return{...(w=this.parent)==null?void 0:w.call(this),style:{default:null}}}}),j5t.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}}}}),k5t.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:e,onUpdate:({editor:w})=>{t(w.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":s},handlePaste:(w,S)=>{var C;const T=(C=S.clipboardData)==null?void 0:C.items;if(!T)return!1;for(const I of Array.from(T))if(I.type.startsWith("image/")){S.preventDefault();const R=I.getAsFile();if(!R)continue;const D=new FileReader;return D.onload=B=>{var q;const $=(q=B.target)==null?void 0:q.result;w.dispatch(w.state.tr.replaceSelectionWith(w.state.schema.nodes.image.create({src:$})))},D.readAsDataURL(R),!0}return!1}}});A.useEffect(()=>{g&&e!==g.getHTML()&&g.commands.setContent(e)},[e,g]);const v=()=>{if(!g)return;const w=g.getAttributes("link").href||"",S=g.getAttributes("link").target;d(w),p(S==="_blank"),l(!0)},_=()=>{g&&(i===""?g.chain().focus().extendMarkRange("link").unsetLink().run():g.chain().focus().extendMarkRange("link").setLink({href:i,target:m?"_blank":null,rel:m?"noopener noreferrer nofollow":null}).run(),l(!1),d(""))},k=()=>{g&&g.chain().focus().extendMarkRange("link").unsetLink().run()};return g?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-0.5 p-2 border-b bg-muted/30",children:[r.jsx(X,{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:r.jsx(xE,{className:"h-4 w-4"})}),r.jsx(X,{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:r.jsx(yE,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleBold().run(),className:g.isActive("bold")?"bg-muted":"",title:"Bold",children:r.jsx(b4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleItalic().run(),className:g.isActive("italic")?"bg-muted":"",title:"Italic",children:r.jsx(M4,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleBulletList().run(),className:g.isActive("bulletList")?"bg-muted":"",title:"Bullet List",children:r.jsx(Rf,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().toggleOrderedList().run(),className:g.isActive("orderedList")?"bg-muted":"",title:"Numbered List",children:r.jsx(E4,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("left").run(),className:g.isActive({textAlign:"left"})?"bg-muted":"",title:"Align Left",children:r.jsx(y4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("center").run(),className:g.isActive({textAlign:"center"})?"bg-muted":"",title:"Align Center",children:r.jsx(x4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().setTextAlign("right").run(),className:g.isActive({textAlign:"right"})?"bg-muted":"",title:"Align Right",children:r.jsx(v4,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:v,className:g.isActive("link")?"bg-muted":"",title:"Add Link",children:r.jsx(Lo,{className:"h-4 w-4"})}),g.isActive("link")&&r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:k,title:"Remove Link",children:r.jsx(Lo,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().undo().run(),disabled:!g.can().undo(),title:"Undo",children:r.jsx(z4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>g.chain().focus().redo().run(),disabled:!g.can().redo(),title:"Redo",children:r.jsx(R4,{className:"h-4 w-4"})})]}),r.jsx(FUe,{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}})]}),r.jsx(Ir,{open:o,onOpenChange:l,children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Insert Link"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"link-url",children:"URL"}),r.jsx(Ye,{id:"link-url",value:i,onChange:w=>d(w.target.value),placeholder:"https://example.com"})]}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(fn,{id:"link-new-tab",checked:m,onCheckedChange:p}),r.jsx(Ee,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),r.jsx(X,{type:"button",onClick:_,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var N5t=Object.defineProperty,S5t=(e,t,s)=>t in e?N5t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,El=(e,t,s)=>S5t(e,typeof t!="symbol"?t+"":t,s);const fne={x:0,y:0,width:0,height:0,unit:"px"},NC=(e,t,s)=>Math.min(Math.max(e,t),s),C5t=(...e)=>e.filter(t=>t&&typeof t=="string").join(" "),U3e=(e,t)=>e===t||e.width===t.width&&e.height===t.height&&e.x===t.x&&e.y===t.y&&e.unit===t.unit;function M5t(e,t,s,n){const a=Gg(e,s,n);return e.width&&(a.height=a.width/t),e.height&&(a.width=a.height*t),a.y+a.height>n&&(a.height=n-a.y,a.width=a.height*t),a.x+a.width>s&&(a.width=s-a.x,a.height=a.width/t),e.unit==="%"?Ev(a,s,n):a}function T5t(e,t,s){const n=Gg(e,t,s);return n.x=(t-n.width)/2,n.y=(s-n.height)/2,e.unit==="%"?Ev(n,t,s):n}function Ev(e,t,s){return e.unit==="%"?{...fne,...e,unit:"%"}:{unit:"%",x:e.x?e.x/t*100:0,y:e.y?e.y/s*100:0,width:e.width?e.width/t*100:0,height:e.height?e.height/s*100:0}}function Gg(e,t,s){return e.unit?e.unit==="px"?{...fne,...e,unit:"px"}:{unit:"px",x:e.x?e.x*t/100:0,y:e.y?e.y*s/100:0,width:e.width?e.width*t/100:0,height:e.height?e.height*s/100:0}:{...fne,...e,unit:"px"}}function V3e(e,t,s,n,a,o=0,l=0,i=n,d=a){const m={...e};let p=Math.min(o,n),g=Math.min(l,a),v=Math.min(i,n),_=Math.min(d,a);t&&(t>1?(p=l?l*t:p,g=p/t,v=i*t):(g=o?o/t:g,p=g*t,_=d/t)),m.y<0&&(m.height=Math.max(m.height+m.y,g),m.y=0),m.x<0&&(m.width=Math.max(m.width+m.x,p),m.x=0);const k=n-(m.x+m.width);k<0&&(m.x=Math.min(m.x,n-p),m.width+=k);const w=a-(m.y+m.height);if(w<0&&(m.y=Math.min(m.y,a-g),m.height+=w),m.widthv&&((s==="sw"||s=="nw")&&(m.x-=v-m.width),m.width=v),m.height>_&&((s==="nw"||s=="ne")&&(m.y-=_-m.height),m.height=_),t){const S=m.width/m.height;if(St){const T=Math.max(m.height*t,p);(s==="sw"||s=="nw")&&(m.x-=T-m.width),m.width=T}}return m}function A5t(e,t,s,n){const a={...e};return t==="ArrowLeft"?n==="nw"?(a.x-=s,a.y-=s,a.width+=s,a.height+=s):n==="w"?(a.x-=s,a.width+=s):n==="sw"?(a.x-=s,a.width+=s,a.height+=s):n==="ne"?(a.y+=s,a.width-=s,a.height-=s):n==="e"?a.width-=s:n==="se"&&(a.width-=s,a.height-=s):t==="ArrowRight"&&(n==="nw"?(a.x+=s,a.y+=s,a.width-=s,a.height-=s):n==="w"?(a.x+=s,a.width-=s):n==="sw"?(a.x+=s,a.width-=s,a.height-=s):n==="ne"?(a.y-=s,a.width+=s,a.height+=s):n==="e"?a.width+=s:n==="se"&&(a.width+=s,a.height+=s)),t==="ArrowUp"?n==="nw"?(a.x-=s,a.y-=s,a.width+=s,a.height+=s):n==="n"?(a.y-=s,a.height+=s):n==="ne"?(a.y-=s,a.width+=s,a.height+=s):n==="sw"?(a.x+=s,a.width-=s,a.height-=s):n==="s"?a.height-=s:n==="se"&&(a.width-=s,a.height-=s):t==="ArrowDown"&&(n==="nw"?(a.x+=s,a.y+=s,a.width-=s,a.height-=s):n==="n"?(a.y+=s,a.height-=s):n==="ne"?(a.y+=s,a.width-=s,a.height-=s):n==="sw"?(a.x-=s,a.width+=s,a.height+=s):n==="s"?a.height+=s:n==="se"&&(a.width+=s,a.height+=s)),a}const SC={capture:!0,passive:!1};let E5t=0;const xv=class Ip extends A.PureComponent{constructor(){super(...arguments),El(this,"docMoveBound",!1),El(this,"mouseDownOnCrop",!1),El(this,"dragStarted",!1),El(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),El(this,"componentRef",A.createRef()),El(this,"mediaRef",A.createRef()),El(this,"resizeObserver"),El(this,"initChangeCalled",!1),El(this,"instanceId",`rc-${E5t++}`),El(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),El(this,"onCropPointerDown",t=>{const{crop:s,disabled:n}=this.props,a=this.getBox();if(!s)return;const o=Gg(s,a.width,a.height);if(n)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const l=t.target.dataset.ord,i=!!l;let d=t.clientX,m=t.clientY,p=o.x,g=o.y;if(l){const v=t.clientX-a.x,_=t.clientY-a.y;let k=0,w=0;l==="ne"||l=="e"?(k=v-(o.x+o.width),w=_-o.y,p=o.x,g=o.y+o.height):l==="se"||l==="s"?(k=v-(o.x+o.width),w=_-(o.y+o.height),p=o.x,g=o.y):l==="sw"||l=="w"?(k=v-o.x,w=_-(o.y+o.height),p=o.x+o.width,g=o.y):(l==="nw"||l=="n")&&(k=v-o.x,w=_-o.y,p=o.x+o.width,g=o.y+o.height),d=p+a.x+k,m=g+a.y+w}this.evData={startClientX:d,startClientY:m,startCropX:p,startCropY:g,clientX:t.clientX,clientY:t.clientY,isResize:i,ord:l},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),El(this,"onComponentPointerDown",t=>{const{crop:s,disabled:n,locked:a,keepSelection:o,onChange:l}=this.props,i=this.getBox();if(n||a||o&&s)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const d=t.clientX-i.x,m=t.clientY-i.y,p={unit:"px",x:d,y:m,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:d,startCropY:m,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,l(Gg(p,i.width,i.height),Ev(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),El(this,"onDocPointerMove",t=>{const{crop:s,disabled:n,onChange:a,onDragStart:o}=this.props,l=this.getBox();if(n||!s||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,o&&o(t));const{evData:i}=this;i.clientX=t.clientX,i.clientY=t.clientY;let d;i.isResize?d=this.resizeCrop():d=this.dragCrop(),U3e(s,d)||a(Gg(d,l.width,l.height),Ev(d,l.width,l.height))}),El(this,"onComponentKeyDown",t=>{const{crop:s,disabled:n,onChange:a,onComplete:o}=this.props;if(n)return;const l=t.key;let i=!1;if(!s)return;const d=this.getBox(),m=this.makePixelCrop(d),p=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?Ip.nudgeStepLarge:t.shiftKey?Ip.nudgeStepMedium:Ip.nudgeStep;if(l==="ArrowLeft"?(m.x-=p,i=!0):l==="ArrowRight"?(m.x+=p,i=!0):l==="ArrowUp"?(m.y-=p,i=!0):l==="ArrowDown"&&(m.y+=p,i=!0),i){t.cancelable&&t.preventDefault(),m.x=NC(m.x,0,d.width-m.width),m.y=NC(m.y,0,d.height-m.height);const g=Gg(m,d.width,d.height),v=Ev(m,d.width,d.height);a(g,v),o&&o(g,v)}}),El(this,"onHandlerKeyDown",(t,s)=>{const{aspect:n=0,crop:a,disabled:o,minWidth:l=0,minHeight:i=0,maxWidth:d,maxHeight:m,onChange:p,onComplete:g}=this.props,v=this.getBox();if(o||!a)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const _=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?Ip.nudgeStepLarge:t.shiftKey?Ip.nudgeStepMedium:Ip.nudgeStep,k=Gg(a,v.width,v.height),w=A5t(k,t.key,_,s),S=V3e(w,n,s,v.width,v.height,l,i,d,m);if(!U3e(a,S)){const T=Ev(S,v.width,v.height);p(S,T),g&&g(S,T)}}),El(this,"onDocPointerDone",t=>{const{crop:s,disabled:n,onComplete:a,onDragEnd:o}=this.props,l=this.getBox();this.unbindDocMove(),!(n||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,o&&o(t),a&&a(Gg(s,l.width,l.height),Ev(s,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),El(this,"onDragFocus",()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)})}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:s,y:n,width:a,height:o}=t.getBoundingClientRect();return{x:s,y:n,width:a,height:o}}componentDidUpdate(t){const{crop:s,onComplete:n}=this.props;if(n&&!t.crop&&s){const{width:a,height:o}=this.getBox();a&&o&&n(Gg(s,a,o),Ev(s,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,SC),this.document.addEventListener("pointerup",this.onDocPointerDone,SC),this.document.addEventListener("pointercancel",this.onDocPointerDone,SC),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,SC),this.document.removeEventListener("pointerup",this.onDocPointerDone,SC),this.document.removeEventListener("pointercancel",this.onDocPointerDone,SC),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,s=this.getBox(),n=this.makePixelCrop(s),a=t.clientX-t.startClientX,o=t.clientY-t.startClientY;return n.x=NC(t.startCropX+a,0,s.width-n.width),n.y=NC(t.startCropY+o,0,s.height-n.height),n}getPointRegion(t,s,n,a){const{evData:o}=this,l=o.clientX-t.x,i=o.clientY-t.y;let d;a&&s?d=s==="nw"||s==="n"||s==="ne":d=i1?o?[o,o/s]:[l*s,l]:l?[l*s,l]:[o,o/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:n,maxHeight:a}=this.props,o=this.getBox(),[l,i]=this.resolveMinDimensions(o,s,this.props.minWidth,this.props.minHeight);let d=this.makePixelCrop(o);const m=this.getPointRegion(o,t.ord,l,i),p=t.ord||m;let g=t.clientX-t.startClientX,v=t.clientY-t.startClientY;(l&&p==="nw"||p==="w"||p==="sw")&&(g=Math.min(g,-l)),(i&&p==="nw"||p==="n"||p==="ne")&&(v=Math.min(v,-i));const _={unit:"px",x:0,y:0,width:0,height:0};m==="ne"?(_.x=t.startCropX,_.width=g,s?(_.height=_.width/s,_.y=t.startCropY-_.height):(_.height=Math.abs(v),_.y=t.startCropY-_.height)):m==="se"?(_.x=t.startCropX,_.y=t.startCropY,_.width=g,s?_.height=_.width/s:_.height=v):m==="sw"?(_.x=t.startCropX+g,_.y=t.startCropY,_.width=Math.abs(g),s?_.height=_.width/s:_.height=v):m==="nw"&&(_.x=t.startCropX+g,_.width=Math.abs(g),s?(_.height=_.width/s,_.y=t.startCropY-_.height):(_.height=Math.abs(v),_.y=t.startCropY+v));const k=V3e(_,s,m,o.width,o.height,l,i,n,a);return s||Ip.xyOrds.indexOf(p)>-1?d=k:Ip.xOrds.indexOf(p)>-1?(d.x=k.x,d.width=k.width):Ip.yOrds.indexOf(p)>-1&&(d.y=k.y,d.height=k.height),d.x=NC(d.x,0,o.width-d.width),d.y=NC(d.y,0,o.height-d.height),d}renderCropSelection(){const{ariaLabels:t=Ip.defaultProps.ariaLabels,disabled:s,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":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!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":t.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":t.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":t.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":t.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":t.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":t.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":t.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":t.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(t){const s={...fne,...this.props.crop||{}};return Gg(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:n,className:a,crop:o,disabled:l,locked:i,style:d,ruleOfThirds:m}=this.props,{cropIsActive:p,newCropIsBeingDrawn:g}=this.state,v=o?this.renderCropSelection():null,_=C5t("ReactCrop",a,p&&"ReactCrop--active",l&&"ReactCrop--disabled",i&&"ReactCrop--locked",g&&"ReactCrop--new-crop",o&&t&&"ReactCrop--fixed-aspect",o&&n&&"ReactCrop--circular-crop",o&&m&&"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},s),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)}};El(xv,"xOrds",["e","w"]),El(xv,"yOrds",["n","s"]),El(xv,"xyOrds",["nw","ne","se","sw"]),El(xv,"nudgeStep",1),El(xv,"nudgeStepMedium",10),El(xv,"nudgeStepLarge",100),El(xv,"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 I5t=xv;var fVe=["PageUp","PageDown"],pVe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],gVe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},R3="Slider",[gge,P5t,L5t]=h6(R3),[xVe]=Sc(R3,[L5t]),[D5t,ooe]=xVe(R3),yVe=A.forwardRef((e,t)=>{const{name:s,min:n=0,max:a=100,step:o=1,orientation:l="horizontal",disabled:i=!1,minStepsBetweenThumbs:d=0,defaultValue:m=[n],value:p,onValueChange:g=()=>{},onValueCommit:v=()=>{},inverted:_=!1,form:k,...w}=e,S=A.useRef(new Set),T=A.useRef(0),I=l==="horizontal"?O5t:R5t,[R=[],D]=bh({prop:p,defaultProp:m,onChange:re=>{var oe;(oe=[...S.current][T.current])==null||oe.focus(),g(re)}}),B=A.useRef(R);function $(re){const ae=U5t(R,re);K(re,ae)}function q(re){K(re,T.current)}function W(){const re=B.current[T.current];R[T.current]!==re&&v(R)}function K(re,ae,{commit:oe}={commit:!1}){const se=W5t(o),pe=G5t(Math.round((re-n)/o)*o+n,se),ie=YI(pe,[n,a]);D((de=[])=>{const ce=B5t(de,ie,ae);if(H5t(ce,d*o)){T.current=ce.indexOf(ie);const ge=String(ce)!==String(de);return ge&&oe&&v(ce),ge?ce:de}else return de})}return r.jsx(D5t,{scope:e.__scopeSlider,name:s,disabled:i,min:n,max:a,valueIndexToChangeRef:T,thumbs:S.current,values:R,orientation:l,form:k,children:r.jsx(gge.Provider,{scope:e.__scopeSlider,children:r.jsx(gge.Slot,{scope:e.__scopeSlider,children:r.jsx(I,{"aria-disabled":i,"data-disabled":i?"":void 0,...w,ref:t,onPointerDown:bs(w.onPointerDown,()=>{i||(B.current=R)}),min:n,max:a,inverted:_,onSlideStart:i?void 0:$,onSlideMove:i?void 0:q,onSlideEnd:i?void 0:W,onHomeKeyDown:()=>!i&&K(n,0,{commit:!0}),onEndKeyDown:()=>!i&&K(a,R.length-1,{commit:!0}),onStepKeyDown:({event:re,direction:ae})=>{if(!i){const pe=fVe.includes(re.key)||re.shiftKey&&pVe.includes(re.key)?10:1,ie=T.current,de=R[ie],ce=o*pe*ae;K(de+ce,ie,{commit:!0})}}})})})})});yVe.displayName=R3;var[vVe,_Ve]=xVe(R3,{startEdge:"left",endEdge:"right",size:"width",direction:1}),O5t=A.forwardRef((e,t)=>{const{min:s,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:d,onStepKeyDown:m,...p}=e,[g,v]=A.useState(null),_=va(t,I=>v(I)),k=A.useRef(void 0),w=vN(a),S=w==="ltr",T=S&&!o||!S&&o;function C(I){const R=k.current||g.getBoundingClientRect(),D=[0,R.width],$=r_e(D,T?[s,n]:[n,s]);return k.current=R,$(I-R.left)}return r.jsx(vVe,{scope:e.__scopeSlider,startEdge:T?"left":"right",endEdge:T?"right":"left",direction:T?1:-1,size:"width",children:r.jsx(bVe,{dir:w,"data-orientation":"horizontal",...p,ref:_,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:I=>{const R=C(I.clientX);l==null||l(R)},onSlideMove:I=>{const R=C(I.clientX);i==null||i(R)},onSlideEnd:()=>{k.current=void 0,d==null||d()},onStepKeyDown:I=>{const D=gVe[T?"from-left":"from-right"].includes(I.key);m==null||m({event:I,direction:D?-1:1})}})})}),R5t=A.forwardRef((e,t)=>{const{min:s,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:d,...m}=e,p=A.useRef(null),g=va(t,p),v=A.useRef(void 0),_=!a;function k(w){const S=v.current||p.current.getBoundingClientRect(),T=[0,S.height],I=r_e(T,_?[n,s]:[s,n]);return v.current=S,I(w-S.top)}return r.jsx(vVe,{scope:e.__scopeSlider,startEdge:_?"bottom":"top",endEdge:_?"top":"bottom",size:"height",direction:_?1:-1,children:r.jsx(bVe,{"data-orientation":"vertical",...m,ref:g,style:{...m.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const S=k(w.clientY);o==null||o(S)},onSlideMove:w=>{const S=k(w.clientY);l==null||l(S)},onSlideEnd:()=>{v.current=void 0,i==null||i()},onStepKeyDown:w=>{const T=gVe[_?"from-bottom":"from-top"].includes(w.key);d==null||d({event:w,direction:T?-1:1})}})})}),bVe=A.forwardRef((e,t)=>{const{__scopeSlider:s,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:d,...m}=e,p=ooe(R3,s);return r.jsx(Hs.span,{...m,ref:t,onKeyDown:bs(e.onKeyDown,g=>{g.key==="Home"?(l(g),g.preventDefault()):g.key==="End"?(i(g),g.preventDefault()):fVe.concat(pVe).includes(g.key)&&(d(g),g.preventDefault())}),onPointerDown:bs(e.onPointerDown,g=>{const v=g.target;v.setPointerCapture(g.pointerId),g.preventDefault(),p.thumbs.has(v)?v.focus():n(g)}),onPointerMove:bs(e.onPointerMove,g=>{g.target.hasPointerCapture(g.pointerId)&&a(g)}),onPointerUp:bs(e.onPointerUp,g=>{const v=g.target;v.hasPointerCapture(g.pointerId)&&(v.releasePointerCapture(g.pointerId),o(g))})})}),wVe="SliderTrack",jVe=A.forwardRef((e,t)=>{const{__scopeSlider:s,...n}=e,a=ooe(wVe,s);return r.jsx(Hs.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:t})});jVe.displayName=wVe;var xge="SliderRange",kVe=A.forwardRef((e,t)=>{const{__scopeSlider:s,...n}=e,a=ooe(xge,s),o=_Ve(xge,s),l=A.useRef(null),i=va(t,l),d=a.values.length,m=a.values.map(v=>CVe(v,a.min,a.max)),p=d>1?Math.min(...m):0,g=100-Math.max(...m);return r.jsx(Hs.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...e.style,[o.startEdge]:p+"%",[o.endEdge]:g+"%"}})});kVe.displayName=xge;var yge="SliderThumb",NVe=A.forwardRef((e,t)=>{const s=P5t(e.__scopeSlider),[n,a]=A.useState(null),o=va(t,i=>a(i)),l=A.useMemo(()=>n?s().findIndex(i=>i.ref.current===n):-1,[s,n]);return r.jsx(F5t,{...e,ref:o,index:l})}),F5t=A.forwardRef((e,t)=>{const{__scopeSlider:s,index:n,name:a,...o}=e,l=ooe(yge,s),i=_Ve(yge,s),[d,m]=A.useState(null),p=va(t,C=>m(C)),g=d?l.form||!!d.closest("form"):!0,v=p6(d),_=l.values[n],k=_===void 0?0:CVe(_,l.min,l.max),w=$5t(n,l.values.length),S=v==null?void 0:v[i.size],T=S?V5t(S,k,i.direction):0;return A.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),r.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${k}% + ${T}px)`},children:[r.jsx(gge.ItemSlot,{scope:e.__scopeSlider,children:r.jsx(Hs.span,{role:"slider","aria-label":e["aria-label"]||w,"aria-valuemin":l.min,"aria-valuenow":_,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...o,ref:p,style:_===void 0?{display:"none"}:e.style,onFocus:bs(e.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),g&&r.jsx(SVe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:_},n)]})});NVe.displayName=yge;var z5t="RadioBubbleInput",SVe=A.forwardRef(({__scopeSlider:e,value:t,...s},n)=>{const a=A.useRef(null),o=va(a,n),l=C6(t);return A.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&p){const g=new Event("input",{bubbles:!0});p.call(i,t),i.dispatchEvent(g)}},[l,t]),r.jsx(Hs.input,{style:{display:"none"},...s,ref:o,defaultValue:t})});SVe.displayName=z5t;function B5t(e=[],t,s){const n=[...e];return n[s]=t,n.sort((a,o)=>a-o)}function CVe(e,t,s){const o=100/(s-t)*(e-t);return YI(o,[0,100])}function $5t(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function U5t(e,t){if(e.length===1)return 0;const s=e.map(a=>Math.abs(a-t)),n=Math.min(...s);return s.indexOf(n)}function V5t(e,t,s){const n=e/2,o=r_e([0,50],[0,n]);return(n-o(t)*s)*s}function q5t(e){return e.slice(0,-1).map((t,s)=>e[s+1]-t)}function H5t(e,t){if(t>0){const s=q5t(e);return Math.min(...s)>=t}return!0}function r_e(e,t){return s=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const n=(t[1]-t[0])/(e[1]-e[0]);return t[0]+n*(s-e[0])}}function W5t(e){return(String(e).split(".")[1]||"").length}function G5t(e,t){const s=Math.pow(10,t);return Math.round(e*s)/s}var MVe=yVe,K5t=jVe,Z5t=kVe,Y5t=NVe;const Xp=A.forwardRef(({className:e,...t},s)=>r.jsxs(MVe,{ref:s,className:Vt("relative flex w-full touch-none select-none items-center",e),...t,children:[r.jsx(K5t,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:r.jsx(Z5t,{className:"absolute h-full bg-primary"})}),r.jsx(Y5t,{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"})]}));Xp.displayName=MVe.displayName;function X5t(e,t,s){return T5t(M5t({unit:"%",width:90},s,e,t),e,t)}const s_e=({open:e,onClose:t,imageSrc:s,onCropComplete:n,aspectRatio:a=1})=>{const o=A.useRef(null),[l,i]=A.useState(),[d,m]=A.useState(),[p,g]=A.useState(1),[v,_]=A.useState(0),k=A.useCallback(T=>{const{width:C,height:I}=T.currentTarget;i(X5t(C,I,a))},[a]),w=A.useCallback(async()=>{const T=o.current;if(!T||!d)return;const C=document.createElement("canvas"),I=C.getContext("2d");if(!I)return;const R=T.naturalWidth/T.width,D=T.naturalHeight/T.height,B=400;C.width=B,C.height=B,I.imageSmoothingQuality="high";const $=d.x*R,q=d.y*D,W=d.width*R,K=d.height*D,re=v*Math.PI/180,ae=C.width/2,oe=C.height/2;return I.save(),I.translate(ae,oe),I.rotate(re),I.scale(p,p),I.translate(-ae,-oe),I.drawImage(T,$,q,W,K,0,0,B,B),I.restore(),new Promise((se,pe)=>{C.toBlob(ie=>{ie?se(ie):pe(new Error("Canvas is empty"))},"image/jpeg",.95)})},[d,p,v]),S=async()=>{try{const T=await w();T&&(n(T),t())}catch(T){console.error("Error cropping image:",T)}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-lg",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Crop Your Photo"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"relative max-h-[400px] overflow-hidden rounded-lg bg-muted flex items-center justify-center",children:r.jsx(I5t,{crop:l,onChange:(T,C)=>i(C),onComplete:T=>m(T),aspect:a,circularCrop:!0,className:"max-h-[400px]",children:r.jsx("img",{ref:o,src:s,alt:"Crop preview",style:{transform:`scale(${p}) rotate(${v}deg)`,maxHeight:"400px",width:"auto"},onLoad:k})})}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx($4,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Xp,{value:[p],min:.5,max:3,step:.1,onValueChange:([T])=>g(T),className:"flex-1"}),r.jsx(B4,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(PE,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Xp,{value:[v],min:-180,max:180,step:1,onValueChange:([T])=>_(T),className:"flex-1"}),r.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[v,"°"]})]})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:t,children:"Cancel"}),r.jsx(X,{onClick:S,children:"Save Photo"})]})]})})},Q5t=()=>{const{user:e}=Gr(),{toast:t}=_i(),[s,n]=A.useState(!1),[a,o]=A.useState(!1),[l,i]=A.useState(null);A.useEffect(()=>{e&&d()},[e]);const d=async()=>{n(!0);try{const{data:g}=await Y.from("profiles").select("subscription_status, subscription_product_id, subscription_end_date, is_grandfathered").eq("id",e==null?void 0:e.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)}},m=async()=>{o(!0);try{const{data:{session:g}}=await Y.auth.getSession();if(!g)throw new Error("Not authenticated");const{data:v,error:_}=await Y.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),t({title:"Error",description:g.message||"Failed to open billing portal",variant:"destructive"})}finally{o(!1)}},p=()=>{if(l!=null&&l.isGrandfathered)return r.jsx(_t,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return r.jsx(_t,{className:"bg-green-500",children:"Active"});case"trialing":return r.jsx(_t,{className:"bg-blue-500",children:"Trial"});case"past_due":return r.jsx(_t,{variant:"destructive",children:"Past Due"});case"canceled":return r.jsx(_t,{variant:"secondary",children:"Canceled"});default:return r.jsx(_t,{variant:"outline",children:"No Subscription"})}};return s?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Dm,{className:"h-5 w-5"}),"Subscription"]})}),r.jsx(qe,{children:r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Dm,{className:"h-5 w-5"}),"Subscription"]}),r.jsx(Cs,{children:"Manage your subscription and billing"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Status"}),r.jsx("div",{className:"mt-1",children:p()})]}),(l==null?void 0:l.endDate)&&l.status==="active"&&r.jsxs("div",{className:"text-right",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Next billing date"}),r.jsx("p",{className:"font-medium",children:new Date(l.endDate).toLocaleDateString()})]})]}),l!=null&&l.isGrandfathered?r.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"?r.jsxs(r.Fragment,{children:[(l==null?void 0:l.status)==="trialing"&&(l==null?void 0:l.endDate)&&r.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."]}),r.jsxs(X,{onClick:m,variant:"outline",disabled:a,children:[a?r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}):r.jsx(jn,{className:"mr-2 h-4 w-4"}),"Manage Billing"]})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"You don't have an active subscription."})]})]})},J5t=()=>{const{user:e}=Gr(),t=Ks(),{toast:s}=_i(),[n]=Cc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:d,subscribe:m,unsubscribe:p}=KBe(),[g,v]=A.useState(!1),[_,k]=A.useState(""),[w,S]=A.useState(!1),[T,C]=A.useState(!1),[I,R]=A.useState(""),[D,B]=A.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[$,q]=A.useState(!1),[W,K]=A.useState(!1),[re,ae]=A.useState({newPassword:"",confirmPassword:""});A.useEffect(()=>{e&&oe()},[e]),A.useEffect(()=>{o&&e&&setTimeout(()=>{var ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,e]);const oe=async()=>{var ce,ge,Te;if(!(e!=null&&e.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",e.id);const{data:_e,error:ve}=await Y.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",e.id).maybeSingle();if(ve)throw console.error("Profile query error:",ve),ve;_e?(console.log("Profile loaded successfully:",_e),B({name:_e.name||"",email:_e.email||"",title:_e.title||"",bio:_e.bio||"",areas_served:_e.areas_served||"",years_experience:((ce=_e.years_experience)==null?void 0:ce.toString())||"",instagram_url:_e.instagram_url||"",facebook_url:_e.facebook_url||"",linkedin_url:_e.linkedin_url||"",email_signature:_e.email_signature||"",use_email_signature:_e.use_email_signature||!1}),q(_e.digest_opt_out||!1)):(console.warn("No profile found for user"),B({name:((ge=e.user_metadata)==null?void 0:ge.name)||((Te=e.email)==null?void 0:Te.split("@")[0])||"",email:e.email||"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:Me}=await Y.storage.from("avatars").list(`${e.id}`);if(Me&&Me.length>0){const{data:Ze}=Y.storage.from("avatars").getPublicUrl(`${e.id}/${Me[0].name}`);k(Ze.publicUrl)}}catch(_e){console.error("Error loading profile:",_e),s({title:"Error",description:_e.message||"Failed to load profile",variant:"destructive"})}},se=ce=>{var _e;const ge=(_e=ce.target.files)==null?void 0:_e[0];if(!ge)return;const Te=new FileReader;Te.onloadend=()=>{R(Te.result),C(!0)},Te.readAsDataURL(ge),ce.target.value=""},pe=async ce=>{if(e){S(!0);try{const{data:ge}=await Y.storage.from("avatars").list(`${e.id}`);ge&&ge.length>0&&await Y.storage.from("avatars").remove(ge.map(Ze=>`${e.id}/${Ze.name}`));const _e=`${e.id}/avatar.jpg`,{error:ve}=await Y.storage.from("avatars").upload(_e,ce,{upsert:!0,contentType:"image/jpeg"});if(ve)throw ve;const{data:Me}=Y.storage.from("avatars").getPublicUrl(_e);k(`${Me.publicUrl}?t=${Date.now()}`),s({title:"Success",description:"Profile photo updated successfully"})}catch(ge){console.error("Error uploading avatar:",ge),s({title:"Error",description:ge.message||"Failed to upload photo",variant:"destructive"})}finally{S(!1)}}},ie=async()=>{if(!D.name.trim()||!D.email.trim()){s({title:"Error",description:"Name and email are required",variant:"destructive"});return}v(!0);try{const{error:ce}=await Y.from("profiles").update({name:D.name.trim(),email:D.email.trim(),title:D.title.trim()||null,bio:D.bio.trim()||null,areas_served:D.areas_served.trim()||null,years_experience:D.years_experience?parseInt(D.years_experience):null,instagram_url:D.instagram_url.trim()||null,facebook_url:D.facebook_url.trim()||null,linkedin_url:D.linkedin_url.trim()||null,email_signature:D.email_signature||"",use_email_signature:D.use_email_signature}).eq("id",e==null?void 0:e.id);if(ce)throw ce;s({title:"Success",description:"Profile updated successfully"})}catch(ce){console.error("Error updating profile:",ce),s({title:"Error",description:ce.message||"Failed to update profile",variant:"destructive"})}finally{v(!1)}},de=async()=>{if(!re.newPassword){s({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(re.newPassword.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(re.newPassword!==re.confirmPassword){s({title:"Error",description:"Passwords do not match",variant:"destructive"});return}v(!0);try{const{error:ce}=await Y.auth.updateUser({password:re.newPassword});if(ce)throw ce;s({title:"Success",description:"Password updated successfully"}),ae({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>t("/dashboard"),1e3)}catch(ce){console.error("Error updating password:",ce),s({title:"Error",description:ce.message||"Failed to update password",variant:"destructive"})}finally{v(!1)}};return r.jsx(Ur,{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:r.jsxs("div",{className:"mx-auto max-w-4xl",children:[!a&&!o&&r.jsx("div",{className:"mb-6",children:r.jsxs(X,{variant:"outline",onClick:()=>{var ce;(ce=document.getElementById("change-password-section"))==null||ce.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[r.jsx(_k,{className:"h-4 w-4"}),"Change Password"]})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Profile Photo"}),r.jsx(Cs,{children:"Upload a professional photo for your profile"})]}),r.jsxs(qe,{className:"flex items-center gap-6",children:[r.jsxs(cn,{className:"h-24 w-24",children:[r.jsx(xa,{src:_}),r.jsx(dn,{className:"text-2xl",children:D.name.split(" ").map(ce=>ce[0]).join("").toUpperCase()||"U"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:se,disabled:w}),r.jsxs(X,{variant:"outline",onClick:()=>{var ce;return(ce=document.getElementById("avatar-upload"))==null?void 0:ce.click()},disabled:w,children:[r.jsx(Xi,{className:"mr-2 h-4 w-4"}),w?"Uploading...":"Upload Photo"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Upload an image and crop it to your liking."})]})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Personal Information"}),r.jsx(Cs,{children:"Update your profile details"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",value:D.name,onChange:ce=>B({...D,name:ce.target.value}),maxLength:100})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"email",children:"Email"}),r.jsx(Ye,{id:"email",type:"email",value:D.email,onChange:ce=>B({...D,email:ce.target.value}),maxLength:255})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Job Title"}),r.jsx(Ye,{id:"title",value:D.title,onChange:ce=>B({...D,title:ce.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"bio",children:"Bio"}),r.jsx(qs,{id:"bio",value:D.bio,onChange:ce=>B({...D,bio:ce.target.value}),placeholder:"A short description about yourself",maxLength:500,className:"min-h-[120px] resize-y"})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"areas_served",children:"Areas Served"}),r.jsx(Ye,{id:"areas_served",value:D.areas_served,onChange:ce=>B({...D,areas_served:ce.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"years_experience",children:"Years Experience"}),r.jsx(Ye,{id:"years_experience",type:"number",min:"0",value:D.years_experience,onChange:ce=>B({...D,years_experience:ce.target.value}),placeholder:"e.g., 5"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Social Links"}),r.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[r.jsx(Ye,{value:D.linkedin_url,onChange:ce=>B({...D,linkedin_url:ce.target.value}),placeholder:"LinkedIn URL"}),r.jsx(Ye,{value:D.instagram_url,onChange:ce=>B({...D,instagram_url:ce.target.value}),placeholder:"Instagram URL"}),r.jsx(Ye,{value:D.facebook_url,onChange:ce=>B({...D,facebook_url:ce.target.value}),placeholder:"Facebook URL"})]})]}),r.jsxs(X,{onClick:ie,disabled:g,children:[r.jsx(zf,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(jv,{className:"h-5 w-5"}),"Email Signature"]}),r.jsx(Cs,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Use email signature in all emails"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:D.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),r.jsx(fn,{checked:D.use_email_signature,onCheckedChange:ce=>B({...D,use_email_signature:ce})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Signature"}),r.jsx(yg,{content:D.email_signature,onChange:ce=>B({...D,email_signature:ce}),placeholder:"Paste your Gmail signature here or create one...",minHeight:"120px",compact:!0}),r.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."})]}),r.jsxs(X,{onClick:ie,disabled:g,children:[r.jsx(zf,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),r.jsxs(ze,{id:"change-password-section",children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:a?"Set Your Password":"Change Password"}),r.jsx(Cs,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"newPassword",children:"New Password"}),r.jsx(Ye,{id:"newPassword",type:"password",value:re.newPassword,onChange:ce=>ae({...re,newPassword:ce.target.value}),placeholder:"Min 6 characters"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"confirmPassword",children:"Confirm Password"}),r.jsx(Ye,{id:"confirmPassword",type:"password",value:re.confirmPassword,onChange:ce=>ae({...re,confirmPassword:ce.target.value}),placeholder:"Re-enter your new password"})]}),r.jsxs(X,{onClick:de,disabled:g,children:[r.jsx(zf,{className:"mr-2 h-4 w-4"}),a?"Complete Setup":"Update Password"]}),a&&r.jsx(X,{variant:"outline",onClick:()=>t("/dashboard"),className:"ml-2",children:"Skip for Now"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[i?r.jsx(tg,{className:"h-5 w-5"}):r.jsx(mk,{className:"h-5 w-5"}),"Push Notifications"]}),r.jsx(Cs,{children:"Receive browser notifications when new content is added"})]}),r.jsx(qe,{children:l?r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:i?"Notifications enabled":"Notifications disabled"}),r.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"})]}),r.jsx(fn,{checked:i,onCheckedChange:ce=>{ce?m():p()},disabled:d})]}):r.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[r.jsx("p",{children:"Push notifications are not supported in this browser."}),r.jsxs("p",{className:"text-xs",children:[r.jsx("strong",{children:"Desktop:"})," Use Chrome, Firefox, or Edge.",r.jsx("br",{}),r.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.']})]})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[$?r.jsx(_E,{className:"h-5 w-5"}):r.jsx(Vs,{className:"h-5 w-5"}),"Email Preferences"]}),r.jsx(Cs,{children:"Manage your email subscription settings"})]}),r.jsx(qe,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Weekly Digest"}),r.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"})]}),r.jsx(fn,{checked:!$,onCheckedChange:async ce=>{K(!0);try{const{error:ge}=await Y.from("profiles").update({digest_opt_out:!ce}).eq("id",e==null?void 0:e.id);if(ge)throw ge;q(!ce),s({title:ce?"Subscribed":"Unsubscribed",description:ce?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(ge){s({title:"Error",description:ge.message||"Failed to update preference",variant:"destructive"})}finally{K(!1)}},disabled:W})]})})]}),r.jsx(Awt,{}),r.jsx(Q5t,{})]}),r.jsx(s_e,{open:T,onClose:()=>C(!1),imageSrc:I,onCropComplete:pe,aspectRatio:1})]})})};var e3t="AspectRatio",TVe=A.forwardRef((e,t)=>{const{ratio:s=1/1,style:n,...a}=e;return r.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/s}%`},"data-radix-aspect-ratio-wrapper":"",children:r.jsx(Hs.div,{...a,ref:t,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});TVe.displayName=e3t;var t3t=TVe;const r3t=t3t;function s3t(){const{user:e}=Gr(),t=Rr(),[s,n]=A.useState(!1),[a,o]=A.useState(!1),{data:l,isLoading:i}=Ht({queryKey:["calendar-token",e==null?void 0:e.id],queryFn:async()=>{const{data:k,error:w}=await Y.from("profiles").select("calendar_token").eq("id",e==null?void 0:e.id).single();if(w)throw w;return k},enabled:!!e&&a}),d=Qt({mutationFn:async()=>{const k=new Uint8Array(12);crypto.getRandomValues(k);const w=btoa(String.fromCharCode(...k)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:S}=await Y.from("profiles").update({calendar_token:w}).eq("id",e==null?void 0:e.id);if(S)throw S;return w},onSuccess:()=>{t.invalidateQueries({queryKey:["calendar-token",e==null?void 0:e.id]}),we.success("Calendar subscription URL generated!")},onError:k=>{we.error("Failed to generate calendar URL: "+k.message)}}),m=l!=null&&l.calendar_token?`https://dashboard.relevelup.com/api/calendar/${l.calendar_token}.ics`:null,p=async()=>{m&&(await navigator.clipboard.writeText(m),n(!0),we.success("Calendar URL copied to clipboard!"),setTimeout(()=>n(!1),2e3))},g=()=>{m&&(window.location.href=m.replace("https://","webcal://"))},v=()=>{if(m){const k=m.replace("https://","webcal://"),w=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(k)}`;window.open(w,"_blank")}},_=()=>{if(m){const k=`https://outlook.live.com/calendar/0/addfromweb?url=${encodeURIComponent(m)}&name=Level%20Up%20Events`;window.open(k,"_blank")}};return r.jsxs(Ir,{open:a,onOpenChange:o,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:"gap-2",children:[r.jsx(An,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(An,{className:"h-5 w-5 text-primary"}),"Subscribe to Events Calendar"]}),r.jsx(Zs,{children:"Add all Level Up events to your personal calendar. Events will sync automatically and update when we add or change events."})]}),r.jsx("div",{className:"space-y-4 py-4",children:i?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):m?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-sm font-medium",children:"Your Calendar URL"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:m,readOnly:!0,className:"text-xs font-mono"}),r.jsx(X,{variant:"outline",size:"icon",onClick:p,children:s?r.jsx(mi,{className:"h-4 w-4 text-green-500"}):r.jsx(uo,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-sm font-medium",children:"Quick Add"}),r.jsxs("div",{className:"grid gap-2",children:[r.jsxs(X,{variant:"outline",className:"w-full justify-start gap-2",onClick:g,children:[r.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:r.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",r.jsx(jn,{className:"h-3 w-3 ml-auto opacity-50"})]}),r.jsxs(X,{variant:"outline",className:"w-full justify-start gap-2",onClick:v,children:[r.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:[r.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"}),r.jsx("path",{d:"M12 2v8.5a1.5 1.5 0 0 0 1.5 1.5H22V2h-10z",fill:"#4285F4"}),r.jsx("path",{d:"M12 12V2H4.5A2.5 2.5 0 0 0 2 4.5V12h10z",fill:"#34A853"}),r.jsx("path",{d:"M2 12v7.5A2.5 2.5 0 0 0 4.5 22H12v-10H2z",fill:"#FBBC05"}),r.jsx("path",{d:"M12 22h7.5a2.5 2.5 0 0 0 2.5-2.5V12h-10v10z",fill:"#EA4335"})]}),"Add to Google Calendar",r.jsx(jn,{className:"h-3 w-3 ml-auto opacity-50"})]}),r.jsxs(X,{variant:"outline",className:"w-full justify-start gap-2",onClick:_,children:[r.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:r.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",r.jsx(jn,{className:"h-3 w-3 ml-auto opacity-50"})]})]})]}),r.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."})]}):r.jsxs("div",{className:"text-center space-y-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Generate your personal calendar subscription URL to get started."}),r.jsx(X,{onClick:()=>d.mutate(),disabled:d.isPending,className:"w-full",children:d.isPending?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):r.jsxs(r.Fragment,{children:[r.jsx(An,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var loe="Tabs",[n3t]=Sc(loe,[E3]),AVe=E3(),[a3t,n_e]=n3t(loe),EVe=A.forwardRef((e,t)=>{const{__scopeTabs:s,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:d="automatic",...m}=e,p=vN(i),[g,v]=bh({prop:n,onChange:a,defaultProp:o??"",caller:loe});return r.jsx(a3t,{scope:s,baseId:Md(),value:g,onValueChange:v,orientation:l,dir:p,activationMode:d,children:r.jsx(Hs.div,{dir:p,"data-orientation":l,...m,ref:t})})});EVe.displayName=loe;var IVe="TabsList",PVe=A.forwardRef((e,t)=>{const{__scopeTabs:s,loop:n=!0,...a}=e,o=n_e(IVe,s),l=AVe(s);return r.jsx(dve,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:r.jsx(Hs.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});PVe.displayName=IVe;var LVe="TabsTrigger",DVe=A.forwardRef((e,t)=>{const{__scopeTabs:s,value:n,disabled:a=!1,...o}=e,l=n_e(LVe,s),i=AVe(s),d=FVe(l.baseId,n),m=zVe(l.baseId,n),p=n===l.value;return r.jsx(uve,{asChild:!0,...i,focusable:!a,active:p,children:r.jsx(Hs.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":m,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...o,ref:t,onMouseDown:bs(e.onMouseDown,g=>{!a&&g.button===0&&g.ctrlKey===!1?l.onValueChange(n):g.preventDefault()}),onKeyDown:bs(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&l.onValueChange(n)}),onFocus:bs(e.onFocus,()=>{const g=l.activationMode!=="manual";!p&&!a&&g&&l.onValueChange(n)})})})});DVe.displayName=LVe;var OVe="TabsContent",RVe=A.forwardRef((e,t)=>{const{__scopeTabs:s,value:n,forceMount:a,children:o,...l}=e,i=n_e(OVe,s),d=FVe(i.baseId,n),m=zVe(i.baseId,n),p=n===i.value,g=A.useRef(p);return A.useEffect(()=>{const v=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(v)},[]),r.jsx(Wc,{present:a||p,children:({present:v})=>r.jsx(Hs.div,{"data-state":p?"active":"inactive","data-orientation":i.orientation,role:"tabpanel","aria-labelledby":d,hidden:!v,id:m,tabIndex:0,...l,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:v&&o})})});RVe.displayName=OVe;function FVe(e,t){return`${e}-trigger-${t}`}function zVe(e,t){return`${e}-content-${t}`}var i3t=EVe,BVe=PVe,$Ve=DVe,UVe=RVe;const ii=i3t,si=A.forwardRef(({className:e,...t},s)=>r.jsx(BVe,{ref:s,className:Vt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));si.displayName=BVe.displayName;const Kr=A.forwardRef(({className:e,...t},s)=>r.jsx($Ve,{ref:s,className:Vt("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",e),...t}));Kr.displayName=$Ve.displayName;const hs=A.forwardRef(({className:e,...t},s)=>r.jsx(UVe,{ref:s,className:Vt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));hs.displayName=UVe.displayName;const o3t={first_timer:Dn,regular:Uy,dedicated:Yl,veteran:go,streak_master:Om,century:go},l3t={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 q3e(e){return e===1?r.jsx(go,{className:"h-5 w-5 text-yellow-500"}):e===2?r.jsx(Uy,{className:"h-5 w-5 text-gray-400"}):e===3?r.jsx(Yl,{className:"h-5 w-5 text-amber-600"}):r.jsx("span",{className:"w-5 text-center text-sm font-medium text-muted-foreground",children:e})}function VVe({showUserStats:e=!0,compact:t=!1,brokerageId:s,title:n="Event Leaderboard"}){const{user:a}=Gr(),{data:o,isLoading:l}=x9e(t?5:10,s),{data:i}=y9e(a==null?void 0:a.id),{data:d}=_9e(a==null?void 0:a.id),{data:m}=v9e(a==null?void 0:a.id);return l?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(go,{className:"h-5 w-5 text-yellow-500"}),n]})}),r.jsx(qe,{children:r.jsx("div",{className:"space-y-3",children:[...Array(5)].map((p,g)=>r.jsx(pr,{className:"h-12 w-full"},g))})})]}):r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(go,{className:"h-5 w-5 text-yellow-500"}),n]})}),r.jsxs(qe,{children:[e&&i&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg bg-primary/5 border border-primary/10",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-sm font-medium",children:"Your Stats"}),d&&r.jsxs(_t,{variant:"secondary",className:"text-xs",children:["Rank #",d]})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-lg font-bold text-primary",children:i.total_points}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Points"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-lg font-bold",children:i.total_events_attended}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Events"})]}),r.jsxs("div",{className:"flex items-center justify-center gap-1",children:[r.jsx(Om,{className:"h-4 w-4 text-orange-500"}),r.jsx("div",{className:"text-lg font-bold",children:i.current_streak}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Streak"})]})]}),m&&m.length>0&&r.jsxs("div",{className:"mt-3 flex flex-wrap gap-1",children:[m.slice(0,4).map(p=>{const g=o3t[p.badge_type]||Dn;return r.jsxs(_t,{variant:"outline",className:`text-xs ${l3t[p.badge_type]||""}`,title:p.badge_description||"",children:[r.jsx(g,{className:"h-3 w-3 mr-1"}),p.badge_name]},p.id)}),m.length>4&&r.jsxs(_t,{variant:"outline",className:"text-xs",children:["+",m.length-4," more"]})]})]}),r.jsxs(ii,{defaultValue:"points",className:"w-full",children:[r.jsxs(si,{className:"w-full mb-3",children:[r.jsx(Kr,{value:"points",className:"flex-1",children:"By Points"}),r.jsx(Kr,{value:"events",className:"flex-1",children:"By Events"})]}),r.jsx(hs,{value:"points",className:"mt-0",children:r.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,g)=>{var v,_,k;return r.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${g===0?"bg-yellow-500/5":""}`,children:[r.jsx("div",{className:"w-6 flex justify-center",children:q3e(g+1)}),r.jsx(cn,{className:"h-8 w-8",children:r.jsx(dn,{className:"text-xs",children:((_=(v=p.profile)==null?void 0:v.name)==null?void 0:_.charAt(0))||"?"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"font-medium text-sm truncate",children:[((k=p.profile)==null?void 0:k.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&r.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_events_attended," events"]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"font-bold text-primary",children:p.total_points}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"pts"})]})]},p.user_id)}),(!o||o.length===0)&&r.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!"})]})}),r.jsx(hs,{value:"events",className:"mt-0",children:r.jsx("div",{className:"space-y-2",children:[...o||[]].sort((p,g)=>g.total_events_attended-p.total_events_attended).map((p,g)=>{var v,_,k;return r.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg ${p.user_id===(a==null?void 0:a.id)?"bg-primary/5 border border-primary/10":""} ${g===0?"bg-yellow-500/5":""}`,children:[r.jsx("div",{className:"w-6 flex justify-center",children:q3e(g+1)}),r.jsx(cn,{className:"h-8 w-8",children:r.jsx(dn,{className:"text-xs",children:((_=(v=p.profile)==null?void 0:v.name)==null?void 0:_.charAt(0))||"?"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"font-medium text-sm truncate",children:[((k=p.profile)==null?void 0:k.name)||"Unknown",p.user_id===(a==null?void 0:a.id)&&r.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(You)"})]}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.total_points," points"]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"font-bold",children:p.total_events_attended}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"events"})]})]},p.user_id)})})})]})]})]})}function c3t(){const e=Ks(),{user:t,isAdmin:s}=Gr(),n=Rr(),{data:a,isLoading:o}=Ht({queryKey:["public-events"],queryFn:async()=>{const{data:w,error:S}=await Y.from("events").select("*").order("event_date",{ascending:!0});if(S)throw S;return w}}),{data:l}=Ht({queryKey:["my-registrations"],queryFn:async()=>{if(!t)return[];const{data:w,error:S}=await Y.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",t.id);if(S)throw S;return w},enabled:!!t}),{data:i}=Ht({queryKey:["event-registration-counts"],queryFn:async()=>{const{data:w,error:S}=await Y.from("event_registrations").select("event_id");if(S)throw S;const T={};return w.forEach(C=>{T[C.event_id]=(T[C.event_id]||0)+1}),T}}),d=Qt({mutationFn:async w=>{const{data:S,error:T}=await Y.functions.invoke("zoom-register",{body:{event_id:w}});if(T)throw T;if(S!=null&&S.error)throw new Error(S.error);return S},onSuccess:w=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),w!=null&&w.join_url?we.success("Successfully registered! You'll receive a Zoom confirmation email."):we.success("Successfully registered for the event!")},onError:w=>{we.error("Failed to register: "+w.message)}}),m=Qt({mutationFn:async w=>{const{data:S,error:T}=await Y.functions.invoke("zoom-unregister",{body:{event_id:w}});if(T)throw T;if(S!=null&&S.error)throw new Error(S.error);return S},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),we.success("Registration cancelled and removed from Zoom")},onError:w=>{we.error("Failed to cancel: "+w.message)}}),p=w=>l==null?void 0:l.some(S=>S.event_id===w),g=w=>{const S=l==null?void 0:l.find(T=>T.event_id===w);return S==null?void 0:S.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=>Z4(w.event_date)!=="ended"))||[],k=(a==null?void 0:a.filter(w=>Z4(w.event_date)==="ended"))||[];return r.jsx(Ur,{title:"Events",children:r.jsxs("div",{className:"max-w-6xl mx-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Events"}),r.jsx("p",{className:"text-muted-foreground",children:"Browse and register for upcoming events"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(s3t,{}),s&&r.jsx(X,{variant:"outline",onClick:()=>e("/admin/events"),children:"Manage Events"})]})]}),r.jsxs("div",{className:`grid grid-cols-1 ${s?"lg:grid-cols-3":""} gap-6`,children:[r.jsxs("div",{className:s?"lg:col-span-2":"",children:[o?r.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading events..."}):_.length===0?r.jsx(ze,{className:"text-center py-12",children:r.jsx(qe,{children:r.jsx("p",{className:"text-muted-foreground",children:"No upcoming events at the moment. Check back soon!"})})}):r.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:_.map(w=>{const S=Z4(w.event_date),T=o1e(w.event_date),C=S==="live",I=S==="starting_soon";return r.jsxs(ze,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${C?"border-red-500 ring-2 ring-red-500/20":I?"border-amber-500 ring-2 ring-amber-500/20":"hover:border-primary/50"}`,onClick:()=>e(`/events/${w.id}`),children:[T&&r.jsxs("div",{className:`${C?"bg-red-500":"bg-amber-500"} text-white px-3 py-1.5 flex items-center gap-2 text-sm font-medium`,children:[r.jsxs("span",{className:"relative flex h-2 w-2",children:[r.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-white opacity-75"}),r.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-white"})]}),C?r.jsxs(r.Fragment,{children:[r.jsx(Ck,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):r.jsxs(r.Fragment,{children:[r.jsx(Pa,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),w.image_url&&r.jsx(r3t,{ratio:3/2,className:"overflow-hidden",children:r.jsx("img",{src:w.image_url,alt:w.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),r.jsxs(Wt,{children:[r.jsx(Zt,{className:"line-clamp-2",children:w.title}),w.description&&r.jsx(Cs,{className:"line-clamp-2",children:w.description.replace(/<[^>]*>/g,"")})]}),r.jsxs(qe,{className:"flex-1 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(An,{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))]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(Pa,{className:"h-4 w-4"}),JI(new Date(w.event_date))]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(ws,{className:"h-4 w-4"}),(i==null?void 0:i[w.id])||0," registered",w.capacity&&` / ${w.capacity} spots`]})]}),r.jsx(GE,{className:"flex gap-2",onClick:R=>R.stopPropagation(),children:p(w.id)?r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"outline",className:"flex-1",onClick:()=>m.mutate(w.id),disabled:m.isPending,children:[r.jsx(Xs,{className:"h-4 w-4 mr-2"}),"Cancel"]}),r.jsxs(X,{className:"flex-1",onClick:()=>window.open(g(w.id)||w.zoom_link,"_blank"),children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):r.jsx(X,{className:"w-full",onClick:()=>d.mutate(w.id),disabled:d.isPending||v(w),children:v(w)?"Event Full":r.jsxs(r.Fragment,{children:[r.jsx(mi,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},w.id)})}),k.length>0&&r.jsxs("div",{className:"mt-12",children:[r.jsx("h3",{className:"text-xl font-semibold mb-4 text-muted-foreground",children:"Past Events"}),r.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:k.map(w=>r.jsx(ze,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>e(`/events/${w.id}`),children:r.jsxs(Wt,{children:[r.jsx(Zt,{className:"text-base line-clamp-1",children:w.title}),r.jsx(Cs,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(w.event_date))})]})},w.id))})]})]}),s&&r.jsx("div",{className:"lg:col-span-1",children:r.jsx(VVe,{showUserStats:!0})})]})]})})}const lhe=[{value:"all",label:"All Roles",icon:ws},{value:"brokerage_manager",label:"Brokerage Managers",icon:$E},{value:"admin",label:"Admins",icon:Ou}];function d3t({open:e,onOpenChange:t,resourceType:s,resourceId:n,resourceTitle:a}){var We,wt;const{user:o,isAdmin:l,isBrokerageManager:i}=Gr(),[d,m]=A.useState([]),[p,g]=A.useState([]),[v,_]=A.useState([]),[k,w]=A.useState([]),[S,T]=A.useState(""),[C,I]=A.useState(""),[R,D]=A.useState(""),[B,$]=A.useState(!1),[q,W]=A.useState(!1),[K,re]=A.useState("agents"),[ae,oe]=A.useState("all"),[se,pe]=A.useState({}),ie=l||i;A.useEffect(()=>{e&&o&&(l?de():ce())},[e,o,l]),A.useEffect(()=>{e||(_([]),w([]),T(""),I(""),D(""),re("agents"),oe("all"))},[e]);const de=async()=>{if(o){$(!0);try{const{data:Pe,error:st}=await Y.from("brokerages").select("id, name").order("name");if(st)throw st;const ue=1e3,$e={};let tt=0,rt=!0;for(;rt;){const{data:Se,error:et}=await Y.from("profiles").select("brokerage_id").range(tt*ue,(tt+1)*ue-1);if(et)throw et;Se==null||Se.forEach(Qe=>{Qe.brokerage_id&&($e[Qe.brokerage_id]=($e[Qe.brokerage_id]||0)+1)}),rt=(Se==null?void 0:Se.length)===ue,tt++}g((Pe==null?void 0:Pe.map(Se=>({...Se,agent_count:$e[Se.id]||0})))||[]);const je=[];for(tt=0,rt=!0;rt;){const{data:Se,error:et}=await Y.from("profiles").select("id, name, email, brokerage_id, brokerages(name)").neq("id",o.id).order("name").range(tt*ue,(tt+1)*ue-1);if(et)throw et;Se&&je.push(...Se),rt=(Se==null?void 0:Se.length)===ue,tt++}const it={};for(tt=0,rt=!0;rt;){const{data:Se,error:et}=await Y.from("user_roles").select("user_id, role").range(tt*ue,(tt+1)*ue-1);if(et)throw et;Se==null||Se.forEach(Qe=>{it[Qe.user_id]||(it[Qe.user_id]=[]),it[Qe.user_id].push(Qe.role)}),rt=(Se==null?void 0:Se.length)===ue,tt++}pe(it),m(je.map(Se=>{var et;return{id:Se.id,name:Se.name,email:Se.email,brokerage_name:((et=Se.brokerages)==null?void 0:et.name)||"No Brokerage",roles:it[Se.id]||[]}}))}catch(Pe){console.error("Error loading data:",Pe),we.error("Failed to load agents and brokerages")}finally{$(!1)}}},ce=async()=>{if(o){$(!0);try{const{data:Pe}=await Y.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(Pe!=null&&Pe.brokerage_id)){we.error("You must be part of a brokerage to share resources"),t(!1);return}const{data:st,error:ue}=await Y.from("profiles").select("id, name, email").eq("brokerage_id",Pe.brokerage_id).neq("id",o.id).order("name");if(ue)throw ue;m(st||[])}catch(Pe){console.error("Error loading agents:",Pe),we.error("Failed to load agents")}finally{$(!1)}}},ge=d.filter(Pe=>{var ue;const st=Pe.name.toLowerCase().includes(S.toLowerCase())||Pe.email.toLowerCase().includes(S.toLowerCase())||((ue=Pe.brokerage_name)==null?void 0:ue.toLowerCase().includes(S.toLowerCase()));if(l&&ae!=="all"){const $e=se[Pe.id]||[];return st&&$e.includes(ae)}return st}),Te=p.filter(Pe=>Pe.name.toLowerCase().includes(C.toLowerCase())),_e=()=>{v.length===ge.length?_([]):_(ge.map(Pe=>Pe.id))},ve=()=>{k.length===Te.length?w([]):w(Te.map(Pe=>Pe.id))},Me=Pe=>{if(!ie){_([Pe]);return}_(st=>st.includes(Pe)?st.filter(ue=>ue!==Pe):[...st,Pe])},Ze=Pe=>{w(st=>st.includes(Pe)?st.filter(ue=>ue!==Pe):[...st,Pe])},Ae=async()=>{if(!(v.length>0||k.length>0)){we.error("Please select at least one agent or brokerage to share with");return}W(!0);try{const{data:st,error:ue}=await Y.functions.invoke("send-share-notification",{body:{recipientIds:v,brokerageIds:k,resourceType:s,resourceId:n,resourceTitle:a,message:R.trim()||void 0}});if(ue)throw ue;const $e=(st==null?void 0:st.sharesCreated)||v.length;we.success(`Shared with ${$e} agent${$e!==1?"s":""}`),t(!1)}catch(st){console.error("Error sharing resource:",st),we.error("Failed to share resource")}finally{W(!1)}},Le=Pe=>Pe.split(" ").map(st=>st[0]).join("").toUpperCase().slice(0,2),Ue=Pe=>{const st=se[Pe]||[];return st.includes("admin")?r.jsx(_t,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):st.includes("brokerage_manager")?r.jsx(_t,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Ve=v.length+k.length,Ie=ae!=="all"?ge.length:null;return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-lg max-h-[90vh] overflow-hidden flex flex-col",children:[r.jsxs(zr,{className:"flex-shrink-0",children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(ai,{className:"h-5 w-5 text-primary"}),"Share Resource"]}),r.jsxs(Zs,{className:"line-clamp-2",children:['Share "',a,'" with ',l?"agents or brokerages":"agents in your brokerage"]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[l?r.jsxs(ii,{value:K,onValueChange:re,className:"flex-1 flex flex-col overflow-hidden",children:[r.jsxs(si,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[r.jsxs(Kr,{value:"agents",className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-4 w-4"}),r.jsx("span",{children:"Agents"}),v.length>0&&r.jsx(_t,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:v.length})]}),r.jsxs(Kr,{value:"brokerages",className:"flex items-center gap-2",children:[r.jsx(Ni,{className:"h-4 w-4"}),r.jsx("span",{children:"Brokerages"}),k.length>0&&r.jsx(_t,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:k.length})]})]}),r.jsxs(hs,{value:"agents",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[r.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name, email, or brokerage...",value:S,onChange:Pe=>T(Pe.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:ae,onValueChange:oe,children:[r.jsxs(ls,{className:"w-[180px]",children:[r.jsx(b1,{className:"h-4 w-4 mr-2 text-muted-foreground"}),r.jsx(us,{placeholder:"Filter by role"})]}),r.jsx(cs,{children:lhe.map(Pe=>r.jsx(Ut,{value:Pe.value,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Pe.icon,{className:"h-4 w-4"}),r.jsx("span",{children:Pe.label})]})},Pe.value))})]})]}),r.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:_e,className:"text-xs h-8",disabled:ge.length===0,children:[r.jsx(ws,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Ie!==null&&r.jsxs("span",{className:"text-primary font-medium",children:[Ie," ",(We=lhe.find(Pe=>Pe.value===ae))==null?void 0:We.label]}),r.jsxs("span",{className:"font-medium",children:[v.length," selected"]})]})]}),r.jsx(To,{className:"h-[300px] border rounded-lg",children:B?r.jsx("div",{className:"flex items-center justify-center h-[200px]",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[r.jsx(ws,{className:"h-8 w-8 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:ae!=="all"?`No ${(wt=lhe.find(Pe=>Pe.value===ae))==null?void 0:wt.label.toLowerCase()} found`:"No agents found"})]}):r.jsx("div",{className:"p-2 space-y-1",children:ge.map(Pe=>r.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(Pe.id)?"bg-accent":""}`,onClick:()=>Me(Pe.id),children:[r.jsx(Qo,{checked:v.includes(Pe.id),onCheckedChange:()=>Me(Pe.id),className:"flex-shrink-0"}),r.jsx(cn,{className:"h-9 w-9 flex-shrink-0",children:r.jsx(dn,{className:"text-xs bg-primary/10 text-primary",children:Le(Pe.name)})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:Pe.name}),Ue(Pe.id)]}),r.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[Pe.email,Pe.brokerage_name&&r.jsxs("span",{className:"ml-1 opacity-75",children:["• ",Pe.brokerage_name]})]})]})]},Pe.id))})})]}),r.jsxs(hs,{value:"brokerages",className:"flex-1 flex flex-col space-y-3 mt-3 overflow-hidden",children:[r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search brokerages...",value:C,onChange:Pe=>I(Pe.target.value),className:"pl-9"})]}),r.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:ve,className:"text-xs h-8",disabled:Te.length===0,children:[r.jsx(Ni,{className:"h-3.5 w-3.5 mr-1.5"}),k.length===Te.length&&Te.length>0?"Deselect All":"Select All"]}),r.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[k.length," selected"]})]}),r.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."}),r.jsx(To,{className:"h-[250px] border rounded-lg",children:B?r.jsx("div",{className:"flex items-center justify-center h-[180px]",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):Te.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[r.jsx(Ni,{className:"h-8 w-8 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No brokerages found"})]}):r.jsx("div",{className:"p-2 space-y-1",children:Te.map(Pe=>r.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${k.includes(Pe.id)?"bg-accent":""}`,onClick:()=>Ze(Pe.id),children:[r.jsx(Qo,{checked:k.includes(Pe.id),onCheckedChange:()=>Ze(Pe.id),className:"flex-shrink-0"}),r.jsx("div",{className:"h-9 w-9 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:r.jsx(Ni,{className:"h-4 w-4 text-primary"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:Pe.name}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[Pe.agent_count," agent",Pe.agent_count!==1?"s":""]})]})]},Pe.id))})})]})]}):r.jsxs("div",{className:"flex-1 flex flex-col space-y-3 overflow-hidden",children:[r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search agents...",value:S,onChange:Pe=>T(Pe.target.value),className:"pl-9"})]}),ie&&r.jsxs("div",{className:"flex items-center justify-between px-1 flex-shrink-0",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:_e,className:"text-xs h-8",disabled:ge.length===0,children:[r.jsx(ws,{className:"h-3.5 w-3.5 mr-1.5"}),v.length===ge.length&&ge.length>0?"Deselect All":"Select All"]}),r.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[v.length," selected"]})]}),r.jsx(To,{className:"h-[300px] border rounded-lg",children:B?r.jsx("div",{className:"flex items-center justify-center h-[200px]",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ge.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[r.jsx(ws,{className:"h-8 w-8 mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No agents found"})]}):r.jsx("div",{className:"p-2 space-y-1",children:ge.map(Pe=>r.jsxs("div",{className:`flex items-center gap-3 p-2.5 rounded-lg cursor-pointer hover:bg-accent/50 transition-colors ${v.includes(Pe.id)?"bg-accent":""}`,onClick:()=>Me(Pe.id),children:[r.jsx(Qo,{checked:v.includes(Pe.id),onCheckedChange:()=>Me(Pe.id),className:"flex-shrink-0"}),r.jsx(cn,{className:"h-9 w-9 flex-shrink-0",children:r.jsx(dn,{className:"text-xs bg-primary/10 text-primary",children:Le(Pe.name)})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:Pe.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Pe.email})]})]},Pe.id))})})]}),r.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[r.jsx(Ee,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),r.jsx(qs,{id:"message",placeholder:"I thought you might find this useful...",value:R,onChange:Pe=>D(Pe.target.value),rows:2,className:"resize-none"})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2 flex-shrink-0",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsx(X,{onClick:Ae,disabled:Ve===0||q,children:q?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function F3({resourceType:e,resourceId:t,resourceTitle:s,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=A.useState(!1),{user:d}=Gr();return d?r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[r.jsx(Uc,{className:"h-4 w-4 mr-2"}),"Share"]}),r.jsx(d3t,{open:l,onOpenChange:i,resourceType:e,resourceId:t,resourceTitle:s})]}):null}function u3t(){const{eventId:e}=Bl(),t=Ks(),{user:s}=Gr(),[n,a]=A.useState(null),[o,l]=A.useState(null),[i,d]=A.useState(0),[m,p]=A.useState(!0),[g,v]=A.useState(!1);A.useEffect(()=>{e&&_()},[e,s]);const _=async()=>{try{const{data:I,error:R}=await Y.from("events").select("*").eq("id",e).single();if(R)throw R;a(I);const{count:D}=await Y.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",e);if(d(D||0),s){const{data:B}=await Y.from("event_registrations").select("id, zoom_join_url").eq("event_id",e).eq("user_id",s.id).maybeSingle();l(B)}}catch(I){console.error("Error loading event:",I),we.error("Failed to load event"),t("/events")}finally{p(!1)}},k=async()=>{if(!(!s||!n)){v(!0);try{if(o){const{error:I}=await Y.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(I)throw I;we.success("Successfully cancelled registration"),l(null),d(R=>R-1)}else{const{data:I,error:R}=await Y.functions.invoke("zoom-register",{body:{event_id:n.id}});if(R)throw R;we.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.zoom_join_url}),d(D=>D+1)}}catch(I){console.error("Registration error:",I),we.error(o?"Failed to cancel registration":"Failed to register for event")}finally{v(!1)}}},w=I=>{var R,D,B;if(I.includes("iframe.mediadelivery.net")||I.includes("video.bunnycdn.com")){const $=I.match(/embed\/(\d+)\/([a-f0-9-]+)/);if($)return`https://iframe.mediadelivery.net/embed/${$[1]}/${$[2]}?autoplay=false&preload=true`}if(I.includes("youtube.com")||I.includes("youtu.be")){const $=I.includes("youtu.be")?(R=I.split("youtu.be/")[1])==null?void 0:R.split("?")[0]:(D=I.split("v=")[1])==null?void 0:D.split("&")[0];if($)return`https://www.youtube.com/embed/${$}`}if(I.includes("vimeo.com")){const $=(B=I.split("vimeo.com/")[1])==null?void 0:B.split("?")[0];if($)return`https://player.vimeo.com/video/${$}`}return I};if(m)return r.jsx(Ur,{title:"Event",children:r.jsx("div",{className:"flex items-center justify-center py-16",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"Loading event..."})]})})});if(!n)return r.jsx(Ur,{title:"Event Not Found",children:r.jsxs("div",{className:"text-center py-16",children:[r.jsx("p",{className:"text-muted-foreground",children:"Event not found"}),r.jsx(X,{onClick:()=>t("/events"),className:"mt-4",children:"Back to Events"})]})});const S=Rve(new Date(n.event_date)),T=n.capacity&&i>=n.capacity,C=(o==null?void 0:o.zoom_join_url)||n.zoom_link;return r.jsx(Ur,{title:n.title,children:r.jsxs("div",{className:"max-w-4xl mx-auto",children:[r.jsxs(X,{variant:"ghost",className:"mb-6 gap-2",onClick:()=>t("/events"),children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Events"]}),n.image_url&&r.jsxs("div",{className:"relative aspect-video rounded-xl overflow-hidden mb-6",children:[r.jsx("img",{src:n.image_url,alt:n.title,className:"w-full h-full object-cover"}),S&&r.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:r.jsx(_t,{variant:"secondary",className:"text-lg px-4 py-2",children:"Event Ended"})})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[r.jsx("h1",{className:"text-3xl font-bold text-foreground",children:n.title}),r.jsx(F3,{resourceType:"event",resourceId:n.id,resourceTitle:n.title})]}),n.description&&r.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground dark:prose-invert",dangerouslySetInnerHTML:{__html:n.description}})]}),n.video_url&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[r.jsx(kf,{className:"h-5 w-5"}),"Event Preview"]}),r.jsx("div",{className:"relative w-full aspect-video rounded-xl overflow-hidden border bg-muted",children:r.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"})})]})]}),r.jsx("div",{className:"space-y-4",children:r.jsx(ze,{children:r.jsxs(qe,{className:"p-6 space-y-4",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(An,{className:"h-5 w-5 text-primary mt-0.5"}),r.jsxs("div",{children:[r.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))}),r.jsx("p",{className:"text-sm text-muted-foreground",children:JI(new Date(n.event_date))})]})]}),n.capacity&&r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx(ws,{className:"h-5 w-5 text-primary mt-0.5"}),r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium",children:[i," / ",n.capacity]}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Registered"})]})]}),o&&r.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 rounded-lg",children:[r.jsx(ui,{className:"h-5 w-5 text-green-600"}),r.jsx("span",{className:"text-sm font-medium text-green-700",children:"You're registered!"})]}),r.jsxs("div",{className:"space-y-2 pt-2",children:[!S&&r.jsx(r.Fragment,{children:o?r.jsxs(r.Fragment,{children:[r.jsxs(X,{className:"w-full gap-2",onClick:()=>window.open(C,"_blank"),children:[r.jsx(jn,{className:"h-4 w-4"}),"Join Event"]}),r.jsxs(X,{variant:"outline",className:"w-full",onClick:k,disabled:g,children:[g?r.jsx($r,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):r.jsx(X,{className:"w-full gap-2",onClick:k,disabled:g||(T??!1),children:g?r.jsx($r,{className:"h-4 w-4 animate-spin"}):T?"Event Full":"Register Now"})}),S&&o&&r.jsxs(X,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[r.jsx(jn,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const h3t=()=>{const{user:e,isAdmin:t}=Gr(),s=Ks(),[n,a]=A.useState([]),[o,l]=A.useState(!0),[i,d]=A.useState(""),[m,p]=A.useState("all"),[g,v]=A.useState(new Set);A.useEffect(()=>{_()},[e]);const _=async()=>{try{const{data:C}=await Y.from("user_tags").select("tag").eq("user_id",e==null?void 0:e.id),I=(C==null?void 0:C.map(K=>K.tag))||[],{data:R,error:D}=await Y.from("app_tiles").select("*").order("name");if(D)throw D;const{data:B}=await Y.from("user_favorites").select("app_id").eq("user_id",e==null?void 0:e.id),$=new Set((B==null?void 0:B.map(K=>K.app_id))||[]);v($);const W=((R==null?void 0:R.filter(K=>!K.required_tags||K.required_tags.length===0?!0:K.required_tags.some(re=>I.includes(re))))||[]).sort((K,re)=>K.name==="LevelUp Members Portal"?-1:re.name==="LevelUp Members Portal"?1:0);a(W)}catch(C){console.error("Error loading apps:",C),we.error("Failed to load apps")}finally{l(!1)}},k=async C=>{var R;const I=window.open("about:blank","_blank");try{const{data:D,error:B}=await Y.auth.getSession();if(B||!D.session){I==null||I.close(),we.error("Session expired. Please refresh the page and try again.");return}const $=D.session.access_token;await Y.from("activity_logs").insert({user_id:e==null?void 0:e.id,app_id:C.app_id,app_name:C.name,user_agent:navigator.userAgent});const{data:q,error:W}=await Y.functions.invoke("sso-launch",{body:{app_id:C.app_id},headers:{Authorization:`Bearer ${$}`}});if(W)throw W;q!=null&&q.redirect_url?I&&!I.closed?(I.location.href=q.redirect_url,(R=I.focus)==null||R.call(I)):window.location.assign(q.redirect_url):(I==null||I.close(),we.error("Launch link unavailable"))}catch(D){I==null||I.close(),console.error("Error launching app:",D),we.error("Failed to launch app. Please try again.")}},w=async(C,I)=>{C.stopPropagation();const R=g.has(I);try{if(R){const{error:D}=await Y.from("user_favorites").delete().eq("user_id",e==null?void 0:e.id).eq("app_id",I);if(D)throw D;v(B=>{const $=new Set(B);return $.delete(I),$}),we.success("Removed from favorites")}else{const{error:D}=await Y.from("user_favorites").insert({user_id:e==null?void 0:e.id,app_id:I});if(D)throw D;v(B=>new Set(B).add(I)),we.success("Added to favorites")}}catch(D){console.error("Error toggling favorite:",D),we.error("Failed to update favorites")}},S=n.filter(C=>{var R;const I=C.name.toLowerCase().includes(i.toLowerCase())||((R=C.description)==null?void 0:R.toLowerCase().includes(i.toLowerCase()));return m==="favorites"?I&&g.has(C.id):I}),T=[{id:"all",label:"All"},{id:"favorites",label:"Favorites"}];return o?r.jsx(Ur,{title:"Apps",children:r.jsx("div",{className:"flex items-center justify-center py-16",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"Loading apps..."})]})})}):r.jsxs(Ur,{title:"Apps",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[r.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Apps"}),r.jsxs("div",{className:"relative max-w-sm w-full",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search apps...",className:"pl-10 bg-muted/50 border-0 focus-visible:ring-1",value:i,onChange:C=>d(C.target.value)})]})]}),r.jsx("div",{className:"flex gap-6 border-b border-border mb-8",children:T.map(C=>r.jsxs("button",{onClick:()=>p(C.id),className:Vt("pb-3 text-sm font-medium transition-colors relative",m===C.id?"text-primary":"text-muted-foreground hover:text-foreground"),children:[C.label,m===C.id&&r.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-primary"})]},C.id))}),S.length===0?r.jsx("div",{className:"flex flex-col items-center justify-center py-16 bg-card rounded-xl border border-border",children:m==="favorites"?r.jsxs(r.Fragment,{children:[r.jsx(rg,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No favorites yet"}),r.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"})]}):r.jsxs(r.Fragment,{children:[r.jsx(Du,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("p",{className:"text-lg font-medium mb-2 text-foreground",children:"No apps available"}),r.jsx("p",{className:"text-sm text-muted-foreground text-center max-w-md",children:t?"Get started by adding apps in the admin panel":"Contact your administrator to get access to apps"}),t&&r.jsx(X,{className:"mt-4",onClick:()=>s("/admin/apps"),children:"Add Apps"})]})}):r.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:S.map(C=>{const I=g.has(C.id),R=C.name.toLowerCase().includes("agent review")||C.app_id==="agent_review";return r.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:[r.jsxs("div",{className:"flex items-start gap-4 cursor-pointer",onClick:()=>k(C),children:[r.jsx("div",{className:"flex-shrink-0 w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center text-3xl",children:C.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-semibold text-foreground group-hover:text-primary transition-colors truncate",children:C.name}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:C.description})]}),r.jsx("button",{className:Vt("flex-shrink-0 p-1 transition-colors",I?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:D=>w(D,C.id),children:r.jsx(rg,{className:Vt("h-5 w-5",I&&"fill-current")})})]}),R&&r.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:D=>D.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},C.id)})})]})},m3t=()=>{const e=Ks(),[t,s]=A.useState(""),[n,a]=A.useState("all"),[o,l]=A.useState("all"),[i,d]=A.useState("grid"),{data:m=[]}=Ht({queryKey:["template-categories"],queryFn:async()=>{const{data:T,error:C}=await Y.from("template_categories").select("*").order("name");if(C)throw C;return T}}),{data:p=[]}=Ht({queryKey:["template-types"],queryFn:async()=>{const{data:T,error:C}=await Y.from("template_types").select("*").order("name");if(C)throw C;return T}}),{data:g=[],isLoading:v}=Ht({queryKey:["canva-templates"],queryFn:async()=>{const{data:T,error:C}=await Y.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(C)throw C;const{data:I,error:R}=await Y.from("template_links").select("*").order("sort_order");if(R)throw R;const{data:D}=await Y.from("template_likes").select("template_id"),{data:B}=await Y.from("template_comments").select("template_id"),$=new Map;D==null||D.forEach(K=>{$.set(K.template_id,($.get(K.template_id)||0)+1)});const q=new Map;return B==null||B.forEach(K=>{q.set(K.template_id,(q.get(K.template_id)||0)+1)}),(T||[]).map(K=>({...K,links:(I||[]).filter(re=>re.template_id===K.id)||[],likesCount:$.get(K.id)||0,commentsCount:q.get(K.id)||0}))}}),_=g.filter(T=>{var D;const C=T.name.toLowerCase().includes(t.toLowerCase())||((D=T.description)==null?void 0:D.toLowerCase().includes(t.toLowerCase())),I=n==="all"||T.category_id===n,R=o==="all"||T.type_id===o;return C&&I&&R}),k=()=>{s(""),a("all"),l("all")},w=t||n!=="all"||o!=="all",S=T=>{e(`/templates/${T}`)};return r.jsx(Ur,{title:"Canva Templates",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Canva Templates"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse and use our collection of professionally designed templates"})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search templates...",value:t,onChange:T=>s(T.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:n,onValueChange:a,children:[r.jsx(ls,{className:"w-full sm:w-48",children:r.jsx(us,{placeholder:"All Categories"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Categories"}),m.map(T=>r.jsx(Ut,{value:T.id,children:T.name},T.id))]})]}),r.jsxs(ds,{value:o,onValueChange:l,children:[r.jsx(ls,{className:"w-full sm:w-48",children:r.jsx(us,{placeholder:"All Types"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Types"}),p.map(T=>r.jsx(Ut,{value:T.id,children:T.name},T.id))]})]}),r.jsxs("div",{className:"flex gap-2",children:[w&&r.jsx(X,{variant:"outline",size:"sm",onClick:k,children:"Clear Filters"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:i==="grid"?"secondary":"outline",size:"icon",onClick:()=>d("grid"),className:"rounded-full",children:r.jsx(Of,{className:"h-4 w-4"})}),r.jsx(X,{variant:i==="list"?"secondary":"outline",size:"icon",onClick:()=>d("list"),className:"rounded-full",children:r.jsx(Rf,{className:"h-4 w-4"})})]})]})]}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[_.length," template",_.length!==1?"s":""," found"]}),v&&r.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((T,C)=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx(pr,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),r.jsx(pr,{className:"h-5 w-3/4 mb-2"}),r.jsx(pr,{className:"h-4 w-full mb-4"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pr,{className:"h-5 w-16"}),r.jsx(pr,{className:"h-5 w-20"})]})]})},C))}),!v&&_.length===0&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"text-muted-foreground mb-4",children:w?"No templates match your filters":"No templates available yet"}),w&&r.jsx(X,{variant:"outline",onClick:k,children:"Clear Filters"})]}),!v&&_.length>0&&r.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(T=>r.jsxs(ze,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>S(T.id),children:[r.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[T.preview_image_url?r.jsx("img",{src:T.preview_image_url,alt:T.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),T.links.length>1&&r.jsx("div",{className:"absolute top-2 right-2",children:r.jsxs(_t,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[r.jsx(Lo,{className:"h-3 w-3"}),T.links.length]})})]}),r.jsxs(qe,{className:`p-4 flex flex-col ${i==="list"?"flex-1":""}`,children:[r.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:T.name}),T.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Zae(T.description)}),r.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[T.category&&r.jsx(_t,{variant:"secondary",className:"text-xs",children:T.category.name}),T.type&&r.jsx(_t,{variant:"outline",className:"text-xs",children:T.type.name})]}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Cd,{className:"h-3.5 w-3.5"}),T.likesCount]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Rl,{className:"h-3.5 w-3.5"}),T.commentsCount]})]}),r.jsxs(X,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),S(T.id)},children:[r.jsx(jn,{className:"h-4 w-4"}),"View Template"]})]})]},T.id))})]})})};var f3t="Separator",H3e="horizontal",p3t=["horizontal","vertical"],qVe=A.forwardRef((e,t)=>{const{decorative:s,orientation:n=H3e,...a}=e,o=g3t(n)?n:H3e,i=s?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return r.jsx(Hs.div,{"data-orientation":o,...i,...a,ref:t})});qVe.displayName=f3t;function g3t(e){return p3t.includes(e)}var HVe=qVe;const kd=A.forwardRef(({className:e,orientation:t="horizontal",decorative:s=!0,...n},a)=>r.jsx(HVe,{ref:a,decorative:s,orientation:t,className:Vt("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));kd.displayName=HVe.displayName;const L6=()=>({trackEngagement:A.useCallback(async(t,s,n,a="view")=>{try{const{data:{user:o}}=await Y.auth.getUser();if(!o)return;await Y.from("content_engagement_logs").insert({user_id:o.id,resource_type:t,resource_id:s,resource_title:n,action_type:a})}catch(o){console.error("Error tracking engagement:",o)}},[])}),x3t=()=>{const{templateId:e}=Bl(),{user:t,isAdmin:s}=Gr(),{toast:n}=_i(),a=Rr(),{trackEngagement:o}=L6(),[l,i]=A.useState(""),{data:d,isLoading:m}=Ht({queryKey:["template-detail",e],queryFn:async()=>{const{data:C,error:I}=await Y.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",e).single();if(I)throw I;const{data:R}=await Y.from("template_links").select("*").eq("template_id",e).order("sort_order"),{data:D}=await Y.from("template_guides").select("*").eq("template_id",e).order("sort_order");return{...C,links:R||[],guides:D||[]}},enabled:!!e});A.useEffect(()=>{d&&o("template",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=Ht({queryKey:["template-likes",e],queryFn:async()=>{const{data:C,error:I}=await Y.from("template_likes").select("*").eq("template_id",e);if(I)throw I;return C},enabled:!!e}),{data:g=[]}=Ht({queryKey:["template-comments",e],queryFn:async()=>{const{data:C,error:I}=await Y.from("template_comments").select("*").eq("template_id",e).order("created_at",{ascending:!1});if(I)throw I;const R=[...new Set(C.map($=>$.user_id))],{data:D}=await Y.from("profiles").select("id, name").in("id",R),B=new Map((D==null?void 0:D.map($=>[$.id,$.name]))||[]);return C.map($=>({...$,user_name:B.get($.user_id)||"Unknown User"}))},enabled:!!e}),v=Qt({mutationFn:async C=>{const{error:I}=await Y.from("template_comments").insert({template_id:e,user_id:t.id,content:C});if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["template-comments",e]}),i(""),n({title:"Comment added!"})},onError:C=>{n({title:"Error adding comment",description:C.message,variant:"destructive"})}}),_=Qt({mutationFn:async C=>{const{error:I}=await Y.from("template_comments").delete().eq("id",C);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["template-comments",e]}),n({title:"Comment deleted"})}}),k=Qt({mutationFn:async()=>{const C=p.find(I=>I.user_id===(t==null?void 0:t.id));if(C){const{error:I}=await Y.from("template_likes").delete().eq("id",C.id);if(I)throw I}else{const{error:I}=await Y.from("template_likes").insert({template_id:e,user_id:t.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["template-likes",e]})}}),w=p.some(C=>C.user_id===(t==null?void 0:t.id)),S=C=>C.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),T=C=>{C.preventDefault(),!(!l.trim()||!t)&&v.mutate(l.trim())};return m?r.jsx(Ur,{title:"Templates",children:r.jsx("div",{className:"flex justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?r.jsx(Ur,{title:d.name,children:r.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[r.jsx(X,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:r.jsxs(vo,{to:"/templates",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Templates"]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.name}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.category&&r.jsx(_t,{variant:"secondary",children:d.category.name}),d.type&&r.jsx(_t,{variant:"outline",children:d.type.name})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[s&&r.jsx(X,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:r.jsxs(vo,{to:`/admin/templates?edit=${d.id}`,children:[r.jsx(Qa,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit"})]})}),r.jsx(F3,{resourceType:"template",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),r.jsxs(X,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>k.mutate(),disabled:!t||k.isPending,children:[r.jsx(Cd,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&r.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}})]}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(Lo,{className:"h-4 w-4"}),d.links.length===1?"Template Link":"Template Links"]}),r.jsx("div",{className:"grid gap-2",children:d.links.map(C=>r.jsxs(X,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{o("template",d.id,d.name,"click_canva"),window.open(C.canva_share_link,"_blank")},children:[r.jsx("span",{className:"font-medium",children:C.title}),r.jsx(jn,{className:"h-4 w-4 text-muted-foreground"})]},C.id))})]})}),d.video_url&&r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsx("div",{className:"aspect-video w-full rounded-lg overflow-hidden",children:r.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&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(ya,{className:"h-4 w-4"}),"Guide Files"]}),r.jsx("div",{className:"grid gap-2",children:d.guides.map(C=>r.jsxs(X,{variant:"outline",className:"w-full justify-between gap-2 h-auto py-3",onClick:()=>{o("template",d.id,d.name,"click_pdf"),window.open(C.file_url,"_blank")},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"font-medium",children:C.name}),C.file_size&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(C.file_size/1024).toFixed(0)," KB)"]})]}),r.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"})]},C.id))})]})}),r.jsx(kd,{}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[r.jsx(Rl,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),t?r.jsxs("form",{onSubmit:T,className:"flex gap-2",children:[r.jsx(qs,{placeholder:"Add a comment...",value:l,onChange:C=>i(C.target.value),className:"min-h-[80px] resize-none flex-1"}),r.jsx(X,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:r.jsx(ai,{className:"h-4 w-4"})})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),r.jsx("div",{className:"space-y-4",children:g.length===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-8 text-center",children:r.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):g.map(C=>r.jsx(ze,{children:r.jsx(qe,{className:"pt-4 pb-4",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx(cn,{className:"h-10 w-10 flex-shrink-0",children:r.jsx(dn,{className:"text-sm",children:S(C.user_name||"U")})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"font-medium",children:C.user_name}),r.jsx("span",{className:"text-sm text-muted-foreground",children:gu(new Date(C.created_at),{addSuffix:!0})}),C.user_id===(t==null?void 0:t.id)&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(C.id),children:r.jsx(Os,{className:"h-3 w-3 text-muted-foreground"})})]}),r.jsx("p",{className:"text-sm whitespace-pre-wrap",children:C.content})]})]})})},C.id))})]})]})}):r.jsx(Ur,{title:"Templates",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Lo,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold",children:"Template not found"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"This template may have been removed or is not available."}),r.jsx(X,{asChild:!0,className:"mt-4",children:r.jsx(vo,{to:"/templates",children:"Back to Templates"})})]})})},y3t=()=>{const{user:e}=Gr(),[t,s]=A.useState(""),[n,a]=A.useState("all"),{data:o=[]}=Ht({queryKey:["academy-categories"],queryFn:async()=>{const{data:v,error:_}=await Y.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(_)throw _;return v}}),{data:l=[],isLoading:i}=Ht({queryKey:["academy-videos"],queryFn:async()=>{const{data:v,error:_}=await Y.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;const{data:k,error:w}=await Y.from("academy_resources").select("*").order("sort_order");if(w)throw w;return v.map(T=>({...T,resources:(k==null?void 0:k.filter(C=>C.video_id===T.id))||[]}))}}),{data:d=[]}=Ht({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:v,error:_}=await Y.from("academy_video_likes").select("video_id, user_id");if(_)throw _;return v}}),m=l.filter(v=>{var w;const _=t===""||v.title.toLowerCase().includes(t.toLowerCase())||((w=v.description)==null?void 0:w.toLowerCase().includes(t.toLowerCase())),k=n==="all"||v.category_id===n;return _&&k}),p=v=>d.filter(_=>_.video_id===v).length,g=v=>d.some(_=>_.video_id===v&&_.user_id===(e==null?void 0:e.id));return r.jsx(Ur,{title:"Academy",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Academy"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"On-demand training videos and resources"})]}),r.jsx("div",{className:"flex flex-col sm:flex-row gap-4",children:r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search videos...",value:t,onChange:v=>s(v.target.value),className:"pl-10"})]})}),r.jsx(ii,{value:n,onValueChange:a,children:r.jsxs(si,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[r.jsx(Kr,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(v=>r.jsx(Kr,{value:v.id,className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:v.name},v.id))]})}),i?r.jsx("div",{className:"flex justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):m.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ma,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold",children:"No videos found"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:t?"Try adjusting your search terms":"Check back soon for new content"})]})}):r.jsx("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3",children:m.map(v=>r.jsx(vo,{to:`/academy/${v.id}`,children:r.jsxs(ze,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow group h-full",children:[r.jsxs("div",{className:"relative aspect-video bg-muted",children:[v.thumbnail_url?r.jsx("img",{src:v.thumbnail_url,alt:v.title,className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(ma,{className:"h-12 w-12 text-muted-foreground"})}),r.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/90 flex items-center justify-center",children:r.jsx(tc,{className:"h-8 w-8 text-primary-foreground ml-1"})})}),v.duration&&r.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:[r.jsx(Pa,{className:"h-3 w-3"}),v.duration]})]}),r.jsxs(Wt,{className:"pb-2",children:[r.jsx("div",{className:"flex items-start justify-between gap-2",children:r.jsx(Zt,{className:"text-lg line-clamp-2",children:v.title})}),v.category&&r.jsx(_t,{variant:"secondary",className:"w-fit",children:v.category.name})]}),r.jsxs(qe,{className:"pt-0",children:[v.description&&r.jsx(Cs,{className:"line-clamp-2",children:v.description.replace(/<[^>]*>/g,"")}),r.jsxs("div",{className:"flex items-center gap-4 mt-3 text-sm text-muted-foreground",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Cd,{className:`h-4 w-4 ${g(v.id)?"fill-primary text-primary":""}`}),p(v.id)]}),v.resources&&v.resources.length>0&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ya,{className:"h-4 w-4"}),v.resources.length]})]})]})]})},v.id))})]})})};function WVe({resourceType:e,resourceId:t}){const{data:s=[]}=Ht({queryKey:["linked-templates",e,t],queryFn:async()=>{if(e==="academy_video"){const{data:n,error:a}=await Y.from("academy_video_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("video_id",t);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}else{const{data:n,error:a}=await Y.from("resource_kit_templates").select("template_id, canva_templates:template_id(id, name, preview_image_url)").eq("kit_id",t);if(a)throw a;return(n||[]).map(o=>o.canva_templates).filter(Boolean)}},enabled:!!t});return s.length===0?null:r.jsxs("div",{className:"space-y-2",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-sm",children:[r.jsx(id,{className:"h-4 w-4"}),"Related Templates"]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(n=>r.jsx(vo,{to:`/templates/${n.id}`,children:r.jsxs(_t,{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:[r.jsx(id,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const v3t=(e,t)=>{if(t==="bunny_stream"){let s=e.replace("iframe.mediadelivery.net","player.mediadelivery.net");return s.includes("?")||(s+="?autoplay=false&loop=false&muted=false&preload=true&responsive=true"),s}if(t==="youtube"){const s=/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=e.match(s);if(n)return`https://www.youtube.com/embed/${n[1]}`}if(t==="vimeo"){const s=/vimeo\.com\/(?:video\/)?(\d+)/,n=e.match(s);if(n)return`https://player.vimeo.com/video/${n[1]}`}if(t==="loom"){const s=/loom\.com\/share\/([a-zA-Z0-9]+)/,n=e.match(s);if(n)return`https://www.loom.com/embed/${n[1]}`}return e},_3t=()=>{const{videoId:e}=Bl();Ks();const{user:t,isAdmin:s}=Gr(),{toast:n}=_i(),a=Rr(),{trackEngagement:o}=L6(),[l,i]=A.useState(""),{data:d,isLoading:m}=Ht({queryKey:["academy-video",e],queryFn:async()=>{const{data:I,error:R}=await Y.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",e).eq("is_published",!0).single();if(R)throw R;const{data:D}=await Y.from("academy_resources").select("*").eq("video_id",e).order("sort_order");return{...I,resources:D||[]}},enabled:!!e});A.useEffect(()=>{d&&o("academy_video",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p=[]}=Ht({queryKey:["academy-video-likes",e],queryFn:async()=>{const{data:I,error:R}=await Y.from("academy_video_likes").select("*").eq("video_id",e);if(R)throw R;return I},enabled:!!e}),{data:g=[]}=Ht({queryKey:["academy-video-comments",e],queryFn:async()=>{const{data:I,error:R}=await Y.from("academy_video_comments").select("*").eq("video_id",e).order("created_at",{ascending:!1});if(R)throw R;const D=[...new Set(I.map(q=>q.user_id))],{data:B}=await Y.from("profiles").select("id, name").in("id",D),$=new Map((B==null?void 0:B.map(q=>[q.id,q.name]))||[]);return I.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!e}),v=Qt({mutationFn:async I=>{const{error:R}=await Y.from("academy_video_comments").insert({video_id:e,user_id:t.id,content:I});if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",e]}),i(""),n({title:"Comment added!"})},onError:I=>{n({title:"Error adding comment",description:I.message,variant:"destructive"})}}),_=Qt({mutationFn:async I=>{const{error:R}=await Y.from("academy_video_comments").delete().eq("id",I);if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",e]}),n({title:"Comment deleted"})}}),k=Qt({mutationFn:async()=>{const I=p.find(R=>R.user_id===(t==null?void 0:t.id));if(I){const{error:R}=await Y.from("academy_video_likes").delete().eq("id",I.id);if(R)throw R}else{const{error:R}=await Y.from("academy_video_likes").insert({video_id:e,user_id:t.id});if(R)throw R}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",e]})}}),w=p.some(I=>I.user_id===(t==null?void 0:t.id)),S=I=>{switch(I==null?void 0:I.toLowerCase()){case"pdf":return"📄";case"pptx":case"ppt":return"📊";case"xlsx":case"xls":return"📈";case"docx":case"doc":return"📝";case"zip":return"📦";default:return"📁"}},T=I=>I.split(" ").map(R=>R[0]).join("").toUpperCase().slice(0,2),C=I=>{I.preventDefault(),!(!l.trim()||!t)&&v.mutate(l.trim())};return m?r.jsx(Ur,{title:"Academy",children:r.jsx("div",{className:"flex justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?r.jsx(Ur,{title:d.title,children:r.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[r.jsx(X,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:r.jsxs(vo,{to:"/academy",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Academy"]})}),r.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)?r.jsx("iframe",{src:v3t(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}):r.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-white gap-4",children:[r.jsx(ma,{className:"h-16 w-16 opacity-50"}),r.jsx(X,{variant:"secondary",asChild:!0,children:r.jsxs("a",{href:d.video_url,target:"_blank",rel:"noopener noreferrer",className:"gap-2",children:[r.jsx(jn,{className:"h-4 w-4"}),"Open Video"]})})]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.title}),d.category&&r.jsx(_t,{variant:"secondary",children:d.category.name})]}),r.jsxs("div",{className:"flex gap-2",children:[s&&r.jsx(X,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:r.jsxs(vo,{to:`/admin/academy?edit=${d.id}`,children:[r.jsx(Qa,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit"})]})}),r.jsx(F3,{resourceType:"academy_video",resourceId:d.id,resourceTitle:d.title}),r.jsxs(X,{variant:w?"default":"outline",className:"gap-2 w-fit",onClick:()=>k.mutate(),disabled:!t||k.isPending,children:[r.jsx(Cd,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&r.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&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(ya,{className:"h-4 w-4"}),"Resources"]}),r.jsx("div",{className:"grid gap-2",children:d.resources.map(I=>r.jsxs("a",{href:I.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-3 rounded-lg border hover:bg-muted transition-colors",children:[r.jsx("span",{className:"text-2xl",children:S(I.file_type)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium truncate",children:I.title}),r.jsx("p",{className:"text-xs text-muted-foreground uppercase",children:I.file_type})]}),r.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),r.jsx(WVe,{resourceType:"academy_video",resourceId:d.id}),r.jsx(kd,{}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[r.jsx(Rl,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),t?r.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[r.jsx(qs,{placeholder:"Add a comment...",value:l,onChange:I=>i(I.target.value),className:"min-h-[80px] resize-none flex-1"}),r.jsx(X,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:r.jsx(ai,{className:"h-4 w-4"})})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),r.jsx("div",{className:"space-y-4",children:g.length===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-8 text-center",children:r.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):g.map(I=>r.jsx(ze,{children:r.jsx(qe,{className:"pt-4 pb-4",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx(cn,{className:"h-10 w-10 flex-shrink-0",children:r.jsx(dn,{className:"text-sm",children:T(I.user_name||"U")})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"font-medium",children:I.user_name}),r.jsx("span",{className:"text-sm text-muted-foreground",children:gu(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(t==null?void 0:t.id)&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(I.id),children:r.jsx(Os,{className:"h-3 w-3 text-muted-foreground"})})]}),r.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):r.jsx(Ur,{title:"Academy",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ma,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold",children:"Video not found"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"This video may have been removed or is not available."}),r.jsx(X,{asChild:!0,className:"mt-4",children:r.jsx(vo,{to:"/academy",children:"Back to Academy"})})]})})};function b3t(){const e=Ks(),[t,s]=A.useState(""),{data:n,isLoading:a}=Ht({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:_,error:k}=await Y.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(k)throw k;return _}}),{data:o}=Ht({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:_,error:k}=await Y.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(k)throw k;return _}}),{data:l}=Ht({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:_,error:k}=await Y.from("resource_kit_likes").select("kit_id");if(k)throw k;return _}}),{data:i}=Ht({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:_,error:k}=await Y.from("resource_kit_comments").select("kit_id");if(k)throw k;return _}}),d=n==null?void 0:n.filter(_=>{var k;return _.name.toLowerCase().includes(t.toLowerCase())||((k=_.description)==null?void 0:k.toLowerCase().includes(t.toLowerCase()))}),m=_=>(o==null?void 0:o.filter(k=>k.kit_id===_))||[],p=_=>(l==null?void 0:l.filter(k=>k.kit_id===_).length)||0,g=_=>(i==null?void 0:i.filter(k=>k.kit_id===_).length)||0,v=_=>{e(`/toolbox/${_}`)};return r.jsx(Ur,{title:"Toolbox",description:"Download resource kits and tools to help grow your business",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Toolbox"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Download resource kits and tools to help grow your business"})]}),r.jsxs("div",{className:"relative max-w-md",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search resource kits...",value:t,onChange:_=>s(_.target.value),className:"pl-10"})]}),!a&&r.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?r.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((_,k)=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx(pr,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),r.jsx(pr,{className:"h-5 w-3/4 mb-2"}),r.jsx(pr,{className:"h-4 w-full mb-4"}),r.jsx(pr,{className:"h-4 w-2/3"})]})},k))}):(d==null?void 0:d.length)===0?r.jsxs(ze,{className:"p-12 text-center",children:[r.jsx(ec,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resource kits found"}),r.jsx("p",{className:"text-muted-foreground",children:t?"Try adjusting your search terms":"Check back later for new resources"})]}):r.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 k=m(_.id).length,w=p(_.id),S=g(_.id);return r.jsxs(ze,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>v(_.id),children:[r.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:_.featured_image_url?r.jsx("img",{src:_.featured_image_url,alt:_.name,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(ec,{className:"h-16 w-16 text-muted-foreground"})})}),r.jsxs(qe,{className:"p-4",children:[r.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:_.name}),_.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:Zae(_.description)}),r.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ya,{className:"h-4 w-4"}),k," file",k!==1?"s":""]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Cd,{className:"h-3.5 w-3.5"}),w]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Rl,{className:"h-3.5 w-3.5"}),S]})]})]})]})]},_.id)})})]})})}const w3t=()=>{const{kitId:e}=Bl(),{user:t,isAdmin:s}=Gr(),{toast:n}=_i(),a=Rr(),{trackEngagement:o}=L6(),[l,i]=A.useState(""),{data:d,isLoading:m}=Ht({queryKey:["resource-kit-detail",e],queryFn:async()=>{const{data:I,error:R}=await Y.from("resource_kits").select("*").eq("id",e).eq("is_published",!0).single();if(R)throw R;const{data:D}=await Y.from("resource_kit_files").select("*").eq("kit_id",e).order("sort_order"),{data:B}=await Y.from("resource_kit_links").select("*").eq("kit_id",e).order("sort_order");return{...I,files:D||[],links:B||[]}},enabled:!!e});A.useEffect(()=>{d&&o("toolbox",d.id,d.name,"view")},[d==null?void 0:d.id]);const{data:p=[]}=Ht({queryKey:["resource-kit-likes",e],queryFn:async()=>{const{data:I,error:R}=await Y.from("resource_kit_likes").select("*").eq("kit_id",e);if(R)throw R;return I},enabled:!!e}),{data:g=[]}=Ht({queryKey:["resource-kit-comments",e],queryFn:async()=>{const{data:I,error:R}=await Y.from("resource_kit_comments").select("*").eq("kit_id",e).order("created_at",{ascending:!1});if(R)throw R;const D=[...new Set(I.map(q=>q.user_id))],{data:B}=await Y.from("profiles").select("id, name").in("id",D),$=new Map((B==null?void 0:B.map(q=>[q.id,q.name]))||[]);return I.map(q=>({...q,user_name:$.get(q.user_id)||"Unknown User"}))},enabled:!!e}),v=Qt({mutationFn:async I=>{const{error:R}=await Y.from("resource_kit_comments").insert({kit_id:e,user_id:t.id,content:I});if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",e]}),i(""),n({title:"Comment added!"})},onError:I=>{n({title:"Error adding comment",description:I.message,variant:"destructive"})}}),_=Qt({mutationFn:async I=>{const{error:R}=await Y.from("resource_kit_comments").delete().eq("id",I);if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",e]}),n({title:"Comment deleted"})}}),k=Qt({mutationFn:async()=>{const I=p.find(R=>R.user_id===(t==null?void 0:t.id));if(I){const{error:R}=await Y.from("resource_kit_likes").delete().eq("id",I.id);if(R)throw R}else{const{error:R}=await Y.from("resource_kit_likes").insert({kit_id:e,user_id:t.id});if(R)throw R}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",e]})}}),w=p.some(I=>I.user_id===(t==null?void 0:t.id)),S=I=>I.split(" ").map(R=>R[0]).join("").toUpperCase().slice(0,2),T=I=>I?I<1024?I+" B":I<1024*1024?(I/1024).toFixed(1)+" KB":(I/(1024*1024)).toFixed(1)+" MB":"",C=I=>{I.preventDefault(),!(!l.trim()||!t)&&v.mutate(l.trim())};return m?r.jsx(Ur,{title:"Toolbox",children:r.jsx("div",{className:"flex justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):d?r.jsx(Ur,{title:d.name,children:r.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[r.jsx(X,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:r.jsxs(vo,{to:"/toolbox",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Toolbox"]})}),d.featured_image_url&&r.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:r.jsx("img",{src:d.featured_image_url,alt:d.name,className:"w-full max-h-[400px] object-cover"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[r.jsx("div",{className:"space-y-2",children:r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:d.name})}),r.jsxs("div",{className:"flex items-center gap-2",children:[s&&r.jsx(X,{variant:"outline",className:"gap-2 rounded-full",asChild:!0,children:r.jsxs(vo,{to:`/admin/toolbox?edit=${d.id}`,children:[r.jsx(Qa,{className:"h-4 w-4"}),r.jsx("span",{children:"Edit"})]})}),r.jsx(F3,{resourceType:"resource_kit",resourceId:d.id,resourceTitle:d.name,size:"default",className:"rounded-full"}),r.jsxs(X,{variant:w?"default":"outline",className:"gap-2 rounded-full",onClick:()=>k.mutate(),disabled:!t||k.isPending,children:[r.jsx(Cd,{className:`h-4 w-4 ${w?"fill-current":""}`}),p.length," ",p.length===1?"Like":"Likes"]})]})]}),d.description&&r.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&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(ya,{className:"h-4 w-4"}),"Included Resources (",d.files.length,")"]}),r.jsx("div",{className:"grid gap-2",children:d.files.map(I=>r.jsxs("a",{href:I.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:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:r.jsx(ya,{className:"h-4 w-4 text-primary"})}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-sm",children:I.name}),I.file_size&&r.jsx("div",{className:"text-xs text-muted-foreground",children:T(I.file_size)})]})]}),r.jsx(Fi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},I.id))})]})}),d.links&&d.links.length>0&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(jn,{className:"h-4 w-4"}),"Canva Templates (",d.links.length,")"]}),r.jsx("div",{className:"grid gap-2",children:d.links.map(I=>r.jsxs("a",{href:I.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:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-md bg-purple-500/10",children:r.jsx(jn,{className:"h-4 w-4 text-purple-600"})}),r.jsx("div",{className:"font-medium text-sm",children:I.title})]}),r.jsx("span",{className:"text-xs text-muted-foreground group-hover:text-primary transition-colors",children:"Open in Canva"})]},I.id))})]})}),r.jsx(WVe,{resourceType:"resource_kit",resourceId:d.id}),r.jsx(kd,{}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[r.jsx(Rl,{className:"h-5 w-5"}),"Comments (",g.length,")"]}),t?r.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[r.jsx(qs,{placeholder:"Add a comment...",value:l,onChange:I=>i(I.target.value),className:"min-h-[80px] resize-none flex-1"}),r.jsx(X,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!l.trim()||v.isPending,children:r.jsx(ai,{className:"h-4 w-4"})})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),r.jsx("div",{className:"space-y-4",children:g.length===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-8 text-center",children:r.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):g.map(I=>r.jsx(ze,{children:r.jsx(qe,{className:"pt-4 pb-4",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx(cn,{className:"h-10 w-10 flex-shrink-0",children:r.jsx(dn,{className:"text-sm",children:S(I.user_name||"U")})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"font-medium",children:I.user_name}),r.jsx("span",{className:"text-sm text-muted-foreground",children:gu(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(t==null?void 0:t.id)&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>_.mutate(I.id),children:r.jsx(Os,{className:"h-3 w-3 text-muted-foreground"})})]}),r.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.id))})]})]})}):r.jsx(Ur,{title:"Toolbox",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ec,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold",children:"Resource kit not found"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource kit may have been removed or is not available."}),r.jsx(X,{asChild:!0,className:"mt-4",children:r.jsx(vo,{to:"/toolbox",children:"Back to Toolbox"})})]})})},j3t=()=>{const e=Ks(),[t,s]=A.useState(""),[n,a]=A.useState("grid"),{data:o=[],isLoading:l}=Ht({queryKey:["social-swag"],queryFn:async()=>{const{data:m,error:p}=await Y.from("social_swag").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(p)throw p;const{data:g,error:v}=await Y.from("social_swag_links").select("*").order("sort_order");if(v)throw v;const{data:_}=await Y.from("social_swag_likes").select("swag_id"),{data:k}=await Y.from("social_swag_comments").select("swag_id"),w=new Map;_==null||_.forEach(C=>{w.set(C.swag_id,(w.get(C.swag_id)||0)+1)});const S=new Map;return k==null||k.forEach(C=>{S.set(C.swag_id,(S.get(C.swag_id)||0)+1)}),(m||[]).map(C=>({...C,links:(g||[]).filter(I=>I.swag_id===C.id)||[],likesCount:w.get(C.id)||0,commentsCount:S.get(C.id)||0}))}}),i=o.filter(m=>{var g;return m.title.toLowerCase().includes(t.toLowerCase())||((g=m.description)==null?void 0:g.toLowerCase().includes(t.toLowerCase()))}),d=m=>{e(`/social-swag/${m}`)};return r.jsx(Ur,{title:"Social Swag",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Social Swag"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Browse our collection of social media content and graphics"})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search social swag...",value:t,onChange:m=>s(m.target.value),className:"pl-9"})]}),r.jsxs("div",{className:"flex gap-2",children:[t&&r.jsx(X,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:r.jsx(Of,{className:"h-4 w-4"})}),r.jsx(X,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:r.jsx(Rf,{className:"h-4 w-4"})})]})]})]}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," item",i.length!==1?"s":""," found"]}),l&&r.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((m,p)=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx(pr,{className:"aspect-[4/3] w-full rounded-lg mb-4"}),r.jsx(pr,{className:"h-5 w-3/4 mb-2"}),r.jsx(pr,{className:"h-4 w-full mb-4"})]})},p))}),!l&&i.length===0&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No items match your search":"No social swag available yet"}),t&&r.jsx(X,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&i.length>0&&r.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(m=>r.jsxs(ze,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${n==="list"?"flex flex-row":""}`,onClick:()=>d(m.id),children:[r.jsxs("div",{className:`relative overflow-hidden bg-muted ${n==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[m.preview_image_url?r.jsx("img",{src:m.preview_image_url,alt:m.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"}),m.links.length>1&&r.jsx("div",{className:"absolute top-2 right-2",children:r.jsxs(_t,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[r.jsx(Lo,{className:"h-3 w-3"}),m.links.length]})})]}),r.jsxs(qe,{className:`p-4 flex flex-col ${n==="list"?"flex-1":""}`,children:[r.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:m.title}),m.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:m.description.replace(/<[^>]*>/g,"")}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Cd,{className:"h-3.5 w-3.5"}),m.likesCount]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Rl,{className:"h-3.5 w-3.5"}),m.commentsCount]})]}),r.jsxs(X,{size:"sm",className:"w-full gap-2",onClick:p=>{p.stopPropagation(),d(m.id)},children:[r.jsx(jn,{className:"h-4 w-4"}),"View Details"]})]})]},m.id))})]})})};var Ka=function(){return Ka=Object.assign||function(t){for(var s,n=1,a=arguments.length;n1&&(d||!m),g=t>1&&(m||!d),v=function(){n&&o(n)},_=function(){a&&o(a)};return r.jsx(rMt,{displayMonth:e.displayMonth,hideNext:p,hidePrevious:g,nextMonth:a,previousMonth:n,onPreviousClick:v,onNextClick:_})}function sMt(e){var t,s=pl(),n=s.classNames,a=s.disableNavigation,o=s.styles,l=s.captionLayout,i=s.components,d=(t=i==null?void 0:i.CaptionLabel)!==null&&t!==void 0?t:ZVe,m;return a?m=r.jsx(d,{id:e.id,displayMonth:e.displayMonth}):l==="dropdown"?m=r.jsx(W3e,{displayMonth:e.displayMonth,id:e.id}):l==="dropdown-buttons"?m=r.jsxs(r.Fragment,{children:[r.jsx(W3e,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id}),r.jsx(G3e,{displayMonth:e.displayMonth,displayIndex:e.displayIndex,id:e.id})]}):m=r.jsxs(r.Fragment,{children:[r.jsx(d,{id:e.id,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),r.jsx(G3e,{displayMonth:e.displayMonth,id:e.id})]}),r.jsx("div",{className:n.caption,style:o.caption,children:m})}function nMt(e){var t=pl(),s=t.footer,n=t.styles,a=t.classNames.tfoot;return s?r.jsx("tfoot",{className:a,style:n.tfoot,children:r.jsx("tr",{children:r.jsx("td",{colSpan:8,children:s})})}):r.jsx(r.Fragment,{})}function aMt(e,t,s){for(var n=s?n0(new Date):Hm(new Date,{locale:e,weekStartsOn:t}),a=[],o=0;o<7;o++){var l=dc(n,o);a.push(l)}return a}function iMt(){var e=pl(),t=e.classNames,s=e.styles,n=e.showWeekNumber,a=e.locale,o=e.weekStartsOn,l=e.ISOWeek,i=e.formatters.formatWeekdayName,d=e.labels.labelWeekday,m=aMt(a,o,l);return r.jsxs("tr",{style:s.head_row,className:t.head_row,children:[n&&r.jsx("td",{style:s.head_cell,className:t.head_cell}),m.map(function(p,g){return r.jsx("th",{scope:"col",className:t.head_cell,style:s.head_cell,"aria-label":d(p,{locale:a}),children:i(p,{locale:a})},g)})]})}function oMt(){var e,t=pl(),s=t.classNames,n=t.styles,a=t.components,o=(e=a==null?void 0:a.HeadRow)!==null&&e!==void 0?e:iMt;return r.jsx("thead",{style:n.head,className:s.head,children:r.jsx(o,{})})}function lMt(e){var t=pl(),s=t.locale,n=t.formatters.formatDay;return r.jsx(r.Fragment,{children:n(e.date,{locale:s})})}var a_e=A.createContext(void 0);function cMt(e){if(!D6(e.initialProps)){var t={selected:void 0,modifiers:{disabled:[]}};return r.jsx(a_e.Provider,{value:t,children:e.children})}return r.jsx(dMt,{initialProps:e.initialProps,children:e.children})}function dMt(e){var t=e.initialProps,s=e.children,n=t.selected,a=t.min,o=t.max,l=function(m,p,g){var v,_;(v=t.onDayClick)===null||v===void 0||v.call(t,m,p,g);var k=!!(p.selected&&a&&(n==null?void 0:n.length)===a);if(!k){var w=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!w){var S=n?GVe([],n):[];if(p.selected){var T=S.findIndex(function(C){return Xl(m,C)});S.splice(T,1)}else S.push(m);(_=t.onSelect)===null||_===void 0||_.call(t,S,m,p,g)}}},i={disabled:[]};n&&i.disabled.push(function(m){var p=o&&n.length>o-1,g=n.some(function(v){return Xl(v,m)});return!!(p&&!g)});var d={selected:n,onDayClick:l,modifiers:i};return r.jsx(a_e.Provider,{value:d,children:s})}function i_e(){var e=A.useContext(a_e);if(!e)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return e}function uMt(e,t){var s=t||{},n=s.from,a=s.to;return n&&a?Xl(a,e)&&Xl(n,e)?void 0:Xl(a,e)?{from:a,to:void 0}:Xl(n,e)?void 0:use(n,e)?{from:e,to:a}:{from:n,to:e}:a?use(e,a)?{from:a,to:e}:{from:e,to:a}:n?kie(e,n)?{from:e,to:n}:{from:n,to:e}:{from:e,to:void 0}}var o_e=A.createContext(void 0);function hMt(e){if(!O6(e.initialProps)){var t={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return r.jsx(o_e.Provider,{value:t,children:e.children})}return r.jsx(mMt,{initialProps:e.initialProps,children:e.children})}function mMt(e){var t=e.initialProps,s=e.children,n=t.selected,a=n||{},o=a.from,l=a.to,i=t.min,d=t.max,m=function(_,k,w){var S,T;(S=t.onDayClick)===null||S===void 0||S.call(t,_,k,w);var C=uMt(_,n);(T=t.onSelect)===null||T===void 0||T.call(t,C,_,k,w)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],Xl(o,l)||(p.range_middle=[{after:o,before:l}])):p.range_end=[o]):l&&(p.range_start=[l],p.range_end=[l]),i&&(o&&!l&&p.disabled.push({after:Sue(o,i-1),before:dc(o,i-1)}),o&&l&&p.disabled.push({after:o,before:dc(o,i-1)}),!o&&l&&p.disabled.push({after:Sue(l,i-1),before:dc(l,i-1)})),d){if(o&&!l&&(p.disabled.push({before:dc(o,-d+1)}),p.disabled.push({after:dc(o,d-1)})),o&&l){var g=Yp(l,o)+1,v=d-g;p.disabled.push({before:Sue(o,v)}),p.disabled.push({after:dc(l,v)})}!o&&l&&(p.disabled.push({before:dc(l,-d+1)}),p.disabled.push({after:dc(l,d-1)}))}return r.jsx(o_e.Provider,{value:{selected:n,onDayClick:m,modifiers:p},children:s})}function l_e(){var e=A.useContext(o_e);if(!e)throw new Error("useSelectRange must be used within a SelectRangeProvider");return e}function fre(e){return Array.isArray(e)?GVe([],e):e!==void 0?[e]:[]}function fMt(e){var t={};return Object.entries(e).forEach(function(s){var n=s[0],a=s[1];t[n]=fre(a)}),t}var mg;(function(e){e.Outside="outside",e.Disabled="disabled",e.Selected="selected",e.Hidden="hidden",e.Today="today",e.RangeStart="range_start",e.RangeEnd="range_end",e.RangeMiddle="range_middle"})(mg||(mg={}));var pMt=mg.Selected,uy=mg.Disabled,gMt=mg.Hidden,xMt=mg.Today,che=mg.RangeEnd,dhe=mg.RangeMiddle,uhe=mg.RangeStart,yMt=mg.Outside;function vMt(e,t,s){var n,a=(n={},n[pMt]=fre(e.selected),n[uy]=fre(e.disabled),n[gMt]=fre(e.hidden),n[xMt]=[e.today],n[che]=[],n[dhe]=[],n[uhe]=[],n[yMt]=[],n);return e.fromDate&&a[uy].push({before:e.fromDate}),e.toDate&&a[uy].push({after:e.toDate}),D6(e)?a[uy]=a[uy].concat(t.modifiers[uy]):O6(e)&&(a[uy]=a[uy].concat(s.modifiers[uy]),a[uhe]=s.modifiers[uhe],a[dhe]=s.modifiers[dhe],a[che]=s.modifiers[che]),a}var QVe=A.createContext(void 0);function _Mt(e){var t=pl(),s=i_e(),n=l_e(),a=vMt(t,s,n),o=fMt(t.modifiers),l=Ka(Ka({},a),o);return r.jsx(QVe.Provider,{value:l,children:e.children})}function JVe(){var e=A.useContext(QVe);if(!e)throw new Error("useModifiers must be used within a ModifiersProvider");return e}function bMt(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function wMt(e){return!!(e&&typeof e=="object"&&"from"in e)}function jMt(e){return!!(e&&typeof e=="object"&&"after"in e)}function kMt(e){return!!(e&&typeof e=="object"&&"before"in e)}function NMt(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function SMt(e,t){var s,n=t.from,a=t.to;if(n&&a){var o=Yp(a,n)<0;o&&(s=[a,n],n=s[0],a=s[1]);var l=Yp(e,n)>=0&&Yp(a,e)>=0;return l}return a?Xl(a,e):n?Xl(n,e):!1}function CMt(e){return Tve(e)}function MMt(e){return Array.isArray(e)&&e.every(Tve)}function TMt(e,t){return t.some(function(s){if(typeof s=="boolean")return s;if(CMt(s))return Xl(e,s);if(MMt(s))return s.includes(e);if(wMt(s))return SMt(e,s);if(NMt(s))return s.dayOfWeek.includes(e.getDay());if(bMt(s)){var n=Yp(s.before,e),a=Yp(s.after,e),o=n>0,l=a<0,i=use(s.before,s.after);return i?l&&o:o||l}return jMt(s)?Yp(e,s.after)>0:kMt(s)?Yp(s.before,e)>0:typeof s=="function"?s(e):!1})}function c_e(e,t,s){var n=Object.keys(t).reduce(function(o,l){var i=t[l];return TMt(e,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),s&&!Fve(e,s)&&(a.outside=!0),a}function AMt(e,t){for(var s=em(e[0]),n=wie(e[e.length-1]),a,o,l=s;l<=n;){var i=c_e(l,t),d=!i.disabled&&!i.hidden;if(!d){l=dc(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=dc(l,1)}return o||a}var EMt=365;function eqe(e,t){var s=t.moveBy,n=t.direction,a=t.context,o=t.modifiers,l=t.retry,i=l===void 0?{count:0,lastFocused:e}:l,d=a.weekStartsOn,m=a.fromDate,p=a.toDate,g=a.locale,v={day:dc,week:Vj,month:rm,year:Kgt,startOfWeek:function(S){return a.ISOWeek?n0(S):Hm(S,{locale:g,weekStartsOn:d})},endOfWeek:function(S){return a.ISOWeek?v7e(S):Ave(S,{locale:g,weekStartsOn:d})}},_=v[s](e,n==="after"?1:-1);n==="before"&&m?_=Zgt([m,_]):n==="after"&&p&&(_=Ygt([p,_]));var k=!0;if(o){var w=c_e(_,o);k=!w.disabled&&!w.hidden}return k?_:i.count>EMt?i.lastFocused:eqe(_,{moveBy:s,direction:n,context:a,modifiers:o,retry:Ka(Ka({},i),{count:i.count+1})})}var tqe=A.createContext(void 0);function IMt(e){var t=R6(),s=JVe(),n=A.useState(),a=n[0],o=n[1],l=A.useState(),i=l[0],d=l[1],m=AMt(t.displayMonths,s),p=a??(i&&t.isDateDisplayed(i))?i:m,g=function(){d(a),o(void 0)},v=function(S){o(S)},_=pl(),k=function(S,T){if(a){var C=eqe(a,{moveBy:S,direction:T,context:_,modifiers:s});Xl(a,C)||(t.goToDate(C,a),v(C))}},w={focusedDay:a,focusTarget:p,blur:g,focus:v,focusDayAfter:function(){return k("day","after")},focusDayBefore:function(){return k("day","before")},focusWeekAfter:function(){return k("week","after")},focusWeekBefore:function(){return k("week","before")},focusMonthBefore:function(){return k("month","before")},focusMonthAfter:function(){return k("month","after")},focusYearBefore:function(){return k("year","before")},focusYearAfter:function(){return k("year","after")},focusStartOfWeek:function(){return k("startOfWeek","before")},focusEndOfWeek:function(){return k("endOfWeek","after")}};return r.jsx(tqe.Provider,{value:w,children:e.children})}function d_e(){var e=A.useContext(tqe);if(!e)throw new Error("useFocusContext must be used within a FocusProvider");return e}function PMt(e,t){var s=JVe(),n=c_e(e,s,t);return n}var u_e=A.createContext(void 0);function LMt(e){if(!coe(e.initialProps)){var t={selected:void 0};return r.jsx(u_e.Provider,{value:t,children:e.children})}return r.jsx(DMt,{initialProps:e.initialProps,children:e.children})}function DMt(e){var t=e.initialProps,s=e.children,n=function(o,l,i){var d,m,p;if((d=t.onDayClick)===null||d===void 0||d.call(t,o,l,i),l.selected&&!t.required){(m=t.onSelect)===null||m===void 0||m.call(t,void 0,o,l,i);return}(p=t.onSelect)===null||p===void 0||p.call(t,o,o,l,i)},a={selected:t.selected,onDayClick:n};return r.jsx(u_e.Provider,{value:a,children:s})}function rqe(){var e=A.useContext(u_e);if(!e)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return e}function OMt(e,t){var s=pl(),n=rqe(),a=i_e(),o=l_e(),l=d_e(),i=l.focusDayAfter,d=l.focusDayBefore,m=l.focusWeekAfter,p=l.focusWeekBefore,g=l.blur,v=l.focus,_=l.focusMonthBefore,k=l.focusMonthAfter,w=l.focusYearBefore,S=l.focusYearAfter,T=l.focusStartOfWeek,C=l.focusEndOfWeek,I=function(de){var ce,ge,Te,_e;coe(s)?(ce=n.onDayClick)===null||ce===void 0||ce.call(n,e,t,de):D6(s)?(ge=a.onDayClick)===null||ge===void 0||ge.call(a,e,t,de):O6(s)?(Te=o.onDayClick)===null||Te===void 0||Te.call(o,e,t,de):(_e=s.onDayClick)===null||_e===void 0||_e.call(s,e,t,de)},R=function(de){var ce;v(e),(ce=s.onDayFocus)===null||ce===void 0||ce.call(s,e,t,de)},D=function(de){var ce;g(),(ce=s.onDayBlur)===null||ce===void 0||ce.call(s,e,t,de)},B=function(de){var ce;(ce=s.onDayMouseEnter)===null||ce===void 0||ce.call(s,e,t,de)},$=function(de){var ce;(ce=s.onDayMouseLeave)===null||ce===void 0||ce.call(s,e,t,de)},q=function(de){var ce;(ce=s.onDayPointerEnter)===null||ce===void 0||ce.call(s,e,t,de)},W=function(de){var ce;(ce=s.onDayPointerLeave)===null||ce===void 0||ce.call(s,e,t,de)},K=function(de){var ce;(ce=s.onDayTouchCancel)===null||ce===void 0||ce.call(s,e,t,de)},re=function(de){var ce;(ce=s.onDayTouchEnd)===null||ce===void 0||ce.call(s,e,t,de)},ae=function(de){var ce;(ce=s.onDayTouchMove)===null||ce===void 0||ce.call(s,e,t,de)},oe=function(de){var ce;(ce=s.onDayTouchStart)===null||ce===void 0||ce.call(s,e,t,de)},se=function(de){var ce;(ce=s.onDayKeyUp)===null||ce===void 0||ce.call(s,e,t,de)},pe=function(de){var ce;switch(de.key){case"ArrowLeft":de.preventDefault(),de.stopPropagation(),s.dir==="rtl"?i():d();break;case"ArrowRight":de.preventDefault(),de.stopPropagation(),s.dir==="rtl"?d():i();break;case"ArrowDown":de.preventDefault(),de.stopPropagation(),m();break;case"ArrowUp":de.preventDefault(),de.stopPropagation(),p();break;case"PageUp":de.preventDefault(),de.stopPropagation(),de.shiftKey?w():_();break;case"PageDown":de.preventDefault(),de.stopPropagation(),de.shiftKey?S():k();break;case"Home":de.preventDefault(),de.stopPropagation(),T();break;case"End":de.preventDefault(),de.stopPropagation(),C();break}(ce=s.onDayKeyDown)===null||ce===void 0||ce.call(s,e,t,de)},ie={onClick:I,onFocus:R,onBlur:D,onKeyDown:pe,onKeyUp:se,onMouseEnter:B,onMouseLeave:$,onPointerEnter:q,onPointerLeave:W,onTouchCancel:K,onTouchEnd:re,onTouchMove:ae,onTouchStart:oe};return ie}function RMt(){var e=pl(),t=rqe(),s=i_e(),n=l_e(),a=coe(e)?t.selected:D6(e)?s.selected:O6(e)?n.selected:void 0;return a}function FMt(e){return Object.values(mg).includes(e)}function zMt(e,t){var s=[e.classNames.day];return Object.keys(t).forEach(function(n){var a=e.modifiersClassNames[n];if(a)s.push(a);else if(FMt(n)){var o=e.classNames["day_".concat(n)];o&&s.push(o)}}),s}function BMt(e,t){var s=Ka({},e.styles.day);return Object.keys(t).forEach(function(n){var a;s=Ka(Ka({},s),(a=e.modifiersStyles)===null||a===void 0?void 0:a[n])}),s}function $Mt(e,t,s){var n,a,o,l=pl(),i=d_e(),d=PMt(e,t),m=OMt(e,d),p=RMt(),g=!!(l.onDayClick||l.mode!=="default");A.useEffect(function(){var B;d.outside||i.focusedDay&&g&&Xl(i.focusedDay,e)&&((B=s.current)===null||B===void 0||B.focus())},[i.focusedDay,e,s,g,d.outside]);var v=zMt(l,d).join(" "),_=BMt(l,d),k=!!(d.outside&&!l.showOutsideDays||d.hidden),w=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:lMt,S=r.jsx(w,{date:e,displayMonth:t,activeModifiers:d}),T={style:_,className:v,children:S,role:"gridcell"},C=i.focusTarget&&Xl(i.focusTarget,e)&&!d.outside,I=i.focusedDay&&Xl(i.focusedDay,e),R=Ka(Ka(Ka({},T),(n={disabled:d.disabled,role:"gridcell"},n["aria-selected"]=d.selected,n.tabIndex=I||C?0:-1,n)),m),D={isButton:g,isHidden:k,activeModifiers:d,selectedDays:p,buttonProps:R,divProps:T};return D}function UMt(e){var t=A.useRef(null),s=$Mt(e.date,e.displayMonth,t);return s.isHidden?r.jsx("div",{role:"gridcell"}):s.isButton?r.jsx(pne,Ka({name:"day",ref:t},s.buttonProps)):r.jsx("div",Ka({},s.divProps))}function VMt(e){var t=e.number,s=e.dates,n=pl(),a=n.onWeekNumberClick,o=n.styles,l=n.classNames,i=n.locale,d=n.labels.labelWeekNumber,m=n.formatters.formatWeekNumber,p=m(Number(t),{locale:i});if(!a)return r.jsx("span",{className:l.weeknumber,style:o.weeknumber,children:p});var g=d(Number(t),{locale:i}),v=function(_){a(t,s,_)};return r.jsx(pne,{name:"week-number","aria-label":g,className:l.weeknumber,style:o.weeknumber,onClick:v,children:p})}function qMt(e){var t,s,n=pl(),a=n.styles,o=n.classNames,l=n.showWeekNumber,i=n.components,d=(t=i==null?void 0:i.Day)!==null&&t!==void 0?t:UMt,m=(s=i==null?void 0:i.WeekNumber)!==null&&s!==void 0?s:VMt,p;return l&&(p=r.jsx("td",{className:o.cell,style:a.cell,children:r.jsx(m,{number:e.weekNumber,dates:e.dates})})),r.jsxs("tr",{className:o.row,style:a.row,children:[p,e.dates.map(function(g){return r.jsx("td",{className:o.cell,style:a.cell,role:"presentation",children:r.jsx(d,{displayMonth:e.displayMonth,date:g})},Qxt(g))})]})}function K3e(e,t,s){for(var n=s!=null&&s.ISOWeek?v7e(t):Ave(t,s),a=s!=null&&s.ISOWeek?n0(e):Hm(e,s),o=Yp(n,a),l=[],i=0;i<=o;i++)l.push(dc(a,i));var d=l.reduce(function(m,p){var g=s!=null&&s.ISOWeek?Eve(p):Pve(p,s),v=m.find(function(_){return _.weekNumber===g});return v?(v.dates.push(p),m):(m.push({weekNumber:g,dates:[p]}),m)},[]);return d}function HMt(e,t){var s=K3e(em(e),wie(e),t);if(t!=null&&t.useFixedWeeks){var n=eyt(e,t);if(n<6){var a=s[s.length-1],o=a.dates[a.dates.length-1],l=Vj(o,6-n),i=K3e(Vj(o,1),l,t);s.push.apply(s,i)}}return s}function WMt(e){var t,s,n,a=pl(),o=a.locale,l=a.classNames,i=a.styles,d=a.hideHead,m=a.fixedWeeks,p=a.components,g=a.weekStartsOn,v=a.firstWeekContainsDate,_=a.ISOWeek,k=HMt(e.displayMonth,{useFixedWeeks:!!m,ISOWeek:_,locale:o,weekStartsOn:g,firstWeekContainsDate:v}),w=(t=p==null?void 0:p.Head)!==null&&t!==void 0?t:oMt,S=(s=p==null?void 0:p.Row)!==null&&s!==void 0?s:qMt,T=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:nMt;return r.jsxs("table",{id:e.id,className:l.table,style:i.table,role:"grid","aria-labelledby":e["aria-labelledby"],children:[!d&&r.jsx(w,{}),r.jsx("tbody",{className:l.tbody,style:i.tbody,children:k.map(function(C){return r.jsx(S,{displayMonth:e.displayMonth,dates:C.dates,weekNumber:C.weekNumber},C.weekNumber)})}),r.jsx(T,{displayMonth:e.displayMonth})]})}function GMt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var KMt=GMt()?A.useLayoutEffect:A.useEffect,hhe=!1,ZMt=0;function Z3e(){return"react-day-picker-".concat(++ZMt)}function YMt(e){var t,s=e??(hhe?Z3e():null),n=A.useState(s),a=n[0],o=n[1];return KMt(function(){a===null&&o(Z3e())},[]),A.useEffect(function(){hhe===!1&&(hhe=!0)},[]),(t=e??a)!==null&&t!==void 0?t:void 0}function XMt(e){var t,s,n=pl(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,d=R6().displayMonths,m=YMt(n.id?"".concat(n.id,"-").concat(e.displayIndex):void 0),p=n.id?"".concat(n.id,"-grid-").concat(e.displayIndex):void 0,g=[o.month],v=l.month,_=e.displayIndex===0,k=e.displayIndex===d.length-1,w=!_&&!k;a==="rtl"&&(t=[_,k],k=t[0],_=t[1]),_&&(g.push(o.caption_start),v=Ka(Ka({},v),l.caption_start)),k&&(g.push(o.caption_end),v=Ka(Ka({},v),l.caption_end)),w&&(g.push(o.caption_between),v=Ka(Ka({},v),l.caption_between));var S=(s=i==null?void 0:i.Caption)!==null&&s!==void 0?s:sMt;return r.jsxs("div",{className:g.join(" "),style:v,children:[r.jsx(S,{id:m,displayMonth:e.displayMonth,displayIndex:e.displayIndex}),r.jsx(WMt,{id:p,"aria-labelledby":m,displayMonth:e.displayMonth})]},e.displayIndex)}function QMt(e){var t=pl(),s=t.classNames,n=t.styles;return r.jsx("div",{className:s.months,style:n.months,children:e.children})}function JMt(e){var t,s,n=e.initialProps,a=pl(),o=d_e(),l=R6(),i=A.useState(!1),d=i[0],m=i[1];A.useEffect(function(){a.initialFocus&&o.focusTarget&&(d||(o.focus(o.focusTarget),m(!0)))},[a.initialFocus,d,o.focus,o.focusTarget,o]);var p=[a.classNames.root,a.className];a.numberOfMonths>1&&p.push(a.classNames.multiple_months),a.showWeekNumber&&p.push(a.classNames.with_weeknumber);var g=Ka(Ka({},a.styles.root),a.style),v=Object.keys(n).filter(function(k){return k.startsWith("data-")}).reduce(function(k,w){var S;return Ka(Ka({},k),(S={},S[w]=n[w],S))},{}),_=(s=(t=n.components)===null||t===void 0?void 0:t.Months)!==null&&s!==void 0?s:QMt;return r.jsx("div",Ka({className:p.join(" "),style:g,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},v,{children:r.jsx(_,{children:l.displayMonths.map(function(k,w){return r.jsx(XMt,{displayIndex:w,displayMonth:k},w)})})}))}function eTt(e){var t=e.children,s=k3t(e,["children"]);return r.jsx(V3t,{initialProps:s,children:r.jsx(J3t,{children:r.jsx(LMt,{initialProps:s,children:r.jsx(cMt,{initialProps:s,children:r.jsx(hMt,{initialProps:s,children:r.jsx(_Mt,{children:r.jsx(IMt,{children:t})})})})})})})}function tTt(e){return r.jsx(eTt,Ka({},e,{children:r.jsx(JMt,{initialProps:e})}))}function ig({className:e,classNames:t,showOutsideDays:s=!0,...n}){return r.jsx(tTt,{showOutsideDays:s,className:Vt("p-3",e),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:Vt(GI({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:Vt(GI({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",...t},components:{IconLeft:({...a})=>r.jsx(jc,{className:"h-4 w-4"}),IconRight:({...a})=>r.jsx(Zi,{className:"h-4 w-4"})},...n})}ig.displayName="Calendar";var doe="Popover",[sqe]=Sc(doe,[Ix]),F6=Ix(),[rTt,u_]=sqe(doe),nqe=e=>{const{__scopePopover:t,children:s,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=e,i=F6(t),d=A.useRef(null),[m,p]=A.useState(!1),[g,v]=bh({prop:n,defaultProp:a??!1,onChange:o,caller:doe});return r.jsx(g6,{...i,children:r.jsx(rTt,{scope:t,contentId:Md(),triggerRef:d,open:g,onOpenChange:v,onOpenToggle:A.useCallback(()=>v(_=>!_),[v]),hasCustomAnchor:m,onCustomAnchorAdd:A.useCallback(()=>p(!0),[]),onCustomAnchorRemove:A.useCallback(()=>p(!1),[]),modal:l,children:s})})};nqe.displayName=doe;var aqe="PopoverAnchor",sTt=A.forwardRef((e,t)=>{const{__scopePopover:s,...n}=e,a=u_(aqe,s),o=F6(s),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return A.useEffect(()=>(l(),()=>i()),[l,i]),r.jsx(k3,{...o,...n,ref:t})});sTt.displayName=aqe;var iqe="PopoverTrigger",oqe=A.forwardRef((e,t)=>{const{__scopePopover:s,...n}=e,a=u_(iqe,s),o=F6(s),l=va(t,a.triggerRef),i=r.jsx(Hs.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":hqe(a.open),...n,ref:l,onClick:bs(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:r.jsx(k3,{asChild:!0,...o,children:i})});oqe.displayName=iqe;var h_e="PopoverPortal",[nTt,aTt]=sqe(h_e,{forceMount:void 0}),lqe=e=>{const{__scopePopover:t,forceMount:s,children:n,container:a}=e,o=u_(h_e,t);return r.jsx(nTt,{scope:t,forceMount:s,children:r.jsx(Wc,{present:s||o.open,children:r.jsx(v3,{asChild:!0,container:a,children:n})})})};lqe.displayName=h_e;var q5="PopoverContent",cqe=A.forwardRef((e,t)=>{const s=aTt(q5,e.__scopePopover),{forceMount:n=s.forceMount,...a}=e,o=u_(q5,e.__scopePopover);return r.jsx(Wc,{present:n||o.open,children:o.modal?r.jsx(oTt,{...a,ref:t}):r.jsx(lTt,{...a,ref:t})})});cqe.displayName=q5;var iTt=$1("PopoverContent.RemoveScroll"),oTt=A.forwardRef((e,t)=>{const s=u_(q5,e.__scopePopover),n=A.useRef(null),a=va(t,n),o=A.useRef(!1);return A.useEffect(()=>{const l=n.current;if(l)return iie(l)},[]),r.jsx(w6,{as:iTt,allowPinchZoom:!0,children:r.jsx(dqe,{...e,ref:a,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:bs(e.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=s.triggerRef.current)==null||i.focus()}),onPointerDownOutside:bs(e.onPointerDownOutside,l=>{const i=l.detail.originalEvent,d=i.button===0&&i.ctrlKey===!0,m=i.button===2||d;o.current=m},{checkForDefaultPrevented:!1}),onFocusOutside:bs(e.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),lTt=A.forwardRef((e,t)=>{const s=u_(q5,e.__scopePopover),n=A.useRef(!1),a=A.useRef(!1);return r.jsx(dqe,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var l,i;(l=e.onCloseAutoFocus)==null||l.call(e,o),o.defaultPrevented||(n.current||(i=s.triggerRef.current)==null||i.focus(),o.preventDefault()),n.current=!1,a.current=!1},onInteractOutside:o=>{var d,m;(d=e.onInteractOutside)==null||d.call(e,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const l=o.target;((m=s.triggerRef.current)==null?void 0:m.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),dqe=A.forwardRef((e,t)=>{const{__scopePopover:s,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:m,onInteractOutside:p,...g}=e,v=u_(q5,s),_=F6(s);return aie(),r.jsx(_6,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(J1,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:d,onFocusOutside:m,onDismiss:()=>v.onOpenChange(!1),children:r.jsx(x6,{"data-state":hqe(v.open),role:"dialog",id:v.contentId,..._,...g,ref:t,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)"}})})})}),uqe="PopoverClose",cTt=A.forwardRef((e,t)=>{const{__scopePopover:s,...n}=e,a=u_(uqe,s);return r.jsx(Hs.button,{type:"button",...n,ref:t,onClick:bs(e.onClick,()=>a.onOpenChange(!1))})});cTt.displayName=uqe;var dTt="PopoverArrow",uTt=A.forwardRef((e,t)=>{const{__scopePopover:s,...n}=e,a=F6(s);return r.jsx(y6,{...a,...n,ref:t})});uTt.displayName=dTt;function hqe(e){return e?"open":"closed"}var hTt=nqe,mTt=oqe,fTt=lqe,mqe=cqe;const cd=hTt,dd=mTt,Hc=A.forwardRef(({className:e,align:t="center",sideOffset:s=4,...n},a)=>r.jsx(fTt,{children:r.jsx(mqe,{ref:a,align:t,sideOffset:s,className:Vt("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",e),...n})}));Hc.displayName=mqe.displayName;const pTt=_3("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"}}),m_e=A.forwardRef(({className:e,variant:t,...s},n)=>r.jsx("div",{ref:n,role:"alert",className:Vt(pTt({variant:t}),e),...s}));m_e.displayName="Alert";const gTt=A.forwardRef(({className:e,...t},s)=>r.jsx("h5",{ref:s,className:Vt("mb-1 font-medium leading-none tracking-tight",e),...t}));gTt.displayName="AlertTitle";const f_e=A.forwardRef(({className:e,...t},s)=>r.jsx("div",{ref:s,className:Vt("text-sm [&_p]:leading-relaxed",e),...t}));f_e.displayName="AlertDescription";function xTt({open:e,onOpenChange:t,imageUrl:s,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=Rr(),[d,m]=A.useState(a),[p,g]=A.useState([]),[v,_]=A.useState(null),[k,w]=A.useState("now"),[S,T]=A.useState(o4e(f4e(new Date),1)),[C,I]=A.useState("12"),[R,D]=A.useState("00"),[B,$]=A.useState("PM");A.useEffect(()=>{if(e){m(a),w("now"),g([]);const Me=o4e(f4e(new Date),1);T(Me);const Ze=Me.getHours();I(String(Ze>12?Ze-12:Ze===0?12:Ze)),D("00"),$(Ze>=12?"PM":"AM")}},[e,a]);const q=()=>{if(!S)return null;let Me=parseInt(C);const Ze=parseInt(R);return B==="PM"&&Me!==12&&(Me+=12),B==="AM"&&Me===12&&(Me=0),M7e(C7e(S,Me),Ze)},{data:W,isLoading:K}=Ht({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:Me}}=await Y.auth.getUser();if(!Me)return[];const{data:Ze,error:Ae}=await Y.from("social_accounts").select("*").eq("user_id",Me.id).eq("is_active",!0).order("platform",{ascending:!0});if(Ae)throw Ae;return console.log("Fetched social accounts for posting:",Ze),Ze},enabled:e,staleTime:0}),re=Qt({mutationFn:async({accountId:Me,platform:Ze})=>{_(Me);const{data:Ae,error:Le}=await Y.functions.invoke("social-post",{body:{platform:Ze,accountId:Me,imageUrl:s,caption:d}});if(Le)throw Le;if(Ae!=null&&Ae.error)throw new Error(Ae.error);return Ae},onSuccess:Me=>{const Ze=Me.platform==="facebook"?"Facebook":Me.platform==="instagram"?"Instagram":Me.platform==="linkedin"?"LinkedIn":"Google Business";we.success(`Posted to ${Ze}!`)},onError:Me=>{we.error(`Failed to post: ${Me.message}`)},onSettled:()=>{_(null)}}),ae=Qt({mutationFn:async({accountId:Me,platform:Ze,scheduledFor:Ae})=>{const{data:{user:Le}}=await Y.auth.getUser();if(!Le)throw new Error("Not authenticated");const{error:Ue}=await Y.from("scheduled_posts").insert({user_id:Le.id,social_account_id:Me,platform:Ze,image_url:s,caption:d,swag_item_id:o||null,reel_id:l||null,scheduled_for:Ae.toISOString(),status:"scheduled"});if(Ue)throw Ue;return{platform:Ze}},onSuccess:Me=>{const Ze=Me.platform==="facebook"?"Facebook":Me.platform==="instagram"?"Instagram":"LinkedIn";we.success(`Post scheduled for ${Ze}!`)},onError:Me=>{we.error(`Failed to schedule: ${Me.message}`)}}),oe=async()=>{if(p.length===0){we.error("Please select at least one account");return}if(k==="schedule"){const Me=q();if(!Me||Me<=new Date){we.error("Please select a future date and time");return}for(const Ze of p){const Ae=W==null?void 0:W.find(Le=>Le.id===Ze);Ae&&await ae.mutateAsync({accountId:Ze,platform:Ae.platform,scheduledFor:Me})}i.invalidateQueries({queryKey:["scheduled-posts"]}),we.success(`${p.length} post(s) scheduled for ${Xr(Me,"PPp")}`)}else for(const Me of p){const Ze=W==null?void 0:W.find(Ae=>Ae.id===Me);Ze&&await re.mutateAsync({accountId:Me,platform:Ze.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),m(""),g([]),t(!1)},se=Me=>{g(Ze=>Ze.includes(Me)?Ze.filter(Ae=>Ae!==Me):[...Ze,Me])},pe=(W==null?void 0:W.filter(Me=>Me.platform==="facebook"))||[],ie=(W==null?void 0:W.filter(Me=>Me.platform==="instagram"))||[],de=(W==null?void 0:W.filter(Me=>Me.platform==="linkedin"))||[],ce=(W==null?void 0:W.filter(Me=>Me.platform==="google_business"))||[],ge=((W==null?void 0:W.length)||0)>0,Te=re.isPending||ae.isPending,_e=Array.from({length:12},(Me,Ze)=>String(Ze+1)),ve=["00","15","30","45"];return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create Social Post"}),r.jsx(Zs,{children:"Share this image to your connected social accounts"})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx("div",{className:"aspect-square w-full max-w-[200px] mx-auto overflow-hidden rounded-lg border",children:r.jsx("img",{src:s,alt:"Post preview",className:"h-full w-full object-cover"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"caption",children:"Caption"}),r.jsx(qs,{id:"caption",placeholder:"Write a caption for your post...",value:d,onChange:Me=>m(Me.target.value),rows:3}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.length,"/2200 characters"]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Publish Time"}),r.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-lg",children:[r.jsx("button",{type:"button",onClick:()=>w("now"),className:Vt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",k==="now"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Post Now"}),r.jsx("button",{type:"button",onClick:()=>w("schedule"),className:Vt("flex-1 px-4 py-2 rounded-md text-sm font-medium transition-all",k==="schedule"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Schedule"})]})]}),k==="schedule"&&r.jsxs("div",{className:"space-y-3 p-4 border rounded-lg bg-muted/30",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r.jsx(Pa,{className:"h-4 w-4"}),"Schedule for"]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("justify-start text-left font-normal flex-1",!S&&"text-muted-foreground"),children:[r.jsx(An,{className:"mr-2 h-4 w-4"}),S?Xr(S,"PPP"):r.jsx("span",{children:"Pick a date"})]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:S,onSelect:T,disabled:Me=>Mer.jsx(Ut,{value:Me,children:Me},Me))})]}),r.jsx("span",{className:"text-muted-foreground",children:":"}),r.jsxs(ds,{value:R,onValueChange:D,children:[r.jsx(ls,{className:"w-[70px]",children:r.jsx(us,{})}),r.jsx(cs,{children:ve.map(Me=>r.jsx(Ut,{value:Me,children:Me},Me))})]}),r.jsxs(ds,{value:B,onValueChange:Me=>$(Me),children:[r.jsx(ls,{className:"w-[70px]",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"AM",children:"AM"}),r.jsx(Ut,{value:"PM",children:"PM"})]})]})]})]}),S&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",Xr(q()||new Date,"PPP 'at' p")]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Post to"}),K&&r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx($r,{className:"h-6 w-6 animate-spin"})}),!K&&!ge&&r.jsxs(m_e,{children:[r.jsx(kl,{className:"h-4 w-4"}),r.jsxs(f_e,{className:"flex flex-col gap-2",children:[r.jsx("span",{children:"No social accounts connected yet."}),r.jsxs(vo,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[r.jsx(ld,{className:"h-3.5 w-3.5"}),"Connect your Facebook, Instagram & LinkedIn"]})]})]}),pe.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[r.jsx(fu,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),pe.map(Me=>r.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsx(Qo,{checked:p.includes(Me.id),onCheckedChange:()=>se(Me.id),disabled:v===Me.id}),r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:Me.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(fu,{className:"h-4 w-4"})})]}),r.jsx("span",{className:"flex-1 text-sm font-medium",children:Me.page_name||Me.platform_username}),v===Me.id&&r.jsx($r,{className:"h-4 w-4 animate-spin"})]},Me.id))]}),ie.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[r.jsx(Lu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ie.map(Me=>r.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsx(Qo,{checked:p.includes(Me.id),onCheckedChange:()=>se(Me.id),disabled:v===Me.id}),r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:Me.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(Lu,{className:"h-4 w-4"})})]}),r.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",Me.platform_username]}),v===Me.id&&r.jsx($r,{className:"h-4 w-4 animate-spin"})]},Me.id))]}),de.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[r.jsx(zm,{className:"h-4 w-4 text-blue-700"})," LinkedIn"]}),de.map(Me=>r.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsx(Qo,{checked:p.includes(Me.id),onCheckedChange:()=>se(Me.id),disabled:v===Me.id}),r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:Me.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(zm,{className:"h-4 w-4"})})]}),r.jsx("span",{className:"flex-1 text-sm font-medium",children:Me.platform_username}),v===Me.id&&r.jsx($r,{className:"h-4 w-4 animate-spin"})]},Me.id))]}),ce.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("p",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[r.jsx(Yi,{className:"h-4 w-4 text-red-600"})," Google Business"]}),ce.map(Me=>r.jsxs("label",{className:"flex items-center gap-3 rounded-lg border p-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[r.jsx(Qo,{checked:p.includes(Me.id),onCheckedChange:()=>se(Me.id),disabled:v===Me.id}),r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:Me.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(Yi,{className:"h-4 w-4"})})]}),r.jsx("span",{className:"flex-1 text-sm font-medium",children:Me.page_name||Me.platform_username}),v===Me.id&&r.jsx($r,{className:"h-4 w-4 animate-spin"})]},Me.id))]})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{onClick:oe,disabled:p.length===0||Te,className:"gap-2",children:[Te?r.jsx($r,{className:"h-4 w-4 animate-spin"}):k==="schedule"?r.jsx(An,{className:"h-4 w-4"}):r.jsx(ai,{className:"h-4 w-4"}),k==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function yTt(){const e=Rr(),[t,s]=A.useState(void 0),[n,a]=A.useState("all"),[o,l]=A.useState(null),[i,d]=A.useState(""),[m,p]=A.useState(void 0),[g,v]=A.useState("12"),[_,k]=A.useState("00"),[w,S]=A.useState("PM"),{data:T=[],isLoading:C}=Ht({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:ce,error:ge}=await Y.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(ge)throw ge;return ce}}),I=T.filter(ce=>{if(n!=="all"&&ce.status!==n)return!1;if(t&&ce.scheduled_for){const ge=new Date(ce.scheduled_for);if(!Xl(ge,t))return!1}return!0}),R=T.filter(ce=>ce.scheduled_for).map(ce=>Wm(new Date(ce.scheduled_for))),D=Qt({mutationFn:async ce=>{const{error:ge}=await Y.from("scheduled_posts").update({caption:ce.caption,scheduled_for:ce.scheduled_for}).eq("id",ce.id);if(ge)throw ge},onSuccess:()=>{we.success("Post updated!"),e.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:ce=>{we.error(`Failed to update: ${ce.message}`)}}),B=Qt({mutationFn:async ce=>{const{error:ge}=await Y.from("scheduled_posts").update({status:"cancelled"}).eq("id",ce);if(ge)throw ge},onSuccess:()=>{we.success("Post cancelled"),e.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{we.error(`Failed to cancel: ${ce.message}`)}}),$=Qt({mutationFn:async ce=>{const{error:ge}=await Y.from("scheduled_posts").delete().eq("id",ce);if(ge)throw ge},onSuccess:()=>{we.success("Post deleted"),e.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{we.error(`Failed to delete: ${ce.message}`)}}),q=Qt({mutationFn:async ce=>{const{data:ge,error:Te}=await Y.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 Y.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";we.success(`Posted to ${ge}!`),e.invalidateQueries({queryKey:["scheduled-posts"]})},onError:ce=>{we.error(`Failed to post: ${ce.message}`)}}),W=ce=>{if(l(ce),d(ce.caption||""),ce.scheduled_for){const ge=new Date(ce.scheduled_for);p(ge);const Te=ge.getHours();v(String(Te>12?Te-12:Te===0?12:Te)),k(String(ge.getMinutes()).padStart(2,"0")),S(Te>=12?"PM":"AM")}},K=()=>{if(!o||!m)return;let ce=parseInt(g);const ge=parseInt(_);w==="PM"&&ce!==12&&(ce+=12),w==="AM"&&ce===12&&(ce=0);const Te=M7e(C7e(m,ce),ge);D.mutate({id:o.id,caption:i,scheduled_for:Te.toISOString()})},re=ce=>{switch(ce){case"facebook":return r.jsx(fu,{className:"h-4 w-4 text-blue-600"});case"instagram":return r.jsx(Lu,{className:"h-4 w-4 text-pink-600"});case"linkedin":return r.jsx(zm,{className:"h-4 w-4 text-blue-700"});default:return null}},ae=ce=>{switch(ce){case"scheduled":return r.jsxs(_t,{variant:"secondary",className:"gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return r.jsxs(_t,{variant:"default",className:"gap-1 bg-green-600",children:[r.jsx(ui,{className:"h-3 w-3"}),"Posted"]});case"failed":return r.jsxs(_t,{variant:"destructive",className:"gap-1",children:[r.jsx(Fc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return r.jsxs(_t,{variant:"outline",className:"gap-1 text-muted-foreground",children:[r.jsx(kl,{className:"h-3 w-3"}),"Cancelled"]});default:return r.jsx(_t,{variant:"outline",children:ce})}},oe=Array.from({length:12},(ce,ge)=>String(ge+1)),se=["00","15","30","45"],pe=T.filter(ce=>ce.status==="scheduled").length,ie=T.filter(ce=>ce.status==="posted").length,de=T.filter(ce=>ce.status==="scheduled"&&ce.scheduled_for&&tyt(new Date(ce.scheduled_for))).length;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsxs(ze,{className:"p-4",children:[r.jsx("div",{className:"text-2xl font-bold",children:pe}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Scheduled"})]}),r.jsxs(ze,{className:"p-4",children:[r.jsx("div",{className:"text-2xl font-bold",children:de}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Upcoming"})]}),r.jsxs(ze,{className:"p-4",children:[r.jsx("div",{className:"text-2xl font-bold",children:ie}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Posted"})]}),r.jsxs(ze,{className:"p-4",children:[r.jsx("div",{className:"text-2xl font-bold",children:T.length}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Total"})]})]}),r.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[r.jsxs(ze,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[r.jsx(sg,{className:"h-5 w-5"}),r.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),r.jsx(ig,{mode:"single",selected:t,onSelect:s,className:Vt("pointer-events-auto"),modifiers:{hasPost:R},modifiersStyles:{hasPost:{fontWeight:"bold",backgroundColor:"hsl(var(--primary) / 0.1)",borderRadius:"50%"}}}),t&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>s(void 0),className:"w-full mt-2",children:"Clear date filter"})]}),r.jsxs("div",{className:"flex-1 space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(b1,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(ce=>r.jsx(X,{variant:n===ce?"default":"outline",size:"sm",onClick:()=>a(ce),className:"capitalize",children:ce},ce))})]}),C&&r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!C&&I.length===0&&r.jsxs(ze,{className:"p-8 text-center",children:[r.jsx(An,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),r.jsx("h3",{className:"font-medium mb-2",children:"No posts found"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:t?`No posts scheduled for ${Xr(t,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),r.jsx("div",{className:"space-y-4",children:I.map(ce=>{var ge,Te;return r.jsx(ze,{className:"overflow-hidden",children:r.jsxs("div",{className:"flex flex-col sm:flex-row",children:[r.jsx("div",{className:"sm:w-32 h-32 sm:h-auto bg-muted flex-shrink-0",children:r.jsx("img",{src:ce.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),r.jsxs(qe,{className:"flex-1 p-4",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2 mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[re(ce.platform),r.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"}),ae(ce.status)]}),r.jsxs("div",{className:"flex items-center gap-1",children:[ce.status==="scheduled"&&r.jsxs(xN,{children:[r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>W(ce),children:r.jsx(Qa,{className:"h-4 w-4"})})}),r.jsx(dh,{children:"Edit post"})]}),r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>q.mutate(ce),disabled:q.isPending,children:q.isPending?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(ai,{className:"h-4 w-4"})})}),r.jsx(dh,{children:"Post now"})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Cancel this scheduled post?"}),r.jsx(bc,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Keep"}),r.jsx(Ql,{onClick:()=>B.mutate(ce.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),r.jsx(Ql,{onClick:()=>$.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(ce.status==="posted"||ce.status==="cancelled"||ce.status==="failed")&&r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Delete this post?"}),r.jsx(bc,{children:"This will permanently remove this post from your history."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>$.mutate(ce.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),ce.caption&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:ce.caption}),r.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),ce.status==="posted"&&ce.posted_at?`Posted ${Xr(new Date(ce.posted_at),"PPp")}`:ce.scheduled_for?`Scheduled for ${Xr(new Date(ce.scheduled_for),"PPp")}`:"Not scheduled"]}),ce.status==="failed"&&ce.error_message&&r.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",ce.error_message]})]})]})},ce.id)})})]})]}),r.jsx(Ir,{open:!!o,onOpenChange:ce=>!ce&&l(null),children:r.jsxs(Er,{className:"max-w-lg",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Edit Scheduled Post"}),r.jsx(Zs,{children:"Update the caption or reschedule this post"})]}),o&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx("div",{className:"aspect-square w-32 mx-auto overflow-hidden rounded-lg border",children:r.jsx("img",{src:o.image_url,alt:"Post preview",className:"h-full w-full object-cover"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Caption"}),r.jsx(qs,{value:i,onChange:ce=>d(ce.target.value),rows:3})]}),r.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[r.jsx(Ee,{children:"Schedule for"}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("justify-start text-left font-normal flex-1",!m&&"text-muted-foreground"),children:[r.jsx(An,{className:"mr-2 h-4 w-4"}),m?Xr(m,"PPP"):"Pick a date"]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:m,onSelect:p,disabled:ce=>cer.jsx(Ut,{value:ce,children:ce},ce))})]}),r.jsx("span",{className:"text-muted-foreground",children:":"}),r.jsxs(ds,{value:_,onValueChange:k,children:[r.jsx(ls,{className:"w-[70px]",children:r.jsx(us,{})}),r.jsx(cs,{children:se.map(ce=>r.jsx(Ut,{value:ce,children:ce},ce))})]}),r.jsxs(ds,{value:w,onValueChange:ce=>S(ce),children:[r.jsx(ls,{className:"w-[70px]",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"AM",children:"AM"}),r.jsx(Ut,{value:"PM",children:"PM"})]})]})]})]})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),r.jsxs(X,{onClick:K,disabled:D.isPending,children:[D.isPending?r.jsx($r,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function WO(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var fqe={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(e,t){(function(s){e.exports=s()})(function(){return function s(n,a,o){function l(m,p){if(!a[m]){if(!n[m]){var g=typeof WO=="function"&&WO;if(!p&&g)return g(m,!0);if(i)return i(m,!0);var v=new Error("Cannot find module '"+m+"'");throw v.code="MODULE_NOT_FOUND",v}var _=a[m]={exports:{}};n[m][0].call(_.exports,function(k){var w=n[m][1][k];return l(w||k)},_,_.exports,s,n,a,o)}return a[m].exports}for(var i=typeof WO=="function"&&WO,d=0;d>2,_=(3&m)<<4|p>>4,k=1>6:64,w=2>4,p=(15&v)<<4|(_=i.indexOf(d.charAt(w++)))>>2,g=(3&_)<<6|(k=i.indexOf(d.charAt(w++))),C[S++]=m,_!==64&&(C[S++]=p),k!==64&&(C[S++]=g);return C}},{"./support":30,"./utils":32}],2:[function(s,n,a){var o=s("./external"),l=s("./stream/DataWorker"),i=s("./stream/Crc32Probe"),d=s("./stream/DataLengthProbe");function m(p,g,v,_,k){this.compressedSize=p,this.uncompressedSize=g,this.crc32=v,this.compression=_,this.compressedContent=k}m.prototype={getContentWorker:function(){var p=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),g=this;return p.on("end",function(){if(this.streamInfo.data_length!==g.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),p},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},m.createWorkerFrom=function(p,g,v){return p.pipe(new i).pipe(new d("uncompressedSize")).pipe(g.compressWorker(v)).pipe(new d("compressedSize")).withStreamInfo("compression",g)},n.exports=m},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(s,n,a){var o=s("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},a.DEFLATE=s("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(s,n,a){var o=s("./utils"),l=function(){for(var i,d=[],m=0;m<256;m++){i=m;for(var p=0;p<8;p++)i=1&i?3988292384^i>>>1:i>>>1;d[m]=i}return d}();n.exports=function(i,d){return i!==void 0&&i.length?o.getTypeOf(i)!=="string"?function(m,p,g,v){var _=l,k=v+g;m^=-1;for(var w=v;w>>8^_[255&(m^p[w])];return-1^m}(0|d,i,i.length,0):function(m,p,g,v){var _=l,k=v+g;m^=-1;for(var w=v;w>>8^_[255&(m^p.charCodeAt(w))];return-1^m}(0|d,i,i.length,0):0}},{"./utils":32}],5:[function(s,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(s,n,a){var o=null;o=typeof Promise<"u"?Promise:s("lie"),n.exports={Promise:o}},{lie:37}],7:[function(s,n,a){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=s("pako"),i=s("./utils"),d=s("./stream/GenericWorker"),m=o?"uint8array":"array";function p(g,v){d.call(this,"FlateWorker/"+g),this._pako=null,this._pakoAction=g,this._pakoOptions=v,this.meta={}}a.magic="\b\0",i.inherits(p,d),p.prototype.processChunk=function(g){this.meta=g.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(m,g.data),!1)},p.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},p.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},p.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var g=this;this._pako.onData=function(v){g.push({data:v,meta:g.meta})}},a.compressWorker=function(g){return new p("Deflate",g)},a.uncompressWorker=function(){return new p("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(s,n,a){function o(_,k){var w,S="";for(w=0;w>>=8;return S}function l(_,k,w,S,T,C){var I,R,D=_.file,B=_.compression,$=C!==m.utf8encode,q=i.transformTo("string",C(D.name)),W=i.transformTo("string",m.utf8encode(D.name)),K=D.comment,re=i.transformTo("string",C(K)),ae=i.transformTo("string",m.utf8encode(K)),oe=W.length!==D.name.length,se=ae.length!==K.length,pe="",ie="",de="",ce=D.dir,ge=D.date,Te={crc32:0,compressedSize:0,uncompressedSize:0};k&&!w||(Te.crc32=_.crc32,Te.compressedSize=_.compressedSize,Te.uncompressedSize=_.uncompressedSize);var _e=0;k&&(_e|=8),$||!oe&&!se||(_e|=2048);var ve=0,Me=0;ce&&(ve|=16),T==="UNIX"?(Me=798,ve|=function(Ae,Le){var Ue=Ae;return Ae||(Ue=Le?16893:33204),(65535&Ue)<<16}(D.unixPermissions,ce)):(Me=20,ve|=function(Ae){return 63&(Ae||0)}(D.dosPermissions)),I=ge.getUTCHours(),I<<=6,I|=ge.getUTCMinutes(),I<<=5,I|=ge.getUTCSeconds()/2,R=ge.getUTCFullYear()-1980,R<<=4,R|=ge.getUTCMonth()+1,R<<=5,R|=ge.getUTCDate(),oe&&(ie=o(1,1)+o(p(q),4)+W,pe+="up"+o(ie.length,2)+ie),se&&(de=o(1,1)+o(p(re),4)+ae,pe+="uc"+o(de.length,2)+de);var Ze="";return Ze+=` \0`,Ze+=o(_e,2),Ze+=B.magic,Ze+=o(I,2),Ze+=o(R,2),Ze+=o(Te.crc32,4),Ze+=o(Te.compressedSize,4),Ze+=o(Te.uncompressedSize,4),Ze+=o(q.length,2),Ze+=o(pe.length,2),{fileRecord:g.LOCAL_FILE_HEADER+Ze+q+pe,dirRecord:g.CENTRAL_FILE_HEADER+o(Me,2)+Ze+o(re.length,2)+"\0\0\0\0"+o(ve,4)+o(S,4)+q+pe+re}}var i=s("../utils"),d=s("../stream/GenericWorker"),m=s("../utf8"),p=s("../crc32"),g=s("../signature");function v(_,k,w,S){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=k,this.zipPlatform=w,this.encodeFileName=S,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 k=_.meta.percent||0,w=this.entriesCount,S=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?(k+100*(w-S-1))/w:100}}))},v.prototype.openedSource=function(_){this.currentSourceOffset=this.bytesWritten,this.currentFile=_.file.name;var k=this.streamFiles&&!_.file.dir;if(k){var w=l(_,k,!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 k=this.streamFiles&&!_.file.dir,w=l(_,k,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(w.dirRecord),k)this.push({data:function(S){return g.DATA_DESCRIPTOR+o(S.crc32,4)+o(S.compressedSize,4)+o(S.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,k=0;k=this.index;d--)m=(m<<8)+this.byteAt(d);return this.index+=i,m},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(s,n,a){var o=s("./Uint8ArrayReader");function l(i){o.call(this,i)}s("../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(s,n,a){var o=s("./DataReader");function l(i){o.call(this,i)}s("../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(s,n,a){var o=s("./ArrayReader");function l(i){o.call(this,i)}s("../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(s,n,a){var o=s("../utils"),l=s("../support"),i=s("./ArrayReader"),d=s("./StringReader"),m=s("./NodeBufferReader"),p=s("./Uint8ArrayReader");n.exports=function(g){var v=o.getTypeOf(g);return o.checkSupport(v),v!=="string"||l.uint8array?v==="nodebuffer"?new m(g):l.uint8array?new p(o.transformTo("uint8array",g)):new i(o.transformTo("array",g)):new d(g)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(s,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(s,n,a){var o=s("./GenericWorker"),l=s("../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(s,n,a){var o=s("./GenericWorker"),l=s("../crc32");function i(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}s("../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(s,n,a){var o=s("../utils"),l=s("./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 m=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=m+d.data.length}l.prototype.processChunk.call(this,d)},n.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(s,n,a){var o=s("../utils"),l=s("./GenericWorker");function i(d){l.call(this,"DataWorker");var m=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(p){m.dataIsReady=!0,m.data=p,m.max=p&&p.length||0,m.type=o.getTypeOf(p),m.isPaused||m._tickAndRepeat()},function(p){m.error(p)})}o.inherits(i,l),i.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var d=null,m=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,m);break;case"uint8array":d=this.data.subarray(this.index,m);break;case"array":case"nodebuffer":d=this.data.slice(this.index,m)}return this.index=m,this.push({data:d,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(s,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(s,n,a){var o=s("../utils"),l=s("./ConvertWorker"),i=s("./GenericWorker"),d=s("../base64"),m=s("../support"),p=s("../external"),g=null;if(m.nodestream)try{g=s("../nodejs/NodejsStreamOutputAdapter")}catch{}function v(k,w){return new p.Promise(function(S,T){var C=[],I=k._internalType,R=k._outputType,D=k._mimeType;k.on("data",function(B,$){C.push(B),w&&w($)}).on("error",function(B){C=[],T(B)}).on("end",function(){try{var B=function($,q,W){switch($){case"blob":return o.newBlob(o.transformTo("arraybuffer",q),W);case"base64":return d.encode(q);default:return o.transformTo($,q)}}(R,function($,q){var W,K=0,re=null,ae=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=!!s("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(s,n,a){for(var o=s("./utils"),l=s("./support"),i=s("./nodejsUtils"),d=s("./stream/GenericWorker"),m=new Array(256),p=0;p<256;p++)m[p]=252<=p?6:248<=p?5:240<=p?4:224<=p?3:192<=p?2:1;m[254]=m[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(k){var w,S,T,C,I,R=k.length,D=0;for(C=0;C>>6:(S<65536?w[I++]=224|S>>>12:(w[I++]=240|S>>>18,w[I++]=128|S>>>12&63),w[I++]=128|S>>>6&63),w[I++]=128|63&S);return w}(_)},a.utf8decode=function(_){return l.nodebuffer?o.transformTo("nodebuffer",_).toString("utf-8"):function(k){var w,S,T,C,I=k.length,R=new Array(2*I);for(w=S=0;w>10&1023,R[S++]=56320|1023&T)}return R.length!==S&&(R.subarray?R=R.subarray(0,S):R.length=S),o.applyFromCharCode(R)}(_=o.transformTo(l.uint8array?"uint8array":"array",_))},o.inherits(g,d),g.prototype.processChunk=function(_){var k=o.transformTo(l.uint8array?"uint8array":"array",_.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var w=k;(k=new Uint8Array(w.length+this.leftOver.length)).set(this.leftOver,0),k.set(w,this.leftOver.length)}else k=this.leftOver.concat(k);this.leftOver=null}var S=function(C,I){var R;for((I=I||C.length)>C.length&&(I=C.length),R=I-1;0<=R&&(192&C[R])==128;)R--;return R<0||R===0?I:R+m[C[R]]>I?R:I}(k),T=k;S!==k.length&&(l.uint8array?(T=k.subarray(0,S),this.leftOver=k.subarray(S,k.length)):(T=k.slice(0,S),this.leftOver=k.slice(S,k.length))),this.push({data:a.utf8decode(T),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(s,n,a){var o=s("./support"),l=s("./base64"),i=s("./nodejsUtils"),d=s("./external");function m(w){return w}function p(w,S){for(var T=0;T>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 k,w,S,T=_.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});_.index+4>>6:(_<65536?v[S++]=224|_>>>12:(v[S++]=240|_>>>18,v[S++]=128|_>>>12&63),v[S++]=128|_>>>6&63),v[S++]=128|63&_);return v},a.buf2binstring=function(g){return p(g,g.length)},a.binstring2buf=function(g){for(var v=new o.Buf8(g.length),_=0,k=v.length;_>10&1023,C[k++]=56320|1023&w)}return p(C,k)},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(s,n,a){n.exports=function(o,l,i,d){for(var m=65535&o|0,p=o>>>16&65535|0,g=0;i!==0;){for(i-=g=2e3>>1:l>>>1;i[d]=l}return i}();n.exports=function(l,i,d,m){var p=o,g=m+d;l^=-1;for(var v=m;v>>8^p[255&(l^i[v])];return-1^l}},{}],46:[function(s,n,a){var o,l=s("../utils/common"),i=s("./trees"),d=s("./adler32"),m=s("./crc32"),p=s("./messages"),g=0,v=4,_=0,k=-2,w=-1,S=4,T=2,C=8,I=9,R=286,D=30,B=19,$=2*R+1,q=15,W=3,K=258,re=K+W+1,ae=42,oe=113,se=1,pe=2,ie=3,de=4;function ce(ue,$e){return ue.msg=p[$e],$e}function ge(ue){return(ue<<1)-(4ue.avail_out&&(tt=ue.avail_out),tt!==0&&(l.arraySet(ue.output,$e.pending_buf,$e.pending_out,tt,ue.next_out),ue.next_out+=tt,$e.pending_out+=tt,ue.total_out+=tt,ue.avail_out-=tt,$e.pending-=tt,$e.pending===0&&($e.pending_out=0))}function ve(ue,$e){i._tr_flush_block(ue,0<=ue.block_start?ue.block_start:-1,ue.strstart-ue.block_start,$e),ue.block_start=ue.strstart,_e(ue.strm)}function Me(ue,$e){ue.pending_buf[ue.pending++]=$e}function Ze(ue,$e){ue.pending_buf[ue.pending++]=$e>>>8&255,ue.pending_buf[ue.pending++]=255&$e}function Ae(ue,$e){var tt,rt,je=ue.max_chain_length,it=ue.strstart,Se=ue.prev_length,et=ue.nice_match,Qe=ue.strstart>ue.w_size-re?ue.strstart-(ue.w_size-re):0,He=ue.window,ot=ue.w_mask,ut=ue.prev,ft=ue.strstart+K,ct=He[it+Se-1],Tt=He[it+Se];ue.prev_length>=ue.good_match&&(je>>=2),et>ue.lookahead&&(et=ue.lookahead);do if(He[(tt=$e)+Se]===Tt&&He[tt+Se-1]===ct&&He[tt]===He[it]&&He[++tt]===He[it+1]){it+=2,tt++;do;while(He[++it]===He[++tt]&&He[++it]===He[++tt]&&He[++it]===He[++tt]&&He[++it]===He[++tt]&&He[++it]===He[++tt]&&He[++it]===He[++tt]&&He[++it]===He[++tt]&&He[++it]===He[++tt]&&itQe&&--je!=0);return Se<=ue.lookahead?Se:ue.lookahead}function Le(ue){var $e,tt,rt,je,it,Se,et,Qe,He,ot,ut=ue.w_size;do{if(je=ue.window_size-ue.lookahead-ue.strstart,ue.strstart>=ut+(ut-re)){for(l.arraySet(ue.window,ue.window,ut,ut,0),ue.match_start-=ut,ue.strstart-=ut,ue.block_start-=ut,$e=tt=ue.hash_size;rt=ue.head[--$e],ue.head[$e]=ut<=rt?rt-ut:0,--tt;);for($e=tt=ut;rt=ue.prev[--$e],ue.prev[$e]=ut<=rt?rt-ut:0,--tt;);je+=ut}if(ue.strm.avail_in===0)break;if(Se=ue.strm,et=ue.window,Qe=ue.strstart+ue.lookahead,He=je,ot=void 0,ot=Se.avail_in,He=W)for(it=ue.strstart-ue.insert,ue.ins_h=ue.window[it],ue.ins_h=(ue.ins_h<=W&&(ue.ins_h=(ue.ins_h<=W)if(rt=i._tr_tally(ue,ue.strstart-ue.match_start,ue.match_length-W),ue.lookahead-=ue.match_length,ue.match_length<=ue.max_lazy_match&&ue.lookahead>=W){for(ue.match_length--;ue.strstart++,ue.ins_h=(ue.ins_h<=W&&(ue.ins_h=(ue.ins_h<=W&&ue.match_length<=ue.prev_length){for(je=ue.strstart+ue.lookahead-W,rt=i._tr_tally(ue,ue.strstart-1-ue.prev_match,ue.prev_length-W),ue.lookahead-=ue.prev_length-1,ue.prev_length-=2;++ue.strstart<=je&&(ue.ins_h=(ue.ins_h<ue.pending_buf_size-5&&(tt=ue.pending_buf_size-5);;){if(ue.lookahead<=1){if(Le(ue),ue.lookahead===0&&$e===g)return se;if(ue.lookahead===0)break}ue.strstart+=ue.lookahead,ue.lookahead=0;var rt=ue.block_start+tt;if((ue.strstart===0||ue.strstart>=rt)&&(ue.lookahead=ue.strstart-rt,ue.strstart=rt,ve(ue,!1),ue.strm.avail_out===0)||ue.strstart-ue.block_start>=ue.w_size-re&&(ve(ue,!1),ue.strm.avail_out===0))return se}return ue.insert=0,$e===v?(ve(ue,!0),ue.strm.avail_out===0?ie:de):(ue.strstart>ue.block_start&&(ve(ue,!1),ue.strm.avail_out),se)}),new Ie(4,4,8,4,Ue),new Ie(4,5,16,8,Ue),new Ie(4,6,32,32,Ue),new Ie(4,4,16,16,Ve),new Ie(8,16,32,32,Ve),new Ie(8,16,128,128,Ve),new Ie(8,32,128,256,Ve),new Ie(32,128,258,1024,Ve),new Ie(32,258,258,4096,Ve)],a.deflateInit=function(ue,$e){return st(ue,$e,C,15,8,0)},a.deflateInit2=st,a.deflateReset=Pe,a.deflateResetKeep=wt,a.deflateSetHeader=function(ue,$e){return ue&&ue.state?ue.state.wrap!==2?k:(ue.state.gzhead=$e,_):k},a.deflate=function(ue,$e){var tt,rt,je,it;if(!ue||!ue.state||5<$e||$e<0)return ue?ce(ue,k):k;if(rt=ue.state,!ue.output||!ue.input&&ue.avail_in!==0||rt.status===666&&$e!==v)return ce(ue,ue.avail_out===0?-5:k);if(rt.strm=ue,tt=rt.last_flush,rt.last_flush=$e,rt.status===ae)if(rt.wrap===2)ue.adler=0,Me(rt,31),Me(rt,139),Me(rt,8),rt.gzhead?(Me(rt,(rt.gzhead.text?1:0)+(rt.gzhead.hcrc?2:0)+(rt.gzhead.extra?4:0)+(rt.gzhead.name?8:0)+(rt.gzhead.comment?16:0)),Me(rt,255&rt.gzhead.time),Me(rt,rt.gzhead.time>>8&255),Me(rt,rt.gzhead.time>>16&255),Me(rt,rt.gzhead.time>>24&255),Me(rt,rt.level===9?2:2<=rt.strategy||rt.level<2?4:0),Me(rt,255&rt.gzhead.os),rt.gzhead.extra&&rt.gzhead.extra.length&&(Me(rt,255&rt.gzhead.extra.length),Me(rt,rt.gzhead.extra.length>>8&255)),rt.gzhead.hcrc&&(ue.adler=m(ue.adler,rt.pending_buf,rt.pending,0)),rt.gzindex=0,rt.status=69):(Me(rt,0),Me(rt,0),Me(rt,0),Me(rt,0),Me(rt,0),Me(rt,rt.level===9?2:2<=rt.strategy||rt.level<2?4:0),Me(rt,3),rt.status=oe);else{var Se=C+(rt.w_bits-8<<4)<<8;Se|=(2<=rt.strategy||rt.level<2?0:rt.level<6?1:rt.level===6?2:3)<<6,rt.strstart!==0&&(Se|=32),Se+=31-Se%31,rt.status=oe,Ze(rt,Se),rt.strstart!==0&&(Ze(rt,ue.adler>>>16),Ze(rt,65535&ue.adler)),ue.adler=1}if(rt.status===69)if(rt.gzhead.extra){for(je=rt.pending;rt.gzindex<(65535&rt.gzhead.extra.length)&&(rt.pending!==rt.pending_buf_size||(rt.gzhead.hcrc&&rt.pending>je&&(ue.adler=m(ue.adler,rt.pending_buf,rt.pending-je,je)),_e(ue),je=rt.pending,rt.pending!==rt.pending_buf_size));)Me(rt,255&rt.gzhead.extra[rt.gzindex]),rt.gzindex++;rt.gzhead.hcrc&&rt.pending>je&&(ue.adler=m(ue.adler,rt.pending_buf,rt.pending-je,je)),rt.gzindex===rt.gzhead.extra.length&&(rt.gzindex=0,rt.status=73)}else rt.status=73;if(rt.status===73)if(rt.gzhead.name){je=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>je&&(ue.adler=m(ue.adler,rt.pending_buf,rt.pending-je,je)),_e(ue),je=rt.pending,rt.pending===rt.pending_buf_size)){it=1;break}it=rt.gzindexje&&(ue.adler=m(ue.adler,rt.pending_buf,rt.pending-je,je)),it===0&&(rt.gzindex=0,rt.status=91)}else rt.status=91;if(rt.status===91)if(rt.gzhead.comment){je=rt.pending;do{if(rt.pending===rt.pending_buf_size&&(rt.gzhead.hcrc&&rt.pending>je&&(ue.adler=m(ue.adler,rt.pending_buf,rt.pending-je,je)),_e(ue),je=rt.pending,rt.pending===rt.pending_buf_size)){it=1;break}it=rt.gzindexje&&(ue.adler=m(ue.adler,rt.pending_buf,rt.pending-je,je)),it===0&&(rt.status=103)}else rt.status=103;if(rt.status===103&&(rt.gzhead.hcrc?(rt.pending+2>rt.pending_buf_size&&_e(ue),rt.pending+2<=rt.pending_buf_size&&(Me(rt,255&ue.adler),Me(rt,ue.adler>>8&255),ue.adler=0,rt.status=oe)):rt.status=oe),rt.pending!==0){if(_e(ue),ue.avail_out===0)return rt.last_flush=-1,_}else if(ue.avail_in===0&&ge($e)<=ge(tt)&&$e!==v)return ce(ue,-5);if(rt.status===666&&ue.avail_in!==0)return ce(ue,-5);if(ue.avail_in!==0||rt.lookahead!==0||$e!==g&&rt.status!==666){var et=rt.strategy===2?function(Qe,He){for(var ot;;){if(Qe.lookahead===0&&(Le(Qe),Qe.lookahead===0)){if(He===g)return se;break}if(Qe.match_length=0,ot=i._tr_tally(Qe,0,Qe.window[Qe.strstart]),Qe.lookahead--,Qe.strstart++,ot&&(ve(Qe,!1),Qe.strm.avail_out===0))return se}return Qe.insert=0,He===v?(ve(Qe,!0),Qe.strm.avail_out===0?ie:de):Qe.last_lit&&(ve(Qe,!1),Qe.strm.avail_out===0)?se:pe}(rt,$e):rt.strategy===3?function(Qe,He){for(var ot,ut,ft,ct,Tt=Qe.window;;){if(Qe.lookahead<=K){if(Le(Qe),Qe.lookahead<=K&&He===g)return se;if(Qe.lookahead===0)break}if(Qe.match_length=0,Qe.lookahead>=W&&0Qe.lookahead&&(Qe.match_length=Qe.lookahead)}if(Qe.match_length>=W?(ot=i._tr_tally(Qe,1,Qe.match_length-W),Qe.lookahead-=Qe.match_length,Qe.strstart+=Qe.match_length,Qe.match_length=0):(ot=i._tr_tally(Qe,0,Qe.window[Qe.strstart]),Qe.lookahead--,Qe.strstart++),ot&&(ve(Qe,!1),Qe.strm.avail_out===0))return se}return Qe.insert=0,He===v?(ve(Qe,!0),Qe.strm.avail_out===0?ie:de):Qe.last_lit&&(ve(Qe,!1),Qe.strm.avail_out===0)?se:pe}(rt,$e):o[rt.level].func(rt,$e);if(et!==ie&&et!==de||(rt.status=666),et===se||et===ie)return ue.avail_out===0&&(rt.last_flush=-1),_;if(et===pe&&($e===1?i._tr_align(rt):$e!==5&&(i._tr_stored_block(rt,0,0,!1),$e===3&&(Te(rt.head),rt.lookahead===0&&(rt.strstart=0,rt.block_start=0,rt.insert=0))),_e(ue),ue.avail_out===0))return rt.last_flush=-1,_}return $e!==v?_:rt.wrap<=0?1:(rt.wrap===2?(Me(rt,255&ue.adler),Me(rt,ue.adler>>8&255),Me(rt,ue.adler>>16&255),Me(rt,ue.adler>>24&255),Me(rt,255&ue.total_in),Me(rt,ue.total_in>>8&255),Me(rt,ue.total_in>>16&255),Me(rt,ue.total_in>>24&255)):(Ze(rt,ue.adler>>>16),Ze(rt,65535&ue.adler)),_e(ue),0=tt.w_size&&(it===0&&(Te(tt.head),tt.strstart=0,tt.block_start=0,tt.insert=0),He=new l.Buf8(tt.w_size),l.arraySet(He,$e,ot-tt.w_size,tt.w_size,0),$e=He,ot=tt.w_size),Se=ue.avail_in,et=ue.next_in,Qe=ue.input,ue.avail_in=ot,ue.next_in=0,ue.input=$e,Le(tt);tt.lookahead>=W;){for(rt=tt.strstart,je=tt.lookahead-(W-1);tt.ins_h=(tt.ins_h<>>=W=q>>>24,I-=W,(W=q>>>16&255)===0)pe[p++]=65535&q;else{if(!(16&W)){if(!(64&W)){q=R[(65535&q)+(C&(1<>>=W,I-=W),I<15&&(C+=se[d++]<>>=W=q>>>24,I-=W,!(16&(W=q>>>16&255))){if(!(64&W)){q=D[(65535&q)+(C&(1<>>=W,I-=W,(W=p-g)>3,C&=(1<<(I-=K<<3))-1,o.next_in=d,o.next_out=p,o.avail_in=d>>24&255)+(ae>>>8&65280)+((65280&ae)<<8)+((255&ae)<<24)}function C(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function I(ae){var oe;return ae&&ae.state?(oe=ae.state,ae.total_in=ae.total_out=oe.total=0,ae.msg="",oe.wrap&&(ae.adler=1&oe.wrap),oe.mode=k,oe.last=0,oe.havedict=0,oe.dmax=32768,oe.head=null,oe.hold=0,oe.bits=0,oe.lencode=oe.lendyn=new o.Buf32(w),oe.distcode=oe.distdyn=new o.Buf32(S),oe.sane=1,oe.back=-1,v):_}function R(ae){var oe;return ae&&ae.state?((oe=ae.state).wsize=0,oe.whave=0,oe.wnext=0,I(ae)):_}function D(ae,oe){var se,pe;return ae&&ae.state?(pe=ae.state,oe<0?(se=0,oe=-oe):(se=1+(oe>>4),oe<48&&(oe&=15)),oe&&(oe<8||15=de.wsize?(o.arraySet(de.window,oe,se-de.wsize,de.wsize,0),de.wnext=0,de.whave=de.wsize):(pe<(ie=de.wsize-de.wnext)&&(ie=pe),o.arraySet(de.window,oe,se-pe,ie,de.wnext),(pe-=ie)?(o.arraySet(de.window,oe,se-pe,pe,0),de.wnext=pe,de.whave=de.wsize):(de.wnext+=ie,de.wnext===de.wsize&&(de.wnext=0),de.whave>>8&255,se.check=i(se.check,it,2,0),ve=_e=0,se.mode=2;break}if(se.flags=0,se.head&&(se.head.done=!1),!(1&se.wrap)||(((255&_e)<<8)+(_e>>8))%31){ae.msg="incorrect header check",se.mode=30;break}if((15&_e)!=8){ae.msg="unknown compression method",se.mode=30;break}if(ve-=4,ue=8+(15&(_e>>>=4)),se.wbits===0)se.wbits=ue;else if(ue>se.wbits){ae.msg="invalid window size",se.mode=30;break}se.dmax=1<>8&1),512&se.flags&&(it[0]=255&_e,it[1]=_e>>>8&255,se.check=i(se.check,it,2,0)),ve=_e=0,se.mode=3;case 3:for(;ve<32;){if(ge===0)break e;ge--,_e+=pe[de++]<>>8&255,it[2]=_e>>>16&255,it[3]=_e>>>24&255,se.check=i(se.check,it,4,0)),ve=_e=0,se.mode=4;case 4:for(;ve<16;){if(ge===0)break e;ge--,_e+=pe[de++]<>8),512&se.flags&&(it[0]=255&_e,it[1]=_e>>>8&255,se.check=i(se.check,it,2,0)),ve=_e=0,se.mode=5;case 5:if(1024&se.flags){for(;ve<16;){if(ge===0)break e;ge--,_e+=pe[de++]<>>8&255,se.check=i(se.check,it,2,0)),ve=_e=0}else se.head&&(se.head.extra=null);se.mode=6;case 6:if(1024&se.flags&&(ge<(Ae=se.length)&&(Ae=ge),Ae&&(se.head&&(ue=se.head.extra_len-se.length,se.head.extra||(se.head.extra=new Array(se.head.extra_len)),o.arraySet(se.head.extra,pe,de,Ae,ue)),512&se.flags&&(se.check=i(se.check,pe,Ae,de)),ge-=Ae,de+=Ae,se.length-=Ae),se.length))break e;se.length=0,se.mode=7;case 7:if(2048&se.flags){if(ge===0)break e;for(Ae=0;ue=pe[de+Ae++],se.head&&ue&&se.length<65536&&(se.head.name+=String.fromCharCode(ue)),ue&&Ae>9&1,se.head.done=!0),ae.adler=se.check=0,se.mode=12;break;case 10:for(;ve<32;){if(ge===0)break e;ge--,_e+=pe[de++]<>>=7&ve,ve-=7&ve,se.mode=27;break}for(;ve<3;){if(ge===0)break e;ge--,_e+=pe[de++]<>>=1)){case 0:se.mode=14;break;case 1:if(K(se),se.mode=20,oe!==6)break;_e>>>=2,ve-=2;break e;case 2:se.mode=17;break;case 3:ae.msg="invalid block type",se.mode=30}_e>>>=2,ve-=2;break;case 14:for(_e>>>=7&ve,ve-=7&ve;ve<32;){if(ge===0)break e;ge--,_e+=pe[de++]<>>16^65535)){ae.msg="invalid stored block lengths",se.mode=30;break}if(se.length=65535&_e,ve=_e=0,se.mode=15,oe===6)break e;case 15:se.mode=16;case 16:if(Ae=se.length){if(ge>>=5,ve-=5,se.ndist=1+(31&_e),_e>>>=5,ve-=5,se.ncode=4+(15&_e),_e>>>=4,ve-=4,286>>=3,ve-=3}for(;se.have<19;)se.lens[Se[se.have++]]=0;if(se.lencode=se.lendyn,se.lenbits=7,tt={bits:se.lenbits},$e=m(0,se.lens,0,19,se.lencode,0,se.work,tt),se.lenbits=tt.bits,$e){ae.msg="invalid code lengths set",se.mode=30;break}se.have=0,se.mode=19;case 19:for(;se.have>>16&255,We=65535&je,!((Ve=je>>>24)<=ve);){if(ge===0)break e;ge--,_e+=pe[de++]<>>=Ve,ve-=Ve,se.lens[se.have++]=We;else{if(We===16){for(rt=Ve+2;ve>>=Ve,ve-=Ve,se.have===0){ae.msg="invalid bit length repeat",se.mode=30;break}ue=se.lens[se.have-1],Ae=3+(3&_e),_e>>>=2,ve-=2}else if(We===17){for(rt=Ve+3;ve>>=Ve)),_e>>>=3,ve-=3}else{for(rt=Ve+7;ve>>=Ve)),_e>>>=7,ve-=7}if(se.have+Ae>se.nlen+se.ndist){ae.msg="invalid bit length repeat",se.mode=30;break}for(;Ae--;)se.lens[se.have++]=ue}}if(se.mode===30)break;if(se.lens[256]===0){ae.msg="invalid code -- missing end-of-block",se.mode=30;break}if(se.lenbits=9,tt={bits:se.lenbits},$e=m(p,se.lens,0,se.nlen,se.lencode,0,se.work,tt),se.lenbits=tt.bits,$e){ae.msg="invalid literal/lengths set",se.mode=30;break}if(se.distbits=6,se.distcode=se.distdyn,tt={bits:se.distbits},$e=m(g,se.lens,se.nlen,se.ndist,se.distcode,0,se.work,tt),se.distbits=tt.bits,$e){ae.msg="invalid distances set",se.mode=30;break}if(se.mode=20,oe===6)break e;case 20:se.mode=21;case 21:if(6<=ge&&258<=Te){ae.next_out=ce,ae.avail_out=Te,ae.next_in=de,ae.avail_in=ge,se.hold=_e,se.bits=ve,d(ae,Ze),ce=ae.next_out,ie=ae.output,Te=ae.avail_out,de=ae.next_in,pe=ae.input,ge=ae.avail_in,_e=se.hold,ve=se.bits,se.mode===12&&(se.back=-1);break}for(se.back=0;Ie=(je=se.lencode[_e&(1<>>16&255,We=65535&je,!((Ve=je>>>24)<=ve);){if(ge===0)break e;ge--,_e+=pe[de++]<>wt)])>>>16&255,We=65535&je,!(wt+(Ve=je>>>24)<=ve);){if(ge===0)break e;ge--,_e+=pe[de++]<>>=wt,ve-=wt,se.back+=wt}if(_e>>>=Ve,ve-=Ve,se.back+=Ve,se.length=We,Ie===0){se.mode=26;break}if(32&Ie){se.back=-1,se.mode=12;break}if(64&Ie){ae.msg="invalid literal/length code",se.mode=30;break}se.extra=15&Ie,se.mode=22;case 22:if(se.extra){for(rt=se.extra;ve>>=se.extra,ve-=se.extra,se.back+=se.extra}se.was=se.length,se.mode=23;case 23:for(;Ie=(je=se.distcode[_e&(1<>>16&255,We=65535&je,!((Ve=je>>>24)<=ve);){if(ge===0)break e;ge--,_e+=pe[de++]<>wt)])>>>16&255,We=65535&je,!(wt+(Ve=je>>>24)<=ve);){if(ge===0)break e;ge--,_e+=pe[de++]<>>=wt,ve-=wt,se.back+=wt}if(_e>>>=Ve,ve-=Ve,se.back+=Ve,64&Ie){ae.msg="invalid distance code",se.mode=30;break}se.offset=We,se.extra=15&Ie,se.mode=24;case 24:if(se.extra){for(rt=se.extra;ve>>=se.extra,ve-=se.extra,se.back+=se.extra}if(se.offset>se.dmax){ae.msg="invalid distance too far back",se.mode=30;break}se.mode=25;case 25:if(Te===0)break e;if(Ae=Ze-Te,se.offset>Ae){if((Ae=se.offset-Ae)>se.whave&&se.sane){ae.msg="invalid distance too far back",se.mode=30;break}Le=Ae>se.wnext?(Ae-=se.wnext,se.wsize-Ae):se.wnext-Ae,Ae>se.length&&(Ae=se.length),Ue=se.window}else Ue=ie,Le=ce-se.offset,Ae=se.length;for(Te$?(W=Le[Ue+S[oe]],ve[Me+S[oe]]):(W=96,0),C=1<>ce)+(I-=C)]=q<<24|W<<16|K|0,I!==0;);for(C=1<>=1;if(C!==0?(_e&=C-1,_e+=C):_e=0,oe++,--Ze[ae]==0){if(ae===pe)break;ae=g[v+S[oe]]}if(ie>>7)]}function Me(je,it){je.pending_buf[je.pending++]=255&it,je.pending_buf[je.pending++]=it>>>8&255}function Ze(je,it,Se){je.bi_valid>T-Se?(je.bi_buf|=it<>T-je.bi_valid,je.bi_valid+=Se-T):(je.bi_buf|=it<>>=1,Se<<=1,0<--it;);return Se>>>1}function Ue(je,it,Se){var et,Qe,He=new Array(S+1),ot=0;for(et=1;et<=S;et++)He[et]=ot=ot+Se[et-1]<<1;for(Qe=0;Qe<=it;Qe++){var ut=je[2*Qe+1];ut!==0&&(je[2*Qe]=Le(He[ut]++,ut))}}function Ve(je){var it;for(it=0;it>1;1<=Se;Se--)wt(je,He,Se);for(Qe=ft;Se=je.heap[1],je.heap[1]=je.heap[je.heap_len--],wt(je,He,1),et=je.heap[1],je.heap[--je.heap_max]=Se,je.heap[--je.heap_max]=et,He[2*Qe]=He[2*Se]+He[2*et],je.depth[Qe]=(je.depth[Se]>=je.depth[et]?je.depth[Se]:je.depth[et])+1,He[2*Se+1]=He[2*et+1]=Qe,je.heap[1]=Qe++,wt(je,He,1),2<=je.heap_len;);je.heap[--je.heap_max]=je.heap[1],function(Tt,Ot){var rr,Lr,cr,Mr,As,Et,Pt=Ot.dyn_tree,Sr=Ot.max_code,fs=Ot.stat_desc.static_tree,Ws=Ot.stat_desc.has_stree,tn=Ot.stat_desc.extra_bits,xi=Ot.stat_desc.extra_base,La=Ot.stat_desc.max_length,un=0;for(Mr=0;Mr<=S;Mr++)Tt.bl_count[Mr]=0;for(Pt[2*Tt.heap[Tt.heap_max]+1]=0,rr=Tt.heap_max+1;rr>=7;Qe<_;Qe++)for(ge[Qe]=He<<7,it=0;it<1<>>=1)if(1&ct&&ut.dyn_ltree[2*ft]!==0)return l;if(ut.dyn_ltree[18]!==0||ut.dyn_ltree[20]!==0||ut.dyn_ltree[26]!==0)return i;for(ft=32;ft>>3,(He=je.static_len+3+7>>>3)<=Qe&&(Qe=He)):Qe=He=Se+5,Se+4<=Qe&&it!==-1?rt(je,it,Se,et):je.strategy===4||He===Qe?(Ze(je,2+(et?1:0),3),Pe(je,re,ae)):(Ze(je,4+(et?1:0),3),function(ut,ft,ct,Tt){var Ot;for(Ze(ut,ft-257,5),Ze(ut,ct-1,5),Ze(ut,Tt-4,4),Ot=0;Ot>>8&255,je.pending_buf[je.d_buf+2*je.last_lit+1]=255&it,je.pending_buf[je.l_buf+je.last_lit]=255&Se,je.last_lit++,it===0?je.dyn_ltree[2*Se]++:(je.matches++,it--,je.dyn_ltree[2*(se[Se]+g+1)]++,je.dyn_dtree[2*ve(it)]++),je.last_lit===je.lit_bufsize-1},a._tr_align=function(je){Ze(je,2,3),Ae(je,I,re),function(it){it.bi_valid===16?(Me(it,it.bi_buf),it.bi_buf=0,it.bi_valid=0):8<=it.bi_valid&&(it.pending_buf[it.pending++]=255&it.bi_buf,it.bi_buf>>=8,it.bi_valid-=8)}(je)}},{"../utils/common":41}],53:[function(s,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(s,n,a){(function(o){(function(l,i){if(!l.setImmediate){var d,m,p,g,v=1,_={},k=!1,w=l.document,S=Object.getPrototypeOf&&Object.getPrototypeOf(l);S=S&&S.setTimeout?S:l,d={}.toString.call(l.process)==="[object process]"?function(R){process.nextTick(function(){C(R)})}:function(){if(l.postMessage&&!l.importScripts){var R=!0,D=l.onmessage;return l.onmessage=function(){R=!1},l.postMessage("","*"),l.onmessage=D,R}}()?(g="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",I,!1):l.attachEvent("onmessage",I),function(R){l.postMessage(g+R,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(R){C(R.data)},function(R){p.port2.postMessage(R)}):w&&"onreadystatechange"in w.createElement("script")?(m=w.documentElement,function(R){var D=w.createElement("script");D.onreadystatechange=function(){C(R),D.onreadystatechange=null,m.removeChild(D),D=null},m.appendChild(D)}):function(R){setTimeout(C,0,R)},S.setImmediate=function(R){typeof R!="function"&&(R=new Function(""+R));for(var D=new Array(arguments.length-1),B=0;B"u"?o===void 0?this:o:self)}).call(this,typeof Ny<"u"?Ny:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(fqe);var vTt=fqe.exports;const _Tt=ho(vTt);function mhe(e,t=400,s=75){return e&&`${e.replace("/storage/v1/object/public/","/storage/v1/render/image/public/")}?width=${t}&quality=${s}&resize=contain`}const bTt=()=>{const{isAdmin:e}=Gr(),[t,s]=A.useState(null),[n,a]=A.useState(null),[o,l]=A.useState("all"),[i,d]=A.useState(new Set),[m,p]=A.useState(!1),[g,v]=A.useState(!1),[_,k]=A.useState("images"),[w,S]=A.useState(null),{data:T=[],isLoading:C}=Ht({queryKey:["social-swag-2"],queryFn:async()=>{const{data:ge,error:Te}=await Y.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(Te)throw Te;return ge}}),{data:I=[]}=Ht({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:ge,error:Te}=await Y.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(Te)throw Te;return ge}}),{data:R=[]}=Ht({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:ge,error:Te}=await Y.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(Te)throw Te;return ge}}),{data:D=[]}=Ht({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:ge,error:Te}=await Y.from("social_accounts").select("id, platform").eq("is_active",!0);if(Te)throw Te;return ge||[]}}),B=D.length>0,$=A.useMemo(()=>o==="all"?null:R.find(ge=>ge.month===o)||null,[o,R]),q=A.useMemo(()=>[...new Set(T.map(Te=>Te.month))].sort((Te,_e)=>_e.localeCompare(Te)),[T]);A.useEffect(()=>{q.length>0&&o==="all"&&l(q[0])},[q,o]);const W=ge=>{try{const Te=Ove(ge,"yyyy-MM",new Date);return Xr(Te,"MMMM yyyy")}catch{return ge}},K=A.useMemo(()=>o==="all"?T:T.filter(ge=>ge.month===o),[o,T]),re=A.useMemo(()=>{var ge;return o==="all"?null:((ge=I.find(Te=>Te.month===o))==null?void 0:ge.canva_link)||null},[o,I]),ae=async ge=>{try{await navigator.clipboard.writeText(ge),we.success("Caption copied to clipboard!")}catch{we.error("Failed to copy caption")}},oe=async(ge,Te)=>{try{const ve=await(await fetch(ge)).blob(),Me=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ze=navigator.canShare&&navigator.canShare({files:[new File([ve],"test.jpg",{type:"image/jpeg"})]});if(Me&&Ze){const Ae=new File([ve],`social-swag-${Te}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Ae],title:"Social Swag Image"}),we.success("Image ready to save!")}else{const Ae=window.URL.createObjectURL(ve),Le=document.createElement("a");Le.href=Ae,Le.download=`social-swag-${Te}.jpg`,document.body.appendChild(Le),Le.click(),document.body.removeChild(Le),window.URL.revokeObjectURL(Ae),we.success("Image downloaded!")}}catch(_e){_e.name!=="AbortError"&&we.error("Failed to download image")}},se=ge=>{d(Te=>{const _e=new Set(Te);return _e.has(ge)?_e.delete(ge):_e.add(ge),_e})},pe=()=>{d(new Set(K.map(ge=>ge.id)))},ie=()=>{d(new Set),p(!1)},de=async()=>{const ge=K.filter(Te=>i.has(Te.id));if(ge.length===0){we.error("No images selected");return}v(!0),we.info(`Preparing ${ge.length} images for download...`);try{const Te=new _Tt,_e=[...ge].sort((Le,Ue)=>Le.sort_order-Ue.sort_order);for(let Le=0;Le<_e.length;Le++){const Ue=_e[Le];try{const Ve=await fetch(Ue.image_url),Ie=await Ve.blob(),We=Ve.headers.get("content-type")||"image/jpeg",wt=We.includes("png")?"png":We.includes("webp")?"webp":"jpg",Pe=`${Le+1}.${wt}`;Te.file(Pe,Ie)}catch{console.error("Failed to fetch image:",Ue.id)}}const ve=o!=="all"?W(o):"Social Swag",Me=await Te.generateAsync({type:"blob"}),Ze=window.URL.createObjectURL(Me),Ae=document.createElement("a");Ae.href=Ze,Ae.download=`${ve}.zip`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),window.URL.revokeObjectURL(Ze),we.success(`Downloaded ${_e.length} images as "${ve}.zip"!`)}catch(Te){console.error("Failed to create ZIP:",Te),we.error("Failed to create download package")}v(!1),ie()},ce=ge=>{m?se(ge.id):s(ge)};return r.jsx(Ur,{title:"Social Swag 2.0",children:r.jsxs("div",{className:"space-y-8",children:[r.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:[r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[r.jsxs(_t,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[r.jsx(bn,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),r.jsxs(_t,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[r.jsx(Nl,{className:"h-3 w-3 mr-1"}),T.length," images"]})]}),r.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3",children:"Social Swag 📸"}),r.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!"})]})]}),e?r.jsxs(ii,{defaultValue:"gallery",className:"space-y-6",children:[r.jsxs(si,{className:"grid w-full max-w-md grid-cols-2",children:[r.jsxs(Kr,{value:"gallery",className:"gap-2",children:[r.jsx(Nl,{className:"h-4 w-4"}),"Gallery"]}),r.jsxs(Kr,{value:"scheduled",className:"gap-2",children:[r.jsx(sg,{className:"h-4 w-4"}),"Scheduled"]})]}),r.jsxs(hs,{value:"gallery",className:"space-y-6",children:[e?B?r.jsx(ze,{className:"border rounded-xl",children:r.jsx(qe,{className:"p-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{className:"p-3 rounded-full bg-muted text-2xl",children:"📸"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Ready to post!"}),r.jsx("p",{className:"text-muted-foreground",children:'Click any image and use "Create Post" to share directly to your connected accounts.'})]}),r.jsx(X,{variant:"outline",size:"sm",asChild:!0,className:"gap-2",children:r.jsx(vo,{to:"/social-connections",children:"Manage Accounts"})})]})})}):r.jsx(ze,{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:r.jsx(qe,{className:"p-6",children:r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:r.jsx(fu,{className:"h-5 w-5 text-blue-600"})}),r.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:r.jsx(Lu,{className:"h-5 w-5 text-pink-600"})})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"font-semibold text-foreground mb-1",children:"Post directly to social media"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your Facebook & Instagram accounts to post images with one click!"})]}),r.jsx(X,{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:r.jsxs(vo,{to:"/social-connections",children:[r.jsx(Fm,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):r.jsx(ze,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:r.jsx(qe,{className:"p-6",children:r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"p-2 rounded-full bg-muted",children:r.jsx(Pa,{className:"h-5 w-5 text-muted-foreground"})}),r.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:r.jsx(fu,{className:"h-5 w-5 text-blue-400"})}),r.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:r.jsx(Lu,{className:"h-5 w-5 text-pink-400"})})]}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),r.jsx(_t,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),r.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!"})]})]})})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(ge=>r.jsx("button",{onClick:()=>l(ge),className:Vt("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"&&(re?r.jsxs("a",{href:re,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[r.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",W(o)," Images in Canva"]}):r.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[r.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",W(o)," Images in Canva"]}))]}),r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[r.jsxs("button",{onClick:()=>{k("images"),ie()},className:Vt("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:[r.jsx(Nl,{className:"h-4 w-4"}),"Images"]}),r.jsxs("button",{onClick:()=>{k("reels"),ie()},className:Vt("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:[r.jsx(Ud,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:m?r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:pe,className:"gap-2",children:["Select All (",K.length,")"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[r.jsx(Xs,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(X,{size:"sm",onClick:de,disabled:g,className:"gap-2",children:[r.jsx(Fi,{className:"h-4 w-4"}),g?"Downloading...":`Download ${i.size} Selected`]}),r.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:"Please ensure your browser allows downloads from the LevelUp Dashboard."})]})]}):r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[r.jsx(mi,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&r.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:K.map(ge=>{const Te=i.has(ge.id);return r.jsx(ze,{className:Vt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",m&&Te&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(ge),children:r.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[r.jsx("img",{src:mhe(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&&!m&&r.jsx("div",{className:"absolute top-0 left-0 w-24 h-24 overflow-hidden pointer-events-none",children:r.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:Xr(new Date(ge.post_date+"T00:00:00"),"MMM d")})}),m&&r.jsx("div",{className:Vt("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&&r.jsx(mi,{className:"h-4 w-4"})}),!m&&r.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:r.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)})}),K.length===0&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Nl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&r.jsx(r.Fragment,{children:$?r.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:r.jsx(ze,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:r.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[r.jsx("img",{src:mhe($.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"}),r.jsx("div",{className:"absolute top-2 left-2",children:r.jsxs(_t,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[r.jsx(Ud,{className:"h-3 w-3 mr-1"}),"Reel"]})}),r.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:r.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"})})]})})}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Ud,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),r.jsx(Ir,{open:!!t,onOpenChange:()=>s(null),children:r.jsx(Er,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:r.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:t&&r.jsxs("div",{className:"flex flex-col md:flex-row",children:[r.jsx("div",{className:"md:w-1/2 bg-muted",children:r.jsx("div",{className:"aspect-[4/5]",children:r.jsx("img",{src:mhe(t.image_url,900,85),alt:"Social swag",className:"w-full h-full object-cover",decoding:"async"})})}),r.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground mb-4",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(An,{className:"h-4 w-4"}),Xr(new Date(t.created_at),"MMMM d, yyyy")]}),t.post_date&&r.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:[r.jsx(An,{className:"h-3.5 w-3.5"}),"Post on ",Xr(new Date(t.post_date+"T00:00:00"),"MMMM d, yyyy")]})]}),r.jsxs("div",{className:"flex-1 min-h-0",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),r.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:r.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:t.caption})})]}),r.jsxs("div",{className:"flex flex-col gap-3 mt-6",children:[e&&r.jsxs(X,{onClick:()=>{S({imageUrl:t.image_url,imageId:t.id,caption:t.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:[r.jsx(ai,{className:"h-4 w-4"}),"Create Post"]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsxs(X,{variant:"outline",onClick:()=>ae(t.caption),className:"flex-1 gap-2",children:[r.jsx(uo,{className:"h-4 w-4"}),"Copy Caption"]}),r.jsxs(X,{variant:"outline",onClick:()=>oe(t.image_url,t.id),className:"flex-1 gap-2",children:[r.jsx(Fi,{className:"h-4 w-4"}),"Download"]})]})]})]})]})})})}),r.jsx(Ir,{open:!!n,onOpenChange:()=>a(null),children:r.jsx(Er,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:r.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&r.jsxs("div",{className:"flex flex-col md:flex-row",children:[r.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:r.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:r.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),r.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[r.jsx(Ud,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&r.jsxs("div",{className:"flex-1 min-h-0",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),r.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:r.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&r.jsxs(X,{onClick:()=>ae(n.caption||""),className:"flex-1 gap-2",children:[r.jsx(uo,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&r.jsxs(X,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[r.jsx(jn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),r.jsx(xTt,{open:!!w,onOpenChange:ge=>!ge&&S(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})]}),r.jsx(hs,{value:"scheduled",children:r.jsx(yTt,{})})]}):r.jsxs("div",{className:"space-y-6",children:[r.jsx(ze,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:r.jsx(qe,{className:"p-6",children:r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"p-2 rounded-full bg-muted",children:r.jsx(Pa,{className:"h-5 w-5 text-muted-foreground"})}),r.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:r.jsx(fu,{className:"h-5 w-5 text-blue-400"})}),r.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:r.jsx(Lu,{className:"h-5 w-5 text-pink-400"})})]}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:"Post directly to social media"}),r.jsx(_t,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]}),r.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!"})]})]})})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(ge=>r.jsx("button",{onClick:()=>l(ge),className:Vt("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"&&(re?r.jsxs("a",{href:re,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[r.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",W(o)," Images in Canva"]}):r.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground/50",children:[r.jsx("span",{className:"text-base",children:"🎨"}),"Edit ",W(o)," Images in Canva"]}))]}),r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-1 p-1 bg-muted rounded-full",children:[r.jsxs("button",{onClick:()=>{k("images"),ie()},className:Vt("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:[r.jsx(Nl,{className:"h-4 w-4"}),"Images"]}),r.jsxs("button",{onClick:()=>{k("reels"),ie()},className:Vt("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:[r.jsx(Ud,{className:"h-4 w-4"}),"Reels"]})]}),_==="images"&&r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:m?r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:pe,className:"gap-2",children:["Select All (",K.length,")"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:ie,className:"gap-2",children:[r.jsx(Xs,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&r.jsxs(X,{size:"sm",onClick:de,disabled:g,className:"gap-2",children:[r.jsx(Fi,{className:"h-4 w-4"}),g?"Downloading...":`Download ${i.size} Selected`]})]}):r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>p(!0),className:"gap-2",children:[r.jsx(mi,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&r.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&_==="images"&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:K.map(ge=>{const Te=i.has(ge.id);return r.jsx(ze,{className:Vt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",m&&Te&&"ring-2 ring-primary ring-offset-2"),onClick:()=>ce(ge),children:r.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[r.jsx("img",{src:ge.image_url,alt:"Social swag",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"}),m&&r.jsx("div",{className:Vt("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&&r.jsx(mi,{className:"h-4 w-4"})}),!m&&r.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:r.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)})}),K.length===0&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Nl,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"No images available for this month yet."})]})]}),!C&&_==="reels"&&r.jsx(r.Fragment,{children:$?r.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:r.jsx(ze,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a($),children:r.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[r.jsx("img",{src:$.image_url,alt:"Reel preview",className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"}),r.jsx("div",{className:"absolute top-2 left-2",children:r.jsxs(_t,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[r.jsx(Ud,{className:"h-3 w-3 mr-1"}),"Reel"]})}),r.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/40 transition-colors duration-300 flex items-center justify-center",children:r.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"})})]})})}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Ud,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"No reel available for this month yet."})]})})]}),r.jsx(Ir,{open:!!t,onOpenChange:()=>s(null),children:r.jsx(Er,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:r.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:t&&r.jsxs("div",{className:"flex flex-col md:flex-row",children:[r.jsx("div",{className:"md:w-1/2 bg-muted",children:r.jsx("div",{className:"aspect-[4/5]",children:r.jsx("img",{src:t.image_url,alt:"Social swag",className:"w-full h-full object-cover"})})}),r.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[r.jsx(An,{className:"h-4 w-4"}),Xr(new Date(t.created_at),"MMMM d, yyyy")]}),r.jsxs("div",{className:"flex-1 min-h-0",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),r.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:r.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:t.caption})})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[r.jsxs(X,{variant:"outline",onClick:()=>ae(t.caption),className:"flex-1 gap-2",children:[r.jsx(uo,{className:"h-4 w-4"}),"Copy Caption"]}),r.jsxs(X,{variant:"outline",onClick:()=>oe(t.image_url,t.id),className:"flex-1 gap-2",children:[r.jsx(Fi,{className:"h-4 w-4"}),"Download"]})]})]})]})})})}),r.jsx(Ir,{open:!!n,onOpenChange:()=>a(null),children:r.jsx(Er,{className:"max-w-4xl max-h-[90vh] overflow-hidden p-0",children:r.jsx("div",{className:"max-h-[90vh] overflow-y-auto touch-pan-y",style:{WebkitOverflowScrolling:"touch"},children:n&&r.jsxs("div",{className:"flex flex-col md:flex-row",children:[r.jsx("div",{className:"md:w-1/2 bg-black flex items-center justify-center",children:r.jsx("div",{className:"aspect-[9/16] max-h-[70vh]",children:r.jsx("img",{src:n.image_url,alt:"Reel preview",className:"w-full h-full object-contain"})})}),r.jsxs("div",{className:"md:w-1/2 p-6 flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-4",children:[r.jsx(Ud,{className:"h-4 w-4"}),"Monthly Reel"]}),n.caption&&r.jsxs("div",{className:"flex-1 min-h-0",children:[r.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:"Caption"}),r.jsx("div",{className:"bg-muted/50 rounded-lg p-4 max-h-64 overflow-y-auto",children:r.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap",children:n.caption})})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-6",children:[n.caption&&r.jsxs(X,{onClick:()=>ae(n.caption||""),className:"flex-1 gap-2",children:[r.jsx(uo,{className:"h-4 w-4"}),"Copy Caption"]}),n.canva_link&&r.jsxs(X,{variant:"outline",onClick:()=>window.open(n.canva_link,"_blank"),className:"flex-1 gap-2",children:[r.jsx(jn,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},wTt=()=>{const{swagId:e}=Bl(),{user:t}=Gr(),{toast:s}=_i(),n=Rr(),{trackEngagement:a}=L6(),[o,l]=A.useState(""),{data:i,isLoading:d}=Ht({queryKey:["social-swag-detail",e],queryFn:async()=>{const{data:T,error:C}=await Y.from("social_swag").select("*").eq("id",e).single();if(C)throw C;const{data:I}=await Y.from("social_swag_links").select("*").eq("swag_id",e).order("sort_order");return{...T,links:I||[]}},enabled:!!e});A.useEffect(()=>{i&&a("social_swag",i.id,i.title,"view")},[i==null?void 0:i.id]);const{data:m=[]}=Ht({queryKey:["social-swag-likes",e],queryFn:async()=>{const{data:T,error:C}=await Y.from("social_swag_likes").select("*").eq("swag_id",e);if(C)throw C;return T},enabled:!!e}),{data:p=[]}=Ht({queryKey:["social-swag-comments",e],queryFn:async()=>{const{data:T,error:C}=await Y.from("social_swag_comments").select("*").eq("swag_id",e).order("created_at",{ascending:!1});if(C)throw C;const I=[...new Set(T.map(B=>B.user_id))],{data:R}=await Y.from("profiles").select("id, name").in("id",I),D=new Map((R==null?void 0:R.map(B=>[B.id,B.name]))||[]);return T.map(B=>({...B,user_name:D.get(B.user_id)||"Unknown User"}))},enabled:!!e}),g=Qt({mutationFn:async T=>{const{error:C}=await Y.from("social_swag_comments").insert({swag_id:e,user_id:t.id,content:T});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",e]}),l(""),s({title:"Comment added!"})},onError:T=>{s({title:"Error adding comment",description:T.message,variant:"destructive"})}}),v=Qt({mutationFn:async T=>{const{error:C}=await Y.from("social_swag_comments").delete().eq("id",T);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",e]}),s({title:"Comment deleted"})}}),_=Qt({mutationFn:async()=>{const T=m.find(C=>C.user_id===(t==null?void 0:t.id));if(T){const{error:C}=await Y.from("social_swag_likes").delete().eq("id",T.id);if(C)throw C}else{const{error:C}=await Y.from("social_swag_likes").insert({swag_id:e,user_id:t.id});if(C)throw C}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",e]})}}),k=m.some(T=>T.user_id===(t==null?void 0:t.id)),w=T=>T.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),S=T=>{T.preventDefault(),!(!o.trim()||!t)&&g.mutate(o.trim())};return d?r.jsx(Ur,{title:"Social Swag",children:r.jsx("div",{className:"flex justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):i?r.jsx(Ur,{title:i.title,children:r.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[r.jsx(X,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:r.jsxs(vo,{to:"/social-swag",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Social Swag"]})}),i.preview_image_url&&r.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:r.jsx("img",{src:i.preview_image_url,alt:i.title,className:"w-full max-h-[500px] object-contain"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[r.jsx("div",{className:"space-y-2",children:r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:i.title})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(F3,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),r.jsxs(X,{variant:k?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!t||_.isPending,children:[r.jsx(Cd,{className:`h-4 w-4 ${k?"fill-current":""}`}),m.length," ",m.length===1?"Like":"Likes"]})]})]}),i.description&&r.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:i.description}})]}),i.links.length>0&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(Lo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),r.jsx("div",{className:"grid gap-2",children:i.links.map(T=>r.jsxs(X,{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(T.canva_share_link,"_blank")},children:[r.jsx("span",{className:"font-medium",children:T.title}),r.jsx(jn,{className:"h-4 w-4 text-muted-foreground"})]},T.id))})]})}),r.jsx(kd,{}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[r.jsx(Rl,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),t?r.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[r.jsx(qs,{placeholder:"Add a comment...",value:o,onChange:T=>l(T.target.value),className:"min-h-[80px] resize-none flex-1"}),r.jsx(X,{type:"submit",size:"icon",className:"h-10 w-10",disabled:!o.trim()||g.isPending,children:r.jsx(ai,{className:"h-4 w-4"})})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"Log in to add a comment"}),r.jsx("div",{className:"space-y-4",children:p.length===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-8 text-center",children:r.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):p.map(T=>r.jsx(ze,{children:r.jsx(qe,{className:"pt-4 pb-4",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx(cn,{className:"h-10 w-10 flex-shrink-0",children:r.jsx(dn,{className:"text-sm",children:w(T.user_name||"U")})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"font-medium",children:T.user_name}),r.jsx("span",{className:"text-sm text-muted-foreground",children:gu(new Date(T.created_at),{addSuffix:!0})}),T.user_id===(t==null?void 0:t.id)&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>v.mutate(T.id),children:r.jsx(Os,{className:"h-3 w-3 text-muted-foreground"})})]}),r.jsx("p",{className:"text-sm whitespace-pre-wrap",children:T.content})]})]})})},T.id))})]})]})}):r.jsx(Ur,{title:"Social Swag",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Lo,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold",children:"Item not found"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"This item may have been removed or is not available."}),r.jsx(X,{asChild:!0,className:"mt-4",children:r.jsx(vo,{to:"/social-swag",children:"Back to Social Swag"})})]})})},jTt=({categories:e,privateGroups:t,selectedFilter:s,onFilterChange:n,onlineUsers:a})=>{const[o,l]=A.useState(!0),[i,d]=A.useState(!0),[m,p]=A.useState(!0),g=v=>v.split(" ").map(_=>_[0]).join("").toUpperCase().slice(0,2);return r.jsx("aside",{className:"w-64 shrink-0 hidden lg:block relative z-0",children:r.jsx("div",{className:"sticky top-4 space-y-4 max-h-[calc(100vh-8rem)] overflow-y-auto overscroll-contain",children:r.jsxs("div",{className:"space-y-2 pr-4",children:[r.jsxs(X,{variant:s==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>n("all"),children:[r.jsx(S4,{className:"h-4 w-4 mr-2"}),"All Posts"]}),r.jsxs(Ek,{open:o,onOpenChange:l,children:[r.jsx(Ik,{asChild:!0,children:r.jsxs(X,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[r.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:"Categories"}),o?r.jsx(ad,{className:"h-4 w-4"}):r.jsx(Zi,{className:"h-4 w-4"})]})}),r.jsx(Pk,{className:"space-y-1 pl-2",children:e.map(v=>r.jsxs(X,{variant:s===v.id?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(v.id),children:[r.jsx("span",{className:"mr-2",children:v.icon||"📂"}),r.jsx("span",{className:"truncate",children:v.name})]},v.id))})]}),t.length>0&&r.jsxs(Ek,{open:i,onOpenChange:d,children:[r.jsx(Ik,{asChild:!0,children:r.jsxs(X,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[r.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[r.jsx(Du,{className:"h-3 w-3"}),"Your Groups"]}),i?r.jsx(ad,{className:"h-4 w-4"}):r.jsx(Zi,{className:"h-4 w-4"})]})}),r.jsx(Pk,{className:"space-y-1 pl-2",children:t.map(v=>r.jsxs(X,{variant:s===`group:${v.id}`?"secondary":"ghost",size:"sm",className:"w-full justify-start h-9",onClick:()=>n(`group:${v.id}`),children:[r.jsx("span",{className:"mr-2",children:v.icon||"🔒"}),r.jsx("span",{className:"truncate",children:v.name})]},v.id))})]}),r.jsxs(Ek,{open:m,onOpenChange:p,children:[r.jsx(Ik,{asChild:!0,children:r.jsxs(X,{variant:"ghost",className:"w-full justify-between text-muted-foreground hover:text-foreground",children:[r.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wider flex items-center gap-1",children:[r.jsx(ws,{className:"h-3 w-3"}),"Online Now",a.length>0&&r.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})]}),m?r.jsx(ad,{className:"h-4 w-4"}):r.jsx(Zi,{className:"h-4 w-4"})]})}),r.jsx(Pk,{className:"pl-2 space-y-1",children:a.length===0?r.jsx("p",{className:"text-sm text-muted-foreground py-2 px-2",children:"No one else online right now"}):a.map(v=>r.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded-md hover:bg-muted transition-colors",children:[r.jsxs("div",{className:"relative",children:[r.jsxs(cn,{className:"h-7 w-7",children:[r.jsx(xa,{src:v.avatarUrl}),r.jsx(dn,{className:"text-xs",children:g(v.name)})]}),r.jsx(vh,{className:"h-2.5 w-2.5 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),r.jsx("span",{className:"text-sm truncate",children:v.name})]},v.id))})]})]})})})},kTt=({categories:e,privateGroups:t,selectedFilter:s,onFilterChange:n,onlineUsers:a})=>{const[o,l]=A.useState(!1),i=m=>m.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),d=()=>{if(s==="all")return"All Posts";if(s.startsWith("group:")){const p=s.replace("group:",""),g=t.find(v=>v.id===p);return g?`🔒 ${g.name}`:"Private Group"}const m=e.find(p=>p.id===s);return m?`${m.icon||"📂"} ${m.name}`:"Category"};return r.jsxs("div",{className:"lg:hidden flex items-center gap-2 mb-4",children:[r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:"flex-1 justify-between",children:[r.jsx("span",{className:"truncate",children:d()}),r.jsx(ad,{className:"h-4 w-4 ml-2 shrink-0"})]})}),r.jsxs(vu,{className:"w-56 bg-background border",children:[r.jsxs(Ba,{onClick:()=>n("all"),children:[r.jsx(S4,{className:"h-4 w-4 mr-2"}),"All Posts"]}),r.jsx(Yk,{}),r.jsx(cpe,{className:"text-xs text-muted-foreground",children:"Categories"}),e.map(m=>r.jsxs(Ba,{onClick:()=>n(m.id),children:[r.jsx("span",{className:"mr-2",children:m.icon||"📂"}),m.name]},m.id)),t.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(Yk,{}),r.jsxs(cpe,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r.jsx(Du,{className:"h-3 w-3"}),"Your Groups"]}),t.map(m=>r.jsxs(Ba,{onClick:()=>n(`group:${m.id}`),children:[r.jsx("span",{className:"mr-2",children:m.icon||"🔒"}),m.name]},m.id))]})]})]}),r.jsxs(Nie,{open:o,onOpenChange:l,children:[r.jsx(Bve,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"icon",className:"relative",children:[r.jsx(ws,{className:"h-4 w-4"}),a.length>0&&r.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})]})}),r.jsxs(M6,{children:[r.jsx(Sie,{children:r.jsxs(Cie,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),r.jsx(To,{className:"h-[calc(100vh-8rem)] mt-4",children:a.length===0?r.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No one else online right now"}):r.jsx("div",{className:"space-y-2",children:a.map(m=>r.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded-lg hover:bg-muted transition-colors",children:[r.jsxs("div",{className:"relative",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:m.avatarUrl}),r.jsx(dn,{children:i(m.name)})]}),r.jsx(vh,{className:"h-3 w-3 fill-green-500 text-green-500 absolute -bottom-0.5 -right-0.5"})]}),r.jsx("span",{className:"font-medium",children:m.name})]},m.id))})})]})]})]})};var fhe,uoe="HoverCard",[pqe]=Sc(uoe,[Ix]),hoe=Ix(),[NTt,p_e]=pqe(uoe),gqe=e=>{const{__scopeHoverCard:t,children:s,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=e,d=hoe(t),m=A.useRef(0),p=A.useRef(0),g=A.useRef(!1),v=A.useRef(!1),[_,k]=bh({prop:n,defaultProp:a??!1,onChange:o,caller:uoe}),w=A.useCallback(()=>{clearTimeout(p.current),m.current=window.setTimeout(()=>k(!0),l)},[l,k]),S=A.useCallback(()=>{clearTimeout(m.current),!g.current&&!v.current&&(p.current=window.setTimeout(()=>k(!1),i))},[i,k]),T=A.useCallback(()=>k(!1),[k]);return A.useEffect(()=>()=>{clearTimeout(m.current),clearTimeout(p.current)},[]),r.jsx(NTt,{scope:t,open:_,onOpenChange:k,onOpen:w,onClose:S,onDismiss:T,hasSelectionRef:g,isPointerDownOnContentRef:v,children:r.jsx(g6,{...d,children:s})})};gqe.displayName=uoe;var xqe="HoverCardTrigger",yqe=A.forwardRef((e,t)=>{const{__scopeHoverCard:s,...n}=e,a=p_e(xqe,s),o=hoe(s);return r.jsx(k3,{asChild:!0,...o,children:r.jsx(Hs.a,{"data-state":a.open?"open":"closed",...n,ref:t,onPointerEnter:bs(e.onPointerEnter,xne(a.onOpen)),onPointerLeave:bs(e.onPointerLeave,xne(a.onClose)),onFocus:bs(e.onFocus,a.onOpen),onBlur:bs(e.onBlur,a.onClose),onTouchStart:bs(e.onTouchStart,l=>l.preventDefault())})})});yqe.displayName=xqe;var STt="HoverCardPortal",[tfr,CTt]=pqe(STt,{forceMount:void 0}),gne="HoverCardContent",vqe=A.forwardRef((e,t)=>{const s=CTt(gne,e.__scopeHoverCard),{forceMount:n=s.forceMount,...a}=e,o=p_e(gne,e.__scopeHoverCard);return r.jsx(Wc,{present:n||o.open,children:r.jsx(MTt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:bs(e.onPointerEnter,xne(o.onOpen)),onPointerLeave:bs(e.onPointerLeave,xne(o.onClose)),ref:t})})});vqe.displayName=gne;var MTt=A.forwardRef((e,t)=>{const{__scopeHoverCard:s,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=e,d=p_e(gne,s),m=hoe(s),p=A.useRef(null),g=va(t,p),[v,_]=A.useState(!1);return A.useEffect(()=>{if(v){const k=document.body;return fhe=k.style.userSelect||k.style.webkitUserSelect,k.style.userSelect="none",k.style.webkitUserSelect="none",()=>{k.style.userSelect=fhe,k.style.webkitUserSelect=fhe}}},[v]),A.useEffect(()=>{if(p.current){const k=()=>{_(!1),d.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var S;((S=document.getSelection())==null?void 0:S.toString())!==""&&(d.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",k),()=>{document.removeEventListener("pointerup",k),d.hasSelectionRef.current=!1,d.isPointerDownOnContentRef.current=!1}}},[d.isPointerDownOnContentRef,d.hasSelectionRef]),A.useEffect(()=>{p.current&&ETt(p.current).forEach(w=>w.setAttribute("tabindex","-1"))}),r.jsx(J1,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:bs(o,k=>{k.preventDefault()}),onDismiss:d.onDismiss,children:r.jsx(x6,{...m,...i,onPointerDown:bs(i.onPointerDown,k=>{k.currentTarget.contains(k.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)"}})})}),TTt="HoverCardArrow",ATt=A.forwardRef((e,t)=>{const{__scopeHoverCard:s,...n}=e,a=hoe(s);return r.jsx(y6,{...a,...n,ref:t})});ATt.displayName=TTt;function xne(e){return t=>t.pointerType==="touch"?void 0:e()}function ETt(e){const t=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});for(;s.nextNode();)t.push(s.currentNode);return t}var ITt=gqe,PTt=yqe,_qe=vqe;const LTt=ITt,DTt=PTt,bqe=A.forwardRef(({className:e,align:t="center",sideOffset:s=4,...n},a)=>r.jsx(_qe,{ref:a,align:t,sideOffset:s,className:Vt("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",e),...n}));bqe.displayName=_qe.displayName;const OTt=[{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"}],RTt=e=>e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2),wqe=({reactions:e,children:t})=>{if(e.length===0)return r.jsx(r.Fragment,{children:t});const s={};return e.forEach(n=>{s[n.reaction_type]||(s[n.reaction_type]=[]),s[n.reaction_type].push(n)}),r.jsxs(LTt,{openDelay:200,closeDelay:100,children:[r.jsx(DTt,{asChild:!0,children:r.jsx("div",{className:"cursor-pointer",children:t})}),r.jsx(bqe,{className:"w-64 p-3 bg-popover border shadow-lg z-50",side:"top",align:"start",children:r.jsx("div",{className:"space-y-3",children:Object.entries(s).map(([n,a])=>{const o=OTt.find(l=>l.type===n);return r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("span",{className:"text-lg",children:o==null?void 0:o.emoji}),r.jsxs("span",{className:"text-sm font-medium text-foreground",children:[o==null?void 0:o.label," (",a.length,")"]})]}),r.jsxs("div",{className:"space-y-1.5",children:[a.slice(0,10).map(l=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(cn,{className:"h-6 w-6",children:[r.jsx(xa,{src:l.user_avatar||void 0}),r.jsx(dn,{className:"text-[10px]",children:RTt(l.user_name||"U")})]}),r.jsx("span",{className:"text-sm text-foreground truncate",children:l.user_name||"Unknown User"})]},l.id)),a.length>10&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",a.length-10," more"]})]})]},n)})})})]})};function FTt({images:e,initialIndex:t=0,open:s,onOpenChange:n}){const[a,o]=A.useState(t),[l,i]=A.useState(!1);A.useEffect(()=>{s&&(o(t),i(!1))},[s,t]);const d=()=>{o(v=>v>0?v-1:e.length-1),i(!1)},m=()=>{o(v=>v{s&&(v.key==="ArrowLeft"&&d(),v.key==="ArrowRight"&&m(),v.key==="Escape"&&n(!1))},[s,e.length]);A.useEffect(()=>(window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)),[p]);const g=e[a];return r.jsx(Ir,{open:s,onOpenChange:n,children:r.jsxs(Er,{className:"max-w-[95vw] max-h-[95vh] w-auto h-auto p-0 border-none bg-black/95 overflow-hidden",children:[r.jsx(X,{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:r.jsx(Xs,{className:"h-6 w-6"})}),e.length>1&&r.jsxs(r.Fragment,{children:[r.jsx(X,{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:r.jsx(jc,{className:"h-8 w-8"})}),r.jsx(X,{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:m,children:r.jsx(Zi,{className:"h-8 w-8"})})]}),e.length>1&&r.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," / ",e.length]}),(g==null?void 0:g.type)==="image"&&r.jsx(X,{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?r.jsx($4,{className:"h-5 w-5"}):r.jsx(B4,{className:"h-5 w-5"})}),r.jsx("div",{className:Vt("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"?r.jsx("video",{src:g.url,controls:!0,autoPlay:!0,className:"max-w-full max-h-[85vh] object-contain",onClick:v=>v.stopPropagation()}):r.jsx("img",{src:g==null?void 0:g.url,alt:"",className:Vt("object-contain transition-transform duration-200",l?"max-w-none max-h-none scale-150":"max-w-full max-h-[85vh]")})}),e.length>1&&r.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:e.map((v,_)=>r.jsx("button",{onClick:()=>{o(_),i(!1)},className:Vt("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"?r.jsx("video",{src:v.url,className:"w-full h-full object-cover"}):r.jsx("img",{src:v.url,alt:"",className:"w-full h-full object-cover"})},_))})]})})}const GO=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],zTt=({commentId:e,reactions:t,currentUserId:s})=>{var m,p;const n=Rr(),[a,o]=A.useState(!1),l=t.find(g=>g.user_id===s),i=Qt({mutationFn:async g=>{l?l.reaction_type===g?await Y.from("community_comment_reactions").delete().eq("id",l.id):await Y.from("community_comment_reactions").update({reaction_type:g}).eq("id",l.id):await Y.from("community_comment_reactions").insert({comment_id:e,user_id:s,reaction_type:g})},onSuccess:()=>{n.invalidateQueries({queryKey:["community-posts"]}),o(!1)}}),d={};return t.forEach(g=>{d[g.reaction_type]=(d[g.reaction_type]||0)+1}),r.jsxs("div",{className:"flex items-center gap-2",children:[t.length>0&&r.jsx(wqe,{reactions:t,children:r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[r.jsx("div",{className:"flex -space-x-0.5",children:Object.keys(d).slice(0,2).map(g=>{var v;return r.jsx("span",{className:"text-sm",children:(v=GO.find(_=>_.type===g))==null?void 0:v.emoji},g)})}),r.jsx("span",{children:t.length})]})}),s&&r.jsxs(cd,{open:a,onOpenChange:o,children:[r.jsx(dd,{asChild:!0,children:r.jsx("button",{className:`text-xs hover:text-primary transition-colors ${l?"text-primary font-medium":"text-muted-foreground"}`,children:l?r.jsxs("span",{children:[(m=GO.find(g=>g.type===l.reaction_type))==null?void 0:m.emoji," ",(p=GO.find(g=>g.type===l.reaction_type))==null?void 0:p.label]}):r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ai,{className:"h-3 w-3"}),"Like"]})})}),r.jsx(Hc,{className:"w-auto p-1.5 bg-popover border shadow-lg z-50",side:"top",children:r.jsx("div",{className:"flex gap-0.5",children:GO.map(g=>r.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 g_e({content:e,className:t}){const s=/([@#])\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<>]+)/g,n=[];let a=0,o,l=0;for(;(o=s.exec(e))!==null;){if(o.index>a&&n.push(e.substring(a,o.index)),o[1]){const i=o[1],d=o[2],m=o[3],p=i==="#";n.push(r.jsx(vo,{to:p?`/templates/${m}`:`/profile?user=${m}`,className:Vt("font-medium hover:underline",p?"text-white bg-[#2a4c64] px-1.5 py-0.5 rounded":"text-primary"),onClick:g=>g.stopPropagation(),children:p?d:`@${d}`},`mention-${l++}`))}else if(o[4]){const i=o[4],d=i.replace(/[.,;:!?)]+$/,""),m=i.slice(d.length);let p;try{const g=new URL(d);p=g.hostname+(g.pathname!=="/"?g.pathname.slice(0,20)+(g.pathname.length>20?"...":""):"")}catch{p=d.length>40?d.slice(0,40)+"...":d}n.push(r.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline break-all",onClick:g=>g.stopPropagation(),children:p},`url-${l++}`)),m&&n.push(m)}a=o.index+o[0].length}return ar.jsx(A.Fragment,{children:i},d))})}function yne({value:e,onChange:t,placeholder:s="What's on your mind? Use @ to mention someone",className:n,minHeight:a="80px",onMentionsChange:o,onTemplatesChange:l,onKeyDown:i,mentionFormat:d="encoded",enableTemplateMentions:m=!1}){const p=A.useRef(null),g=A.useRef(null),[v,_]=A.useState(!1),[k,w]=A.useState("user"),[S,T]=A.useState(""),[C,I]=A.useState(null),[R,D]=A.useState(0),[B,$]=A.useState({top:0,left:0,width:0}),q=A.useRef(new Map),W=A.useRef(new Map),K=ve=>{if(d==="plain"){const Le=[];return q.current.forEach((Ve,Ie)=>{ve.includes(`@${Ie}`)&&Le.push(Ve)}),[...new Set(Le)]}const Me=/@\[([^\]]+)\]\(([^)]+)\)/g,Ze=[];let Ae;for(;(Ae=Me.exec(ve))!==null;)Ze.push(Ae[2]);return[...new Set(Ze)]},re=ve=>{if(d==="plain"){const Le=[];return W.current.forEach((Ve,Ie)=>{ve.includes(`#${Ie}`)&&Le.push(Ve)}),[...new Set(Le)]}const Me=/#\[([^\]]+)\]\(([^)]+)\)/g,Ze=[];let Ae;for(;(Ae=Me.exec(ve))!==null;)Ze.push(Ae[2]);return[...new Set(Ze)]};A.useEffect(()=>{if(o){const ve=K(e);o(ve)}if(l){const ve=re(e);l(ve)}},[e,o,l,d]);const{data:ae=[],isLoading:oe}=Ht({queryKey:["mention-users",S],queryFn:async()=>{const ve=Y.from("profiles").select("id, name").limit(8),Me=S.length>=1?ve.ilike("name",`%${S}%`):ve.order("name"),{data:Ze,error:Ae}=await Me;if(Ae)throw Ae;const Le=Ze.map(Ve=>Ve.id),Ue=await R7e(Le);return Ze.map(Ve=>({id:Ve.id,name:Ve.name||"Unknown",avatar_url:Ue.get(Ve.id)}))},enabled:v&&k==="user",staleTime:3e4}),{data:se=[],isLoading:pe}=Ht({queryKey:["mention-templates",S],queryFn:async()=>{let ve=Y.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);S.length>=1&&(ve=ve.ilike("name",`%${S}%`));const{data:Me,error:Ze}=await ve;if(Ze)throw Ze;return Me||[]},enabled:v&&k==="template"&&m,staleTime:3e4}),ie=k==="user"?oe:pe,de=k==="user"?ae:se,ce=ve=>ve.split(" ").map(Me=>Me[0]).join("").toUpperCase().slice(0,2),ge=ve=>{const Me=ve.target.value,Ze=ve.target.selectionStart;t(Me);const Ae=Me.substring(0,Ze),Le=Ae.lastIndexOf("@"),Ue=m?Ae.lastIndexOf("#"):-1;let Ve=-1,Ie="user";if(Le>Ue?(Ve=Le,Ie="user"):Ue>Le&&m&&(Ve=Ue,Ie="template"),Ve!==-1){const We=Ae.substring(Ve+1),wt=We.includes(" "),Pe=We.includes(` `);if(!wt&&!Pe&&We.length<=30){I(Ve),T(We),w(Ie),_(!0),D(0);return}}_(!1),I(null)},Te=ve=>{if(C===null)return;const Me=e.substring(0,C),Ze=e.substring(C+S.length+1),Ae=k==="user"?"@":"#",Le=d==="plain"?`${Ae}${ve.name} `:`${Ae}[${ve.name}](${ve.id}) `;d==="plain"&&(k==="user"?q.current.set(ve.name,ve.id):W.current.set(ve.name,ve.id));const Ue=Me+Le+Ze;t(Ue),_(!1),I(null),T(""),setTimeout(()=>{if(p.current){const Ve=Me.length+Le.length;p.current.focus(),p.current.setSelectionRange(Ve,Ve)}},0)},_e=ve=>{if(!(!v||de.length===0))switch(ve.key){case"ArrowDown":ve.preventDefault(),D(Me=>(Me+1)%de.length);break;case"ArrowUp":ve.preventDefault(),D(Me=>(Me-1+de.length)%de.length);break;case"Enter":de[R]&&(ve.preventDefault(),Te(de[R]));break;case"Escape":ve.preventDefault(),_(!1);break;case"Tab":de[R]&&(ve.preventDefault(),Te(de[R]));break}};return A.useEffect(()=>{const ve=Me=>{g.current&&!g.current.contains(Me.target)&&p.current&&!p.current.contains(Me.target)&&_(!1)};return document.addEventListener("mousedown",ve),()=>document.removeEventListener("mousedown",ve)},[]),A.useEffect(()=>{if(!v)return;const ve=()=>{const Me=p.current;if(!Me)return;const Ze=Me.getBoundingClientRect();$({top:Ze.bottom+4,left:Ze.left,width:Ze.width})};return ve(),window.addEventListener("resize",ve),window.addEventListener("scroll",ve,!0),()=>{window.removeEventListener("resize",ve),window.removeEventListener("scroll",ve,!0)}},[v,e]),r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qs,{ref:p,value:e,onChange:ge,onKeyDown:ve=>{_e(ve),ve.defaultPrevented||i==null||i(ve)},placeholder:s,className:Vt("resize-none",n),style:{minHeight:a}}),v&&Hh.createPortal(r.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:[r.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b bg-muted/30",children:k==="user"?"👤 Mention a person":"📋 Link a template"}),ie?r.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:"Searching..."}):de.length===0?r.jsx("div",{className:"px-3 py-2 text-sm text-muted-foreground",children:S.length<1?`Type to search ${k==="user"?"people":"templates"}...`:`No ${k==="user"?"users":"templates"} found`}):r.jsx("ul",{className:"py-1 max-h-[180px] overflow-y-auto",children:de.map((ve,Me)=>r.jsx("li",{className:Vt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",Me===R?"bg-accent":"hover:bg-accent/50"),onClick:()=>Te(ve),onMouseEnter:()=>D(Me),children:k==="user"?r.jsxs(r.Fragment,{children:[r.jsxs(cn,{className:"h-6 w-6",children:[r.jsx(xa,{src:ve.avatar_url}),r.jsx(dn,{className:"text-xs",children:ce(ve.name)})]}),r.jsx("span",{className:"text-sm font-medium truncate",children:ve.name})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center overflow-hidden flex-shrink-0",children:ve.preview_image_url?r.jsx("img",{src:ve.preview_image_url,alt:"",className:"w-full h-full object-cover"}):r.jsx(id,{className:"h-4 w-4 text-muted-foreground"})}),r.jsx("span",{className:"text-sm font-medium truncate",children:ve.name})]})},ve.id))})]}),document.body)]})}function BTt(e){const t=/#\[([^\]]+)\]\(([^)]+)\)/g,s=[];let n;for(;(n=t.exec(e))!==null;)s.push(n[2]);return[...new Set(s)]}const Y3e=e=>e.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2);function jqe({comment:e,postId:t,currentUserId:s,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=Rr(),[d,m]=A.useState(!1),[p,g]=A.useState(""),[v,_]=A.useState([]),k=Qt({mutationFn:async({content:C,parentCommentId:I})=>{const{data:R,error:D}=await Y.from("community_comments").insert({post_id:t,user_id:s,content:C,parent_comment_id:I}).select("id").single();if(D)throw D;const B=v;if(B.length>0&&R){const $=B.filter(q=>q!==s).map(q=>({comment_id:R.id,mentioned_user_id:q,mentioned_by_user_id:s}));$.length>0&&await Y.from("community_comment_mentions").insert($)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),g(""),_([]),m(!1)}}),w=Qt({mutationFn:async C=>{const{error:I}=await Y.from("community_comments").delete().eq("id",C);if(I)throw I},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),S=()=>{p.trim()&&k.mutate({content:p,parentCommentId:e.id})};return r.jsxs("div",{className:l>0?"ml-8 border-l-2 border-muted pl-3":"",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(cn,{className:"h-8 w-8 shrink-0",children:[r.jsx(xa,{src:e.user_avatar||void 0}),r.jsx(dn,{className:"text-xs",children:Y3e(e.user_name||"U")})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"bg-muted rounded-lg px-3 py-2",children:[r.jsx("div",{className:"font-medium text-sm",children:e.user_name}),r.jsx(g_e,{content:e.content,className:"text-sm break-words"})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground flex-wrap",children:[r.jsx("span",{children:gu(new Date(e.created_at),{addSuffix:!0})}),r.jsx(zTt,{commentId:e.id,reactions:e.reactions,currentUserId:s}),s&&l<2&&r.jsxs("button",{onClick:()=>m(!d),className:"hover:text-primary flex items-center gap-1",children:[r.jsx(IE,{className:"h-3 w-3"}),"Reply"]}),(e.user_id===s||o)&&r.jsx("button",{onClick:()=>w.mutate(e.id),className:"hover:text-destructive",children:e.user_id!==s?"Remove":"Delete"})]}),d&&s&&r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsxs(cn,{className:"h-6 w-6 shrink-0 mt-1",children:[r.jsx(xa,{src:n||void 0}),r.jsx(dn,{className:"text-xs",children:Y3e((a==null?void 0:a.split("@")[0])||"U")})]}),r.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[r.jsx(yne,{placeholder:`Reply to ${e.user_name}...`,value:p,onChange:g,onMentionsChange:_,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),r.jsx(X,{size:"sm",variant:"ghost",onClick:S,disabled:!p.trim()||k.isPending,className:"h-8 px-2 mt-0.5",children:r.jsx(ai,{className:"h-3 w-3"})})]})]})]})]}),e.replies&&e.replies.length>0&&r.jsx("div",{className:"mt-2 space-y-2",children:e.replies.map(C=>r.jsx(jqe,{comment:C,postId:t,currentUserId:s,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},C.id))})]})}const KO=[{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"}],$Tt=()=>{const{user:e,isBrokerageManager:t,managedBrokerages:s,isAdmin:n}=Gr(),{avatarUrl:a}=O7e(e==null?void 0:e.id),{onlineUsers:o}=YBe(),{toast:l}=_i(),i=Rr(),d=A.useRef(null),[m,p]=A.useState("all"),[g,v]=A.useState(""),[_,k]=A.useState(""),[w,S]=A.useState(""),[T,C]=A.useState([]),[I,R]=A.useState([]),[D,B]=A.useState(""),[$,q]=A.useState(!1),[W,K]=A.useState(null),[re,ae]=A.useState(""),[oe,se]=A.useState(new Set),[pe,ie]=A.useState({}),[de,ce]=A.useState({}),[ge,Te]=A.useState([]),[_e,ve]=A.useState([]),[Me,Ze]=A.useState({open:!1,images:[],index:0});A.useEffect(()=>{if(m.startsWith("group:")){const ct=m.replace("group:","");S(ct),k("")}else m!=="all"?(k(m),S("")):(k(""),S(""))},[m]);const{data:Ae=[]}=Ht({queryKey:["community-categories"],queryFn:async()=>{const{data:ct,error:Tt}=await Y.from("community_categories").select("*").order("sort_order");if(Tt)throw Tt;return ct}}),{data:Le=[]}=Ht({queryKey:["community-private-groups"],queryFn:async()=>{const{data:ct,error:Tt}=await Y.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(Tt)throw Tt;return ct}}),Ue=20,{data:Ve,isLoading:Ie,hasNextPage:We,fetchNextPage:wt,isFetchingNextPage:Pe}=hlt({queryKey:["community-posts",m],initialPageParam:0,queryFn:async({pageParam:ct})=>{var De;const Tt=ct*Ue,Ot=Tt+Ue;let rr=Y.from("community_posts").select("*").order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).range(Tt,Ot);if(m.startsWith("group:")){const Xe=m.replace("group:","");rr=rr.eq("private_group_id",Xe)}else m==="all"||(rr=rr.eq("category_id",m).is("private_group_id",null));const{data:Lr,error:cr}=await rr;if(cr)throw cr;const Mr=((Lr==null?void 0:Lr.length)||0)>Ue,As=(Lr||[]).slice(0,Ue);if(As.length===0)return{posts:[],hasMore:!1,nextPage:ct+1};const Et=As.map(Xe=>Xe.id),Pt=[...new Set(As.filter(Xe=>Xe.category_id).map(Xe=>Xe.category_id))].filter(Boolean),[Sr,fs,Ws,tn,xi]=await Promise.all([Pt.length?Y.from("community_categories").select("*").in("id",Pt):Promise.resolve({data:[]}),Y.from("community_post_media").select("*").in("post_id",Et).order("sort_order"),Y.from("community_reactions").select("*").in("post_id",Et),Y.from("community_comments").select("*").in("post_id",Et).order("created_at",{ascending:!0}),Y.from("community_post_resources").select("*").in("post_id",Et)]),La=Sr==null?void 0:Sr.data,un=fs==null?void 0:fs.data,ia=Ws==null?void 0:Ws.data,rn=tn==null?void 0:tn.data,Wn=xi==null?void 0:xi.data,Yn=(rn||[]).map(Xe=>Xe.id),[Pi,dr]=await Promise.all([Yn.length?Y.from("community_comment_reactions").select("*").in("comment_id",Yn):Promise.resolve({data:[]}),(()=>{const Xe=(Wn||[]).filter(Ct=>Ct.resource_type==="template").map(Ct=>Ct.resource_id);return Xe.length===0?Promise.resolve({data:[]}):Y.from("canva_templates").select("id, name, preview_image_url").in("id",Xe)})()]),$a=(Pi==null?void 0:Pi.data)||[],xo=(dr==null?void 0:dr.data)||[],Ei=new Map(xo.map(Xe=>[Xe.id,{name:Xe.name,preview_image_url:Xe.preview_image_url}])),Qs=Array.from(new Set([...As.map(Xe=>Xe.user_id),...(ia||[]).map(Xe=>Xe.user_id),...(rn||[]).map(Xe=>Xe.user_id),...$a.map(Xe=>Xe.user_id)])),[ao,Mc]=await Promise.all([Qs.length?Y.from("profiles").select("id, name").in("id",Qs):Promise.resolve({data:[]}),R7e(Qs)]),No=new Map(((De=ao==null?void 0:ao.data)==null?void 0:De.map(Xe=>[Xe.id,Xe.name]))||[]),Tc=new Map((La||[]).map(Xe=>[Xe.id,Xe])),nt=Xe=>{const Ct=new Map,jt=[];return Xe.forEach(Dt=>{Ct.set(Dt.id,{...Dt,user_name:No.get(Dt.user_id)||"Unknown User",user_avatar:Mc.get(Dt.user_id),reactions:$a.filter(Gt=>Gt.comment_id===Dt.id).map(Gt=>({...Gt,user_name:No.get(Gt.user_id)||"Unknown User",user_avatar:Mc.get(Gt.user_id)})),replies:[]})}),Xe.forEach(Dt=>{const Gt=Ct.get(Dt.id);if(Dt.parent_comment_id&&Ct.has(Dt.parent_comment_id)){const Ft=Ct.get(Dt.parent_comment_id);Ft.replies=Ft.replies||[],Ft.replies.push(Gt)}else jt.push(Gt)}),jt};return{posts:As.map(Xe=>{const Ct=(Wn||[]).filter(jt=>jt.post_id===Xe.id).map(jt=>{let Dt="",Gt=null;if(jt.resource_type==="template"){const Ft=Ei.get(jt.resource_id);Dt=(Ft==null?void 0:Ft.name)||"Unknown Template",Gt=(Ft==null?void 0:Ft.preview_image_url)||null}return{id:jt.id,resource_type:jt.resource_type,resource_id:jt.resource_id,resource_name:Dt,resource_preview_url:Gt}});return{...Xe,user_name:No.get(Xe.user_id)||"Unknown User",user_avatar:Mc.get(Xe.user_id),category:Xe.category_id?Tc.get(Xe.category_id):null,media:(un||[]).filter(jt=>jt.post_id===Xe.id),reactions:((ia||[]).filter(jt=>jt.post_id===Xe.id)||[]).map(jt=>({...jt,user_name:No.get(jt.user_id)||"Unknown User",user_avatar:Mc.get(jt.user_id)})),comments:nt((rn||[]).filter(jt=>jt.post_id===Xe.id)),resources:Ct}}),hasMore:Mr,nextPage:ct+1}},getNextPageParam:ct=>ct.hasMore?ct.nextPage:void 0}),st=A.useMemo(()=>(Ve==null?void 0:Ve.pages.flatMap(ct=>ct.posts))??[],[Ve]),ue=Qt({mutationFn:async()=>{q(!0);const{data:ct,error:Tt}=await Y.from("community_posts").insert({user_id:e.id,category_id:w?null:_||null,private_group_id:w||null,content:g,link_url:D||null}).select().single();if(Tt)throw Tt;for(let rr=0;rr0){const rr=ge.filter(Lr=>Lr!==e.id).map(Lr=>({post_id:ct.id,mentioned_user_id:Lr,mentioned_by_user_id:e.id}));rr.length>0&&await Y.from("community_post_mentions").insert(rr)}const Ot=BTt(g);if(Ot.length>0){const rr=Ot.map(Lr=>({post_id:ct.id,resource_type:"template",resource_id:Lr}));await Y.from("community_post_resources").insert(rr)}return ct},onSuccess:async ct=>{var Tt;i.invalidateQueries({queryKey:["community-posts"]}),v(""),Te([]),ve([]),k(""),S(""),C([]),R([]),B(""),l({title:"Post created!"});try{const Ot=((Tt=e==null?void 0:e.user_metadata)==null?void 0:Tt.name)||"Someone",rr=g.length>50?g.substring(0,50)+"...":g;await Y.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Ot}: ${rr}`,url:"/community"}})}catch(Ot){console.error("Failed to send push notification:",Ot)}},onError:ct=>{l({title:"Error creating post",description:ct.message,variant:"destructive"})},onSettled:()=>q(!1)}),$e=Qt({mutationFn:async({postId:ct,content:Tt})=>{const{error:Ot}=await Y.from("community_posts").update({content:Tt}).eq("id",ct);if(Ot)throw Ot},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),K(null),ae(""),l({title:"Post updated!"})}}),tt=Qt({mutationFn:async ct=>{const{error:Tt}=await Y.from("community_posts").delete().eq("id",ct);if(Tt)throw Tt},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),rt=Qt({mutationFn:async({postId:ct,isPinned:Tt})=>{const{error:Ot}=await Y.from("community_posts").update({is_pinned:!Tt,pinned_at:Tt?null:new Date().toISOString(),pinned_by:Tt?null:e==null?void 0:e.id}).eq("id",ct);if(Ot)throw Ot},onSuccess:(ct,{isPinned:Tt})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:Tt?"Post unpinned":"Post pinned to top"})}}),je=Qt({mutationFn:async({postId:ct,reactionType:Tt})=>{var rr;const Ot=(rr=st.find(Lr=>Lr.id===ct))==null?void 0:rr.reactions.find(Lr=>Lr.user_id===(e==null?void 0:e.id));Ot?Ot.reaction_type===Tt?await Y.from("community_reactions").delete().eq("id",Ot.id):await Y.from("community_reactions").update({reaction_type:Tt}).eq("id",Ot.id):await Y.from("community_reactions").insert({post_id:ct,user_id:e.id,reaction_type:Tt})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),it=Qt({mutationFn:async({postId:ct,content:Tt})=>{const{data:Ot,error:rr}=await Y.from("community_comments").insert({post_id:ct,user_id:e.id,content:Tt}).select("id").single();if(rr)throw rr;const Lr=de[ct]||[];if(Lr.length>0&&Ot){const cr=Lr.filter(Mr=>Mr!==e.id).map(Mr=>({comment_id:Ot.id,mentioned_user_id:Mr,mentioned_by_user_id:e.id}));cr.length>0&&await Y.from("community_comment_mentions").insert(cr)}},onSuccess:(ct,{postId:Tt})=>{i.invalidateQueries({queryKey:["community-posts"]}),ie(Ot=>({...Ot,[Tt]:""})),ce(Ot=>({...Ot,[Tt]:[]}))}});Qt({mutationFn:async ct=>{const{error:Tt}=await Y.from("community_comments").delete().eq("id",ct);if(Tt)throw Tt},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const Se=ct=>{const Tt=Array.from(ct.target.files||[]);if(Tt.length+T.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C(Ot=>[...Ot,...Tt]),Tt.forEach(Ot=>{const rr=new FileReader;rr.onloadend=()=>{R(Lr=>[...Lr,rr.result])},rr.readAsDataURL(Ot)})},et=ct=>{C(Tt=>Tt.filter((Ot,rr)=>rr!==ct)),R(Tt=>Tt.filter((Ot,rr)=>rr!==ct))},Qe=ct=>ct.split(" ").map(Tt=>Tt[0]).join("").toUpperCase().slice(0,2),He=ct=>{const Tt={};return ct.forEach(Ot=>{Tt[Ot.reaction_type]=(Tt[Ot.reaction_type]||0)+1}),Tt},ot=ct=>{var Tt;return(Tt=ct.find(Ot=>Ot.user_id===(e==null?void 0:e.id)))==null?void 0:Tt.reaction_type},ut=ct=>ct.reduce((Tt,Ot)=>Tt+1+(Ot.replies?ut(Ot.replies):0),0),ft=ct=>{if(n)return!0;if(!t||!ct.private_group_id)return!1;const Tt=Le.find(Ot=>Ot.id===ct.private_group_id);return Tt!=null&&Tt.brokerage_id?s.some(Ot=>Ot.id===Tt.brokerage_id):!1};return r.jsx(Ur,{title:"Community",children:r.jsxs("div",{className:"flex gap-6 w-full isolate z-0",children:[r.jsx(jTt,{categories:Ae,privateGroups:Le,selectedFilter:m,onFilterChange:p,onlineUsers:o}),r.jsxs("div",{className:"flex-1 min-w-0 max-w-2xl mx-auto lg:mx-0 space-y-6",children:[r.jsxs("div",{className:"px-1",children:[r.jsx("h1",{className:"text-4xl lg:text-5xl font-bold text-foreground",children:"Community"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Connect and share with fellow agents"})]}),r.jsx(kTt,{categories:Ae,privateGroups:Le,selectedFilter:m,onFilterChange:p,onlineUsers:o}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:a||void 0}),r.jsx(dn,{children:e!=null&&e.email?Qe(e.email.split("@")[0]):"U"})]}),r.jsxs("div",{className:"flex-1 space-y-3",children:[r.jsx(yne,{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:ve,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),I.length>0&&r.jsx("div",{className:"grid grid-cols-3 gap-2",children:I.map((ct,Tt)=>{var Ot;return r.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Ot=T[Tt])!=null&&Ot.type.startsWith("video/")?r.jsx("video",{src:ct,className:"w-full h-full object-cover"}):r.jsx("img",{src:ct,alt:"",className:"w-full h-full object-cover"}),r.jsx(X,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>et(Tt),children:r.jsx(Xs,{className:"h-3 w-3"})})]},Tt)})}),D&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Lo,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{value:D,onChange:ct=>B(ct.target.value),placeholder:"https://...",className:"flex-1"}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>B(""),children:r.jsx(Xs,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex gap-1 flex-wrap",children:[r.jsx("input",{type:"file",ref:d,onChange:Se,accept:"image/*,video/*",multiple:!0,className:"hidden"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>{var ct;return(ct=d.current)==null?void 0:ct.click()},children:[r.jsx(Nl,{className:"h-4 w-4 mr-1"}),"Photo"]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>{var ct;return(ct=d.current)==null?void 0:ct.click()},children:[r.jsx(ma,{className:"h-4 w-4 mr-1"}),"Video"]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>B("https://"),children:[r.jsx(Lo,{className:"h-4 w-4 mr-1"}),"Link"]})]}),r.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[Le.length>0?r.jsxs(ds,{value:w||_||"none",onValueChange:ct=>{ct==="none"?(k(""),S("")):ct.startsWith("group:")?(S(ct.replace("group:","")),k("")):(k(ct),S(""))},children:[r.jsx(ls,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:r.jsx(us,{placeholder:"Select..."})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No category"}),Ae.map(ct=>r.jsxs(Ut,{value:ct.id,children:[ct.icon," ",ct.name]},ct.id)),Le.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-muted-foreground border-t mt-1 pt-1",children:"🔒 Private Groups"}),Le.map(ct=>r.jsxs(Ut,{value:`group:${ct.id}`,children:[ct.icon||"🔒"," ",ct.name]},ct.id))]})]})]}):r.jsxs(ds,{value:_,onValueChange:k,children:[r.jsx(ls,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:r.jsx(us,{placeholder:"Category"})}),r.jsx(cs,{children:Ae.map(ct=>r.jsxs(Ut,{value:ct.id,children:[ct.icon," ",ct.name]},ct.id))})]}),r.jsxs(X,{size:"sm",onClick:()=>ue.mutate(),disabled:!g.trim()||$,children:[r.jsx(ai,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Ie?r.jsx("div",{className:"space-y-4",children:[...Array(3)].map((ct,Tt)=>r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex gap-3",children:[r.jsx(pr,{className:"h-10 w-10 rounded-full"}),r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx(pr,{className:"h-4 w-32"}),r.jsx(pr,{className:"h-4 w-full"}),r.jsx(pr,{className:"h-4 w-3/4"})]})]})})},Tt))}):st.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(Rl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"font-semibold mb-2",children:"No posts yet"}),r.jsx("p",{className:"text-muted-foreground",children:"Be the first to start a conversation!"})]})}):r.jsxs("div",{className:"space-y-4",children:[st.map(ct=>{var Tt,Ot,rr,Lr;return r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{className:"flex gap-3 min-w-0",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:ct.user_avatar||void 0}),r.jsx(dn,{children:Qe(ct.user_name||"U")})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"font-semibold break-words",children:ct.user_name}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[r.jsx("span",{children:gu(new Date(ct.created_at),{addSuffix:!0})}),ct.category&&r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"•"}),r.jsxs(_t,{variant:"secondary",className:"text-xs",children:[ct.category.icon," ",ct.category.name]})]})]})]})]}),(ct.user_id===(e==null?void 0:e.id)||ft(ct))&&r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",children:r.jsx(Nf,{className:"h-4 w-4"})})}),r.jsxs(vu,{align:"end",children:[ft(ct)&&ct.private_group_id&&r.jsx(Ba,{onClick:()=>rt.mutate({postId:ct.id,isPinned:ct.is_pinned}),children:ct.is_pinned?r.jsxs(r.Fragment,{children:[r.jsx(CE,{className:"h-4 w-4 mr-2"}),"Unpin Post"]}):r.jsxs(r.Fragment,{children:[r.jsx(S1,{className:"h-4 w-4 mr-2"}),"Pin to Top"]})}),ct.user_id===(e==null?void 0:e.id)&&r.jsxs(Ba,{onClick:()=>{K(ct),ae(ct.content)},children:[r.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Edit"]}),r.jsxs(Ba,{className:"text-destructive",onClick:()=>tt.mutate(ct.id),children:[r.jsx(Os,{className:"h-4 w-4 mr-2"}),ct.user_id!==(e==null?void 0:e.id)?"Remove (Moderate)":"Delete"]})]})]})]}),ct.is_pinned&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-primary",children:[r.jsx(S1,{className:"h-4 w-4"}),r.jsx("span",{className:"font-medium",children:"Pinned"})]}),r.jsx("div",{className:"mb-3",children:r.jsx(g_e,{content:ct.content})}),ct.media.length>0&&r.jsx("div",{className:`grid gap-2 mb-3 ${ct.media.length===1?"grid-cols-1":ct.media.length===2?"grid-cols-2":ct.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:ct.media.slice(0,4).map((cr,Mr)=>{const As=Mr===3&&ct.media.length>4,Et=ct.media.length-4;return r.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${ct.media.length===1?"max-h-[500px]":ct.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Ze({open:!0,images:ct.media.map(Pt=>({url:Pt.media_url,type:Pt.media_type==="video"?"video":"image"})),index:Mr}),children:[cr.media_type==="video"?r.jsx("video",{src:cr.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):r.jsx("img",{src:cr.media_url,alt:"",className:"w-full h-full object-cover transition-transform group-hover:scale-105"}),r.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/20 transition-colors flex items-center justify-center",children:r.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity text-white",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.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"})})})}),As&&r.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:r.jsxs("span",{className:"text-white text-2xl font-bold",children:["+",Et]})})]},cr.id)})}),ct.link_url&&r.jsxs("a",{href:ct.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[ct.link_image&&r.jsx("div",{className:"aspect-video bg-muted",children:r.jsx("img",{src:ct.link_image,alt:ct.link_title||"Link preview",className:"w-full h-full object-cover",onError:cr=>{cr.currentTarget.style.display="none"}})}),r.jsx("div",{className:"p-3",children:ct.link_title?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:ct.link_title}),ct.link_description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:ct.link_description}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(ct.link_url).hostname})]}):r.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[r.jsx(Lo,{className:"h-4 w-4 flex-shrink-0"}),r.jsx("span",{className:"truncate",children:ct.link_url})]})})]}),ct.reactions.length>0&&r.jsx(wqe,{reactions:ct.reactions,children:r.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer",children:[r.jsx("div",{className:"flex -space-x-1",children:Object.entries(He(ct.reactions)).slice(0,3).map(([cr])=>{var Mr;return r.jsx("span",{className:"text-base",children:(Mr=KO.find(As=>As.type===cr))==null?void 0:Mr.emoji},cr)})}),r.jsx("span",{children:ct.reactions.length})]})}),r.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"ghost",size:"sm",className:"flex-1",children:[ot(ct.reactions)?r.jsx("span",{className:"mr-1",children:(Tt=KO.find(cr=>cr.type===ot(ct.reactions)))==null?void 0:Tt.emoji}):r.jsx(Cd,{className:"h-4 w-4 mr-1"}),ot(ct.reactions)?(Ot=KO.find(cr=>cr.type===ot(ct.reactions)))==null?void 0:Ot.label:"Like"]})}),r.jsx(Hc,{className:"w-auto p-2",side:"top",children:r.jsx("div",{className:"flex gap-1",children:KO.map(cr=>r.jsx("button",{onClick:()=>je.mutate({postId:ct.id,reactionType:cr.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:cr.label,children:cr.emoji},cr.type))})})]}),r.jsxs(X,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>se(cr=>{const Mr=new Set(cr);return Mr.has(ct.id)?Mr.delete(ct.id):Mr.add(ct.id),Mr}),children:[r.jsx(Rl,{className:"h-4 w-4 mr-1"}),(()=>{const cr=ut(ct.comments);return cr>0?`Comment (${cr})`:"Comment"})()]})]}),oe.has(ct.id)&&r.jsxs("div",{className:"space-y-3 mt-3",children:[ct.comments.map(cr=>r.jsx(jqe,{comment:cr,postId:ct.id,currentUserId:e==null?void 0:e.id,currentUserAvatar:a,currentUserEmail:e==null?void 0:e.email,canModerate:ft(ct)},cr.id)),e&&r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:a||void 0}),r.jsx(dn,{className:"text-xs",children:Qe(((rr=e.email)==null?void 0:rr.split("@")[0])||"U")})]}),r.jsxs("div",{className:"flex-1 flex gap-2",children:[r.jsx(yne,{placeholder:"Write a comment... (use @ to mention)",value:pe[ct.id]||"",onChange:cr=>ie(Mr=>({...Mr,[ct.id]:cr})),onMentionsChange:cr=>ce(Mr=>({...Mr,[ct.id]:cr})),mentionFormat:"plain",onKeyDown:cr=>{var Mr;cr.defaultPrevented||cr.key==="Enter"&&!cr.shiftKey&&((Mr=pe[ct.id])!=null&&Mr.trim())&&(cr.preventDefault(),it.mutate({postId:ct.id,content:pe[ct.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>{var cr;(cr=pe[ct.id])!=null&&cr.trim()&&it.mutate({postId:ct.id,content:pe[ct.id]})},disabled:!((Lr=pe[ct.id])!=null&&Lr.trim()),className:"h-8 px-2 mt-0.5",children:r.jsx(ai,{className:"h-4 w-4"})})]})]})]})]})},ct.id)}),We&&r.jsx("div",{className:"flex justify-center pt-2",children:r.jsx(X,{variant:"outline",onClick:()=>wt(),disabled:Pe,children:Pe?"Loading…":"Load more posts"})})]}),r.jsx(Ir,{open:!!W,onOpenChange:()=>K(null),children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Edit Post"})}),r.jsx(qs,{value:re,onChange:ct=>ae(ct.target.value),className:"min-h-[120px]"}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>K(null),children:"Cancel"}),r.jsx(X,{onClick:()=>{W&&$e.mutate({postId:W.id,content:re})},disabled:!re.trim(),children:"Save Changes"})]})]})}),r.jsx(FTt,{images:Me.images,initialIndex:Me.index,open:Me.open,onOpenChange:ct=>Ze(Tt=>({...Tt,open:ct}))})]})]})})},CC={open:{label:"Open",icon:Pa,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Rl,color:"bg-blue-500"},resolved:{label:"Resolved",icon:ui,color:"bg-green-500"},closed:{label:"Closed",icon:Fc,color:"bg-muted-foreground"}},X3e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function UTt(){const{user:e}=Gr(),t=Rr(),[s,n]=A.useState(null),[a,o]=A.useState(""),{data:l=[],isLoading:i}=Ht({queryKey:["support-tickets"],queryFn:async()=>{const{data:g,error:v}=await Y.from("support_tickets").select("*").eq("user_id",e==null?void 0:e.id).order("created_at",{ascending:!1});if(v)throw v;return g},enabled:!!e}),{data:d=[]}=Ht({queryKey:["ticket-replies",s==null?void 0:s.id],queryFn:async()=>{if(!s)return[];const{data:g,error:v}=await Y.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",s.id).order("created_at",{ascending:!0});if(v)throw v;return g},enabled:!!s}),m=Qt({mutationFn:async g=>{if(!s||!e)throw new Error("Missing data");const{error:v}=await Y.from("support_ticket_replies").insert({ticket_id:s.id,user_id:e.id,content:g,is_admin_reply:!1});if(v)throw v},onSuccess:()=>{t.invalidateQueries({queryKey:["ticket-replies",s==null?void 0:s.id]}),o(""),we.success("Reply sent!")},onError:()=>{we.error("Failed to send reply")}}),p=()=>{a.trim()&&m.mutate(a)};if(s){const g=CC[s.status].icon;return r.jsx(Ur,{children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>n(null),children:r.jsx(gi,{className:"h-5 w-5"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h1",{className:"text-2xl font-bold",children:s.subject}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx(_t,{variant:"secondary",children:X3e[s.category]}),r.jsxs(_t,{className:CC[s.status].color,children:[r.jsx(g,{className:"h-3 w-3 mr-1"}),CC[s.status].label]})]})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Cs,{children:["Created on ",Xr(new Date(s.created_at),"MMM d, yyyy 'at' h:mm a")]})}),r.jsx(qe,{children:r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Conversation"})}),r.jsxs(qe,{children:[r.jsx(To,{className:"h-[300px] pr-4",children:d.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):r.jsx("div",{className:"space-y-4",children:d.map(v=>{var _;return r.jsxs("div",{className:`p-4 rounded-lg ${v.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[r.jsxs("div",{className:"flex justify-between items-start mb-2",children:[r.jsx("span",{className:"font-medium text-sm",children:v.is_admin_reply?"Support Team":((_=v.profiles)==null?void 0:_.name)||"You"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Xr(new Date(v.created_at),"MMM d, h:mm a")})]}),r.jsx("p",{className:"text-sm whitespace-pre-wrap",children:v.content})]},v.id)})})}),s.status!=="closed"&&r.jsxs(r.Fragment,{children:[r.jsx(kd,{className:"my-4"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(qs,{placeholder:"Type your reply...",value:a,onChange:v=>o(v.target.value),className:"min-h-[80px]"}),r.jsx(X,{onClick:p,disabled:!a.trim()||m.isPending,className:"self-end",children:r.jsx(ai,{className:"h-4 w-4"})})]})]})]})]})]})})}return r.jsx(Ur,{children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(ze,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:r.jsx(qe,{className:"p-6 sm:p-8",children:r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-6",children:[r.jsx("div",{className:"p-4 bg-primary/20 rounded-full",children:r.jsx(by,{className:"h-8 w-8 text-primary"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Need Help?"}),r.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."}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsx(Mpe,{trigger:r.jsxs(X,{size:"lg",className:"gap-2",children:[r.jsx(gs,{className:"h-5 w-5"}),"Submit a Ticket"]})}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-muted rounded-lg",children:[r.jsx(fi,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Or text us: ",r.jsx("span",{className:"font-semibold text-foreground",children:"1-866-527-8668"})]})]})]})]})]})})}),r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx("h2",{className:"text-lg font-semibold",children:"Your Tickets"}),r.jsx(Mpe,{trigger:r.jsxs(X,{variant:"outline",size:"sm",className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"New Ticket"]})})]}),i?r.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):l.length===0?r.jsx(ze,{className:"border-dashed",children:r.jsxs(qe,{className:"text-center py-12",children:[r.jsx(Rl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets yet"}),r.jsx("p",{className:"text-muted-foreground",children:"You haven't submitted any support tickets. Use the button above to get started!"})]})}):r.jsx("div",{className:"space-y-3",children:l.map(g=>{const v=CC[g.status].icon;return r.jsx(ze,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(g),children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-medium truncate",children:g.subject}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx(_t,{variant:"outline",className:"text-xs",children:X3e[g.category]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Xr(new Date(g.created_at),"MMM d, yyyy")})]})]}),r.jsxs(_t,{className:CC[g.status].color,children:[r.jsx(v,{className:"h-3 w-3 mr-1"}),CC[g.status].label]})]})})},g.id)})})]})})}function VTt({open:e,onOpenChange:t}){return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[r.jsx(zr,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(An,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx(Fr,{children:"Schedule Agent Onboarding"}),r.jsx(Zs,{children:"Book a one-on-one onboarding session with LevelUp"})]})]})}),e&&r.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 qTt({open:e,onOpenChange:t}){const{brokerageId:s}=Gr(),[n,a]=A.useState(""),[o,l]=A.useState([]),[i,d]=A.useState(!1),{data:m,isLoading:p}=Ht({queryKey:["brokerage-agents-for-onboarding",s],queryFn:async()=>{if(!s)return[];const{data:w,error:S}=await Y.from("profiles").select("id, name, email").eq("brokerage_id",s).order("name",{ascending:!0});if(S)throw S;return w},enabled:e&&!!s}),g=m==null?void 0:m.filter(w=>w.name.toLowerCase().includes(n.toLowerCase())||w.email.toLowerCase().includes(n.toLowerCase())),v=w=>{l(S=>S.includes(w)?S.filter(T=>T!==w):[...S,w])},_=async()=>{if(o.length===0){we.error("Please select at least one agent");return}d(!0);try{const{data:w,error:S}=await Y.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(S)throw S;we.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),t(!1)}catch(w){console.error("Error sending onboarding link:",w),we.error(w.message||"Failed to send onboarding link")}finally{d(!1)}},k=w=>{w||(l([]),a("")),t(w)};return r.jsx(Ir,{open:e,onOpenChange:k,children:r.jsxs(Er,{className:"max-w-md",children:[r.jsx(zr,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(ai,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx(Fr,{children:"Send Onboarding Link"}),r.jsx(Zs,{children:"Select agents to receive the onboarding booking link"})]})]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search agents...",value:n,onChange:w=>a(w.target.value),className:"pl-10"})]}),p?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):(g==null?void 0:g.length)===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(ws,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),r.jsx("p",{children:"No agents found"})]}):r.jsx(To,{className:"h-[300px] border rounded-lg",children:r.jsx("div",{className:"p-2 space-y-1",children:g==null?void 0:g.map(w=>r.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>v(w.id),children:[r.jsx(Qo,{checked:o.includes(w.id),onCheckedChange:()=>v(w.id)}),r.jsx(cn,{className:"h-8 w-8",children:r.jsx(dn,{className:"text-xs",children:w.name.split(" ").map(S=>S[0]).join("").toUpperCase()})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:w.name}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w.email})]})]},w.id))})}),o.length>0&&r.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),r.jsx(X,{onClick:_,disabled:o.length===0||i,children:i?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function HTt(){const[e,t]=A.useState(!1),[s,n]=A.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(ze,{className:"mb-8",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(ws,{className:"h-6 w-6 text-primary"})}),r.jsxs("div",{children:[r.jsx(Zt,{children:"Agent Onboarding"}),r.jsx(Cs,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),r.jsx(qe,{children:r.jsxs("div",{className:"flex flex-wrap gap-4",children:[r.jsxs(X,{onClick:()=>t(!0),className:"flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4"}),"Schedule Agent Onboarding"]}),r.jsxs(X,{variant:"outline",onClick:()=>n(!0),className:"flex items-center gap-2",children:[r.jsx(ai,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),r.jsx(VTt,{open:e,onOpenChange:t}),r.jsx(qTt,{open:s,onOpenChange:n})]})}function WTt({open:e,onOpenChange:t}){return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-hidden",children:[r.jsx(zr,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(hx,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx(Fr,{children:"Schedule Launch Meeting"}),r.jsx(Zs,{children:"Book a private LevelUp information session for your brokerage"})]})]})}),e&&r.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 GTt(){const[e,t]=A.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(ze,{className:"mb-8",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(hx,{className:"h-6 w-6 text-primary"})}),r.jsxs("div",{children:[r.jsx(Zt,{children:"Launch or ReLaunch Meeting"}),r.jsx(Cs,{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."})]})]})}),r.jsx(qe,{children:r.jsxs(X,{onClick:()=>t(!0),className:"flex items-center gap-2",children:[r.jsx(hx,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),r.jsx(WTt,{open:e,onOpenChange:t})]})}function KTt(){const e=Ks(),[t,s]=A.useState(""),[n,a]=A.useState(null),{data:o,isLoading:l}=Ht({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:w,error:S}=await Y.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(S)throw S;return w}}),{data:i}=Ht({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:w,error:S}=await Y.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(S)throw S;return w}}),{data:d}=Ht({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:w,error:S}=await Y.from("brokerage_resource_pdfs").select("resource_id");if(S)throw S;return w}}),{data:m}=Ht({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:w,error:S}=await Y.from("brokerage_resource_videos").select("resource_id");if(S)throw S;return w}}),{data:p}=Ht({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:w,error:S}=await Y.from("brokerage_resource_links").select("resource_id");if(S)throw S;return w}}),g=o==null?void 0:o.filter(w=>{var C;const S=w.title.toLowerCase().includes(t.toLowerCase())||((C=w.description)==null?void 0:C.toLowerCase().includes(t.toLowerCase())),T=!n||w.category_id===n;return S&&T}),v=i==null?void 0:i.filter(w=>o==null?void 0:o.some(S=>S.category_id===w.id)),_=w=>{const S=(d==null?void 0:d.filter(I=>I.resource_id===w).length)||0,T=(m==null?void 0:m.filter(I=>I.resource_id===w).length)||0,C=(p==null?void 0:p.filter(I=>I.resource_id===w).length)||0;return{pdfCount:S,videoCount:T,linkCount:C}},k=w=>{e(`/brokerage-resources/${w}`)};return r.jsx(Ur,{title:"Brokerage Resources",description:"Access exclusive resources for brokerage managers",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(HTt,{}),r.jsx(GTt,{}),r.jsxs("div",{className:"relative max-w-md",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search resources...",value:t,onChange:w=>s(w.target.value),className:"pl-10"})]}),v&&v.length>0&&r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(_t,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),v.map(w=>r.jsx(_t,{variant:n===w.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(w.id),children:w.name},w.id))]}),!l&&r.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?r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((w,S)=>r.jsxs(ze,{children:[r.jsx(pr,{className:"h-40 w-full"}),r.jsx(Wt,{children:r.jsx(pr,{className:"h-5 w-3/4"})}),r.jsxs(qe,{children:[r.jsx(pr,{className:"h-4 w-full mb-2"}),r.jsx(pr,{className:"h-4 w-2/3"})]})]},S))}):(g==null?void 0:g.length)===0?r.jsxs(ze,{className:"p-12 text-center",children:[r.jsx(Pu,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No resources found"}),r.jsx("p",{className:"text-muted-foreground",children:t||n?"Try adjusting your filters":"Check back later for new resources"})]}):r.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:S,videoCount:T,linkCount:C}=_(w.id),I=i==null?void 0:i.find(R=>R.id===w.category_id);return r.jsxs(ze,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>k(w.id),children:[w.preview_image_url?r.jsx("img",{src:w.preview_image_url,alt:w.title,className:"w-full h-40 object-cover"}):r.jsx("div",{className:"w-full h-40 bg-muted flex items-center justify-center",children:r.jsx(Pu,{className:"h-16 w-16 text-muted-foreground"})}),r.jsx(Wt,{className:"pb-2",children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsx(Zt,{className:"text-lg line-clamp-1",children:w.title}),I&&r.jsx(_t,{variant:"secondary",className:"shrink-0 text-xs",children:I.name})]})}),r.jsxs(qe,{children:[w.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:w.description}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[S>0&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ya,{className:"h-4 w-4"}),S]}),T>0&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ma,{className:"h-4 w-4"}),T]}),C>0&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Lo,{className:"h-4 w-4"}),C]})]})]})]},w.id)})})]})})}const ZTt=()=>{const{resourceId:e}=Bl(),{data:t,isLoading:s}=Ht({queryKey:["brokerage-resource-detail",e],queryFn:async()=>{const{data:a,error:o}=await Y.from("brokerage_resources").select("*").eq("id",e).eq("is_published",!0).single();if(o)throw o;const{data:l}=await Y.from("brokerage_resource_pdfs").select("*").eq("resource_id",e).order("sort_order"),{data:i}=await Y.from("brokerage_resource_videos").select("*").eq("resource_id",e).order("sort_order"),{data:d}=await Y.from("brokerage_resource_links").select("*").eq("resource_id",e).order("sort_order");return{...a,pdfs:l||[],videos:i||[],links:d||[]}},enabled:!!e}),n=a=>a?a<1024?a+" B":a<1024*1024?(a/1024).toFixed(1)+" KB":(a/(1024*1024)).toFixed(1)+" MB":"";return s?r.jsx(Ur,{title:"Brokerage Resources",children:r.jsx("div",{className:"flex justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):t?r.jsx(Ur,{title:t.title,children:r.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto",children:[r.jsx(X,{variant:"ghost",size:"sm",asChild:!0,className:"gap-2",children:r.jsxs(vo,{to:"/brokerage-resources",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Resources"]})}),t.preview_image_url&&r.jsx("div",{className:"relative w-full rounded-lg overflow-hidden bg-muted",children:r.jsx("img",{src:t.preview_image_url,alt:t.title,className:"w-full max-h-[400px] object-cover"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:t.title}),t.description&&r.jsx("div",{className:"text-muted-foreground prose prose-sm max-w-none dark:prose-invert",dangerouslySetInnerHTML:{__html:t.description}})]}),t.videos&&t.videos.length>0&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(ma,{className:"h-4 w-4"}),"Videos (",t.videos.length,")"]}),r.jsx("div",{className:"space-y-4",children:t.videos.map(a=>r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"font-medium",children:a.title}),r.jsx("div",{className:"relative w-full",style:{paddingTop:"56.25%"},children:r.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))})]})}),t.pdfs&&t.pdfs.length>0&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(ya,{className:"h-4 w-4"}),"Documents (",t.pdfs.length,")"]}),r.jsx("div",{className:"grid gap-2",children:t.pdfs.map(a=>r.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:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:r.jsx(ya,{className:"h-4 w-4 text-primary"})}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-sm",children:a.name}),a.file_size&&r.jsx("div",{className:"text-xs text-muted-foreground",children:n(a.file_size)})]})]}),r.jsx(Fi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),t.links&&t.links.length>0&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[r.jsx(jn,{className:"h-4 w-4"}),"Canva Templates (",t.links.length,")"]}),r.jsx("div",{className:"grid gap-2",children:t.links.map(a=>r.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:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:r.jsx(jn,{className:"h-4 w-4 text-primary"})}),r.jsx("div",{className:"font-medium text-sm",children:a.title})]}),r.jsx(jn,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})})]})}):r.jsx(Ur,{title:"Brokerage Resources",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Pu,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold",children:"Resource not found"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"This resource may have been removed or is not available."}),r.jsx(X,{asChild:!0,className:"mt-4",children:r.jsx(vo,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function YTt(){const{onlineUsers:e,totalOnline:t}=YBe();return r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx(ws,{className:"h-4 w-4"}),"Online Now"]}),r.jsxs(_t,{variant:"secondary",className:"bg-green-100 text-green-700",children:[r.jsx(vh,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),t," online"]})]})}),r.jsx(qe,{children:e.length===0?r.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No other users online right now"}):r.jsx(To,{className:"h-[300px] pr-4",children:r.jsx("div",{className:"space-y-3",children:e.map(s=>{var n;return r.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted/50 transition-colors",children:[r.jsxs("div",{className:"relative",children:[r.jsxs(cn,{className:"h-9 w-9",children:[r.jsx(xa,{src:s.avatarUrl,alt:s.name}),r.jsx(dn,{className:"text-xs",children:(n=s.name)==null?void 0:n.split(" ").map(a=>a[0]).join("").slice(0,2).toUpperCase()})]}),r.jsx("span",{className:"absolute bottom-0 right-0 h-2.5 w-2.5 rounded-full bg-green-500 ring-2 ring-background"})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:s.name}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Online ",gu(new Date(s.onlineSince),{addSuffix:!1})]})]})]},s.id)})})})})]})}const Q3e={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:ws,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:FE,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:Dm,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:px,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:Uc,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:ws,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Bf,path:"/admin/prospector",color:"bg-gradient-to-br from-orange-500/20 to-amber-500/10 text-orange-600"}]},content:{label:"Content",sections:[{title:"Manage Templates",description:"Upload and organize Canva templates",icon:id,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:w1,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Hy,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:bn,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:bn,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:Vy,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:sg,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Pu,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Pu,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:Vs,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:bk,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:bm,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:Vs,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:ag,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:j4,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:po,path:"/admin/reward-store",color:"bg-purple-500/10 text-purple-600"},{title:"Agent Points",description:"View agent points, leaderboard, and award bonus points",icon:go,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:Fm,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:ws,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:ag,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:Vo,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:A4,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:$y,path:"/admin/wishlist",color:"bg-yellow-500/10 text-yellow-600"},{title:"Membership Reviews",description:"View member feedback and ratings",icon:Dn,path:"/admin/membership-reviews",color:"bg-amber-500/10 text-amber-600"},{title:"Weekly Digest",description:"Configure automated weekly email digests",icon:Vs,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:Rc,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:Ai,path:"/admin/agent-os",color:"bg-gradient-to-br from-rose-500/20 to-pink-500/10 text-rose-600"},{title:"Listing Exchange",description:"Approve, feature, and moderate community listings",icon:Vn,path:"/admin/listing-exchange",color:"bg-gradient-to-br from-blue-500/20 to-sky-500/10 text-blue-600"},{title:"Presentation Analytics",description:"Track agent presentation usage, views, and leads",icon:Ff,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:Oy,path:"/admin/guest-book-analytics",color:"bg-gradient-to-br from-emerald-500/20 to-teal-500/10 text-emerald-600"}]}};function XTt(){const e=Ks();return r.jsx(Ur,{title:"Admin Dashboard",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Admin Dashboard"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage all aspects of your platform"})]}),r.jsx("div",{className:"w-full lg:w-80",children:r.jsx(YTt,{})})]}),r.jsxs(ii,{defaultValue:"users",className:"w-full",children:[r.jsx(si,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1",children:Object.entries(Q3e).map(([t,s])=>r.jsx(Kr,{value:t,className:"data-[state=active]:bg-background",children:s.label},t))}),Object.entries(Q3e).map(([t,s])=>r.jsx(hs,{value:t,className:"mt-6",children:r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:s.sections.map(n=>r.jsxs(ze,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>e(n.path),children:[r.jsxs(Wt,{className:"pb-3",children:[r.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:r.jsx(n.icon,{className:"h-5 w-5"})}),r.jsx(Zt,{className:"text-base",children:n.title})]}),r.jsx(qe,{className:"pt-0",children:r.jsx(Cs,{className:"text-sm",children:n.description})})]},n.path))})},t))]})]})})}const Fn=A.forwardRef(({className:e,...t},s)=>r.jsx("div",{className:"relative w-full overflow-auto",children:r.jsx("table",{ref:s,className:Vt("w-full caption-bottom text-sm",e),...t})}));Fn.displayName="Table";const zn=A.forwardRef(({className:e,...t},s)=>r.jsx("thead",{ref:s,className:Vt("[&_tr]:border-b",e),...t}));zn.displayName="TableHeader";const Bn=A.forwardRef(({className:e,...t},s)=>r.jsx("tbody",{ref:s,className:Vt("[&_tr:last-child]:border-0",e),...t}));Bn.displayName="TableBody";const QTt=A.forwardRef(({className:e,...t},s)=>r.jsx("tfoot",{ref:s,className:Vt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));QTt.displayName="TableFooter";const Nr=A.forwardRef(({className:e,...t},s)=>r.jsx("tr",{ref:s,className:Vt("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",e),...t}));Nr.displayName="TableRow";const Mt=A.forwardRef(({className:e,...t},s)=>r.jsx("th",{ref:s,className:Vt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));Mt.displayName="TableHead";const dt=A.forwardRef(({className:e,...t},s)=>r.jsx("td",{ref:s,className:Vt("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));dt.displayName="TableCell";const JTt=A.forwardRef(({className:e,...t},s)=>r.jsx("caption",{ref:s,className:Vt("mt-4 text-sm text-muted-foreground",e),...t}));JTt.displayName="TableCaption";const eAt=()=>{const{isAdmin:e}=Gr(),t=Ks(),[s,n]=A.useState([]),[a,o]=A.useState(!0),[l,i]=A.useState(!1),[d,m]=A.useState(null);A.useEffect(()=>{if(!e){t("/dashboard");return}p()},[e]);const p=async()=>{try{const{data:w,error:S}=await Y.from("app_tiles").select("*").order("name");if(S)throw S;n(w||[])}catch(w){console.error("Error loading apps:",w),we.error("Failed to load apps")}finally{o(!1)}},g=async w=>{w.preventDefault();const S=new FormData(w.currentTarget),T={name:S.get("name"),description:S.get("description"),icon:S.get("icon"),app_id:S.get("app_id"),target_url:S.get("target_url"),required_tags:S.get("required_tags").split(",").map(C=>C.trim()).filter(Boolean)};try{if(d){const{error:C}=await Y.from("app_tiles").update(T).eq("id",d.id);if(C)throw C;we.success("App updated successfully")}else{const{error:C}=await Y.from("app_tiles").insert([T]);if(C)throw C;we.success("App created successfully")}i(!1),m(null),p()}catch(C){console.error("Error saving app:",C),we.error("Failed to save app")}},v=async w=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:S}=await Y.from("app_tiles").delete().eq("id",w);if(S)throw S;we.success("App deleted successfully"),p()}catch(S){console.error("Error deleting app:",S),we.error("Failed to delete app")}},_=w=>{m(w),i(!0)},k=()=>{m(null),i(!0)};return a?r.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}):r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx("header",{className:"border-b bg-card",children:r.jsx("div",{className:"container mx-auto px-4 py-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>t("/dashboard"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back"]}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Manage Apps"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Create and configure application tiles"})]})]}),r.jsxs(Ir,{open:l,onOpenChange:i,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{onClick:k,children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Add App"]})}),r.jsxs(Er,{className:"max-w-2xl",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:d?"Edit App":"Create New App"}),r.jsx(Zs,{children:"Configure the application tile settings"})]}),r.jsxs("form",{onSubmit:g,className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"App Name"}),r.jsx(Ye,{id:"name",name:"name",defaultValue:d==null?void 0:d.name,required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"app_id",children:"App ID"}),r.jsx(Ye,{id:"app_id",name:"app_id",defaultValue:d==null?void 0:d.app_id,placeholder:"agent_connect",required:!0})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",name:"description",defaultValue:d==null?void 0:d.description})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"icon",children:"Icon (emoji)"}),r.jsx(Ye,{id:"icon",name:"icon",defaultValue:d==null?void 0:d.icon,placeholder:"🚀",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"target_url",children:"Target URL"}),r.jsx(Ye,{id:"target_url",name:"target_url",type:"url",defaultValue:d==null?void 0:d.target_url,required:!0})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"required_tags",children:"Required Tags (comma-separated)"}),r.jsx(Ye,{id:"required_tags",name:"required_tags",defaultValue:d==null?void 0:d.required_tags.join(", "),placeholder:"levelup-member, agent-connect"})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),r.jsx(X,{type:"submit",children:d?"Update":"Create"})]})]})]})]})]})})}),r.jsx("div",{className:"container mx-auto px-4 py-8",children:r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Application Tiles"}),r.jsx(Cs,{children:"Manage the apps that appear on the member dashboard"})]}),r.jsx(qe,{children:s.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),r.jsxs(X,{onClick:k,children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Create First App"]})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Icon"}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"App ID"}),r.jsx(Mt,{children:"Target URL"}),r.jsx(Mt,{children:"Tags"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:s.map(w=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"text-2xl",children:w.icon}),r.jsx(dt,{className:"font-medium",children:w.name}),r.jsx(dt,{className:"font-mono text-sm",children:w.app_id}),r.jsx(dt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:w.target_url}),r.jsx(dt,{children:r.jsx("div",{className:"flex flex-wrap gap-1",children:w.required_tags.map(S=>r.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:S},S))})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>_(w),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>v(w.id),children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},w.id))})]})})]})})]})};function Hu({title:e,description:t,children:s}){return r.jsxs("div",{className:"space-y-4",children:[r.jsx(vo,{to:"/admin",children:r.jsxs(X,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Admin Dashboard"]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:e}),t&&r.jsx("p",{className:"text-muted-foreground",children:t})]}),s]})]})}const J3e=({expiresAt:e,className:t})=>{const s=new Date().getTime(),n=new Date(e).getTime(),a=Math.ceil((n-s)/(1e3*60*60*24));return a<=0?r.jsxs(_t,{variant:"destructive",className:Vt("gap-1",t),children:[r.jsx(ch,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?r.jsxs(_t,{variant:"destructive",className:Vt("gap-1",t),children:[r.jsx(Pa,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?r.jsxs(_t,{className:Vt("gap-1 bg-amber-500 hover:bg-amber-600",t),children:[r.jsx(Pa,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):r.jsxs(_t,{variant:"secondary",className:Vt("gap-1",t),children:[r.jsx(Pa,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},kqe=({open:e,onOpenChange:t,brokerages:s,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=_i(),l=A.useRef(null),[i,d]=A.useState([]),[m,p]=A.useState(""),[g,v]=A.useState(!1),[_,k]=A.useState("upload"),[w,S]=A.useState(null),T=()=>{d([]),p(""),k("upload"),S(null),l.current&&(l.current.value="")},C=()=>{T(),t(!1)},I=q=>{const W=q.split(` `).map(se=>se.trim()).filter(se=>se);if(W.length===0)return[];const K=W[0].toLowerCase(),ae=K.includes("first")||K.includes("last")||K.includes("email")||K.includes("name")||K.includes("phone")||K.includes("sms")||K.includes("consent")?W.slice(1):W,oe=[];for(const se of ae){const ie=(se.includes(" ")?se.split(" "):se.split(",")).map(de=>de.trim().replace(/^["']|["']$/g,""));if(ie.length>=2){let de="",ce="",ge="",Te="",_e;if(ie.length===2){const Ze=ie[0].split(" ");de=Ze[0]||"",ce=Ze.slice(1).join(" ")||"",ge=ie[1]}else if(ie.length===3)de=ie[0],ce=ie[1],ge=ie[2];else if(ie.length===4)de=ie[0],ce=ie[1],ge=ie[2],Te=ie[3];else if(ie.length>=5){de=ie[0],ce=ie[1],ge=ie[2],Te=ie[3];const Ze=ie[4].toLowerCase();_e=Ze==="true"||Ze==="yes"||Ze==="1"||Ze==="y"}const Me=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(ge);oe.push({firstName:de.trim(),lastName:ce.trim(),email:ge.trim().toLowerCase(),phone:Te.trim()||void 0,smsConsent:_e,isValid:Me&&de.trim().length>0,error:Me?de.trim()?void 0:"Missing name":"Invalid email"})}}return oe},R=q=>{var re;const W=(re=q.target.files)==null?void 0:re[0];if(!W)return;const K=new FileReader;K.onload=ae=>{var pe;const oe=(pe=ae.target)==null?void 0:pe.result,se=I(oe);if(se.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}d(se),k("preview")},K.readAsText(W)},D=async()=>{const q=i.filter(K=>K.isValid);if(q.length===0){o({title:"No valid users",description:"There are no valid users to import.",variant:"destructive"});return}const W=n||m||null;v(!0);try{const{data:{session:K}}=await Y.auth.getSession(),re=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/bulk-create-users",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${K==null?void 0:K.access_token}`},body:JSON.stringify({users:q.map(oe=>({firstName:oe.firstName,lastName:oe.lastName,email:oe.email,phone:oe.phone,smsConsent:oe.smsConsent})),brokerageId:W})}),ae=await re.json();if(!re.ok)throw new Error(ae.error||"Failed to import users");S(ae),k("result"),ae.created>0&&a(),o({title:"Import Complete",description:`${ae.created} user(s) created successfully.${ae.failed>0?` ${ae.failed} failed.`:""}`})}catch(K){console.error("Import error:",K),o({title:"Import Failed",description:K.message||"Failed to import users",variant:"destructive"})}finally{v(!1)}},B=i.filter(q=>q.isValid).length,$=i.filter(q=>!q.isValid).length;return r.jsx(Ir,{open:e,onOpenChange:C,children:r.jsxs(Er,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(_1,{className:"h-5 w-5"}),"Import Agents from CSV"]}),r.jsx(Zs,{children:"Upload a CSV file with agent information. Each row should contain First Name, Last Name, and Email."})]}),_==="upload"&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[r.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:R,className:"hidden"}),r.jsx(Xi,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),r.jsx(X,{onClick:()=>{var q;return(q=l.current)==null?void 0:q.click()},children:"Select CSV File"})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[r.jsx("p",{className:"font-medium mb-2",children:"Expected CSV Format:"}),r.jsxs("code",{className:"text-xs block bg-background p-2 rounded",children:["First Name, Last Name, Email, Phone, SMS Consent",r.jsx("br",{}),"John, Doe, john@example.com, 555-123-4567, yes",r.jsx("br",{}),"Jane, Smith, jane@example.com, 555-987-6543, true"]}),r.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"&&r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[!n&&s&&s.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Assign to Brokerage (optional)"}),r.jsxs(ds,{value:m||"none",onValueChange:q=>p(q==="none"?"":q),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a brokerage..."})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No brokerage"}),s.map(q=>r.jsx(Ut,{value:q.id,children:q.name},q.id))]})]})]}),r.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ri,{className:"h-4 w-4 text-green-500"}),r.jsxs("span",{children:[B," valid"]})]}),$>0&&r.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[r.jsx(kl,{className:"h-4 w-4"}),r.jsxs("span",{children:[$," invalid"]})]})]}),r.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/30",children:[r.jsx(Mt,{children:"First Name"}),r.jsx(Mt,{children:"Last Name"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Phone"}),r.jsx(Mt,{children:"SMS"}),r.jsx(Mt,{children:"Status"})]})}),r.jsx(Bn,{children:i.slice(0,100).map((q,W)=>r.jsxs(Nr,{children:[r.jsx(dt,{children:q.firstName}),r.jsx(dt,{children:q.lastName}),r.jsx(dt,{children:q.email}),r.jsx(dt,{className:"text-muted-foreground",children:q.phone||"-"}),r.jsx(dt,{className:"text-muted-foreground",children:q.smsConsent===!0?"✓":q.smsConsent===!1?"✗":"-"}),r.jsx(dt,{children:q.isValid?r.jsx(_t,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):r.jsx(_t,{variant:"destructive",children:q.error||"Invalid"})})]},W))})]}),i.length>100&&r.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",i.length," users"]})]})]}),_==="result"&&w&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"text-center",children:[r.jsx(Ri,{className:"h-12 w-12 mx-auto text-green-500 mb-4"}),r.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),r.jsxs("p",{className:"text-muted-foreground mt-2",children:[w.created," agent(s) created and invited"]}),w.failed>0&&r.jsxs("p",{className:"text-destructive mt-1",children:[w.failed," failed to create"]})]}),w.errors.length>0&&r.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 max-h-40 overflow-auto",children:[r.jsx("p",{className:"font-medium text-destructive text-sm mb-2",children:"Errors:"}),r.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[w.errors.slice(0,10).map((q,W)=>r.jsxs("li",{children:["• ",q]},W)),w.errors.length>10&&r.jsxs("li",{children:["...and ",w.errors.length-10," more"]})]})]})]}),r.jsxs(Rn,{children:[_==="upload"&&r.jsx(X,{variant:"outline",onClick:C,children:"Cancel"}),_==="preview"&&r.jsxs(r.Fragment,{children:[r.jsx(X,{variant:"outline",onClick:T,children:"Back"}),r.jsx(X,{onClick:D,disabled:g||B===0,children:g?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${B} Agent${B!==1?"s":""}`})]}),_==="result"&&r.jsx(X,{onClick:C,children:"Done"})]})]})})},tAt=[{type:"custom",title:"Great job!",message:"Keep up the amazing work!",icon:Dn},{type:"custom",title:"You're on fire!",message:"Your dedication is inspiring!",icon:go},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:od}];function Nqe({open:e,onOpenChange:t,userId:s,userName:n}){const[a,o]=A.useState("custom"),[l,i]=A.useState(""),[d,m]=A.useState(""),p=rpt(),g=_=>{o(_.type),i(_.title),m(_.message)},v=async _=>{if(_.preventDefault(),!l.trim()){ta({title:"Title required",description:"Please enter a celebration title",variant:"destructive"});return}try{await p.mutateAsync({user_id:s,celebration_type:a,title:l.trim(),message:d.trim()||void 0}),ta({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),t(!1),i(""),m(""),o("custom")}catch{ta({title:"Error",description:"Failed to send celebration",variant:"destructive"})}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(od,{className:"h-5 w-5 text-primary"}),"Send Celebration to ",n]}),r.jsx(Zs,{children:"They'll see confetti and this message next time they log in!"})]}),r.jsxs("div",{className:"mb-4",children:[r.jsx(Ee,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),r.jsx("div",{className:"flex gap-2 flex-wrap",children:tAt.map((_,k)=>r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>g(_),className:"text-xs",children:[r.jsx(_.icon,{className:"h-3 w-3 mr-1"}),_.title]},k))})]}),r.jsxs("form",{onSubmit:v,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"type",children:"Celebration Type"}),r.jsxs(ds,{value:a,onValueChange:_=>o(_),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"custom",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Dn,{className:"h-4 w-4"})," Custom"]})}),r.jsx(Ut,{value:"points_earned",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(go,{className:"h-4 w-4"})," Points Earned"]})}),r.jsx(Ut,{value:"listing_created",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Vn,{className:"h-4 w-4"})," Listing Created"]})}),r.jsx(Ut,{value:"deal_closed",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Sd,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"title",children:"Title *"}),r.jsx(Ye,{id:"title",value:l,onChange:_=>i(_.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"message",children:"Message (optional)"}),r.jsx(qs,{id:"message",value:d,onChange:_=>m(_.target.value),placeholder:"Add a personal message...",rows:3,maxLength:500})]}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:p.isPending,children:[r.jsx(od,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const phe={points_earned:{label:"Points Earned",icon:go,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Vn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:Sd,color:"bg-green-500"},custom:{label:"Custom",icon:bn,color:"bg-purple-500"}};function rAt(){const[e,t]=A.useState(""),[s,n]=A.useState("all"),[a,o]=A.useState("all"),{data:l=[],isLoading:i}=Ht({queryKey:["admin-celebrations"],queryFn:async()=>{const{data:p,error:g}=await Y.from("celebration_queue").select("*").order("created_at",{ascending:!1}).limit(500);if(g)throw g;const v=[...new Set([...p.map(w=>w.user_id),...p.map(w=>w.created_by).filter(Boolean)])],{data:_}=await Y.from("profiles").select("id, name, email").in("id",v),k=new Map((_==null?void 0:_.map(w=>[w.id,w]))||[]);return p.map(w=>{var S,T,C;return{...w,user_name:((S=k.get(w.user_id))==null?void 0:S.name)||"Unknown",user_email:((T=k.get(w.user_id))==null?void 0:T.email)||"",creator_name:w.created_by?((C=k.get(w.created_by))==null?void 0:C.name)||"System":"Auto-triggered"}})}}),d=l.filter(p=>{var k,w;const g=((k=p.user_name)==null?void 0:k.toLowerCase().includes(e.toLowerCase()))||((w=p.user_email)==null?void 0:w.toLowerCase().includes(e.toLowerCase()))||p.title.toLowerCase().includes(e.toLowerCase()),v=s==="all"||p.celebration_type===s,_=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return g&&v&&_}),m={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(phe).reduce((p,g)=>(p[g]=l.filter(v=>v.celebration_type===g).length,p),{})};return i?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium",children:"Total Celebrations"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:m.total})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold text-green-600",children:m.seen})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold text-orange-600",children:m.unseen})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold text-purple-600",children:m.byType.custom||0})})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(od,{className:"h-5 w-5"}),"Celebration History"]}),r.jsx(Cs,{children:"View all celebrations awarded to agents"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by agent name, email, or title...",value:e,onChange:p=>t(p.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:s,onValueChange:n,children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{placeholder:"Filter by type"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Types"}),Object.entries(phe).map(([p,g])=>r.jsx(Ut,{value:p,children:g.label},p))]})]}),r.jsxs(ds,{value:a,onValueChange:o,children:[r.jsx(ls,{className:"w-[140px]",children:r.jsx(us,{placeholder:"Status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Status"}),r.jsx(Ut,{value:"seen",children:"Seen"}),r.jsx(Ut,{value:"unseen",children:"Pending"})]})]})]}),r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Type"}),r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Points"}),r.jsx(Mt,{children:"Created By"}),r.jsx(Mt,{children:"Created"}),r.jsx(Mt,{children:"Status"})]})}),r.jsx(Bn,{children:d.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):d.map(p=>{const g=phe[p.celebration_type],v=g.icon;return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs(_t,{variant:"outline",className:"gap-1",children:[r.jsx(v,{className:"h-3 w-3"}),g.label]})}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:p.user_name}),r.jsx("div",{className:"text-xs text-muted-foreground",children:p.user_email})]})}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:p.title}),p.message&&r.jsx("div",{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:p.message})]})}),r.jsx(dt,{children:p.points_amount?r.jsxs(_t,{variant:"secondary",children:["+",p.points_amount]}):r.jsx("span",{className:"text-muted-foreground",children:"-"})}),r.jsx(dt,{children:r.jsx("span",{className:"text-sm text-muted-foreground",children:p.creator_name})}),r.jsx(dt,{children:r.jsx("span",{className:"text-sm text-muted-foreground",children:Xr(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),r.jsx(dt,{children:p.seen_at?r.jsx(_t,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):r.jsx(_t,{variant:"outline",className:"bg-orange-50 text-orange-700 border-orange-200",children:"Pending"})})]},p.id)})})]})}),d.length>0&&r.jsxs("p",{className:"text-sm text-muted-foreground text-right",children:["Showing ",d.length," of ",l.length," celebrations"]})]})]})]})}const sAt=()=>{const{user:e}=Gr(),{toast:t}=_i(),[s,n]=A.useState([]),[a,o]=A.useState(!0),[l,i]=A.useState(!1),[d,m]=A.useState("all"),[p,g]=A.useState("all"),[v,_]=A.useState("new"),[k,w]=A.useState(new Set),S=A.useCallback(async()=>{try{o(!0);const{data:oe,error:se}=await Y.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(se)throw se;const{data:pe,error:ie}=await Y.from("trial_email_exports").select("user_id");if(ie)throw ie;const de=new Set((pe||[]).map(ge=>ge.user_id)),ce=(oe||[]).map(ge=>({...ge,converted_from_trial_at:ge.converted_from_trial_at??null,already_exported:de.has(ge.id)}));ce.sort((ge,Te)=>new Date(Te.created_at).getTime()-new Date(ge.created_at).getTime()),n(ce)}catch(oe){console.error("Error loading trial users:",oe),t({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[t]);A.useEffect(()=>{S()},[S]);const T=oe=>oe.trial_started_at?"ghl":"stripe",C=oe=>oe.trial_expires_at?oe.trial_expires_at:oe.subscription_end_date?oe.subscription_end_date:null,I=oe=>oe.converted_from_trial_at!==null,R=oe=>{if(I(oe))return!1;const se=C(oe);return se?new Date(se).getTime()<=Date.now():!1},D=s.filter(oe=>!(d!=="all"&&T(oe)!==d||p==="active"&&(R(oe)||I(oe))||p==="expired"&&!R(oe)||p==="converted"&&!I(oe)||v==="new"&&oe.already_exported||v==="exported"&&!oe.already_exported)),B=()=>{k.size===D.length?w(new Set):w(new Set(D.map(oe=>oe.id)))},$=oe=>{const se=new Set(k);se.has(oe)?se.delete(oe):se.add(oe),w(se)},q=async()=>{if(k.size===0){t({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const oe=s.filter(_e=>k.has(_e.id)),se="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",pe=oe.map(_e=>{const ve=(_e.name||"").split(" "),Me=ve[0]||"",Ze=ve.slice(1).join(" ")||"",Ae=T(_e)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Le=I(_e)?"Converted":R(_e)?"Expired":"Active",Ue=_e.created_at?new Date(_e.created_at).toLocaleDateString():"",Ve=C(_e)?new Date(C(_e)).toLocaleDateString():"";return`"${Me}","${Ze}","${_e.email}","${_e.phone||""}","${Ae}","${Le}","${Ue}","${Ve}"`}),ie=[se,...pe].join(` `),de=new Blob([ie],{type:"text/csv"}),ce=URL.createObjectURL(de),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=oe.filter(_e=>!_e.already_exported).map(_e=>({user_id:_e.id,exported_by:e.id}));if(Te.length>0){const{error:_e}=await Y.from("trial_email_exports").upsert(Te,{onConflict:"user_id"});_e&&console.error("Error marking exports:",_e)}t({title:"Export complete",description:`Downloaded ${oe.length} trial user(s). ${Te.length} newly marked as exported.`}),w(new Set),S()}catch(oe){console.error("Export error:",oe),t({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},W=s.filter(oe=>!oe.already_exported).length,K=s.filter(oe=>oe.already_exported).length,re=s.filter(oe=>I(oe)).length,ae=s.filter(oe=>!R(oe)&&!I(oe)).length;return a?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-4",children:[r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"Total"}),r.jsx(Zt,{className:"text-2xl",children:s.length})]})}),r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"New (Not Exported)"}),r.jsx(Zt,{className:"text-2xl text-green-600",children:W})]})}),r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"Active Trials"}),r.jsx(Zt,{className:"text-2xl",children:ae})]})}),r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"Converted 🎉"}),r.jsx(Zt,{className:"text-2xl text-primary",children:re})]})}),r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"Already Exported"}),r.jsx(Zt,{className:"text-2xl text-muted-foreground",children:K})]})})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsxs(ds,{value:v,onValueChange:oe=>_(oe),children:[r.jsx(ls,{className:"w-[160px]",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Users"}),r.jsx(Ut,{value:"new",children:"New Only"}),r.jsx(Ut,{value:"exported",children:"Already Exported"})]})]}),r.jsxs(ds,{value:d,onValueChange:oe=>m(oe),children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Trial Types"}),r.jsx(Ut,{value:"stripe",children:"Credit Card Trial"}),r.jsx(Ut,{value:"ghl",children:"Free Trial (No CC)"})]})]}),r.jsxs(ds,{value:p,onValueChange:oe=>g(oe),children:[r.jsx(ls,{className:"w-[160px]",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Statuses"}),r.jsx(Ut,{value:"active",children:"Active Trial"}),r.jsx(Ut,{value:"expired",children:"Expired"}),r.jsx(Ut,{value:"converted",children:"Converted ✓"})]})]}),r.jsx("div",{className:"ml-auto",children:r.jsxs(X,{onClick:q,disabled:l||k.size===0,children:[l?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export Selected (",k.size,")"]})})]}),r.jsx("div",{className:"border rounded-lg",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/30 hover:bg-muted/30",children:[r.jsx(Mt,{className:"w-[40px]",children:r.jsx(Qo,{checked:D.length>0&&k.size===D.length,onCheckedChange:B})}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Trial Type"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Signup Date"}),r.jsx(Mt,{children:"Expires / Renews"}),r.jsx(Mt,{children:"Exported"})]})}),r.jsx(Bn,{children:D.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):D.map(oe=>{const se=T(oe),pe=I(oe),ie=R(oe),de=C(oe);return r.jsxs(Nr,{className:`hover:bg-muted/30 ${pe?"bg-primary/5":""}`,children:[r.jsx(dt,{children:r.jsx(Qo,{checked:k.has(oe.id),onCheckedChange:()=>$(oe.id)})}),r.jsx(dt,{className:"font-medium",children:r.jsxs("div",{className:"flex items-center gap-2",children:[oe.name,pe&&r.jsx(pu,{className:"h-3.5 w-3.5 text-primary"})]})}),r.jsx(dt,{className:"text-muted-foreground",children:oe.email}),r.jsx(dt,{children:se==="stripe"?r.jsxs(_t,{variant:"outline",className:"gap-1",children:[r.jsx(Dm,{className:"h-3 w-3"}),"Credit Card"]}):r.jsxs(_t,{variant:"secondary",className:"gap-1",children:[r.jsx(Vs,{className:"h-3 w-3"}),"Free (No CC)"]})}),r.jsx(dt,{children:pe?r.jsxs(_t,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[r.jsx(pu,{className:"h-3 w-3"}),"Converted"]}):ie?r.jsx(_t,{variant:"destructive",children:"Expired"}):r.jsx(_t,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),r.jsx(dt,{className:"text-sm",children:oe.created_at?new Date(oe.created_at).toLocaleDateString():"—"}),r.jsx(dt,{className:"text-sm",children:pe&&de?r.jsxs("span",{className:"text-muted-foreground",children:["Renews ",new Date(de).toLocaleDateString()]}):de?new Date(de).toLocaleDateString():"—"}),r.jsx(dt,{children:oe.already_exported?r.jsx(Ri,{className:"h-4 w-4 text-muted-foreground"}):r.jsx(_t,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},oe.id)})})]})}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",D.length," of ",s.length," trial users · ",re," converted to paid"]})]})},nAt=()=>{const[e,t]=A.useState([]),[s,n]=A.useState(!0);return A.useEffect(()=>{(async()=>{const{data:o,error:l}=await Y.from("user_deletion_log").select("*").order("created_at",{ascending:!1});!l&&o&&t(o),n(!1)})()},[]),s?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center text-muted-foreground",children:[r.jsx(Os,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),r.jsx("p",{children:"No deletion records yet"})]})}):r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"User Deletion History"})}),r.jsx(qe,{children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Date"}),r.jsx(Mt,{children:"User"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Brokerage"}),r.jsx(Mt,{children:"Type"}),r.jsx(Mt,{children:"Deleted By"})]})}),r.jsx(Bn,{children:e.map(a=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"whitespace-nowrap text-sm",children:Xr(new Date(a.created_at),"MMM d, yyyy h:mm a")}),r.jsx(dt,{className:"font-medium",children:a.deleted_user_name||"—"}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:a.deleted_user_email||"—"}),r.jsx(dt,{children:a.brokerage_name||"—"}),r.jsx(dt,{children:r.jsx(_t,{variant:a.deletion_type==="deleted"?"destructive":"secondary",children:a.deletion_type==="deleted"?"Account Deleted":"Removed"})}),r.jsx(dt,{className:"text-sm",children:a.deleted_by_name||a.deleted_by_email||"—"})]},a.id))})]})})]})},jN=e=>{const{user:t}=Gr(),s=Rr(),n=Ht({queryKey:["teams",e],queryFn:async()=>{let g=Y.from("teams").select("*").order("created_at",{ascending:!1});e&&(g=g.eq("brokerage_id",e));const{data:v,error:_}=await g;if(_)throw _;return v||[]},enabled:!!t}),a=g=>Ht({queryKey:["team-members",g],queryFn:async()=>{const{data:v,error:_}=await Y.from("team_members").select("*").eq("team_id",g).order("role",{ascending:!0});if(_)throw _;const k=(v||[]).map(T=>T.user_id),{data:w}=await Y.from("profiles").select("id, name, email, avatar_url").in("id",k),S=new Map((w||[]).map(T=>[T.id,T]));return(v||[]).map(T=>({...T,profile:S.get(T.user_id)||null}))},enabled:!!g}),o=Qt({mutationFn:async g=>{const v={name:g.name,created_by:t.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:k}=await Y.from("teams").insert(v).select().single();if(k)throw k;return _},onSuccess:()=>{s.invalidateQueries({queryKey:["teams"]}),we.success("Team created!")},onError:g=>{we.error("Failed to create team: "+g.message)}}),l=Qt({mutationFn:async({id:g,...v})=>{const{data:_,error:k}=await Y.from("teams").update(v).eq("id",g).select().single();if(k)throw k;return _},onSuccess:()=>{s.invalidateQueries({queryKey:["teams"]}),we.success("Team updated")},onError:g=>{we.error("Failed to update team: "+g.message)}}),i=Qt({mutationFn:async g=>{const{error:v}=await Y.from("teams").delete().eq("id",g);if(v)throw v},onSuccess:()=>{s.invalidateQueries({queryKey:["teams"]}),we.success("Team deleted")},onError:g=>{we.error("Failed to delete team: "+g.message)}}),d=Qt({mutationFn:async g=>{const{data:v,error:_}=await Y.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)=>{s.invalidateQueries({queryKey:["team-members",v.team_id]}),we.success("Member added to team")},onError:g=>{we.error(g.message)}}),m=Qt({mutationFn:async g=>{const{error:v}=await Y.from("team_members").delete().eq("id",g.member_id);if(v)throw v},onSuccess:(g,v)=>{s.invalidateQueries({queryKey:["team-members",v.team_id]}),we.success("Member removed from team")},onError:g=>{we.error("Failed to remove member: "+g.message)}}),p=Qt({mutationFn:async g=>{const{error:v}=await Y.from("team_members").update({role:g.role}).eq("id",g.member_id);if(v)throw v},onSuccess:(g,v)=>{s.invalidateQueries({queryKey:["team-members",v.team_id]}),we.success("Member role updated")},onError:g=>{we.error("Failed to update role: "+g.message)}});return{teams:n.data||[],isLoading:n.isLoading,createTeam:o,updateTeam:l,deleteTeam:i,addMember:d,removeMember:m,updateMemberRole:p,useTeamMembers:a}},aAt=()=>{const{user:e}=Gr();return Ht({queryKey:["team-contacts",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.rpc("get_team_contacts",{_user_id:e.id});if(s)throw s;return t||[]},enabled:!!e})},Sqe=e=>{const{user:t}=Gr(),s=Rr(),n=Ht({queryKey:["lead-pond",e],queryFn:async()=>{const{data:i,error:d}=await Y.from("team_lead_pond").select("*").eq("team_id",e).order("created_at",{ascending:!1});if(d)throw d;if(!i||i.length===0)return[];const m=i.map(T=>T.contact_id),p=[...new Set(i.map(T=>T.added_by))],g=i.filter(T=>T.claimed_by).map(T=>T.claimed_by),v=[...new Set([...p,...g])],[_,k]=await Promise.all([Y.from("innercircle_contacts").select("id, first_name, last_name, email, phone").in("id",m),Y.from("profiles").select("id, name, avatar_url").in("id",v)]),w=new Map((_.data||[]).map(T=>[T.id,T])),S=new Map((k.data||[]).map(T=>[T.id,T]));return i.map(T=>({...T,status:T.claimed_by?"claimed":"available",contact:w.get(T.contact_id)||null,contributor:S.get(T.added_by)||null,claimer:T.claimed_by&&S.get(T.claimed_by)||null}))},enabled:!!e&&!!t}),a=Qt({mutationFn:async i=>{const{data:d,error:m}=await Y.rpc("add_to_lead_pond",{_contact_id:i.contact_id,_team_id:i.team_id,_notes:i.notes||null});if(m)throw m;return d},onSuccess:()=>{s.invalidateQueries({queryKey:["lead-pond"]}),we.success("Contact added to Lead Pond")},onError:i=>{we.error(i.message)}}),o=Qt({mutationFn:async i=>{const{error:d}=await Y.rpc("claim_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{s.invalidateQueries({queryKey:["lead-pond"]}),we.success("Lead claimed!")},onError:i=>{we.error(i.message)}}),l=Qt({mutationFn:async i=>{const{error:d}=await Y.rpc("return_lead_pond_contact",{_lead_pond_id:i});if(d)throw d},onSuccess:()=>{s.invalidateQueries({queryKey:["lead-pond"]}),we.success("Lead returned to pond")},onError:i=>{we.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},iAt=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.rpc("transfer_contact",{_contact_id:t.contactId,_to_user_id:t.toUserId,_notes:t.notes||null});if(n)throw n;const a=s;if(!a.success)throw new Error(a.error);return a},onSuccess:()=>{e.invalidateQueries({queryKey:["innercircle-contacts"]}),e.invalidateQueries({queryKey:["team-contacts"]}),e.invalidateQueries({queryKey:["innercircle-contact-counts"]}),we.success("Contact transferred successfully")},onError:t=>{we.error(t.message||"Failed to transfer contact")}})};function Cqe({open:e,onOpenChange:t,contactIds:s,contactNames:n=[],onComplete:a}){var D;const{user:o}=Gr(),{data:l}=o_(),{useTeamMembers:i}=jN(),{data:d=[]}=i((l==null?void 0:l.teamId)||""),m=iAt(),[p,g]=A.useState(null),[v,_]=A.useState(""),[k,w]=A.useState(!1),S=d.filter(B=>B.user_id!==(o==null?void 0:o.id)),T=async()=>{if(p){w(!0);try{for(const B of s)await m.mutateAsync({contactId:B,toUserId:p,notes:v||void 0});t(!1),g(null),_(""),a==null||a()}catch{}finally{w(!1)}}},C=S.find(B=>B.user_id===p),I=s.length>1,R=n.length>0?I?`${n.length} contacts`:n[0]:I?`${s.length} contacts`:"this contact";return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Dy,{className:"h-5 w-5"}),"Transfer ",R]}),r.jsxs(Zs,{children:["Select a team member to transfer ",I?"these contacts":"this contact"," to. The contact will be removed from the current owner's CRM and added to the selected member's."]})]}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium mb-2 block",children:"Transfer to:"}),r.jsx("div",{className:"space-y-1 max-h-[240px] overflow-y-auto",children:S.length===0?r.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):S.map(B=>{var $,q,W;return r.jsxs("button",{onClick:()=>g(B.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===B.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:(($=B.profile)==null?void 0:$.avatar_url)||""}),r.jsx(dn,{className:"text-xs",children:(((q=B.profile)==null?void 0:q.name)||"?").charAt(0).toUpperCase()})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",children:((W=B.profile)==null?void 0:W.name)||"Unknown"}),r.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:B.role.replace("_"," ")})]})]},B.user_id)})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),r.jsx(qs,{id:"transfer-notes",value:v,onChange:B=>_(B.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{onClick:T,disabled:!p||k,children:[k?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(Dy,{className:"h-4 w-4 mr-2"}),"Transfer",C?` to ${(D=C.profile)==null?void 0:D.name}`:""]})]})]})})}const x_e=()=>{const e=Ks(),{data:t,isLoading:s}=aAt(),{data:n}=o_(),[a,o]=A.useState(""),[l,i]=A.useState("all"),[d,m]=A.useState(null),[p,g]=A.useState(""),v=(n==null?void 0:n.role)==="team_leader",_=A.useMemo(()=>{if(!t)return[];const w=new Map;return t.forEach(S=>{w.has(S.owner_user_id)||w.set(S.owner_user_id,{id:S.owner_user_id,name:S.owner_name||"Unknown",avatar:S.owner_avatar_url})}),Array.from(w.values())},[t]),k=A.useMemo(()=>{if(!t)return[];let w=t;if(l!=="all"&&(w=w.filter(S=>S.owner_user_id===l)),a.trim()){const S=a.toLowerCase();w=w.filter(T=>{var C,I,R;return(T.first_name+" "+(T.last_name||"")).toLowerCase().includes(S)||((C=T.email)==null?void 0:C.toLowerCase().includes(S))||((I=T.phone)==null?void 0:I.includes(S))||((R=T.owner_name)==null?void 0:R.toLowerCase().includes(S))})}return w},[t,a,l]);return s?r.jsxs("div",{className:"space-y-4",children:[r.jsx(pr,{className:"h-10 w-full"}),r.jsx(pr,{className:"h-64 w-full"})]}):!t||t.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ws,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Team Contacts"}),r.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."})]})}):r.jsxs("div",{className:"space-y-4",children:[r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name, email, phone, or agent...",value:a,onChange:w=>o(w.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:l,onValueChange:i,children:[r.jsx(ls,{className:"w-[200px]",children:r.jsx(us,{placeholder:"Filter by agent"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Team Members"}),_.map(w=>r.jsx(Ut,{value:w.id,children:w.name},w.id))]})]})]})})}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:[k.length," contact",k.length!==1?"s":""," from ",_.length," teammate",_.length!==1?"s":""]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0 overflow-x-auto",children:r.jsxs(Fn,{className:"min-w-[800px]",children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{children:"Contact Info"}),r.jsx(Mt,{children:"Address"}),r.jsx(Mt,{children:"Lead Source"}),r.jsx(Mt,{children:"Date Added"}),v&&r.jsx(Mt,{className:"w-[80px]",children:"Actions"})]})}),r.jsx(Bn,{children:k.length===0?r.jsx(Nr,{children:r.jsx(dt,{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"})}):k.map(w=>r.jsxs(Nr,{className:`hover:bg-accent/50 ${v?"cursor-pointer":""}`,onClick:v?()=>e(`/mission-control/contacts/${w.id}`):void 0,children:[r.jsx(dt,{className:"font-medium",children:r.jsxs("span",{className:v?"hover:text-primary hover:underline transition-colors":"",children:[w.first_name," ",w.last_name||""]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(cn,{className:"h-6 w-6",children:[r.jsx(xa,{src:w.owner_avatar_url||""}),r.jsx(dn,{className:"text-[10px]",children:(w.owner_name||"?").charAt(0).toUpperCase()})]}),r.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:w.owner_name||"Unknown"})]})}),r.jsx(dt,{children:r.jsxs("div",{className:"space-y-1 text-sm",children:[w.email&&r.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Vs,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{className:"truncate",children:w.email})]}),w.phone&&r.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(fi,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{children:w.phone})]}),!w.email&&!w.phone&&r.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),r.jsx(dt,{children:w.address?r.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[r.jsx(Yi,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{className:"truncate max-w-[180px]",children:w.address})]}):r.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),r.jsx(dt,{children:w.lead_source?r.jsx(_t,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:w.lead_source}):r.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),r.jsx(dt,{children:r.jsx("span",{className:"text-sm text-muted-foreground",children:Xr(new Date(w.created_at),"MMM d, yyyy")})}),v&&r.jsx(dt,{children:r.jsx(X,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:S=>{S.stopPropagation(),m(w.id),g(`${w.first_name} ${w.last_name||""}`.trim())},title:"Transfer to team member",children:r.jsx(Dy,{className:"h-4 w-4"})})})]},w.id))})]})})}),r.jsx(Cqe,{open:!!d,onOpenChange:w=>{w||m(null)},contactIds:d?[d]:[],contactNames:p?[p]:[],onComplete:()=>m(null)})]})},y_e=({teamId:e})=>{const{user:t}=Gr(),{leadPondItems:s,isLoading:n,claimLead:a,returnLead:o}=Sqe(e);if(console.log("[LeadPondView] render — teamId:",e,"itemCount:",s.length,"loading:",n),n)return r.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>r.jsx(pr,{className:"h-20 w-full"},d))});if(s.length===0)return r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(dx,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Lead Pond is Empty"}),r.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=s.filter(d=>d.status==="available"),i=s.filter(d=>d.status==="claimed");return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Available (",l.length,")"]}),l.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No leads available right now."}):r.jsx("div",{className:"space-y-2",children:l.map(d=>{var m,p,g,v,_,k,w;return r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center justify-between p-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("p",{className:"font-medium text-sm",children:[(m=d.contact)==null?void 0:m.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),r.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-1",children:[((g=d.contact)==null?void 0:g.email)&&r.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r.jsx(Vs,{className:"h-3 w-3"})," ",d.contact.email]}),((v=d.contact)==null?void 0:v.phone)&&r.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r.jsx(fi,{className:"h-3 w-3"})," ",d.contact.phone]})]}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsxs(cn,{className:"h-4 w-4",children:[r.jsx(xa,{src:((_=d.contributor)==null?void 0:_.avatar_url)||""}),r.jsx(dn,{className:"text-[8px]",children:(((k=d.contributor)==null?void 0:k.name)||"?").charAt(0)})]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((w=d.contributor)==null?void 0:w.name)||"Unknown"]})]})]}),r.jsxs(X,{size:"sm",onClick:()=>a.mutate(d.id),disabled:a.isPending,children:[r.jsx(pE,{className:"mr-1 h-3 w-3"}),"Claim"]})]})},d.id)})})]}),i.length>0&&r.jsxs("div",{children:[r.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:["Claimed (",i.length,")"]}),r.jsx("div",{className:"space-y-2",children:i.map(d=>{var m,p,g;return r.jsx(ze,{className:"opacity-75",children:r.jsxs(qe,{className:"flex items-center justify-between p-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("p",{className:"font-medium text-sm",children:[(m=d.contact)==null?void 0:m.first_name," ",((p=d.contact)==null?void 0:p.last_name)||""]}),r.jsx("div",{className:"flex items-center gap-2 mt-1",children:r.jsxs(_t,{variant:"secondary",className:"text-xs",children:["Claimed by ",((g=d.claimer)==null?void 0:g.name)||"Unknown"]})})]}),d.claimed_by===(t==null?void 0:t.id)&&r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>o.mutate(d.id),disabled:o.isPending,children:[r.jsx(Mk,{className:"mr-1 h-3 w-3"}),"Return"]})]})},d.id)})})]})]})},Mqe=({teamId:e})=>{const{useTeamMembers:t}=jN(),{data:s=[]}=t(e),n=s.map(_=>_.user_id),a=new Map(s.map(_=>[_.user_id,_.profile])),{data:o=[],isLoading:l}=Ht({queryKey:["team-shared-presentations",e,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:k}=await Y.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(k)throw k;return _||[]},enabled:n.length>0}),{data:i=[],isLoading:d}=Ht({queryKey:["team-shared-open-houses",e,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:k}=await Y.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(k)throw k;return _||[]},enabled:n.length>0}),{data:m=[],isLoading:p}=Ht({queryKey:["team-shared-videos",e,n],queryFn:async()=>{if(n.length===0)return[];const{data:_,error:k}=await Y.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(k)throw k;return _||[]},enabled:n.length>0});if(l||d||p)return r.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>r.jsx(pr,{className:"h-20 w-full"},_))});const v=_=>{const k=a.get(_);return{name:(k==null?void 0:k.name)||"Unknown",avatar:(k==null?void 0:k.avatar_url)||"",initials:((k==null?void 0:k.name)||"?").charAt(0).toUpperCase()}};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid gap-3 grid-cols-3",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center gap-3 p-4",children:[r.jsx(Ff,{className:"h-5 w-5 text-primary"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:o.length}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Presentations"})]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center gap-3 p-4",children:[r.jsx(Vn,{className:"h-5 w-5 text-primary"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:i.length}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Guest Books"})]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center gap-3 p-4",children:[r.jsx(ma,{className:"h-5 w-5 text-primary"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:m.length}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]}),r.jsxs(ii,{defaultValue:"presentations",className:"space-y-4",children:[r.jsxs(si,{children:[r.jsxs(Kr,{value:"presentations",children:["Presentations (",o.length,")"]}),r.jsxs(Kr,{value:"guest-books",children:["Guest Books (",i.length,")"]}),r.jsxs(Kr,{value:"videos",children:["Videos (",m.length,")"]})]}),r.jsx(hs,{value:"presentations",className:"space-y-2",children:o.length===0?r.jsx(ghe,{icon:r.jsx(Ff,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(_=>{const k=v(_.owner_user_id);return r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center justify-between p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsxs(cn,{className:"h-8 w-8 shrink-0",children:[r.jsx(xa,{src:k.avatar}),r.jsx(dn,{className:"text-xs",children:k.initials})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-medium truncate",children:_.title||"Untitled"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[k.name," · ",Xr(new Date(_.created_at),"MMM d, yyyy")]})]})]}),r.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[r.jsx(_t,{variant:_.status==="published"?"default":"secondary",className:"text-xs capitalize",children:_.status}),r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[r.jsx(Ii,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})}),r.jsx(hs,{value:"guest-books",className:"space-y-2",children:i.length===0?r.jsx(ghe,{icon:r.jsx(Vn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(_=>{const k=v(_.agent_id);return r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center justify-between p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsxs(cn,{className:"h-8 w-8 shrink-0",children:[r.jsx(xa,{src:k.avatar}),r.jsx(dn,{className:"text-xs",children:k.initials})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-medium truncate",children:_.property_address}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[k.name," · ",Xr(new Date(_.event_date),"MMM d, yyyy")]})]})]}),r.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[_.is_active?r.jsx(_t,{className:"text-xs",children:"Active"}):r.jsx(_t,{variant:"secondary",className:"text-xs",children:"Inactive"}),r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[r.jsx(ws,{className:"h-3 w-3"}),_.visitor_count||0]})]})]})},_.id)})}),r.jsx(hs,{value:"videos",className:"space-y-2",children:m.length===0?r.jsx(ghe,{icon:r.jsx(ma,{className:"h-10 w-10"}),label:"No videos yet"}):m.map(_=>{const k=v(_.owner_user_id);return r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center justify-between p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsxs(cn,{className:"h-8 w-8 shrink-0",children:[r.jsx(xa,{src:k.avatar}),r.jsx(dn,{className:"text-xs",children:k.initials})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-medium truncate",children:_.title||_.recipient_name||"Untitled Video"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[k.name," · ",Xr(new Date(_.created_at),"MMM d, yyyy")]})]})]}),r.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[r.jsx(_t,{variant:"secondary",className:"text-xs capitalize",children:_.touch_type}),r.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[r.jsx(Ii,{className:"h-3 w-3"}),_.view_count||0]})]})]})},_.id)})})]})]})},ghe=({icon:e,label:t})=>r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-8 text-center text-muted-foreground",children:[e,r.jsx("p",{className:"mt-2 text-sm",children:t})]})}),Tqe=({team:e,brokerageAgents:t,onBack:s,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:d,isAddingMember:m})=>{const{useTeamMembers:p}=jN(),{data:g=[],isLoading:v}=p(e.id),[_,k]=A.useState(!1),[w,S]=A.useState(""),[T,C]=A.useState("team_member"),{data:I}=Ht({queryKey:["agents-on-other-teams",e.id],queryFn:async()=>{const{data:$}=await Y.from("team_members").select("user_id, team_id, teams:team_id(name)").neq("team_id",e.id),q=new Map;return($||[]).forEach(W=>{var K;q.set(W.user_id,((K=W.teams)==null?void 0:K.name)||"another team")}),q}}),R=new Set(g.map($=>$.user_id)),D=t.filter($=>!R.has($.id)),B=async()=>{w&&(await a(w,T),S(""),C("team_member"),k(!1))};return r.jsxs("div",{className:"space-y-6",children:[r.jsx(X,{variant:"ghost",onClick:s,className:"mb-2",children:"← Back to Teams"}),r.jsxs(ii,{defaultValue:"members",className:"space-y-4",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"members",children:"Members"}),r.jsxs(Kr,{value:"contacts",children:[r.jsx(xk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),e.lead_pond_enabled&&r.jsxs(Kr,{value:"lead-pond",children:[r.jsx(dx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),e.shared_assets_enabled&&r.jsxs(Kr,{value:"shared-assets",children:[r.jsx(Jh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),r.jsx(Kr,{value:"settings",children:"Settings"})]}),r.jsxs(hs,{value:"members",className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("h3",{className:"text-lg font-semibold",children:[e.name," — Members"]}),r.jsxs(Ir,{open:_,onOpenChange:k,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{size:"sm",children:[r.jsx(Kd,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Add Team Member"}),r.jsxs(Zs,{children:["Select an agent from your brokerage to add to ",e.name,"."]})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Agent"}),r.jsxs(ds,{value:w,onValueChange:S,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select an agent"})}),r.jsxs(cs,{children:[D.length===0&&r.jsx(Ut,{value:"none",disabled:!0,children:"No available agents"}),D.map($=>{const q=I==null?void 0:I.get($.id);return r.jsx(Ut,{value:$.id,disabled:!!q,children:r.jsxs("span",{className:"flex items-center gap-2",children:[$.name||$.email,q&&r.jsxs("span",{className:"text-xs text-muted-foreground ml-1",children:["(on ",q,")"]})]})},$.id)})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Role"}),r.jsxs(ds,{value:T,onValueChange:C,children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"team_leader",children:"Team Leader"}),r.jsx(Ut,{value:"team_member",children:"Team Member"})]})]})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),r.jsx(X,{onClick:B,disabled:!w||m,children:m?"Adding...":"Add to Team"})]})]})]})]}),v?r.jsx("div",{className:"space-y-3",children:[1,2,3].map($=>r.jsx(pr,{className:"h-16 w-full"},$))}):g.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-8 text-center",children:[r.jsx(ws,{className:"h-10 w-10 text-muted-foreground mb-3"}),r.jsx("p",{className:"text-muted-foreground",children:"No members yet. Add agents to this team."})]})}):r.jsx("div",{className:"space-y-2",children:g.map($=>{var q,W,K,re,ae;return r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center justify-between p-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:((q=$.profile)==null?void 0:q.avatar_url)||""}),r.jsx(dn,{children:(((W=$.profile)==null?void 0:W.name)||"?").charAt(0).toUpperCase()})]}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:((K=$.profile)==null?void 0:K.name)||"Unknown"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:(re=$.profile)==null?void 0:re.email})]}),$.role==="team_leader"?r.jsxs(_t,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[r.jsx(_h,{className:"mr-1 h-3 w-3"})," Leader"]}):r.jsx(_t,{variant:"secondary",children:"Member"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(ds,{value:$.role,onValueChange:oe=>l($.id,oe),children:[r.jsx(ls,{className:"w-[140px]",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"team_leader",children:"Team Leader"}),r.jsx(Ut,{value:"team_member",children:"Team Member"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:r.jsx(UE,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Remove Member?"}),r.jsxs(bc,{children:["Remove ",((ae=$.profile)==null?void 0:ae.name)||"this member"," from ",e.name,"?"]})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>o($.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},$.id)})})]}),r.jsx(hs,{value:"contacts",className:"space-y-4",children:r.jsx(x_e,{})}),e.lead_pond_enabled&&r.jsx(hs,{value:"lead-pond",className:"space-y-4",children:r.jsx(y_e,{teamId:e.id})}),e.shared_assets_enabled&&r.jsx(hs,{value:"shared-assets",className:"space-y-4",children:r.jsx(Mqe,{teamId:e.id})}),r.jsxs(hs,{value:"settings",className:"space-y-4",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{className:"text-lg",children:"Team Settings"}),r.jsx(Cs,{children:"Configure how this team operates."})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Team Name"}),r.jsx(Ye,{defaultValue:e.name,onBlur:$=>{$.target.value!==e.name&&n({name:$.target.value})}})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(qs,{defaultValue:e.description||"",onBlur:$=>{$.target.value!==(e.description||"")&&n({description:$.target.value||null})},rows:3})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Contact Visibility"}),r.jsxs(ds,{defaultValue:e.contact_visibility,onValueChange:$=>n({contact_visibility:$}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"private",children:"Private — Members keep their contacts private"}),r.jsx(Ut,{value:"leader_only",children:"Leader Only — Only team leaders can see member contacts"}),r.jsx(Ut,{value:"full_team",children:"Full Team — All team members can see shared contacts"})]})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls whether team leaders and members can view each other's contacts."})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Lead Pond"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable a shared lead pool where leaders can drop leads for members to claim."})]}),r.jsx(fn,{checked:e.lead_pond_enabled,onCheckedChange:$=>n({lead_pond_enabled:$})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Shared Assets"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow team members to access shared presentations, guest books, and videos."})]}),r.jsx(fn,{checked:e.shared_assets_enabled,onCheckedChange:$=>n({shared_assets_enabled:$})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Shared Video Library"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Let team members browse and use each other's videos from the Video Library."})]}),r.jsx(fn,{checked:e.shared_videos_enabled??!1,onCheckedChange:$=>n({shared_videos_enabled:$})})]})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsxs(X,{variant:"destructive",size:"sm",children:[r.jsx(Os,{className:"mr-2 h-4 w-4"}),"Delete Team"]})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Delete Team?"}),r.jsxs(bc,{children:['This will permanently delete "',e.name,'" and remove all team members. This cannot be undone.']})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>{i(),s()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},Aqe=({open:e,onOpenChange:t,onCreateTeam:s,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[d,m]=A.useState(1),[p,g]=A.useState(""),[v,_]=A.useState(""),[k,w]=A.useState(""),[S,T]=A.useState(""),[C,I]=A.useState([]),R=()=>{m(1),g(""),_(""),w(""),T(""),I([])},D=W=>{W||R(),t(W)},B=async()=>{const W=k&&k!=="none"?k:i||null;await s({name:p.trim(),description:v.trim()||void 0,brokerage_id:W,leaderId:S||void 0,memberIds:C.length>0?C:void 0}),R()},$=W=>{W!==S&&I(K=>K.includes(W)?K.filter(re=>re!==W):[...K,W])},q=a.filter(W=>W.id!==S);return r.jsx(Ir,{open:e,onOpenChange:D,children:r.jsxs(Er,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:d===1?"Create New Team":"Assign Team Members"}),r.jsx(Zs,{children:d===1?"Name your team and add a description.":"Pick a leader and optionally add initial members."}),r.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[r.jsx("div",{className:Vt("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),r.jsx("div",{className:Vt("h-1.5 flex-1 rounded-full transition-colors",d===2?"bg-primary":"bg-muted")})]})]}),r.jsx("div",{className:"overflow-y-auto flex-1 pr-1",children:d===1?r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"team-name",children:"Team Name *"}),r.jsx(Ye,{id:"team-name",value:p,onChange:W=>g(W.target.value),placeholder:"e.g., Downtown Squad",autoFocus:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"team-desc",children:"Description"}),r.jsx(qs,{id:"team-desc",value:v,onChange:W=>_(W.target.value),placeholder:"What is this team focused on?",rows:3})]}),o&&l&&l.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Brokerage"}),r.jsxs(ds,{value:k,onValueChange:w,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"No brokerage (independent team)"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No brokerage (independent)"}),l.map(W=>r.jsx(Ut,{value:W.id,children:W.name},W.id))]})]})]})]}):r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{className:"flex items-center gap-1.5",children:[r.jsx(_h,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),r.jsxs(ds,{value:S,onValueChange:W=>{T(W),I(K=>K.filter(re=>re!==W))},children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a team leader (optional)"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No leader for now"}),a.map(W=>r.jsx(Ut,{value:W.id,children:W.name||W.email||"Unknown"},W.id))]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{className:"flex items-center gap-1.5",children:[r.jsx(Kd,{className:"h-3.5 w-3.5"}),"Initial Members",C.length>0&&r.jsxs(_t,{variant:"secondary",className:"ml-1 text-xs",children:[C.length," selected"]})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Click agents to add them. You can always add more later."}),r.jsx("div",{className:"border rounded-lg max-h-[240px] overflow-y-auto divide-y",children:q.length===0?r.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:[r.jsx(ws,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):q.map(W=>{const K=C.includes(W.id);return r.jsxs("button",{type:"button",className:Vt("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",K&&"bg-primary/5"),onClick:()=>$(W.id),children:[r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:W.avatar_url||""}),r.jsx(dn,{className:"text-xs",children:(W.name||"?").charAt(0).toUpperCase()})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:W.name||"Unknown"}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:W.email})]}),r.jsx("div",{className:Vt("h-5 w-5 rounded-full border-2 flex items-center justify-center transition-colors shrink-0",K?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30"),children:K&&r.jsx(mi,{className:"h-3 w-3"})})]},W.id)})})]})]})}),r.jsx(Rn,{className:"gap-2 sm:gap-0",children:d===1?r.jsxs(r.Fragment,{children:[r.jsx(X,{variant:"outline",onClick:()=>D(!1),children:"Cancel"}),r.jsxs(X,{onClick:()=>m(2),disabled:!p.trim(),children:["Next",r.jsx(Ki,{className:"ml-2 h-4 w-4"})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"outline",onClick:()=>m(1),children:[r.jsx(gi,{className:"mr-2 h-4 w-4"}),"Back"]}),r.jsx(X,{onClick:B,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},oAt=()=>{const{teams:e,isLoading:t,createTeam:s,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=jN(),[d,m]=A.useState(!1),[p,g]=A.useState(null),[v,_]=A.useState(""),{data:k}=Ht({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:D,error:B}=await Y.from("brokerages").select("id, name").order("name");if(B)throw B;return D||[]}}),{data:w}=Ht({queryKey:["admin-team-member-info",e.map(D=>D.id).join(",")],queryFn:async()=>{var W;if(e.length===0)return{};const{data:D}=await Y.from("team_members").select("team_id, user_id, role").in("team_id",e.map(K=>K.id));if(!D)return{};const B=D.filter(K=>K.role==="team_leader").map(K=>K.user_id);let $={};if(B.length>0){const{data:K}=await Y.from("profiles").select("id, name").in("id",B);K&&($=Object.fromEntries(K.map(re=>[re.id,{name:re.name}])))}const q={};for(const K of e){const re=D.filter(oe=>oe.team_id===K.id),ae=re.find(oe=>oe.role==="team_leader");q[K.id]={count:re.length,leaderName:ae&&((W=$[ae.user_id])==null?void 0:W.name)||null}}return q},enabled:e.length>0}),S=(p==null?void 0:p.brokerage_id)||null,{data:T}=Ht({queryKey:["brokerage-agents-for-teams",S],queryFn:async()=>{let D=Y.from("profiles").select("id, name, email, avatar_url").order("name");S&&(D=D.eq("brokerage_id",S));const{data:B,error:$}=await D;if($)throw $;return B||[]},enabled:!!p}),C=Object.fromEntries((k||[]).map(D=>[D.id,D.name])),I=async D=>{const B=await s.mutateAsync({name:D.name,brokerage_id:D.brokerage_id||null,description:D.description});if(D.leaderId&&D.leaderId!=="none"&&await o.mutateAsync({team_id:B.id,user_id:D.leaderId,role:"team_leader"}),D.memberIds)for(const $ of D.memberIds)await o.mutateAsync({team_id:B.id,user_id:$,role:"team_member"});m(!1)};if(p)return r.jsx(Tqe,{team:p,brokerageAgents:T||[],onBack:()=>g(null),onUpdate:D=>n.mutateAsync({id:p.id,...D}).then(B=>g(B)),onAddMember:(D,B)=>o.mutateAsync({team_id:p.id,user_id:D,role:B}),onRemoveMember:D=>l.mutateAsync({team_id:p.id,member_id:D}),onUpdateRole:(D,B)=>i.mutateAsync({team_id:p.id,member_id:D,role:B}),onDeleteTeam:()=>{a.mutate(p.id),g(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const R=e.filter(D=>D.name.toLowerCase().includes(v.toLowerCase())||(D.description||"").toLowerCase().includes(v.toLowerCase()));return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search teams...",value:v,onChange:D=>_(D.target.value),className:"pl-10"})]}),r.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[R.length," of ",e.length," teams"]})]}),r.jsxs(X,{size:"sm",onClick:()=>m(!0),children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),r.jsx(Aqe,{open:d,onOpenChange:m,onCreateTeam:I,isCreating:s.isPending,brokerageAgents:[],isAdmin:!0,allBrokerages:k,activeBrokerageId:null}),r.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/30 hover:bg-muted/30",children:[r.jsx(Mt,{className:"font-semibold",children:"Team Name"}),r.jsx(Mt,{className:"font-semibold",children:"Brokerage"}),r.jsx(Mt,{className:"font-semibold",children:"Leader"}),r.jsx(Mt,{className:"font-semibold",children:"Members"}),r.jsx(Mt,{className:"font-semibold",children:"Visibility"}),r.jsx(Mt,{className:"w-[100px]"})]})}),r.jsx(Bn,{children:t?r.jsx(r.Fragment,{children:[1,2,3].map(D=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsx(pr,{className:"h-4 w-32"})}),r.jsx(dt,{children:r.jsx(pr,{className:"h-4 w-24"})}),r.jsx(dt,{children:r.jsx(pr,{className:"h-4 w-28"})}),r.jsx(dt,{children:r.jsx(pr,{className:"h-4 w-12"})}),r.jsx(dt,{children:r.jsx(pr,{className:"h-4 w-20"})}),r.jsx(dt,{children:r.jsx(pr,{className:"h-4 w-16"})})]},D))}):R.length===0?r.jsx(Nr,{children:r.jsx(dt,{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."})}):R.map(D=>{const B=w==null?void 0:w[D.id];return r.jsxs(Nr,{className:"hover:bg-muted/30",children:[r.jsxs(dt,{children:[r.jsx("button",{onClick:()=>g(D),className:"text-primary hover:underline font-medium",children:D.name}),D.description&&r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:D.description})]}),r.jsx(dt,{children:D.brokerage_id?r.jsx("span",{className:"text-sm",children:C[D.brokerage_id]||"—"}):r.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),r.jsx(dt,{children:B!=null&&B.leaderName?r.jsxs("span",{className:"text-sm flex items-center gap-1",children:[r.jsx(_h,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),B.leaderName]}):r.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),r.jsx(dt,{children:r.jsxs(_t,{variant:"secondary",className:"text-xs",children:[r.jsx(ws,{className:"h-3 w-3 mr-1"}),(B==null?void 0:B.count)??0]})}),r.jsx(dt,{children:r.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[r.jsx(Ou,{className:"h-3 w-3"}),D.contact_visibility.replace("_"," ")]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>g(D),title:"Edit team",children:r.jsx(Qa,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{confirm(`Delete team "${D.name}"? This cannot be undone.`)&&a.mutate(D.id)},title:"Delete team",children:r.jsx(Os,{className:"h-3.5 w-3.5"})})]})})]},D.id)})})]})})]})},lAt=()=>{const e=Ks(),{user:t,isAdmin:s}=Gr(),{startImpersonation:n,isLoading:a}=ove(),{toast:o}=_i(),[l,i]=A.useState([]),[d,m]=A.useState([]),[p,g]=A.useState([]),[v,_]=A.useState({}),[k,w]=A.useState(!0),[S,T]=A.useState({}),[C,I]=A.useState(!1),[R,D]=A.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[B,$]=A.useState(!1),[q,W]=A.useState(""),[K,re]=A.useState(1),[ae,oe]=A.useState(50),[se,pe]=A.useState("all"),[ie,de]=A.useState("all"),[ce,ge]=A.useState("all"),[Te,_e]=A.useState("all"),[ve,Me]=A.useState(!1),[Ze,Ae]=A.useState(!1),[Le,Ue]=A.useState(null),[Ve,Ie]=A.useState(null),[We,wt]=A.useState(!1),[Pe,st]=A.useState({name:"",email:"",brokerage_id:"",phone:""}),[ue,$e]=A.useState(null),[tt,rt]=A.useState(!1),[je,it]=A.useState(""),[Se,et]=A.useState(!1),[Qe,He]=A.useState(!1),[ot,ut]=A.useState(null),[ft,ct]=A.useState(""),[Tt,Ot]=A.useState(!1),[rr,Lr]=A.useState(!1),[cr,Mr]=A.useState(null),[As,Et]=A.useState(!1),[Pt,Sr]=A.useState(!1),[fs,Ws]=A.useState(null),[tn,xi]=A.useState(""),[La,un]=A.useState(!1),[ia,rn]=A.useState({email:"",name:"",password:"",phone:""}),[Wn,Yn]=A.useState(!1),[Pi,dr]=A.useState(!1),[$a,xo]=A.useState(""),[Ei,Qs]=A.useState(!1),[ao,Mc]=A.useState(!1),[No,Tc]=A.useState(""),[nt,ye]=A.useState(new Set),[De,Xe]=A.useState(!1),[Ct,jt]=A.useState(!1),[Dt,Gt]=A.useState(null),[Ft,Yt]=A.useState(!1),[yr,hr]=A.useState(null),[ss,Is]=A.useState([]),[ts,yn]=A.useState([]),[vn,hn]=A.useState(!1),[ra,eo]=A.useState({});A.useEffect(()=>{!t||!s||(Ma(),Do())},[t,s]);const Eo=async()=>{try{const{data:St,error:vr}=await Y.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(vr)throw vr;const Hr={};for(const pn of St??[])Hr[pn.brokerage_id]||(Hr[pn.brokerage_id]=[]),Hr[pn.brokerage_id].push(pn.user_id);_(Hr)}catch(St){console.error("Error loading brokerage manager assignments:",St)}},Ma=async()=>{try{w(!0);const{data:St,error:vr}=await Y.functions.invoke("get-user-details");if(vr)throw vr;const Hr=St.users||[];i(Hr),g(St.brokerages||[]),await Eo();const pn=Hr.filter(gn=>gn.roles.includes("assistant"));if(pn.length>0){const gn=pn.map(Kn=>Kn.id),{data:ua}=await Y.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",gn);if(ua&&ua.length>0){const Kn=[...new Set(ua.map(bu=>bu.agent_id))],{data:Ta}=await Y.from("profiles").select("id, name, email").in("id",Kn),dm={};for(const bu of ua){const Ul=Ta==null?void 0:Ta.find(Aa=>Aa.id===bu.agent_id);Ul&&(dm[bu.assistant_id]={agent_name:Ul.name||"",agent_email:Ul.email||""})}eo(dm)}}}catch(St){console.error("Error loading members:",St),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{w(!1)}},Do=async()=>{try{const{data:St,error:vr}=await Y.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(vr)throw vr;m(St||[])}catch(St){console.error("Error loading apps:",St),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},$i=async St=>{if(!Pe.name.trim()||!Pe.email.trim()){o({title:"Error",description:"Name and email are required",variant:"destructive"});return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(Pe.email)){o({title:"Error",description:"Please enter a valid email address",variant:"destructive"});return}try{const{error:Hr}=await Y.from("profiles").update({name:Pe.name.trim(),email:Pe.email.trim(),brokerage_id:Pe.brokerage_id||null,phone:Pe.phone.trim()||null}).eq("id",St);if(Hr)throw Hr;o({title:"Success",description:"Member details updated successfully"}),Ue(null),Ma()}catch(Hr){console.error("Error updating member:",Hr),o({title:"Error",description:Hr.message||"Failed to update member",variant:"destructive"})}},da=async St=>{try{const{data:{session:vr}}=await Y.auth.getSession(),Hr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vr==null?void 0:vr.access_token}`},body:JSON.stringify({userId:St})}),pn=await Hr.json();if(!Hr.ok)throw new Error(pn.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(vr){console.error("Error resending welcome email:",vr),o({title:"Error",description:vr.message||"Failed to resend welcome email",variant:"destructive"})}},Ui=async(St,vr)=>{try{const{error:Hr}=await Y.functions.invoke("send-password-reset",{body:{email:St,redirectTo:window.location.origin}});if(Hr)throw Hr;o({title:"Password Reset Sent",description:`Password reset email sent to ${vr}`})}catch(Hr){console.error("Error sending password reset:",Hr),o({title:"Error",description:Hr.message||"Failed to send password reset email",variant:"destructive"})}},Ja=async(St,vr)=>{if(confirm(`Are you sure you want to delete ${vr}? This action cannot be undone.`))try{const{data:{session:Hr}}=await Y.auth.getSession(),pn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hr==null?void 0:Hr.access_token}`},body:JSON.stringify({userId:St})}),gn=await pn.json();if(!pn.ok)throw new Error(gn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Ma()}catch(Hr){console.error("Error deleting user:",Hr),o({title:"Error",description:Hr.message||"Failed to delete user",variant:"destructive"})}},Gn=async()=>{if(!R.email||!R.name||!R.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(R.role==="brokerage_manager"&&!R.brokerage_id){o({title:"Error",description:"Please select a brokerage for this manager",variant:"destructive"});return}I(!0);try{const{data:{session:St}}=await Y.auth.getSession(),vr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${St==null?void 0:St.access_token}`},body:JSON.stringify(R)}),Hr=await vr.json();if(!vr.ok)throw new Error(Hr.error||"Failed to create user");if(R.role&&R.role!=="user"&&Hr.userId){const pn=R.role==="brokerage_manager"?R.brokerage_id:void 0;await Vi(Hr.userId,R.role,"add",pn)}o({title:"Success",description:`User ${R.email} created successfully`}),D({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),$(!1),Ma()}catch(St){console.error("Error creating user:",St),o({title:"Error",description:St.message||"Failed to create user",variant:"destructive"})}finally{I(!1)}},Vi=async(St,vr,Hr,pn)=>{try{const{data:{session:gn}}=await Y.auth.getSession(),ua={userId:St,role:vr,action:Hr};if(vr==="brokerage_manager"){if(!pn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}ua.brokerageId=pn}const Kn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${gn==null?void 0:gn.access_token}`},body:JSON.stringify(ua)}),Ta=await Kn.json();if(!Kn.ok)throw new Error(Ta.error||"Failed to manage user role");o({title:"Success",description:`Role ${Hr==="add"?"added":"removed"} successfully`}),Ma()}catch(gn){console.error("Error managing user role:",gn),o({title:"Error",description:gn.message||"Failed to manage user role",variant:"destructive"})}},Cl=(St,vr)=>vr.length===0?!0:vr.some(Hr=>St.includes(Hr)),$l=async(St,vr,Hr)=>{const pn=`${St}-${vr.id}`;$e(pn);try{if(Hr){const gn=l.find(Kn=>Kn.id===St),ua=vr.required_tags.filter(Kn=>gn==null?void 0:gn.tags.includes(Kn));for(const Kn of ua){const{error:Ta}=await Y.from("user_tags").delete().eq("user_id",St).eq("tag",Kn);if(Ta)throw Ta}o({title:"Access Removed",description:`Removed access to ${vr.name}`})}else if(vr.required_tags.length>0){const{error:gn}=await Y.from("user_tags").insert({user_id:St,tag:vr.required_tags[0]});if(gn)throw gn;o({title:"Access Granted",description:`Granted access to ${vr.name}`})}await Ma()}catch(gn){console.error("Error toggling access:",gn),o({title:"Error",description:gn.message||"Failed to update access",variant:"destructive"})}finally{$e(null)}},hd=async()=>{const St=je.trim();if(!St){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(St.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}if(p.find(Hr=>Hr.name.toLowerCase()===St.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}et(!0);try{const{error:Hr}=await Y.from("brokerages").insert({name:St});if(Hr)throw Hr;o({title:"Success",description:`Brokerage "${St}" created successfully`}),it(""),rt(!1),Ma()}catch(Hr){console.error("Error creating brokerage:",Hr),o({title:"Error",description:Hr.message||"Failed to create brokerage",variant:"destructive"})}finally{et(!1)}},Ym=St=>{ut(St),ct(St.name),He(!0)},el=()=>{ut(null),ct(""),He(!1)},Jd=async()=>{if(!ot)return;const St=ft.trim();if(!St){o({title:"Error",description:"Brokerage name is required",variant:"destructive"});return}if(St.length>100){o({title:"Error",description:"Brokerage name must be less than 100 characters",variant:"destructive"});return}Ot(!0);try{const{error:vr}=await Y.from("brokerages").update({name:St}).eq("id",ot.id);if(vr)throw vr;o({title:"Success",description:"Brokerage updated successfully"}),el(),Ma()}catch(vr){console.error("Error updating brokerage:",vr),o({title:"Error",description:vr.message||"Failed to update brokerage",variant:"destructive"})}finally{Ot(!1)}},Ac=async(St,vr)=>{var Hr;if(!vr||typeof vr!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const pn={userId:St,role:"brokerage_manager",action:"add",brokerageId:vr};console.debug("[assignManagerToBrokerage] payload",pn);const{data:{session:gn}}=await Y.auth.getSession(),ua=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${gn==null?void 0:gn.access_token}`},body:JSON.stringify(pn)}),Kn=await ua.json();if(!ua.ok&&!((Hr=Kn.error)!=null&&Hr.includes("duplicate")))throw new Error(Kn.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Ma()}catch(pn){console.error("Error assigning manager:",pn),o({title:"Error",description:pn.message||"Failed to assign manager",variant:"destructive"})}},Ch=St=>{Mr(St),Lr(!0)},tl=async()=>{if(cr){Et(!0);try{const St=l.filter(pn=>pn.brokerage_id===cr.id),{data:{session:vr}}=await Y.auth.getSession();for(const pn of St){const gn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vr==null?void 0:vr.access_token}`},body:JSON.stringify({userId:pn.id})});if(!gn.ok){const ua=await gn.json();console.error(`Failed to delete user ${pn.email}:`,ua.error)}}const{error:Hr}=await Y.from("brokerages").delete().eq("id",cr.id);if(Hr)throw Hr;o({title:"Success",description:`Brokerage "${cr.name}" and ${St.length} member(s) deleted`}),Lr(!1),Mr(null),Ma()}catch(St){console.error("Error deleting brokerage:",St),o({title:"Error",description:St.message||"Failed to delete brokerage",variant:"destructive"})}finally{Et(!1)}}},ep=St=>{Ws(St),xi(""),Sr(!0)},_g=()=>{Ws(null),xi(""),Sr(!1)},w0=async St=>{try{const{error:vr}=await Y.from("profiles").update({brokerage_id:null}).eq("id",St);if(vr)throw vr;o({title:"Success",description:"User removed from brokerage"}),Ma()}catch(vr){console.error("Error removing user from brokerage:",vr),o({title:"Error",description:vr.message||"Failed to remove user",variant:"destructive"})}},j0=async(St,vr)=>{try{const{error:Hr}=await Y.from("profiles").update({brokerage_id:vr}).eq("id",St);if(Hr)throw Hr;o({title:"Success",description:"User added to brokerage"}),Ma()}catch(Hr){console.error("Error adding user to brokerage:",Hr),o({title:"Error",description:Hr.message||"Failed to add user",variant:"destructive"})}},k0=async()=>{if(!fs||!ia.email||!ia.name||!ia.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Yn(!0);try{const{data:{session:St}}=await Y.auth.getSession(),vr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${St==null?void 0:St.access_token}`},body:JSON.stringify({...ia,brokerage_id:fs.id,role:"user"})}),Hr=await vr.json();if(!vr.ok)throw new Error(Hr.error||"Failed to create agent");o({title:"Success",description:`Agent ${ia.email} created successfully`}),rn({email:"",name:"",password:"",phone:""}),un(!1),Ma()}catch(St){console.error("Error creating agent:",St),o({title:"Error",description:St.message||"Failed to create agent",variant:"destructive"})}finally{Yn(!1)}},lm=St=>l.filter(vr=>vr.brokerage_id===St),Wu=St=>{const vr=lm(St);if(!tn)return vr;const Hr=tn.toLowerCase();return vr.filter(pn=>pn.name.toLowerCase().includes(Hr)||pn.email.toLowerCase().includes(Hr))},md=St=>l.filter(vr=>vr.brokerage_id!==St),_u=l.filter(St=>{var vr;if(q){const Hr=q.toLowerCase();if(!(St.name.toLowerCase().includes(Hr)||St.email.toLowerCase().includes(Hr)||((vr=St.brokerage_name)==null?void 0:vr.toLowerCase().includes(Hr))))return!1}return!(se==="claimed"&&!St.claimed||se==="unclaimed"&&St.claimed||ie!=="all"&&!St.roles.includes(ie)||ce==="trial"&&!St.is_trial||ce==="non-trial"&&St.is_trial||Te==="none"&&St.brokerage_id||Te!=="all"&&Te!=="none"&&St.brokerage_id!==Te)}),Ec=_u.length,fd=ae===0,Zo=fd?1:Math.ceil(Ec/ae),Gu=fd?0:(K-1)*ae,cm=fd?Ec:Gu+ae,eu=_u.slice(Gu,cm),tp=St=>{W(St),re(1)},N0=St=>{oe(St),re(1)},Fx=(St,vr)=>{St(vr),re(1)},rp=async(St,vr)=>{Me(!0);try{const Hr=l.find(Kn=>Kn.id===St);if(!Hr)return;const pn=Hr.trial_expires_at?new Date(Hr.trial_expires_at):new Date,gn=new Date(pn.getTime()+vr*24*60*60*1e3),{error:ua}=await Y.from("profiles").update({trial_expires_at:gn.toISOString()}).eq("id",St);if(ua)throw ua;o({title:"Trial Extended",description:`Trial extended by ${vr} days`}),Ma()}catch(Hr){console.error("Error extending trial:",Hr),o({title:"Error",description:Hr.message||"Failed to extend trial",variant:"destructive"})}finally{Me(!1)}},Ed=async St=>{Ae(!0);try{const{error:vr}=await Y.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",St);if(vr)throw vr;o({title:"Account Converted",description:"User has been converted to a full account"}),Ma(),Ku()}catch(vr){console.error("Error converting trial:",vr),o({title:"Error",description:vr.message||"Failed to convert account",variant:"destructive"})}finally{Ae(!1)}},S0=async St=>{hn(!0);try{const{data:vr}=await Y.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",St);if(vr&&vr.length>0){const pn=vr.map(ua=>ua.assistant_id),{data:gn}=await Y.from("profiles").select("id, name, email").in("id",pn);Is(vr.map(ua=>{const Kn=gn==null?void 0:gn.find(Ta=>Ta.id===ua.assistant_id);return{id:ua.id,assistant_id:ua.assistant_id,assistant_name:(Kn==null?void 0:Kn.name)||"Unknown",assistant_email:(Kn==null?void 0:Kn.email)||"",permissions:ua.permissions||{}}}))}else Is([]);const{data:Hr}=await Y.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",St);if(Hr&&Hr.length>0){const pn=Hr.map(ua=>ua.agent_id),{data:gn}=await Y.from("profiles").select("id, name, email").in("id",pn);yn(Hr.map(ua=>{const Kn=gn==null?void 0:gn.find(Ta=>Ta.id===ua.agent_id);return{id:ua.id,agent_id:ua.agent_id,agent_name:(Kn==null?void 0:Kn.name)||"Unknown",agent_email:(Kn==null?void 0:Kn.email)||"",permissions:ua.permissions||{}}}))}else yn([])}catch(vr){console.error("Error loading assistant data:",vr)}finally{hn(!1)}},Xm=St=>{Ie(St),st({name:St.name,email:St.email,brokerage_id:St.brokerage_id||"",phone:St.phone||""}),wt(!0),S0(St.id)},Ku=()=>{Ie(null),wt(!1),st({name:"",email:"",brokerage_id:"",phone:""})},oM=async()=>{Ve&&(await $i(Ve.id),Ku())},AN=St=>{ye(vr=>{const Hr=new Set(vr);return Hr.has(St)?Hr.delete(St):Hr.add(St),Hr})},zx=()=>{if(nt.size===eu.length&&eu.every(St=>nt.has(St.id))){const St=new Set(nt);eu.forEach(vr=>St.delete(vr.id)),ye(St)}else{const St=new Set(nt);eu.forEach(vr=>St.add(vr.id)),ye(St)}},oa=()=>{ye(new Set)},C0=async()=>{if(nt.size===0)return;Xe(!0);let St=0,vr=0;try{const{data:{session:Hr}}=await Y.auth.getSession();for(const pn of nt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hr==null?void 0:Hr.access_token}`},body:JSON.stringify({userId:pn})})).ok?St++:vr++}catch{vr++}o({title:"Bulk Email Complete",description:`Sent ${St} emails${vr>0?`, ${vr} failed`:""}`}),oa()}catch(Hr){o({title:"Error",description:Hr.message||"Failed to send emails",variant:"destructive"})}finally{Xe(!1)}},x_=async()=>{if(nt.size===0)return;Xe(!0);let St=0,vr=0;try{const{data:{session:Hr}}=await Y.auth.getSession();for(const pn of nt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hr==null?void 0:Hr.access_token}`},body:JSON.stringify({userId:pn})})).ok?St++:vr++}catch{vr++}o({title:"Bulk Password Reset Complete",description:`Sent ${St} reset emails${vr>0?`, ${vr} failed`:""}`}),oa()}catch(Hr){o({title:"Error",description:Hr.message||"Failed to send password reset emails",variant:"destructive"})}finally{Xe(!1)}},EN=async()=>{if(nt.size===0)return;const St=l.filter(gn=>nt.has(gn.id)).map(gn=>gn.name).slice(0,5).join(", "),vr=nt.size>5?` and ${nt.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${nt.size} users (${St}${vr})? This action cannot be undone.`))return;Xe(!0);let Hr=0,pn=0;try{const{data:{session:gn}}=await Y.auth.getSession();for(const ua of nt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${gn==null?void 0:gn.access_token}`},body:JSON.stringify({userId:ua})})).ok?Hr++:pn++}catch{pn++}o({title:"Bulk Delete Complete",description:`Deleted ${Hr} users${pn>0?`, ${pn} failed`:""}`}),oa(),Ma()}catch(gn){o({title:"Error",description:gn.message||"Failed to delete users",variant:"destructive"})}finally{Xe(!1)}},IN=async()=>{jt(!0);try{const{data:{session:St}}=await Y.auth.getSession(),vr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-phone-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${St==null?void 0:St.access_token}`}});if(!vr.ok){const pn=await vr.json();throw new Error(pn.error||"Failed to sync phones")}const Hr=await vr.json();o({title:"Phone Sync Complete",description:`Pulled ${Hr.summary.pulledFromGHL} from GHL, pushed ${Hr.summary.pushedToGHL} to GHL, ${Hr.summary.alreadySynced} already synced`}),Ma()}catch(St){o({title:"Error",description:St.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{jt(!1)}},Qm=async(St,vr)=>{Gt(St);try{const{data:{session:Hr}}=await Y.auth.getSession(),{data:pn}=await Y.from("profiles").select("phone").eq("id",St).single(),gn=(pn==null?void 0:pn.phone)||"",ua=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Hr==null?void 0:Hr.access_token}`},body:JSON.stringify({email:vr,action:"update",phone:gn||void 0})});if(!ua.ok){const Ta=await ua.json();throw new Error(Ta.error||"Failed to sync with GHL")}const Kn=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(vr)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:gn?`Phone ${gn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Ma()}catch(Hr){o({title:"Error",description:Hr.message||"Failed to sync phone",variant:"destructive"})}finally{Gt(null)}},bg=async St=>{await n(St)},Bx=()=>{if(nt.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const St=l.filter(Ta=>nt.has(Ta.id)),vr=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Hr=St.map(Ta=>[Ta.name,Ta.email,Ta.phone||"",Ta.brokerage_name||"",Ta.roles.join("; "),Ta.claimed?"Claimed":"Unclaimed",new Date(Ta.created_at).toLocaleDateString()]),pn=[vr.join(","),...Hr.map(Ta=>Ta.map(dm=>`"${(dm||"").replace(/"/g,'""')}"`).join(","))].join(` `),gn=new Blob([pn],{type:"text/csv"}),ua=URL.createObjectURL(gn),Kn=document.createElement("a");Kn.href=ua,Kn.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,Kn.click(),URL.revokeObjectURL(ua),o({title:"Export complete",description:`Exported ${St.length} member(s)`})};return k?r.jsx(Ur,{title:"Members",children:r.jsx("div",{className:"flex items-center justify-center py-20",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):r.jsxs(Ur,{title:"Members",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Member Management",description:"Manage users, roles, and permissions"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(X,{size:"sm",variant:"outline",onClick:IN,disabled:Ct,children:[Ct?r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}):r.jsx(fi,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:Ct?"Syncing...":"Sync Phones with GHL"}),r.jsx("span",{className:"sm:hidden",children:Ct?"Syncing...":"Sync GHL"})]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>dr(!0),children:[r.jsx(_1,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Import CSV"}),r.jsx("span",{className:"sm:hidden",children:"Import"})]}),r.jsxs(Ir,{open:B,onOpenChange:$,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{size:"sm",children:[r.jsx(Kd,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Add Member"}),r.jsx("span",{className:"sm:hidden",children:"Add"})]})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create New User"}),r.jsx(Zs,{children:"Add a new user to the system. They'll be able to sign in immediately."})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",placeholder:"John Doe",value:R.name,onChange:St=>D({...R,name:St.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"email",children:"Email"}),r.jsx(Ye,{id:"email",type:"email",placeholder:"john@example.com",value:R.email,onChange:St=>D({...R,email:St.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"password",children:"Password"}),r.jsx(Ye,{id:"password",type:"password",placeholder:"Min 6 characters",value:R.password,onChange:St=>D({...R,password:St.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"phone",children:"Phone (optional)"}),r.jsx(Ye,{id:"phone",type:"tel",placeholder:"555-123-4567",value:R.phone,onChange:St=>D({...R,phone:St.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{htmlFor:"brokerage",children:["Brokerage",R.role==="brokerage_manager"?" (required)":""]}),r.jsxs(ds,{value:R.brokerage_id||"none",onValueChange:St=>D({...R,brokerage_id:St==="none"?"":St}),children:[r.jsx(ls,{id:"brokerage",children:r.jsx(us,{placeholder:R.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"None"}),p.map(St=>r.jsx(Ut,{value:St.id,children:St.name},St.id))]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"role",children:"Role"}),r.jsxs(ds,{value:R.role,onValueChange:St=>D({...R,role:St}),children:[r.jsx(ls,{id:"role",children:r.jsx(us,{placeholder:"Select role"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"user",children:"User"}),r.jsx(Ut,{value:"moderator",children:"Moderator"}),r.jsx(Ut,{value:"brokerage_manager",children:"Brokerage Manager"}),r.jsx(Ut,{value:"admin",children:"Admin"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"trial_days",children:"Trial Period (optional)"}),r.jsxs(ds,{value:R.trial_days||"none",onValueChange:St=>D({...R,trial_days:St==="none"?"":St}),children:[r.jsx(ls,{id:"trial_days",children:r.jsx(us,{placeholder:"No trial (full access)"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No trial (full access)"}),r.jsx(Ut,{value:"7",children:"7-day trial"}),r.jsx(Ut,{value:"30",children:"30-day trial"}),r.jsx(Ut,{value:"60",children:"60-day trial"}),r.jsx(Ut,{value:"90",children:"90-day trial"}),r.jsx(Ut,{value:"365",children:"1-year trial"})]})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Trial accounts don't require a credit card. Access expires after the trial period."})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),r.jsx(X,{onClick:Gn,disabled:C,children:C?"Creating...":"Create User"})]})]})]})]})]}),r.jsxs(ii,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"members",children:"Members"}),r.jsx(Kr,{value:"brokerages",children:"Brokerages"}),r.jsx(Kr,{value:"teams",children:"Teams"}),r.jsx(Kr,{value:"trials",children:"Trial Users"}),r.jsx(Kr,{value:"access",children:"Access Matrix"}),r.jsx(Kr,{value:"celebrations",children:"Celebrations"}),r.jsx(Kr,{value:"deletions",children:"Deletion Log"})]}),r.jsxs(hs,{value:"members",className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search members...",value:q,onChange:St=>tp(St.target.value),className:"pl-10 h-9"})]}),r.jsxs(ds,{value:se,onValueChange:St=>Fx(pe,St),children:[r.jsx(ls,{className:"w-[130px] h-9",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Status"}),r.jsx(Ut,{value:"claimed",children:"Active"}),r.jsx(Ut,{value:"unclaimed",children:"Pending"})]})]}),r.jsxs(ds,{value:ie,onValueChange:St=>Fx(de,St),children:[r.jsx(ls,{className:"w-[130px] h-9",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Roles"}),r.jsx(Ut,{value:"admin",children:"Admin"}),r.jsx(Ut,{value:"brokerage_manager",children:"Manager"}),r.jsx(Ut,{value:"assistant",children:"Assistant"}),r.jsx(Ut,{value:"user",children:"User"})]})]}),r.jsxs(ds,{value:ce,onValueChange:St=>Fx(ge,St),children:[r.jsx(ls,{className:"w-[130px] h-9",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Users"}),r.jsx(Ut,{value:"trial",children:"Trial Only"}),r.jsx(Ut,{value:"non-trial",children:"Full Only"})]})]}),r.jsxs(ds,{value:Te,onValueChange:St=>Fx(_e,St),children:[r.jsx(ls,{className:"w-[150px] h-9",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Brokerages"}),r.jsx(Ut,{value:"none",children:"No Brokerage"}),p.map(St=>r.jsx(Ut,{value:St.id,children:St.name},St.id))]})]}),(q||se!=="all"||ie!=="all"||ce!=="all"||Te!=="all")&&r.jsxs(X,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{W(""),pe("all"),de("all"),ge("all"),_e("all"),re(1)},children:[r.jsx(Xs,{className:"h-4 w-4 mr-1"}),"Clear"]}),r.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:fd?`Showing all ${Ec} members`:`Showing ${Gu+1}-${Math.min(cm,Ec)} of ${Ec} members`}),r.jsxs(ds,{value:ae.toString(),onValueChange:St=>N0(Number(St)),children:[r.jsx(ls,{className:"h-9 w-[110px]",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"50",children:"50 / page"}),r.jsx(Ut,{value:"100",children:"100 / page"}),r.jsx(Ut,{value:"250",children:"250 / page"}),r.jsx(Ut,{value:"0",children:"All"})]})]})]})]}),nt.size>0&&r.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/10 border border-primary/20 rounded-lg",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Nv,{className:"h-4 w-4 text-primary"}),r.jsxs("span",{className:"text-sm font-medium",children:[nt.size," selected"]})]}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(X,{size:"sm",variant:"outline",onClick:C0,disabled:De,children:[De?r.jsx($r,{className:"h-4 w-4 animate-spin mr-1"}):r.jsx(Vs,{className:"h-4 w-4 mr-1"}),r.jsx("span",{className:"hidden sm:inline",children:"Resend Invite"}),r.jsx("span",{className:"sm:hidden",children:"Invite"})]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:x_,disabled:De,children:[De?r.jsx($r,{className:"h-4 w-4 animate-spin mr-1"}):r.jsx(Rm,{className:"h-4 w-4 mr-1"}),r.jsx("span",{className:"hidden sm:inline",children:"Password Reset"}),r.jsx("span",{className:"sm:hidden",children:"Reset"})]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:Bx,children:[r.jsx(Fi,{className:"h-4 w-4 mr-1"}),r.jsx("span",{className:"hidden sm:inline",children:"Export"}),r.jsx("span",{className:"sm:hidden",children:"CSV"})]}),r.jsxs(X,{size:"sm",variant:"destructive",onClick:EN,disabled:De,children:[De?r.jsx($r,{className:"h-4 w-4 animate-spin mr-1"}):r.jsx(Os,{className:"h-4 w-4 mr-1"}),r.jsx("span",{className:"hidden sm:inline",children:"Delete"}),r.jsx("span",{className:"sm:hidden",children:"Del"})]}),r.jsx(X,{size:"sm",variant:"ghost",onClick:oa,disabled:De,children:r.jsx(Xs,{className:"h-4 w-4"})})]})]}),r.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/30 hover:bg-muted/30",children:[r.jsx(Mt,{className:"w-[50px]",children:r.jsx(Qo,{checked:eu.length>0&&eu.every(St=>nt.has(St.id)),onCheckedChange:zx,"aria-label":"Select all on page"})}),r.jsx(Mt,{className:"font-semibold",children:"Name"}),r.jsx(Mt,{className:"font-semibold",children:"Brokerage"}),r.jsx(Mt,{className:"font-semibold",children:"Status"}),r.jsx(Mt,{className:"font-semibold",children:"Role"}),r.jsx(Mt,{className:"font-semibold",children:"Last Login"}),r.jsx(Mt,{className:"w-[100px]"})]})}),r.jsx(Bn,{children:eu.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:7,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):eu.map(St=>r.jsxs(Nr,{className:`hover:bg-muted/30 ${nt.has(St.id)?"bg-primary/5":""}`,children:[r.jsx(dt,{children:r.jsx(Qo,{checked:nt.has(St.id),onCheckedChange:()=>AN(St.id),"aria-label":`Select ${St.name}`})}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("button",{onClick:()=>Xm(St),className:"text-primary hover:underline font-medium text-left",children:St.name}),r.jsx("div",{className:"text-xs text-muted-foreground",children:St.email})]})}),r.jsx(dt,{className:"text-muted-foreground",children:St.brokerage_name||"—"}),r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(_t,{variant:St.claimed?"default":"secondary",className:St.claimed?"bg-primary text-primary-foreground w-fit":"w-fit",children:St.claimed?"Active":"Pending"}),St.is_trial&&St.trial_expires_at&&r.jsx(J3e,{expiresAt:St.trial_expires_at,className:"w-fit"})]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-1",children:[St.roles.length>0?r.jsx("span",{className:"text-sm capitalize",children:St.roles[0]}):r.jsx("span",{className:"text-muted-foreground",children:"—"}),St.roles.includes("assistant")&&r.jsxs(_t,{variant:"outline",className:"text-[10px] ml-1",children:["Asst",ra[St.id]?` → ${ra[St.id].agent_name||ra[St.id].agent_email}`:""]})]})}),r.jsx(dt,{className:"text-muted-foreground",children:St.last_sign_in_at?new Date(St.last_sign_in_at).toLocaleDateString():"—"}),r.jsx(dt,{children:r.jsxs("div",{className:"flex gap-1 justify-end",children:[r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8 text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",onClick:()=>{hr(St),Yt(!0)},title:"Send celebration",children:r.jsx(od,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Xm(St),title:"Edit member",children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Qm(St.id,St.email),disabled:Dt===St.id,title:"Sync phone with GHL",children:Dt===St.id?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(fi,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>da(St.id),title:"Resend welcome email",children:r.jsx(Vs,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ui(St.email,St.name),title:"Send password reset",children:r.jsx(_k,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>bg(St.id),disabled:a||St.id===(t==null?void 0:t.id),title:St.id===(t==null?void 0:t.id)?"Cannot impersonate yourself":`Login as ${St.name}`,children:a?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(I4,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ja(St.id,St.name),title:"Delete user",children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},St.id))})]})}),Zo>1&&r.jsxs("div",{className:"flex items-center justify-between px-2 py-4",children:[r.jsxs("div",{className:"text-sm text-muted-foreground",children:["Page ",K," of ",Zo]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"outline",size:"sm",onClick:()=>re(1),disabled:K===1,children:"First"}),r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>re(St=>Math.max(1,St-1)),disabled:K===1,children:r.jsx(jc,{className:"h-4 w-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Zo)},(St,vr)=>{let Hr;return Zo<=5||K<=3?Hr=vr+1:K>=Zo-2?Hr=Zo-4+vr:Hr=K-2+vr,r.jsx(X,{variant:K===Hr?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>re(Hr),children:Hr},Hr)})}),r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>re(St=>Math.min(Zo,St+1)),disabled:K===Zo,children:r.jsx(Zi,{className:"h-4 w-4"})}),r.jsx(X,{variant:"outline",size:"sm",onClick:()=>re(Zo),disabled:K===Zo,children:"Last"})]})]})]}),r.jsx(Ir,{open:We,onOpenChange:wt,children:r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Edit Member"}),r.jsx(Zs,{children:"Update member details, roles, and app access"})]}),Ve&&r.jsxs("div",{className:"space-y-6 py-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"edit-name",children:"Name"}),r.jsx(Ye,{id:"edit-name",value:Pe.name,onChange:St=>st({...Pe,name:St.target.value}),maxLength:100})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"edit-email",children:"Email"}),r.jsx(Ye,{id:"edit-email",type:"email",value:Pe.email,onChange:St=>st({...Pe,email:St.target.value}),maxLength:255})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"edit-phone",children:"Phone"}),r.jsx(Ye,{id:"edit-phone",type:"tel",value:Pe.phone,onChange:St=>st({...Pe,phone:St.target.value}),placeholder:"555-123-4567"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"edit-brokerage",children:"Brokerage"}),r.jsxs(ds,{value:Pe.brokerage_id||"none",onValueChange:St=>st({...Pe,brokerage_id:St==="none"?"":St}),children:[r.jsx(ls,{id:"edit-brokerage",children:r.jsx(us,{placeholder:"Select brokerage"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"None"}),p.map(St=>r.jsx(Ut,{value:St.id,children:St.name},St.id))]})]})]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Roles"}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ve.roles.map(St=>r.jsxs(_t,{variant:"default",className:"gap-1",children:[r.jsx(Ou,{className:"h-3 w-3"}),St,St==="brokerage_manager"?r.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(manage in Brokerages tab)"}):r.jsx("button",{onClick:()=>Vi(Ve.id,St,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:r.jsx(Xs,{className:"h-3 w-3"})})]},St)),Ve.roles.length===0&&r.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),r.jsxs(ds,{onValueChange:St=>Vi(Ve.id,St,"add"),children:[r.jsx(ls,{className:"w-[200px]",children:r.jsx(us,{placeholder:"Add role..."})}),r.jsxs(cs,{children:[!Ve.roles.includes("admin")&&r.jsx(Ut,{value:"admin",children:"Admin"}),!Ve.roles.includes("user")&&r.jsx(Ut,{value:"user",children:"User"})]})]}),!Ve.roles.includes("brokerage_manager")&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"To add as brokerage manager, use Brokerages tab → Manage"})]}),(ss.length>0||ts.length>0||Ve.roles.includes("assistant"))&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[r.jsx(ws,{className:"h-4 w-4"}),"Assistant Relationships"]}),vn?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):r.jsxs("div",{className:"space-y-3",children:[ss.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Has assistants:"}),ss.map(St=>r.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-medium",children:St.assistant_name}),r.jsx(_t,{variant:"outline",className:"text-xs",children:"Assistant"})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:St.assistant_email}),r.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(St.permissions).filter(([,vr])=>vr).map(([vr])=>r.jsx(_t,{variant:"secondary",className:"text-[10px] capitalize",children:vr},vr))})]},St.id))]}),ts.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Assists agents:"}),ts.map(St=>r.jsxs("div",{className:"p-3 rounded-lg border bg-muted/30 space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-medium",children:St.agent_name}),r.jsx(_t,{variant:"outline",className:"text-xs",children:"Agent"})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:St.agent_email}),r.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Object.entries(St.permissions).filter(([,vr])=>vr).map(([vr])=>r.jsx(_t,{variant:"secondary",className:"text-[10px] capitalize",children:vr},vr))})]},St.id))]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"App Access"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Toggle which apps this member can access"}),r.jsx("div",{className:"grid gap-3",children:d.map(St=>{const vr=Cl(Ve.tags,St.required_tags),Hr=`${Ve.id}-${St.id}`,pn=ue===Hr,gn=St.required_tags.length===0;return r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/30",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"text-xl",children:St.icon}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-sm",children:St.name}),gn&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),r.jsx("div",{className:"flex items-center gap-2",children:pn?r.jsx($r,{className:"h-4 w-4 animate-spin text-muted-foreground"}):gn?r.jsx(_t,{variant:"secondary",className:"text-xs",children:"Always On"}):r.jsx(fn,{checked:vr,onCheckedChange:()=>$l(Ve.id,St,vr)})})]},St.id)})})]}),Ve.is_trial&&r.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[r.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[r.jsx(Pa,{className:"h-4 w-4"}),"Trial Status"]}),r.jsxs("div",{className:"p-4 rounded-lg border bg-amber-50 dark:bg-amber-950/20 border-amber-200 dark:border-amber-800",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("div",{children:Ve.trial_expires_at&&r.jsx(J3e,{expiresAt:Ve.trial_expires_at})}),Ve.trial_expires_at&&r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Ve.trial_expires_at).toLocaleDateString()]})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>rp(Ve.id,7),disabled:ve,children:[r.jsx(y1,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>rp(Ve.id,14),disabled:ve,children:[r.jsx(y1,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>rp(Ve.id,30),disabled:ve,children:[r.jsx(y1,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),r.jsxs(X,{size:"sm",variant:"default",onClick:()=>Ed(Ve.id),disabled:Ze,className:"bg-green-600 hover:bg-green-700",children:[r.jsx(Ak,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Ve.trial_started_at&&r.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Ve.trial_started_at).toLocaleDateString(),Ve.trial_claimed_at&&r.jsxs("span",{children:[" • Claimed: ",new Date(Ve.trial_claimed_at).toLocaleDateString()]})]})]})]}),r.jsxs("div",{className:"space-y-2 pt-4 border-t",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Account Information"}),r.jsxs("div",{className:"text-sm space-y-1 text-muted-foreground",children:[Ve.email_confirmed_at&&r.jsxs("div",{children:["Claimed: ",new Date(Ve.email_confirmed_at).toLocaleString()]}),Ve.last_sign_in_at&&r.jsxs("div",{children:["Last login: ",new Date(Ve.last_sign_in_at).toLocaleString()]}),r.jsxs("div",{children:["Created: ",new Date(Ve.created_at).toLocaleString()]})]})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:Ku,children:"Cancel"}),r.jsx(X,{onClick:oM,children:"Save Changes"})]})]})}),r.jsxs(hs,{value:"access",children:[d.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx("p",{className:"text-muted-foreground mb-4",children:"No apps configured yet"}),r.jsx(X,{onClick:()=>e("/admin/apps"),children:"Configure Apps"})]})}):r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Member Access Matrix"}),r.jsx(Cs,{children:"Toggle switches to grant or revoke app access for each member"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b",children:[r.jsx("th",{className:"text-left p-4 font-semibold sticky left-0 bg-card z-10",children:"Member"}),d.map(St=>r.jsx("th",{className:"text-center p-4 font-semibold min-w-[120px]",children:r.jsxs("div",{className:"flex flex-col items-center gap-1",children:[r.jsx("span",{className:"text-2xl",children:St.icon}),r.jsx("span",{className:"text-sm",children:St.name})]})},St.id))]})}),r.jsxs("tbody",{children:[eu.map(St=>r.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[r.jsx("td",{className:"p-4 sticky left-0 bg-card z-10",children:r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:St.name}),r.jsx("div",{className:"text-sm text-muted-foreground",children:St.email})]})}),d.map(vr=>{const Hr=Cl(St.tags,vr.required_tags),pn=`${St.id}-${vr.id}`,gn=ue===pn;return r.jsx("td",{className:"p-4 text-center",children:r.jsx("div",{className:"flex items-center justify-center",children:gn?r.jsx($r,{className:"h-5 w-5 animate-spin text-muted-foreground"}):r.jsx(fn,{checked:Hr,onCheckedChange:()=>$l(St.id,vr,Hr),disabled:vr.required_tags.length===0})})},vr.id)})]},St.id)),eu.length===0&&r.jsx("tr",{children:r.jsx("td",{colSpan:d.length+1,className:"p-8 text-center text-muted-foreground",children:"No members found"})})]})]})}),Zo>1&&r.jsxs("div",{className:"flex items-center justify-between px-2 py-4 border-t",children:[r.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",Gu+1,"-",Math.min(cm,Ec)," of ",Ec," • Page ",K," of ",Zo]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>re(St=>Math.max(1,St-1)),disabled:K===1,children:r.jsx(jc,{className:"h-4 w-4"})}),r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>re(St=>Math.min(Zo,St+1)),disabled:K===Zo,children:r.jsx(Zi,{className:"h-4 w-4"})})]})]})]})]}),r.jsx("div",{className:"mt-6",children:r.jsx(X,{variant:"outline",onClick:()=>e("/admin/apps"),children:"Manage Apps"})})]}),r.jsxs(hs,{value:"brokerages",className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search brokerages...",value:$a,onChange:St=>xo(St.target.value),className:"pl-10"})]}),r.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[p.filter(St=>St.name.toLowerCase().includes($a.toLowerCase())).length," of ",p.length," brokerages"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>{const St=[];for(const Kn of p){const Ta=v[Kn.id]??[];for(const dm of Ta){const bu=l.find(Ul=>Ul.id===dm);if(bu){const Ul=(bu.name||"").trim().split(/\s+/),Aa=Ul[0]||"",PN=Ul.slice(1).join(" ")||"";St.push({firstName:Aa,lastName:PN,email:bu.email,brokerageName:Kn.name})}}}if(St.length===0){o({title:"No managers found to export"});return}const Hr=[["First Name","Last Name","Email","Brokerage Name"].join(","),...St.map(Kn=>[Kn.firstName,Kn.lastName,Kn.email,Kn.brokerageName].map(Ta=>`"${(Ta||"").replace(/"/g,'""')}"`).join(","))].join(` `),pn=new Blob([Hr],{type:"text/csv"}),gn=URL.createObjectURL(pn),ua=document.createElement("a");ua.href=gn,ua.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,ua.click(),URL.revokeObjectURL(gn),o({title:`Exported ${St.length} managers`})},children:[r.jsx(Fi,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),r.jsxs(Ir,{open:tt,onOpenChange:rt,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{size:"sm",children:[r.jsx(Ni,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create New Brokerage"}),r.jsx(Zs,{children:"Add a new brokerage to the system."})]}),r.jsx("div",{className:"space-y-4 py-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"brokerage-name",children:"Brokerage Name"}),r.jsx(Ye,{id:"brokerage-name",placeholder:"Enter brokerage name",value:je,onChange:St=>it(St.target.value),maxLength:100})]})}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>rt(!1),children:"Cancel"}),r.jsx(X,{onClick:hd,disabled:Se,children:Se?"Creating...":"Create Brokerage"})]})]})]})]})]}),r.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/30 hover:bg-muted/30",children:[r.jsx(Mt,{className:"font-semibold",children:"Brokerage Name"}),r.jsx(Mt,{className:"font-semibold",children:"Manager(s)"}),r.jsx(Mt,{className:"font-semibold",children:"Agents"}),r.jsx(Mt,{className:"w-[150px]"})]})}),r.jsx(Bn,{children:(()=>{const St=p.filter(vr=>vr.name.toLowerCase().includes($a.toLowerCase()));return St.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:$a?"No brokerages match your search":"No brokerages found"})}):St.map(vr=>{const Hr=l.filter(Kn=>Kn.brokerage_id===vr.id),gn=(v[vr.id]??[]).map(Kn=>l.find(Ta=>Ta.id===Kn)).filter(Boolean),ua=Hr.length;return r.jsxs(Nr,{className:"hover:bg-muted/30",children:[r.jsx(dt,{children:r.jsx("button",{onClick:()=>Ym(vr),className:"text-primary hover:underline font-medium",children:vr.name})}),r.jsx(dt,{children:gn.length>0?r.jsx("div",{className:"flex flex-wrap gap-1",children:gn.map(Kn=>r.jsx(_t,{variant:"secondary",className:"text-xs",children:Kn.name},Kn.id))}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),r.jsxs(dt,{children:[ua," member",ua!==1?"s":""]}),r.jsx(dt,{children:r.jsxs("div",{className:"flex gap-1 justify-end",children:[r.jsxs(X,{size:"sm",variant:"outline",className:"h-8",onClick:()=>ep(vr),children:[r.jsx(ws,{className:"h-4 w-4 mr-1"}),"Manage"]}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ym(vr),title:"Edit brokerage",children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ch(vr),title:"Delete brokerage",children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},vr.id)})})()})]})}),r.jsx(Ir,{open:Qe,onOpenChange:He,children:r.jsxs(Er,{className:"max-w-lg",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Edit Brokerage"}),r.jsx(Zs,{children:"Update brokerage details and manage managers"})]}),ot&&r.jsxs("div",{className:"space-y-6 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),r.jsx(Ye,{id:"edit-brokerage-name",value:ft,onChange:St=>ct(St.target.value),maxLength:100})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Managers"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Click × to remove manager access for this brokerage (keeps them as a member)"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:(()=>{const vr=(v[ot.id]??[]).map(Hr=>l.find(pn=>pn.id===Hr)).filter(Boolean);return vr.length===0?r.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):vr.map(Hr=>r.jsxs(_t,{variant:"default",className:"gap-1",children:[r.jsx(Ou,{className:"h-3 w-3"}),Hr.name,r.jsx("button",{onClick:()=>Vi(Hr.id,"brokerage_manager","remove",ot.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:r.jsx(Xs,{className:"h-3 w-3"})})]},Hr.id))})()}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),r.jsxs(cd,{open:Ei,onOpenChange:Qs,children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",role:"combobox","aria-expanded":Ei,className:"w-full justify-between",children:["Search for a member...",r.jsx(qn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),r.jsx(Hc,{className:"w-full p-0",align:"start",children:r.jsxs(a0,{children:[r.jsx(i0,{placeholder:"Search by name or email..."}),r.jsxs(o0,{className:"max-h-[200px]",children:[r.jsx(l0,{children:"No members found."}),r.jsx(c0,{children:(()=>{const St=new Set(v[ot.id]??[]);return l.filter(vr=>!St.has(vr.id)&&(s||vr.brokerage_id===ot.id)).map(vr=>r.jsxs(d0,{value:`${vr.name} ${vr.email}`,onSelect:()=>{Ac(vr.id,ot.id),Qs(!1)},children:[vr.name," (",vr.email,")"]},vr.id))})()})]})]})})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Members in this Brokerage"}),r.jsx("div",{className:"max-h-32 overflow-y-auto border rounded p-2",children:l.filter(St=>St.brokerage_id===ot.id).length===0?r.jsx("span",{className:"text-sm text-muted-foreground",children:"No members"}):l.filter(St=>St.brokerage_id===ot.id).map(St=>r.jsxs("div",{className:"text-sm py-1 flex items-center justify-between",children:[r.jsx("span",{children:St.name}),St.roles.includes("brokerage_manager")&&r.jsx(_t,{variant:"outline",className:"text-xs",children:"Manager"})]},St.id))})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:el,children:"Cancel"}),r.jsx(X,{onClick:Jd,disabled:Tt,children:Tt?"Saving...":"Save Changes"})]})]})}),r.jsx(Ir,{open:rr,onOpenChange:Lr,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{className:"text-destructive",children:"Delete Brokerage"}),r.jsxs(Zs,{children:['Are you sure you want to delete "',cr==null?void 0:cr.name,'"?']})]}),r.jsx("div",{className:"py-4",children:r.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 rounded-lg p-4 space-y-2",children:[r.jsx("p",{className:"text-sm font-medium text-destructive",children:"Warning: This action cannot be undone!"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"This will permanently delete:"}),r.jsxs("ul",{className:"text-sm text-muted-foreground list-disc list-inside",children:[r.jsxs("li",{children:['The brokerage "',cr==null?void 0:cr.name,'"']}),r.jsxs("li",{children:["All ",l.filter(St=>St.brokerage_id===(cr==null?void 0:cr.id)).length," member(s) assigned to this brokerage"]}),r.jsx("li",{children:"All their data, roles, and access"})]})]})}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>Lr(!1),children:"Cancel"}),r.jsx(X,{variant:"destructive",onClick:tl,disabled:As,children:As?"Deleting...":"Yes, Delete Brokerage"})]})]})}),r.jsx(Ir,{open:Pt,onOpenChange:Sr,children:r.jsxs(Er,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Ni,{className:"h-5 w-5"}),"Manage ",fs==null?void 0:fs.name]}),r.jsx(Zs,{children:"Add, remove, or manage users in this brokerage"})]}),fs&&r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search members...",value:tn,onChange:St=>xi(St.target.value),className:"pl-10 h-9"})]}),r.jsxs(Ir,{open:La,onOpenChange:un,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{size:"sm",children:[r.jsx(Kd,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Add New Agent"}),r.jsxs(Zs,{children:["Create a new agent for ",fs.name]})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"agent-name",children:"Name"}),r.jsx(Ye,{id:"agent-name",placeholder:"John Doe",value:ia.name,onChange:St=>rn({...ia,name:St.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"agent-email",children:"Email"}),r.jsx(Ye,{id:"agent-email",type:"email",placeholder:"john@example.com",value:ia.email,onChange:St=>rn({...ia,email:St.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"agent-password",children:"Password"}),r.jsx(Ye,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:ia.password,onChange:St=>rn({...ia,password:St.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"agent-phone",children:"Phone (optional)"}),r.jsx(Ye,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:ia.phone,onChange:St=>rn({...ia,phone:St.target.value})})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>un(!1),children:"Cancel"}),r.jsx(X,{onClick:k0,disabled:Wn,children:Wn?"Creating...":"Create Agent"})]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ee,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),r.jsxs(cd,{open:ao,onOpenChange:Mc,children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",role:"combobox","aria-expanded":ao,className:"w-[300px] justify-between",children:["Select a user to add...",r.jsx(qn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),r.jsx(Hc,{className:"w-[300px] p-0",align:"start",children:r.jsxs(a0,{children:[r.jsx(i0,{placeholder:"Search users...",value:No,onValueChange:Tc}),r.jsxs(o0,{children:[r.jsx(l0,{children:"No users found."}),r.jsx(c0,{children:md(fs.id).filter(St=>No===""||St.name.toLowerCase().includes(No.toLowerCase())||St.email.toLowerCase().includes(No.toLowerCase())).map(St=>r.jsxs(d0,{value:`${St.name} ${St.email}`,onSelect:()=>{j0(St.id,fs.id),Mc(!1),Tc("")},children:[St.name," (",St.email,")"]},St.id))})]})]})})]})]}),r.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/30 hover:bg-muted/30",children:[r.jsx(Mt,{className:"font-semibold",children:"Name"}),r.jsx(Mt,{className:"font-semibold",children:"Email"}),r.jsx(Mt,{className:"font-semibold",children:"Status"}),r.jsx(Mt,{className:"font-semibold",children:"Role"}),r.jsx(Mt,{className:"w-[120px]"})]})}),r.jsx(Bn,{children:Wu(fs.id).length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:tn?"No matching members found":"No members in this brokerage"})}):Wu(fs.id).map(St=>r.jsxs(Nr,{className:"hover:bg-muted/30",children:[r.jsx(dt,{className:"font-medium",children:St.name}),r.jsx(dt,{className:"text-muted-foreground",children:St.email}),r.jsx(dt,{children:St.claimed?r.jsx(_t,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):r.jsx(_t,{variant:"secondary",children:"Pending"})}),r.jsx(dt,{children:St.roles.includes("brokerage_manager")?r.jsxs(_t,{variant:"outline",className:"gap-1",children:[r.jsx(Ou,{className:"h-3 w-3"}),"Manager"]}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"Agent"})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex gap-1 justify-end",children:[!St.claimed&&r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>da(St.id),title:"Resend welcome email",children:r.jsx(Vs,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>w0(St.id),title:"Remove from brokerage",children:r.jsx(Xs,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8 text-blue-600 hover:text-blue-700 hover:bg-blue-50",onClick:()=>bg(St.id),disabled:a||St.id===(t==null?void 0:t.id),title:St.id===(t==null?void 0:t.id)?"Cannot impersonate yourself":`Login as ${St.name}`,children:a?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(I4,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>Ja(St.id,St.name),title:"Delete user",children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},St.id))})]})}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[lm(fs.id).length," total member",lm(fs.id).length!==1?"s":""," •",lm(fs.id).filter(St=>St.roles.includes("brokerage_manager")).length," manager",lm(fs.id).filter(St=>St.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),r.jsx(Rn,{children:r.jsx(X,{variant:"outline",onClick:_g,children:"Close"})})]})})]}),r.jsx(hs,{value:"teams",children:r.jsx(oAt,{})}),r.jsx(hs,{value:"trials",children:r.jsx(sAt,{})}),r.jsx(hs,{value:"celebrations",children:r.jsx(rAt,{})}),r.jsx(hs,{value:"deletions",children:r.jsx(nAt,{})})]})]}),r.jsx(kqe,{open:Pi,onOpenChange:dr,brokerages:p,onSuccess:Ma}),yr&&r.jsx(Nqe,{open:Ft,onOpenChange:St=>{Yt(St),St||hr(null)},userId:yr.id,userName:yr.name})]})},cAt=()=>{const[e,t]=A.useState([]),[s,n]=A.useState(!0),[a,o]=A.useState(!1),[l,i]=A.useState(""),[d,m]=A.useState(""),[p,g]=A.useState(""),[v,_]=A.useState("");A.useEffect(()=>{k()},[]);const k=async()=>{const{data:D,error:B}=await Y.from("invite_codes").select("*").order("created_at",{ascending:!1});B?(we.error("Failed to load invite codes"),console.error(B)):t(D||[]),n(!1)},w=async D=>{if(D.preventDefault(),!l.trim()){we.error("Please enter a code");return}o(!0);const{error:B}=await Y.from("invite_codes").insert({code:l.trim().toUpperCase(),description:d.trim()||null,max_uses:p?parseInt(p):null,trial_days:v?parseInt(v):null});B?B.code==="23505"?we.error("This code already exists"):(we.error("Failed to create invite code"),console.error(B)):(we.success("Invite code created"),i(""),m(""),g(""),_(""),k()),o(!1)},S=async(D,B)=>{const{error:$}=await Y.from("invite_codes").update({is_active:!B}).eq("id",D);$?we.error("Failed to update code"):t(e.map(q=>q.id===D?{...q,is_active:!B}:q))},T=async D=>{const{error:B}=await Y.from("invite_codes").delete().eq("id",D);B?we.error("Failed to delete code"):(we.success("Code deleted"),t(e.filter($=>$.id!==D)))},C="https://dashboard.relevelup.com",I=D=>{const B=`${C}/join?code=${D}`;navigator.clipboard.writeText(B),we.success("Link copied to clipboard")},R=`${C}/join`;return r.jsx(Ur,{title:"Invite Codes",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Invite Codes",description:"Manage signup invite codes"}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Create New Code"}),r.jsxs(Cs,{children:["Share link: ",r.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:R})]})]}),r.jsx(qe,{children:r.jsxs("form",{onSubmit:w,className:"flex flex-wrap gap-4 items-end",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"code",children:"Code"}),r.jsx(Ye,{id:"code",placeholder:"WELCOME2024",value:l,onChange:D=>i(D.target.value),className:"w-40"})]}),r.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[r.jsx(Ee,{htmlFor:"description",children:"Description (optional)"}),r.jsx(Ye,{id:"description",placeholder:"For marketing campaign",value:d,onChange:D=>m(D.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"maxUses",children:"Max Uses"}),r.jsx(Ye,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:D=>g(D.target.value),className:"w-28"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"trialDays",children:"Trial Days"}),r.jsx(Ye,{id:"trialDays",type:"number",placeholder:"None",value:v,onChange:D=>_(D.target.value),className:"w-28"})]}),r.jsxs(X,{type:"submit",disabled:a,children:[a?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Active Codes"})}),r.jsx(qe,{children:s?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.length===0?r.jsx("p",{className:"text-center py-8 text-muted-foreground",children:"No invite codes yet"}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Code"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{children:"Uses"}),r.jsx(Mt,{children:"Trial"}),r.jsx(Mt,{children:"Created"}),r.jsx(Mt,{children:"Active"}),r.jsx(Mt,{className:"w-24",children:"Actions"})]})}),r.jsx(Bn,{children:e.map(D=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-mono font-medium",children:D.code}),r.jsx(dt,{className:"text-muted-foreground",children:D.description||"—"}),r.jsxs(dt,{children:[D.uses_count,D.max_uses&&` / ${D.max_uses}`]}),r.jsx(dt,{children:D.trial_days?r.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[D.trial_days," days"]}):r.jsx("span",{className:"text-muted-foreground",children:"—"})}),r.jsx(dt,{className:"text-muted-foreground",children:Xr(new Date(D.created_at),"MMM d, yyyy")}),r.jsx(dt,{children:r.jsx(fn,{checked:D.is_active,onCheckedChange:()=>S(D.id,D.is_active)})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>I(D.code),title:"Copy invite link",children:r.jsx(uo,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>T(D.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},D.id))})]})})]})]})})},z6=async e=>{try{const{data:t,error:s}=await Y.from("push_notification_settings").select("is_enabled").eq("setting_key",e).maybeSingle();return s?(console.error("Error checking notification setting:",s),!0):(t==null?void 0:t.is_enabled)??!0}catch(t){return console.error("Error checking notification setting:",t),!0}},z3=async e=>{try{const{data:t,error:s}=await Y.functions.invoke("send-push-notification",{body:e});return s?(console.error("Error sending notification:",s),{success:!1,error:s}):(console.log("Notification sent:",t),{success:!0,data:t})}catch(t){return console.error("Error sending notification:",t),{success:!1,error:t}}},dAt=async(e,t)=>await z6("new_templates")?z3({title:"New Template Available",body:`Check out the new template: ${e}`,url:`/templates/${t}`}):(console.log("New template notifications are disabled"),{success:!1,skipped:!0}),uAt=async(e,t)=>z3({title:"New Academy Video",body:`New video added: ${e}`,url:`/academy/${t}`}),hAt=async(e,t)=>await z6("new_events")?z3({title:"New Event",body:`New event: ${e}`,url:`/events/${t}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),mAt=async(e,t)=>await z6("new_toolbox")?z3({title:"New Resource Kit",body:`New resource kit available: ${e}`,url:`/toolbox/${t}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),vge=async(e,t)=>await z6("new_social_swag")?z3({title:"New Social Swag",body:`New social swag available: ${e}`,url:`/social-swag/${t}`}):(console.log("New social swag notifications are disabled"),{success:!1,skipped:!0}),fAt=async(e,t)=>await z6("new_newsletters")?z3({title:"New Newsletter",body:`New newsletter available: ${e}`,url:`/newsletters/${t}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),ZO={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 pAt(){const e=Ks(),t=Rr(),[s,n]=A.useState(!1),[a,o]=A.useState(null),[l,i]=A.useState(ZO),[d,m]=A.useState(null),[p,g]=A.useState(null),[v,_]=A.useState(!1),k=A.useRef(null),[w,S]=A.useState(!1),[T,C]=A.useState(null),[I,R]=A.useState(!1),[D,B]=A.useState(null),[$,q]=A.useState(null),[W,K]=A.useState(!0),[re,ae]=A.useState(""),{data:oe,isLoading:se}=Ht({queryKey:["admin-events"],queryFn:async()=>{const{data:je,error:it}=await Y.from("events").select("*").order("event_date",{ascending:!0});if(it)throw it;return je}}),{data:pe}=Ht({queryKey:["event-registrations-count"],queryFn:async()=>{const{data:je,error:it}=await Y.from("event_registrations").select("event_id");if(it)throw it;const Se={};return je.forEach(et=>{Se[et.event_id]=(Se[et.event_id]||0)+1}),Se}}),{data:ie,isLoading:de}=Ht({queryKey:["event-registrations-details",T==null?void 0:T.id],queryFn:async()=>{if(!T)return[];const{data:je,error:it}=await Y.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",T.id).order("registered_at",{ascending:!1});if(it)throw it;if(!je||je.length===0)return[];const Se=je.map(He=>He.user_id).filter(Boolean);let et=[];if(Se.length>0){const{data:He,error:ot}=await Y.from("profiles").select("id, name, email").in("id",Se);if(ot)throw ot;et=He||[]}const Qe=new Map((et==null?void 0:et.map(He=>[He.id,He]))||[]);return je.map(He=>({...He,profiles:He.user_id&&Qe.get(He.user_id)||null}))},enabled:!!T}),{data:ce,isLoading:ge}=Ht({queryKey:["event-attendees-details",T==null?void 0:T.id],queryFn:async()=>{if(!T)return[];const{data:je,error:it}=await Y.from("event_attendees").select("id, user_id, zoom_email, zoom_name, join_time, leave_time, duration_minutes, manually_added, created_at").eq("event_id",T.id).order("created_at",{ascending:!1});if(it)throw it;if(!je||je.length===0)return[];const Se=je.map(ut=>ut.user_id).filter(Boolean);let et=[];if(Se.length>0){const{data:ut,error:ft}=await Y.from("profiles").select("id, name, email").in("id",Se);if(ft)throw ft;et=ut||[]}const{data:Qe}=await Y.from("agent_points").select("user_id").eq("event_id",T.id),He=new Set((Qe==null?void 0:Qe.map(ut=>ut.user_id))||[]),ot=new Map((et==null?void 0:et.map(ut=>[ut.id,ut]))||[]);return je.map(ut=>({...ut,profiles:ut.user_id&&ot.get(ut.user_id)||null,points_awarded:ut.user_id?He.has(ut.user_id):!1}))},enabled:!!T}),Te=je=>{C(je),S(!0)},_e=Qt({mutationFn:async je=>{const{data:{session:it}}=await Y.auth.getSession();if(!it)throw new Error("Not authenticated");const Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-registrations",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:je})}),et=await Se.json();if(!Se.ok)throw new Error(et.error||"Failed to sync");return et},onSuccess:je=>{t.invalidateQueries({queryKey:["event-registrations-details",T==null?void 0:T.id]}),t.invalidateQueries({queryKey:["event-registrations-count"]}),we.success(je.message)},onError:je=>{we.error("Failed to sync: "+je.message)}}),ve=Qt({mutationFn:async je=>{const{data:{session:it}}=await Y.auth.getSession();if(!it)throw new Error("Not authenticated");const Se=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/zoom-sync-attendees",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${it.access_token}`},body:JSON.stringify({event_id:je})}),et=await Se.json();if(!Se.ok)throw new Error(et.error||"Failed to sync attendees");return et},onSuccess:je=>{t.invalidateQueries({queryKey:["event-attendees-details",T==null?void 0:T.id]}),t.invalidateQueries({queryKey:["event-leaderboard"]}),t.invalidateQueries({queryKey:["admin-agent-points"]}),je!=null&&je.message?we.success(je.message):we.success(`Synced ${je.synced||0} attendees. ${je.points_awarded||0} points awarded!`)},onError:je=>{we.error("Failed to sync attendees: "+je.message)}}),Me=Qt({mutationFn:async({eventId:je,testMode:it})=>{const{data:{session:Se}}=await Y.auth.getSession();if(!Se)throw new Error("Not authenticated");const et=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Se.access_token}`},body:JSON.stringify({event_id:je,test_mode:it})}),Qe=await et.json();if(!et.ok)throw new Error(Qe.error||"Failed to send reminders");return Qe},onSuccess:je=>{je.test?we.success(je.message||"Test email sent!"):we.success(je.message||`Reminder emails sent to ${je.sent} registrants!`)},onError:je=>{we.error("Failed to send reminders: "+je.message)}}),{data:Ze}=Ht({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let je=[],it=0;const Se=1e3;for(;;){const{data:et,error:Qe}=await Y.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(it,it+Se-1);if(Qe)throw Qe;if(!et||et.length===0||(je=[...je,...et],et.length{const{error:Qe}=await Y.from("event_attendees").update({user_id:it}).eq("id",je);if(Qe)throw Qe;if(et&&Se){const{error:ot}=await Y.from("zoom_email_aliases").upsert({user_id:it,zoom_email:Se.toLowerCase()},{onConflict:"zoom_email"});ot&&console.error("Failed to save alias:",ot)}const He=T==null?void 0:T.id;if(He){const{data:ot}=await Y.from("user_roles").select("id").eq("user_id",it).eq("role","admin").single();if(!ot){const{data:ut}=await Y.from("agent_points").select("id").eq("user_id",it).eq("event_id",He).single();ut||(await Y.rpc("award_attendance_points",{p_user_id:it,p_event_id:He,p_points:10,p_reason:"Event Attendance (Manual Link)"}),await Y.rpc("check_and_award_badges",{p_user_id:it}))}}return{userId:it,zoomEmail:Se,shouldSaveAlias:et}},onSuccess:je=>{t.invalidateQueries({queryKey:["event-attendees-details",T==null?void 0:T.id]}),t.invalidateQueries({queryKey:["event-leaderboard"]}),t.invalidateQueries({queryKey:["admin-agent-points"]});let it="Attendee linked and points awarded!";je.shouldSaveAlias&&je.zoomEmail&&(it+=` Email "${je.zoomEmail}" will be auto-matched in the future.`),we.success(it),R(!1),B(null),q(null),ae("")},onError:je=>{we.error("Failed to link attendee: "+je.message)}}),Le=je=>{B(je),q(null),K(!0),ae(""),R(!0)},Ue=()=>{!D||!$||Ae.mutate({attendeeId:D.id,userId:$,zoomEmail:D.zoom_email,shouldSaveAlias:W})},Ve=(Ze==null?void 0:Ze.filter(je=>{var Se,et;if(!re)return!0;const it=re.toLowerCase();return((Se=je.name)==null?void 0:Se.toLowerCase().includes(it))||((et=je.email)==null?void 0:et.toLowerCase().includes(it))}))||[],Ie=async je=>{const it=je.name.split(".").pop(),et=`${`${crypto.randomUUID()}.${it}`}`,{error:Qe}=await Y.storage.from("event-images").upload(et,je);if(Qe)throw Qe;const{data:{publicUrl:He}}=Y.storage.from("event-images").getPublicUrl(et);return He},We=je=>{var Se;const it=(Se=je.target.files)==null?void 0:Se[0];if(it){if(it.size>5*1024*1024){we.error("Image must be less than 5MB");return}m(it),g(URL.createObjectURL(it))}},wt=()=>{m(null),g(null),i({...l,image_url:""}),k.current&&(k.current.value="")},Pe=Qt({mutationFn:async je=>{_(!0);let it=je.image_url;d&&(it=await Ie(d)||"");const Se=new Date(je.event_date),[et,Qe]=je.event_time.split(":");Se.setHours(parseInt(et),parseInt(Qe));const He=[new Date(Se)];if(je.is_recurring&&je.recurrence_end_date){let ct=new Date(Se);for(;je.recurrence_pattern==="weekly"?ct=Vj(ct,1):je.recurrence_pattern==="biweekly"?ct=Vj(ct,2):ct=rm(ct,1),!(ct>je.recurrence_end_date);)He.push(new Date(ct))}const ot=He.map(ct=>({title:je.title,description:je.description||null,image_url:it||null,video_url:je.video_url||null,event_date:ct.toISOString(),zoom_link:je.zoom_link,zoom_meeting_id:je.zoom_meeting_id||null,capacity:je.capacity?parseInt(je.capacity):null,is_published:je.is_published})),{data:ut,error:ft}=await Y.from("events").insert(ot).select();if(ft)throw ft;return ut&&ut.length>0&&hAt(je.title,ut[0].id),He.length},onSuccess:je=>{t.invalidateQueries({queryKey:["admin-events"]}),we.success(je>1?`${je} recurring events created successfully`:"Event created successfully"),n(!1),i(ZO),m(null),g(null),_(!1)},onError:je=>{we.error("Failed to create event: "+je.message),_(!1)}}),st=Qt({mutationFn:async({id:je,data:it})=>{_(!0);let Se=it.image_url;d&&(Se=await Ie(d)||"");const et=new Date(it.event_date),[Qe,He]=it.event_time.split(":");et.setHours(parseInt(Qe),parseInt(He));const{error:ot}=await Y.from("events").update({title:it.title,description:it.description||null,image_url:Se||null,video_url:it.video_url||null,event_date:et.toISOString(),zoom_link:it.zoom_link,zoom_meeting_id:it.zoom_meeting_id||null,capacity:it.capacity?parseInt(it.capacity):null,is_published:it.is_published}).eq("id",je);if(ot)throw ot},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-events"]}),we.success("Event updated successfully"),n(!1),o(null),i(ZO),m(null),g(null),_(!1)},onError:je=>{we.error("Failed to update event: "+je.message),_(!1)}}),ue=Qt({mutationFn:async je=>{const{error:it}=await Y.from("events").delete().eq("id",je);if(it)throw it},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-events"]}),we.success("Event deleted successfully")},onError:je=>{we.error("Failed to delete event: "+je.message)}}),$e=je=>{var Se;const it=new Date(je.event_date);o(je),i({title:je.title,description:je.description||"",image_url:je.image_url||"",video_url:je.video_url||"",event_date:it,event_time:Xr(it,"HH:mm"),zoom_link:je.zoom_link,zoom_meeting_id:je.zoom_meeting_id||"",capacity:((Se=je.capacity)==null?void 0:Se.toString())||"",is_published:je.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),g(je.image_url||null),m(null),n(!0)},tt=je=>{if(je.preventDefault(),!l.event_date){we.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){we.error("Please select an end date for recurring events");return}a?st.mutate({id:a.id,data:l}):Pe.mutate(l)},rt=()=>{n(!1),o(null),i(ZO),m(null),g(null)};return r.jsx("div",{className:"min-h-screen bg-background p-6",children:r.jsxs("div",{className:"max-w-6xl mx-auto",children:[r.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>e("/dashboard"),children:r.jsx(gi,{className:"h-5 w-5"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Event Management"}),r.jsx("p",{className:"text-muted-foreground",children:"Create and manage upcoming events"})]})]}),r.jsxs(ze,{className:"mb-6",children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsx(Zt,{children:"All Events"}),r.jsxs(Ir,{open:s,onOpenChange:je=>!je&&rt(),children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{onClick:()=>n(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Event"]})}),r.jsxs(Er,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:a?"Edit Event":"Create New Event"})}),r.jsxs("form",{onSubmit:tt,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title *"}),r.jsx(Ye,{id:"title",value:l.title,onChange:je=>i({...l,title:je.target.value}),placeholder:"Event title",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:l.description,onChange:je=>i({...l,description:je}),placeholder:"Event description",minHeight:"120px"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Event Image"}),r.jsx("input",{type:"file",ref:k,accept:"image/*",onChange:We,className:"hidden"}),p?r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:p,alt:"Event preview",className:"w-full h-32 object-cover rounded-lg border"}),r.jsx(X,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:wt,children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.jsxs(X,{type:"button",variant:"outline",className:"w-full h-32 border-dashed flex flex-col gap-2",onClick:()=>{var je;return(je=k.current)==null?void 0:je.click()},children:[r.jsx(Xi,{className:"h-6 w-6"}),r.jsx("span",{className:"text-sm",children:"Click to upload image"})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Date *"}),r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[r.jsx(An,{className:"mr-2 h-4 w-4"}),l.event_date?Xr(l.event_date,"PPP"):"Pick a date"]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:l.event_date,onSelect:je=>i({...l,event_date:je}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"time",children:"Time *"}),r.jsx(Ye,{id:"time",type:"time",value:l.event_time,onChange:je=>i({...l,event_time:je.target.value}),required:!0})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"zoom_link",children:"Zoom Link *"}),r.jsx(Ye,{id:"zoom_link",value:l.zoom_link,onChange:je=>i({...l,zoom_link:je.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),r.jsx(Ye,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:je=>i({...l,zoom_meeting_id:je.target.value}),placeholder:"e.g., 1234567890 (find in Zoom dashboard)"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional: Enter the numeric meeting ID for automatic Zoom registration"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),r.jsx(Ye,{id:"video_url",value:l.video_url,onChange:je=>i({...l,video_url:je.target.value}),placeholder:"YouTube, Vimeo, or Bunny.net embed URL"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a preview/promo video for this event"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"capacity",children:"Capacity (optional)"}),r.jsx(Ye,{id:"capacity",type:"number",value:l.capacity,onChange:je=>i({...l,capacity:je.target.value}),placeholder:"Leave empty for unlimited",min:"1"})]}),!a&&r.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(EE,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ee,{htmlFor:"is_recurring",children:"Recurring Event"})]}),r.jsx(fn,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:je=>i({...l,is_recurring:je})})]}),l.is_recurring&&r.jsxs("div",{className:"space-y-3 pt-1",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Frequency"}),r.jsxs(ds,{value:l.recurrence_pattern,onValueChange:je=>i({...l,recurrence_pattern:je}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"weekly",children:"Weekly"}),r.jsx(Ut,{value:"biweekly",children:"Every 2 Weeks"}),r.jsx(Ut,{value:"monthly",children:"Monthly"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Repeat Until"}),r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[r.jsx(An,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?Xr(l.recurrence_end_date,"PPP"):"Pick end date"]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:l.recurrence_end_date,onSelect:je=>i({...l,recurrence_end_date:je}),disabled:je=>je<(l.event_date||new Date),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),l.event_date&&l.recurrence_end_date&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create ",(()=>{let je=1,it=new Date(l.event_date);for(;it=l.recurrence_pattern==="weekly"?Vj(it,1):l.recurrence_pattern==="biweekly"?Vj(it,2):rm(it,1),!(it>l.recurrence_end_date);)je++;return je})()," events with the same Zoom link"]})]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{htmlFor:"is_published",children:"Published"}),r.jsx(fn,{id:"is_published",checked:l.is_published,onCheckedChange:je=>i({...l,is_published:je})})]}),r.jsxs("div",{className:"flex gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:rt,className:"flex-1",children:"Cancel"}),r.jsx(X,{type:"submit",className:"flex-1",disabled:Pe.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"})]})]})]})]})]}),r.jsx(qe,{children:se?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(oe==null?void 0:oe.length)===0?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Date & Time"}),r.jsx(Mt,{children:"Registrations"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:oe==null?void 0:oe.map(je=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:je.title}),r.jsx(dt,{children:Xr(new Date(je.event_date),"PPP p")}),r.jsx(dt,{children:r.jsxs(X,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>Te(je),children:[r.jsx(ws,{className:"h-4 w-4"}),(pe==null?void 0:pe[je.id])||0,je.capacity&&` / ${je.capacity}`]})}),r.jsx(dt,{children:r.jsx("span",{className:Vt("px-2 py-1 rounded-full text-xs font-medium",je.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:je.is_published?"Published":"Draft"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>window.open(je.zoom_link,"_blank"),title:"Open Zoom Link",children:r.jsx(jn,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>$e(je),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&ue.mutate(je.id)},children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},je.id))})]})})]}),r.jsx(Ir,{open:w,onOpenChange:S,children:r.jsxs(Er,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),T==null?void 0:T.title]}),r.jsx(Zs,{children:"View registrations and attendees for this event"})]}),r.jsxs("div",{className:"flex items-center justify-end mb-4 gap-2 flex-wrap",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>Me.mutate({eventId:T.id,testMode:!0}),disabled:Me.isPending,children:[r.jsx(Vs,{className:Vt("h-4 w-4 mr-2",Me.isPending&&"animate-spin")}),"Send Test to Me"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>Me.mutate({eventId:T.id}),disabled:Me.isPending||!(ie!=null&&ie.length),children:[r.jsx(Vs,{className:Vt("h-4 w-4 mr-2",Me.isPending&&"animate-spin")}),Me.isPending?"Sending...":"Send Reminder to All"]}),(T==null?void 0:T.zoom_meeting_id)&&r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>_e.mutate(T.id),disabled:_e.isPending,children:[r.jsx(Yo,{className:Vt("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),_e.isPending?"Syncing...":"Sync Registrations"]}),r.jsxs(X,{variant:"default",size:"sm",onClick:()=>ve.mutate(T.id),disabled:ve.isPending,children:[r.jsx(go,{className:Vt("h-4 w-4 mr-2",ve.isPending&&"animate-spin")}),ve.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),r.jsxs(ii,{defaultValue:"registrations",className:"w-full",children:[r.jsxs(si,{className:"grid w-full grid-cols-2",children:[r.jsxs(Kr,{value:"registrations",className:"gap-2",children:[r.jsx(ws,{className:"h-4 w-4"}),"Registrations (",(ie==null?void 0:ie.length)||0,")"]}),r.jsxs(Kr,{value:"attendees",className:"gap-2",children:[r.jsx(Ri,{className:"h-4 w-4"}),"Attendees (",(ce==null?void 0:ce.length)||0,")"]})]}),r.jsx(hs,{value:"registrations",className:"mt-4",children:de?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading registrations..."}):(ie==null?void 0:ie.length)===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx("p",{children:"No registrations yet for this event."}),(T==null?void 0:T.zoom_meeting_id)&&r.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Registered"}),r.jsx(Mt,{children:"Status"})]})}),r.jsx(Bn,{children:ie==null?void 0:ie.map(je=>{var Qe,He;const it=((Qe=je.profiles)==null?void 0:Qe.name)||je.zoom_name||"Unknown",Se=((He=je.profiles)==null?void 0:He.email)||je.zoom_email||null,et=!je.user_id;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:r.jsxs("div",{className:"flex items-center gap-2",children:[it,et&&r.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),r.jsx(dt,{children:Se?r.jsxs("a",{href:`mailto:${Se}`,className:"flex items-center gap-1 text-primary hover:underline",children:[r.jsx(Vs,{className:"h-3 w-3"}),Se]}):r.jsx("span",{className:"text-muted-foreground",children:"No email"})}),r.jsx(dt,{className:"text-muted-foreground text-sm",children:Xr(new Date(je.registered_at),"MMM d, yyyy h:mm a")}),r.jsx(dt,{children:je.zoom_join_url?r.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"}):r.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},je.id)})})]})}),r.jsx(hs,{value:"attendees",className:"mt-4",children:ge?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(ce==null?void 0:ce.length)===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx("p",{children:"No attendees recorded yet."}),(T==null?void 0:T.zoom_meeting_id)&&r.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Attendees & Award Points" after the event ends to import actual participants from Zoom.'})]}):r.jsxs(r.Fragment,{children:[(ce==null?void 0:ce.filter(je=>!je.user_id).length)>0&&r.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:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(kl,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),r.jsxs("h4",{className:"font-medium text-amber-800 dark:text-amber-200",children:["Unmatched Attendees (",ce==null?void 0:ce.filter(je=>!je.user_id).length,")"]})]}),r.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."}),r.jsx("div",{className:"space-y-2",children:ce==null?void 0:ce.filter(je=>!je.user_id).map(je=>r.jsxs("div",{className:"flex items-center justify-between p-2 bg-background rounded border",children:[r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"font-medium text-sm",children:je.zoom_name||"Unknown"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:je.zoom_email||"No email"})]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>Le(je),className:"gap-1",children:[r.jsx(Fm,{className:"h-3 w-3"}),"Link to Profile"]})]},je.id))})]}),r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Duration"}),r.jsx(Mt,{children:"Points"})]})}),r.jsx(Bn,{children:ce==null?void 0:ce.filter(je=>je.user_id).map(je=>{var et,Qe;const it=((et=je.profiles)==null?void 0:et.name)||je.zoom_name||"Unknown",Se=((Qe=je.profiles)==null?void 0:Qe.email)||je.zoom_email||null;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:r.jsxs("div",{className:"flex items-center gap-2",children:[it,je.manually_added&&r.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"})]})}),r.jsx(dt,{children:Se?r.jsxs("a",{href:`mailto:${Se}`,className:"flex items-center gap-1 text-primary hover:underline",children:[r.jsx(Vs,{className:"h-3 w-3"}),Se]}):r.jsx("span",{className:"text-muted-foreground",children:"No email"})}),r.jsx(dt,{children:je.duration_minutes?r.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[r.jsx(Pa,{className:"h-3 w-3"}),je.duration_minutes," min"]}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),r.jsx(dt,{children:je.points_awarded?r.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:[r.jsx(go,{className:"h-3 w-3"}),"+10 pts"]}):r.jsx("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-muted text-muted-foreground",children:"Pending"})})]},je.id)})})]})]})})]})]})}),r.jsx(Ir,{open:I,onOpenChange:R,children:r.jsxs(Er,{className:"max-w-md",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Fm,{className:"h-5 w-5"}),"Link Attendee to Profile"]}),r.jsx(Zs,{children:"Link this Zoom attendee to an existing member profile to award them points."})]}),D&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[r.jsx("p",{className:"text-sm font-medium",children:D.zoom_name||"Unknown"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:D.zoom_email||"No email"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Search for a profile"}),r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name or email...",value:re,onChange:je=>ae(je.target.value),className:"pl-9"})]})]}),r.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Ve.length===0?r.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No profiles found"}):r.jsx("div",{className:"divide-y",children:Ve.slice(0,20).map(je=>r.jsxs("button",{type:"button",onClick:()=>q(je.id),className:Vt("w-full p-3 text-left hover:bg-muted/50 transition-colors",$===je.id&&"bg-primary/10 border-l-2 border-primary"),children:[r.jsx("p",{className:"text-sm font-medium",children:je.name||"Unnamed"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:je.email})]},je.id))})}),D.zoom_email&&r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(Qo,{id:"save-alias",checked:W,onCheckedChange:je=>K(je)}),r.jsx("label",{htmlFor:"save-alias",className:"text-sm text-muted-foreground cursor-pointer",children:"Remember this email for future auto-matching"})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),r.jsx(X,{onClick:Ue,disabled:!$||Ae.isPending,children:Ae.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}const gAt=()=>{const{user:e}=Gr(),{toast:t}=_i(),s=Rr(),[n,a]=Cc(),[o,l]=A.useState(!1),[i,d]=A.useState(null),[m,p]=A.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]=A.useState(null),[_,k]=A.useState(0),[w,S]=A.useState(!1),[T,C]=A.useState(null),[I,R]=A.useState(""),[D,B]=A.useState(""),[$,q]=A.useState(""),[W,K]=A.useState(!1),[re,ae]=A.useState(!1),{data:oe=[]}=Ht({queryKey:["template-categories"],queryFn:async()=>{const{data:st,error:ue}=await Y.from("template_categories").select("*").order("name");if(ue)throw ue;return st}}),{data:se=[]}=Ht({queryKey:["template-types"],queryFn:async()=>{const{data:st,error:ue}=await Y.from("template_types").select("*").order("name");if(ue)throw ue;return st}}),{data:pe=[],isLoading:ie}=Ht({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:st,error:ue}=await Y.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(ue)throw ue;const{data:$e,error:tt}=await Y.from("template_links").select("*").order("sort_order");if(tt)throw tt;const{data:rt,error:je}=await Y.from("template_guides").select("*").order("sort_order");if(je)throw je;return st.map(Se=>({...Se,links:($e==null?void 0:$e.filter(et=>et.template_id===Se.id))||[],guides:(rt==null?void 0:rt.filter(et=>et.template_id===Se.id))||[]}))}});A.useEffect(()=>{const st=n.get("edit");if(st&&pe.length>0){const ue=pe.find($e=>$e.id===st);ue&&(ve(ue),a({},{replace:!0}))}},[pe,n]);const de=Qt({mutationFn:async st=>{const{data:ue,error:$e}=await Y.from("template_categories").insert({name:st}).select().single();if($e)throw $e;return ue},onSuccess:st=>{s.invalidateQueries({queryKey:["template-categories"]}),p({...m,category_id:st.id}),B(""),K(!1),t({title:"Category added"})},onError:st=>{t({title:"Error adding category",description:st.message,variant:"destructive"})}}),ce=Qt({mutationFn:async st=>{const{data:ue,error:$e}=await Y.from("template_types").insert({name:st}).select().single();if($e)throw $e;return ue},onSuccess:st=>{s.invalidateQueries({queryKey:["template-types"]}),p({...m,type_id:st.id}),q(""),ae(!1),t({title:"Type added"})},onError:st=>{t({title:"Error adding type",description:st.message,variant:"destructive"})}}),ge=Qt({mutationFn:async st=>{var je;let ue=st.existingImageUrl;if(st.image){const it=st.image.name.split(".").pop(),Se=`${Date.now()}-${Math.random().toString(36).substring(7)}.${it}`,{error:et}=await Y.storage.from("template-previews").upload(Se,st.image);if(et)throw et;const{data:Qe}=Y.storage.from("template-previews").getPublicUrl(Se);ue=Qe.publicUrl}const $e={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:ue,video_url:st.videoUrl||null,publish_date:st.template.publish_date?new Date(st.template.publish_date).toISOString():new Date().toISOString(),created_by:e==null?void 0:e.id};let tt=st.templateId;if(tt){const{error:it}=await Y.from("canva_templates").update($e).eq("id",tt);if(it)throw it;const{error:Se}=await Y.from("template_links").delete().eq("template_id",tt);if(Se)throw Se;const et=((je=st.existingGuides)==null?void 0:je.map(ot=>ot.id).filter(Boolean))||[],Qe=st.template.guides.map(ot=>ot.id).filter(Boolean),He=et.filter(ot=>!Qe.includes(ot));He.length>0&&await Y.from("template_guides").delete().in("id",He)}else{const{data:it,error:Se}=await Y.from("canva_templates").insert($e).select().single();if(Se)throw Se;tt=it.id,dAt(st.template.name,it.id)}const rt=st.template.links.filter(it=>it.title.trim()&&it.canva_share_link.trim());if(rt.length>0){const it=rt.map((et,Qe)=>({template_id:tt,title:et.title.trim(),canva_share_link:et.canva_share_link.trim(),sort_order:Qe})),{error:Se}=await Y.from("template_links").insert(it);if(Se)throw Se}for(let it=0;it{s.invalidateQueries({queryKey:["canva-templates-admin"]}),s.invalidateQueries({queryKey:["canva-templates"]}),_e(),l(!1),t({title:i?"Template updated":"Template created"})},onError:st=>{t({title:"Error saving template",description:st.message,variant:"destructive"})}}),Te=Qt({mutationFn:async st=>{const{error:ue}=await Y.from("canva_templates").delete().eq("id",st);if(ue)throw ue},onSuccess:()=>{s.invalidateQueries({queryKey:["canva-templates-admin"]}),s.invalidateQueries({queryKey:["canva-templates"]}),t({title:"Template deleted"})},onError:st=>{t({title:"Error deleting template",description:st.message,variant:"destructive"})}}),_e=()=>{p({name:"",description:"",category_id:"",type_id:"",publish_date:new Date().toISOString().split("T")[0],links:[{title:"",canva_share_link:"",sort_order:0}],guides:[],video_url:""}),C(null),R(""),d(null),K(!1),ae(!1),B(""),q(""),v(null),k(0),S(!1)},ve=st=>{var ue;d(st),p({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($e=>({id:$e.id,title:$e.title,canva_share_link:$e.canva_share_link,sort_order:$e.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((ue=st.guides)==null?void 0:ue.map($e=>({id:$e.id,name:$e.name,file_url:$e.file_url,file_type:$e.file_type,file_size:$e.file_size,sort_order:$e.sort_order})))||[],video_url:st.video_url||""}),R(st.preview_image_url||""),v(null),l(!0)},Me=st=>{var $e;const ue=($e=st.target.files)==null?void 0:$e[0];ue&&(C(ue),R(URL.createObjectURL(ue)))},Ze=()=>{p({...m,links:[...m.links,{title:"",canva_share_link:"",sort_order:m.links.length}]})},Ae=st=>{if(m.links.length<=1)return;const ue=m.links.filter(($e,tt)=>tt!==st);p({...m,links:ue})},Le=(st,ue,$e)=>{const tt=[...m.links];tt[st]={...tt[st],[ue]:$e},p({...m,links:tt})},Ue=st=>{const ue=st.target.files;if(!ue)return;const $e=Array.from(ue).map((tt,rt)=>({name:tt.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:tt.type,file_size:tt.size,sort_order:m.guides.length+rt,file:tt}));p({...m,guides:[...m.guides,...$e]}),st.target.value=""},Ve=st=>{const ue=m.guides.filter(($e,tt)=>tt!==st);p({...m,guides:ue})},Ie=(st,ue)=>{const $e=[...m.guides];$e[st]={...$e[st],name:ue},p({...m,guides:$e})},We=async()=>{if(!g)return null;S(!0),k(0);try{const{data:st,error:ue}=await Y.functions.invoke("bunny-upload",{body:{action:"create",title:m.name||g.name}});if(ue)throw new Error(ue.message);const{videoId:$e,libraryId:tt}=st,{data:rt,error:je}=await Y.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:$e}});if(je)throw new Error(je.message);const it=new XMLHttpRequest;return await new Promise((et,Qe)=>{it.upload.addEventListener("progress",He=>{if(He.lengthComputable){const ot=Math.round(He.loaded/He.total*100);k(ot)}}),it.addEventListener("load",()=>{it.status>=200&&it.status<300?et():Qe(new Error(`Upload failed with status ${it.status}`))}),it.addEventListener("error",()=>Qe(new Error("Upload failed"))),it.open("PUT",rt.uploadUrl),it.setRequestHeader("AccessKey",rt.apiKey),it.send(g)}),`https://player.mediadelivery.net/embed/${tt}/${$e}`}catch(st){return console.error("Bunny upload error:",st),t({title:"Video upload failed",description:st instanceof Error?st.message:"Unknown error",variant:"destructive"}),null}finally{S(!1)}},wt=st=>{var $e;const ue=($e=st.target.files)==null?void 0:$e[0];ue&&v(ue),st.target.value=""},Pe=async st=>{if(st.preventDefault(),!m.name.trim()){t({title:"Please enter a template name",variant:"destructive"});return}if(m.links.filter(tt=>tt.title.trim()&&tt.canva_share_link.trim()).length===0){t({title:"Please add at least one Canva link",variant:"destructive"});return}let $e=m.video_url;if(g){const tt=await We();if(!tt)return;$e=tt}ge.mutate({template:m,image:T,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:$e})};return r.jsx(Ur,{title:"Manage Templates",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Manage Templates",description:"Create and manage Canva templates"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:pe.length})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:oe.length})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:se.length})})]})]}),r.jsxs(Ir,{open:o,onOpenChange:st=>{l(st),st||_e()},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Template"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:i?"Edit Template":"Add New Template"})}),r.jsxs("form",{onSubmit:Pe,className:"space-y-6 pt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Name *"}),r.jsx(Ye,{id:"name",value:m.name,onChange:st=>p({...m,name:st.target.value}),placeholder:"Template name",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:m.description,onChange:st=>p({...m,description:st}),placeholder:"Brief description of the template",minHeight:"120px"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Canva Links *"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:Ze,className:"gap-1",children:[r.jsx(gs,{className:"h-3 w-3"}),"Add Link"]})]}),r.jsx("div",{className:"space-y-3",children:m.links.map((st,ue)=>r.jsxs("div",{className:"flex gap-2 items-start p-3 border rounded-lg bg-muted/30",children:[r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx(Ye,{value:st.title,onChange:$e=>Le(ue,"title",$e.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),r.jsx(Ye,{value:st.canva_share_link,onChange:$e=>Le(ue,"canva_share_link",$e.target.value),placeholder:"https://www.canva.com/design/..."})]}),m.links.length>1&&r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>Ae(ue),children:r.jsx(Xs,{className:"h-4 w-4"})})]},ue))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Category"}),W?r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:D,onChange:st=>B(st.target.value),placeholder:"New category name",className:"flex-1"}),r.jsx(X,{type:"button",size:"sm",onClick:()=>D.trim()&&de.mutate(D.trim()),disabled:de.isPending,children:"Add"}),r.jsx(X,{type:"button",size:"sm",variant:"ghost",onClick:()=>{K(!1),B("")},children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ds,{value:m.category_id,onValueChange:st=>p({...m,category_id:st}),children:[r.jsx(ls,{className:"flex-1",children:r.jsx(us,{placeholder:"Select category"})}),r.jsx(cs,{children:oe.map(st=>r.jsx(Ut,{value:st.id,children:st.name},st.id))})]}),r.jsx(X,{type:"button",variant:"outline",size:"icon",onClick:()=>K(!0),children:r.jsx(gs,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Template Type"}),re?r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:$,onChange:st=>q(st.target.value),placeholder:"New type name",className:"flex-1"}),r.jsx(X,{type:"button",size:"sm",onClick:()=>$.trim()&&ce.mutate($.trim()),disabled:ce.isPending,children:"Add"}),r.jsx(X,{type:"button",size:"sm",variant:"ghost",onClick:()=>{ae(!1),q("")},children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ds,{value:m.type_id,onValueChange:st=>p({...m,type_id:st}),children:[r.jsx(ls,{className:"flex-1",children:r.jsx(us,{placeholder:"Select type"})}),r.jsx(cs,{children:se.map(st=>r.jsx(Ut,{value:st.id,children:st.name},st.id))})]}),r.jsx(X,{type:"button",variant:"outline",size:"icon",onClick:()=>ae(!0),children:r.jsx(gs,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"publish_date",children:"Publish Date"}),r.jsx(Ye,{id:"publish_date",type:"date",value:m.publish_date,onChange:st=>p({...m,publish_date:st.target.value})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Templates are sorted by publish date (newest first) on the member page"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Preview Image"}),r.jsxs("div",{className:"flex items-start gap-4",children:[I?r.jsxs("div",{className:"relative w-32 h-24 rounded-lg overflow-hidden border bg-muted",children:[r.jsx("img",{src:I,alt:"Preview",className:"w-full h-full object-cover"}),r.jsx(X,{type:"button",size:"icon",variant:"destructive",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>{C(null),R("")},children:r.jsx(Xs,{className:"h-3 w-3"})})]}):r.jsx("div",{className:"w-32 h-24 rounded-lg border-2 border-dashed border-muted-foreground/25 flex items-center justify-center",children:r.jsx(Nl,{className:"h-8 w-8 text-muted-foreground/50"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx(Ye,{type:"file",accept:"image/*",onChange:Me,className:"cursor-pointer"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Upload a preview image for this template"})]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Video (Optional)"}),m.video_url&&!g?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[r.jsx(ma,{className:"h-5 w-5 text-primary shrink-0"}),r.jsx("span",{className:"text-sm flex-1 truncate",children:"Video uploaded"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({...m,video_url:""}),className:"text-destructive hover:text-destructive",children:"Remove"})]}),r.jsx("div",{className:"aspect-video max-w-md rounded-lg overflow-hidden border",children:r.jsx("iframe",{src:m.video_url,className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}):w?r.jsxs("div",{className:"space-y-2 p-4 border rounded-lg bg-muted/30",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),r.jsxs("span",{className:"text-sm",children:["Uploading video... ",_,"%"]})]}),r.jsx(zl,{value:_,className:"h-2"})]}):g?r.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/30",children:[r.jsx(ma,{className:"h-5 w-5 text-muted-foreground shrink-0"}),r.jsx("span",{className:"text-sm flex-1 truncate",children:g.name}),r.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(g.size/1024/1024).toFixed(1)," MB"]}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>v(null),children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"cursor-pointer",children:[r.jsx(Ye,{type:"file",accept:"video/*",onChange:wt,className:"hidden"}),r.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:[r.jsx(ma,{className:"h-8 w-8 text-muted-foreground/50"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Click to upload a video"})]})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Upload a video to embed on the template page (Bunny.net)"})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Guide Files (PDFs)"}),r.jsxs("label",{className:"cursor-pointer",children:[r.jsx(Ye,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Ue,className:"hidden"}),r.jsx(X,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:r.jsxs("span",{children:[r.jsx(Xi,{className:"h-3 w-3"}),"Add Files"]})})]})]}),m.guides.length>0?r.jsx("div",{className:"space-y-2",children:m.guides.map((st,ue)=>r.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[r.jsx(ya,{className:"h-5 w-5 text-muted-foreground shrink-0"}),r.jsx(Ye,{value:st.name,onChange:$e=>Ie(ue,$e.target.value),placeholder:"Guide name",className:"flex-1"}),st.file_size&&r.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(st.file_size/1024).toFixed(0)," KB"]}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"shrink-0 text-muted-foreground hover:text-destructive h-8 w-8",onClick:()=>Ve(ue),children:r.jsx(Xs,{className:"h-4 w-4"})})]},st.id||ue))}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"No guide files added. Upload PDFs to help agents understand how to use this template."})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>{l(!1),_e()},children:"Cancel"}),r.jsx(X,{type:"submit",disabled:ge.isPending,children:ge.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:ie?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading..."}):pe.length===0?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No templates yet. Add your first template!"}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Preview"}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Links"}),r.jsx(Mt,{children:"Category"}),r.jsx(Mt,{children:"Type"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:pe.map(st=>{var ue,$e,tt,rt,je;return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:st.preview_image_url?r.jsx("img",{src:st.preview_image_url,alt:st.name,className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(Nl,{className:"h-4 w-4 text-muted-foreground"})})})}),r.jsx(dt,{className:"font-medium",children:st.name}),r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsxs(_t,{variant:"secondary",children:[((ue=st.links)==null?void 0:ue.length)||0," link",((($e=st.links)==null?void 0:$e.length)||0)!==1?"s":""]}),(((tt=st.guides)==null?void 0:tt.length)||0)>0&&r.jsxs(_t,{variant:"outline",className:"gap-1",children:[r.jsx(ya,{className:"h-3 w-3"}),(rt=st.guides)==null?void 0:rt.length," guide",(((je=st.guides)==null?void 0:je.length)||0)!==1?"s":""]})]})}),r.jsx(dt,{children:st.category?r.jsx(_t,{variant:"secondary",children:st.category.name}):r.jsx("span",{className:"text-muted-foreground",children:"-"})}),r.jsx(dt,{children:st.type?r.jsx(_t,{variant:"outline",children:st.type.name}):r.jsx("span",{className:"text-muted-foreground",children:"-"})}),r.jsx(dt,{className:"text-muted-foreground",children:new Date(st.publish_date).toLocaleDateString()}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{size:"icon",variant:"ghost",onClick:()=>ve(st),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&Te.mutate(st.id)},children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},st.id)})})]})})})]})})};function Eqe({selectedTemplateIds:e,onChange:t}){const[s,n]=A.useState(""),[a,o]=A.useState(!1),{data:l=[]}=Ht({queryKey:["all-canva-templates-picker"],queryFn:async()=>{const{data:g,error:v}=await Y.from("canva_templates").select("id, name, preview_image_url").order("name");if(v)throw v;return g}}),i=l.filter(g=>e.includes(g.id)),d=l.filter(g=>!e.includes(g.id)&&g.name.toLowerCase().includes(s.toLowerCase())),m=g=>{t([...e,g])},p=g=>{t(e.filter(v=>v!==g))};return r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{className:"flex items-center gap-2",children:[r.jsx(wk,{className:"h-4 w-4"}),"Linked Templates"]}),i.length>0&&r.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(g=>r.jsxs(_t,{variant:"secondary",className:"gap-1 pr-1",children:[g.name,r.jsx("button",{type:"button",onClick:()=>p(g.id),className:"ml-1 rounded-full hover:bg-muted-foreground/20 p-0.5",children:r.jsx(Xs,{className:"h-3 w-3"})})]},g.id))}),r.jsxs(cd,{open:a,onOpenChange:o,children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[r.jsx(wk,{className:"h-3.5 w-3.5"}),"Add Template"]})}),r.jsxs(Hc,{className:"w-80 p-2",align:"start",children:[r.jsxs("div",{className:"relative mb-2",children:[r.jsx(qn,{className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search templates...",value:s,onChange:g=>n(g.target.value),className:"pl-7 h-8 text-sm"})]}),r.jsx("div",{className:"max-h-48 overflow-y-auto space-y-0.5",children:d.length===0?r.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:s?"No templates found":"All templates selected"}):d.map(g=>r.jsxs("button",{type:"button",onClick:()=>{m(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?r.jsx("img",{src:g.preview_image_url,alt:"",className:"w-8 h-8 rounded object-cover flex-shrink-0"}):r.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center flex-shrink-0",children:r.jsx(wk,{className:"h-3.5 w-3.5 text-muted-foreground"})}),r.jsx("span",{className:"truncate",children:g.name})]},g.id))})]})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Link templates that agents can use alongside this content."})]})}const xAt=[{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"}],yAt=()=>{const{user:e}=Gr(),[t,s]=Cc(),{toast:n}=_i(),a=Rr(),[o,l]=A.useState(!1),[i,d]=A.useState(null),[m,p]=A.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[g,v]=A.useState(null),[_,k]=A.useState(""),[w,S]=A.useState([]),[T,C]=A.useState([]),[I,R]=A.useState([]),[D,B]=A.useState([]),[$,q]=A.useState(""),[W,K]=A.useState(!1),[re,ae]=A.useState(null),[oe,se]=A.useState(0),[pe,ie]=A.useState(!1),[de,ce]=A.useState(null),{data:ge=[]}=Ht({queryKey:["academy-categories"],queryFn:async()=>{const{data:ue,error:$e}=await Y.from("academy_categories").select("*").order("sort_order",{ascending:!0});if($e)throw $e;return ue}}),{data:Te=[],isLoading:_e}=Ht({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:ue,error:$e}=await Y.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if($e)throw $e;const{data:tt,error:rt}=await Y.from("academy_resources").select("*").order("sort_order");if(rt)throw rt;return ue.map(it=>({...it,resources:(tt==null?void 0:tt.filter(Se=>Se.video_id===it.id))||[]}))}});A.useEffect(()=>{const ue=t.get("edit");if(ue&&Te.length>0){const $e=Te.find(tt=>tt.id===ue);$e&&(Ue($e),s({},{replace:!0}))}},[Te,t]);const ve=Qt({mutationFn:async ue=>{const{data:$e,error:tt}=await Y.from("academy_categories").insert({name:ue,sort_order:ge.length}).select().single();if(tt)throw tt;return $e},onSuccess:ue=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...m,category_id:ue.id}),q(""),K(!1),n({title:"Category added"})},onError:ue=>{n({title:"Error adding category",description:ue.message,variant:"destructive"})}}),Me=Qt({mutationFn:async ue=>{let $e=ue.existingThumbnailUrl;if(ue.thumbnail){const je=ue.thumbnail.name.split(".").pop(),it=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${je}`,{error:Se}=await Y.storage.from("academy-resources").upload(it,ue.thumbnail);if(Se)throw Se;const{data:et}=Y.storage.from("academy-resources").getPublicUrl(it);$e=et.publicUrl}const tt={title:ue.video.title,description:ue.video.description||null,video_url:ue.video.video_url,video_type:ue.video.video_type,duration:ue.video.duration||null,thumbnail_url:$e,category_id:ue.video.category_id||null,publish_date:ue.video.publish_date?new Date(ue.video.publish_date).toISOString():new Date().toISOString(),is_published:ue.video.is_published,created_by:e==null?void 0:e.id};let rt=ue.videoId;if(rt){const{error:je}=await Y.from("academy_videos").update(tt).eq("id",rt);if(je)throw je}else{const{data:je,error:it}=await Y.from("academy_videos").insert(tt).select().single();if(it)throw it;rt=je.id,uAt(ue.video.title,je.id)}if(ue.resourcesToDelete.length>0){const{error:je}=await Y.from("academy_resources").delete().in("id",ue.resourcesToDelete);if(je)throw je}for(let je=0;je0){const{error:je}=await Y.from("academy_video_templates").insert(D.map(it=>({video_id:rt,template_id:it})));if(je)throw je}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Le(),l(!1),n({title:i?"Video updated":"Video created"})},onError:ue=>{n({title:"Error saving video",description:ue.message,variant:"destructive"})}}),Ze=Qt({mutationFn:async ue=>{const{error:$e}=await Y.from("academy_videos").delete().eq("id",ue);if($e)throw $e},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:ue=>{n({title:"Error deleting video",description:ue.message,variant:"destructive"})}}),Ae=Qt({mutationFn:async({id:ue,is_published:$e})=>{const{error:tt}=await Y.from("academy_videos").update({is_published:$e}).eq("id",ue);if(tt)throw tt},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:ue=>{n({title:"Error updating video",description:ue.message,variant:"destructive"})}}),Le=()=>{p({title:"",description:"",video_url:"",video_type:"bunny_stream",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),v(null),k(""),S([]),C([]),R([]),d(null),B([]),q(""),ae(null),se(0),ie(!1),ce(null)},Ue=async ue=>{d(ue),p({title:ue.title,description:ue.description||"",video_url:ue.video_url,video_type:ue.video_type,duration:ue.duration||"",category_id:ue.category_id||"",publish_date:ue.publish_date?new Date(ue.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:ue.is_published}),k(ue.thumbnail_url||""),C(ue.resources||[]),S([]),R([]);const{data:$e}=await Y.from("academy_video_templates").select("template_id").eq("video_id",ue.id);B(($e||[]).map(tt=>tt.template_id)),l(!0)},Ve=ue=>{var tt;const $e=(tt=ue.target.files)==null?void 0:tt[0];$e&&(v($e),k(URL.createObjectURL($e)))},Ie=ue=>{const $e=ue.target.files;if($e){const tt=Array.from($e).map(rt=>({file:rt,title:rt.name.replace(/\.[^/.]+$/,"")}));S([...w,...tt])}ue.target.value=""},We=ue=>{S(w.filter(($e,tt)=>tt!==ue))},wt=ue=>{R([...I,ue]),C(T.filter($e=>$e.id!==ue))},Pe=async()=>{if(!re)return null;ie(!0),se(0);try{const{data:ue,error:$e}=await Y.functions.invoke("bunny-upload",{body:{action:"create",title:m.title||re.name}});if($e)throw new Error($e.message);const{videoId:tt,libraryId:rt}=ue;ce(tt);const{data:je,error:it}=await Y.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:tt}});if(it)throw new Error(it.message);const Se=new XMLHttpRequest;return await new Promise((Qe,He)=>{Se.upload.addEventListener("progress",ot=>{if(ot.lengthComputable){const ut=Math.round(ot.loaded/ot.total*100);se(ut)}}),Se.addEventListener("load",()=>{Se.status>=200&&Se.status<300?Qe():He(new Error(`Upload failed with status ${Se.status}`))}),Se.addEventListener("error",()=>He(new Error("Upload failed"))),Se.open("PUT",je.uploadUrl),Se.setRequestHeader("AccessKey",je.apiKey),Se.send(re)}),`https://player.mediadelivery.net/embed/${rt}/${tt}`}catch(ue){return console.error("Bunny upload error:",ue),n({title:"Video upload failed",description:ue instanceof Error?ue.message:"Unknown error",variant:"destructive"}),null}finally{ie(!1)}},st=async ue=>{if(ue.preventDefault(),!m.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let $e=m.video_url;if(m.video_type==="bunny_stream"&&re&&!i){const tt=await Pe();if(!tt)return;$e=tt}else if(!m.video_url.trim()&&m.video_type!=="bunny_stream"){n({title:"Please enter a video URL",variant:"destructive"});return}else if(m.video_type==="bunny_stream"&&!re&&!m.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}Me.mutate({video:{...m,video_url:$e},thumbnail:g,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:w,resourcesToDelete:I})};return r.jsx(Ur,{title:"Manage Academy",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Manage Academy",description:"Create and manage training videos and resources"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:Te.length})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:Te.filter(ue=>ue.is_published).length})})]})]}),r.jsxs(Ir,{open:o,onOpenChange:ue=>{l(ue),ue||Le()},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Video"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:i?"Edit Video":"Add New Video"})}),r.jsxs("form",{onSubmit:st,className:"space-y-6 pt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title *"}),r.jsx(Ye,{id:"title",value:m.title,onChange:ue=>p({...m,title:ue.target.value}),placeholder:"Video title",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:m.description,onChange:ue=>p({...m,description:ue}),placeholder:"Brief description of the video",minHeight:"120px"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Video Type"}),r.jsxs(ds,{value:m.video_type,onValueChange:ue=>{p({...m,video_type:ue,video_url:""}),ae(null)},disabled:pe,children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:xAt.map(ue=>r.jsx(Ut,{value:ue.value,children:ue.label},ue.value))})]})]}),m.video_type==="bunny_stream"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs(Ee,{children:["Upload Video File ",!i&&"*"]}),i&&m.video_url&&r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Current video: ",r.jsx("a",{href:m.video_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"View"})]}),!i&&r.jsxs(r.Fragment,{children:[r.jsx(Ye,{type:"file",accept:"video/*",onChange:ue=>{var tt;const $e=(tt=ue.target.files)==null?void 0:tt[0];$e&&ae($e)},disabled:pe}),re&&r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(ma,{className:"h-4 w-4"}),re.name," (",(re.size/(1024*1024)).toFixed(1)," MB)"]}),pe&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),r.jsx(zl,{value:oe,className:"h-2"}),r.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[oe,"%"]})]})]})]}):r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"video_url",children:"Video URL *"}),r.jsx(Ye,{id:"video_url",value:m.video_url,onChange:ue=>p({...m,video_url:ue.target.value}),placeholder:"https://...",required:!0})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"duration",children:"Duration"}),r.jsx(Ye,{id:"duration",value:m.duration,onChange:ue=>p({...m,duration:ue.target.value}),placeholder:"e.g., 45:30"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"publish_date",children:"Publish Date"}),r.jsx(Ye,{id:"publish_date",type:"date",value:m.publish_date,onChange:ue=>p({...m,publish_date:ue.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Category"}),W?r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:$,onChange:ue=>q(ue.target.value),placeholder:"New category name",className:"flex-1"}),r.jsx(X,{type:"button",size:"sm",onClick:()=>$.trim()&&ve.mutate($.trim()),disabled:ve.isPending,children:"Add"}),r.jsx(X,{type:"button",size:"sm",variant:"ghost",onClick:()=>{K(!1),q("")},children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ds,{value:m.category_id,onValueChange:ue=>p({...m,category_id:ue}),children:[r.jsx(ls,{className:"flex-1",children:r.jsx(us,{placeholder:"Select category"})}),r.jsx(cs,{children:ge.map(ue=>r.jsx(Ut,{value:ue.id,children:ue.name},ue.id))})]}),r.jsx(X,{type:"button",variant:"outline",size:"sm",onClick:()=>K(!0),children:r.jsx(gs,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Thumbnail Image"}),r.jsxs("div",{className:"flex items-start gap-4",children:[_&&r.jsx("img",{src:_,alt:"Thumbnail preview",className:"w-32 h-20 object-cover rounded-md border"}),r.jsxs("div",{className:"flex-1",children:[r.jsx(Ye,{type:"file",accept:"image/*",onChange:Ve,className:"cursor-pointer"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Recommended: 16:9 aspect ratio"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Resource Files"}),r.jsx(X,{type:"button",variant:"outline",size:"sm",asChild:!0,children:r.jsxs("label",{className:"cursor-pointer gap-1",children:[r.jsx(Xi,{className:"h-3 w-3"}),"Add Files",r.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Ie,className:"hidden"})]})})]}),(T.length>0||w.length>0)&&r.jsxs("div",{className:"space-y-2 mt-2",children:[T.map(ue=>r.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"flex-1 text-sm truncate",children:ue.title}),r.jsx(_t,{variant:"outline",className:"text-xs",children:ue.file_type}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>wt(ue.id),className:"text-destructive hover:text-destructive",children:r.jsx(Xs,{className:"h-4 w-4"})})]},ue.id)),w.map((ue,$e)=>r.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{value:ue.title,onChange:tt=>{const rt=[...w];rt[$e].title=tt.target.value,S(rt)},className:"flex-1 h-8",placeholder:"Resource title"}),r.jsx(_t,{variant:"secondary",className:"text-xs",children:"New"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>We($e),className:"text-destructive hover:text-destructive",children:r.jsx(Xs,{className:"h-4 w-4"})})]},$e))]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),r.jsx(Eqe,{selectedTemplateIds:D,onChange:B}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"is_published",checked:m.is_published,onCheckedChange:ue=>p({...m,is_published:ue})}),r.jsx(Ee,{htmlFor:"is_published",children:"Published"})]}),r.jsxs(Rn,{children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:pe,children:"Cancel"}),r.jsx(X,{type:"submit",disabled:Me.isPending||pe,children:pe?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):Me.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:_e?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):Te.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(ma,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No videos yet"}),r.jsx("p",{className:"text-sm",children:"Add your first academy video"})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Category"}),r.jsx(Mt,{children:"Duration"}),r.jsx(Mt,{children:"Resources"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"w-[120px]",children:"Actions"})]})}),r.jsx(Bn,{children:Te.map(ue=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[ue.thumbnail_url?r.jsx("img",{src:ue.thumbnail_url,alt:"",className:"w-16 h-10 object-cover rounded"}):r.jsx("div",{className:"w-16 h-10 bg-muted rounded flex items-center justify-center",children:r.jsx(ma,{className:"h-4 w-4 text-muted-foreground"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:ue.title}),r.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:ue.video_type.replace("_"," ")})]})]})}),r.jsx(dt,{children:ue.category?r.jsx(_t,{variant:"outline",children:ue.category.name}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),r.jsx(dt,{children:ue.duration||"-"}),r.jsx(dt,{children:ue.resources&&ue.resources.length>0?r.jsxs(_t,{variant:"secondary",children:[ue.resources.length," file(s)"]}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),r.jsx(dt,{children:new Date(ue.publish_date).toLocaleDateString()}),r.jsx(dt,{children:r.jsx(fn,{checked:ue.is_published,onCheckedChange:$e=>Ae.mutate({id:ue.id,is_published:$e})})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>Ue(ue),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>Ze.mutate(ue.id),className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},ue.id))})]})})})]})})};function vAt(){var Me,Ze,Ae;const e=Rr(),[t,s]=Cc(),[n,a]=A.useState(!1),[o,l]=A.useState(null),[i,d]=A.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[m,p]=A.useState(null),[g,v]=A.useState(""),[_,k]=A.useState([]),[w,S]=A.useState([]),[T,C]=A.useState([]),[I,R]=A.useState(null),{data:D,isLoading:B}=Ht({queryKey:["resource-kits"],queryFn:async()=>{const{data:Le,error:Ue}=await Y.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Ue)throw Ue;return Le}}),{data:$}=Ht({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Le,error:Ue}=await Y.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Ue)throw Ue;return Le}}),{data:q}=Ht({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Le,error:Ue}=await Y.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Ue)throw Ue;return Le}});A.useEffect(()=>{const Le=t.get("edit");if(Le&&D&&D.length>0&&$&&q){const Ue=D.find(Ve=>Ve.id===Le);Ue&&(K(Ue),s({},{replace:!0}))}},[D,$,q,t]);const W=()=>{d({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),v(""),k([]),S([]),C([]),l(null)},K=async Le=>{l(Le),d({name:Le.name,description:Le.description||"",publish_date:Le.publish_date.split("T")[0],is_published:Le.is_published}),v(Le.featured_image_url||"");const Ue=($==null?void 0:$.filter(We=>We.kit_id===Le.id))||[];k(Ue.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})));const Ve=(q==null?void 0:q.filter(We=>We.kit_id===Le.id))||[];S(Ve.map(We=>({id:We.id,title:We.title,canva_share_link:We.canva_share_link,sort_order:We.sort_order})));const{data:Ie}=await Y.from("resource_kit_templates").select("template_id").eq("kit_id",Le.id);C((Ie||[]).map(We=>We.template_id)),a(!0)},re=Le=>{var Ve;const Ue=(Ve=Le.target.files)==null?void 0:Ve[0];Ue&&(p(Ue),v(URL.createObjectURL(Ue)))},ae=()=>{k([..._,{name:"",file_url:"",sort_order:_.length}])},oe=Le=>{k(_.filter((Ue,Ve)=>Ve!==Le))},se=(Le,Ue,Ve)=>{const Ie=[..._];Ie[Le]={...Ie[Le],[Ue]:Ve},k(Ie)},pe=()=>{S([...w,{title:"",canva_share_link:"",sort_order:w.length}])},ie=Le=>{S(w.filter((Ue,Ve)=>Ve!==Le))},de=(Le,Ue,Ve)=>{const Ie=[...w];Ie[Le]={...Ie[Le],[Ue]:Ve},S(Ie)},ce=(Le,Ue)=>{var Ie;const Ve=(Ie=Ue.target.files)==null?void 0:Ie[0];if(Ve){const We=[..._],wt=Ve.name.replace(/\.[^/.]+$/,"");We[Le]={...We[Le],file:Ve,file_type:Ve.type,file_size:Ve.size,name:We[Le].name||wt},k(We)}},ge=Qt({mutationFn:async()=>{let Le=(o==null?void 0:o.featured_image_url)||null;if(m){const wt=m.name.split(".").pop(),Pe=`${Date.now()}.${wt}`,{error:st}=await Y.storage.from("resource-kits").upload(`featured/${Pe}`,m);if(st)throw st;const{data:ue}=Y.storage.from("resource-kits").getPublicUrl(`featured/${Pe}`);Le=ue.publicUrl}const Ue={name:i.name,description:i.description||null,featured_image_url:Le,publish_date:i.publish_date,is_published:i.is_published};let Ve;const Ie=!o,We=(o==null?void 0:o.is_published)||!1;if(o){const{error:wt}=await Y.from("resource_kits").update(Ue).eq("id",o.id);if(wt)throw wt;Ve=o.id;const Pe=($==null?void 0:$.filter(je=>je.kit_id===o.id).map(je=>je.id))||[],st=_.filter(je=>je.id).map(je=>je.id),ue=Pe.filter(je=>!st.includes(je));ue.length>0&&await Y.from("resource_kit_files").delete().in("id",ue);const $e=(q==null?void 0:q.filter(je=>je.kit_id===o.id).map(je=>je.id))||[],tt=w.filter(je=>je.id).map(je=>je.id),rt=$e.filter(je=>!tt.includes(je));rt.length>0&&await Y.from("resource_kit_links").delete().in("id",rt)}else{const{data:wt,error:Pe}=await Y.from("resource_kits").insert(Ue).select().single();if(Pe)throw Pe;Ve=wt.id}for(let wt=0;wt<_.length;wt++){const Pe=_[wt];let st=Pe.file_url;if(Pe.file){const ue=Pe.file.name.split(".").pop(),$e=`${Date.now()}-${wt}.${ue}`,{error:tt}=await Y.storage.from("resource-kits").upload(`files/${$e}`,Pe.file);if(tt)throw tt;const{data:rt}=Y.storage.from("resource-kits").getPublicUrl(`files/${$e}`);st=rt.publicUrl}Pe.id?await Y.from("resource_kit_files").update({name:Pe.name,file_url:st,file_type:Pe.file_type,file_size:Pe.file_size,sort_order:wt}).eq("id",Pe.id):st&&Pe.name&&await Y.from("resource_kit_files").insert({kit_id:Ve,name:Pe.name,file_url:st,file_type:Pe.file_type,file_size:Pe.file_size,sort_order:wt})}for(let wt=0;wt0){const{error:wt}=await Y.from("resource_kit_templates").insert(T.map(Pe=>({kit_id:Ve,template_id:Pe})));if(wt)throw wt}return{kitId:Ve,kitName:i.name,isNewKit:Ie,wasPublished:We,isPublished:i.is_published}},onSuccess:Le=>{e.invalidateQueries({queryKey:["resource-kits"]}),e.invalidateQueries({queryKey:["resource-kit-files"]}),e.invalidateQueries({queryKey:["resource-kit-links"]}),we.success(o?"Resource kit updated":"Resource kit created"),Le.isPublished&&(Le.isNewKit||!Le.wasPublished)&&mAt(Le.kitName,Le.kitId),a(!1),W()},onError:Le=>{we.error("Failed to save resource kit: "+Le.message)}}),Te=Qt({mutationFn:async Le=>{const{error:Ue}=await Y.from("resource_kits").delete().eq("id",Le);if(Ue)throw Ue},onSuccess:()=>{e.invalidateQueries({queryKey:["resource-kits"]}),e.invalidateQueries({queryKey:["resource-kit-files"]}),we.success("Resource kit deleted")},onError:Le=>{we.error("Failed to delete: "+Le.message)}}),_e=Le=>{if(Le.preventDefault(),!i.name){we.error("Please enter a name");return}ge.mutate()},ve=Le=>($==null?void 0:$.filter(Ue=>Ue.kit_id===Le).length)||0;return r.jsx(Ur,{title:"Toolbox Management",description:"Create and manage resource kits for agents",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:(D==null?void 0:D.length)||0})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:(D==null?void 0:D.filter(Le=>Le.is_published).length)||0})})]})]}),r.jsxs(X,{onClick:()=>{W(),a(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Resource Kit"]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Files"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:B?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(D==null?void 0:D.length)===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):D==null?void 0:D.map(Le=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[Le.featured_image_url?r.jsx("img",{src:Le.featured_image_url,alt:Le.name,className:"w-10 h-10 rounded object-cover"}):r.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:r.jsx(ec,{className:"h-5 w-5 text-muted-foreground"})}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:Le.name}),Le.description&&r.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Le.description})]})]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),ve(Le.id)]})}),r.jsx(dt,{children:Xr(new Date(Le.publish_date),"MMM d, yyyy")}),r.jsx(dt,{children:r.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Le.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Le.is_published?"Published":"Draft"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{const Ue=($==null?void 0:$.filter(Ie=>Ie.kit_id===Le.id))||[],Ve=(q==null?void 0:q.filter(Ie=>Ie.kit_id===Le.id))||[];R({...Le,files:Ue,links:Ve})},children:r.jsx(Ii,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>K(Le),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&Te.mutate(Le.id)},children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},Le.id))})]})})}),r.jsx(Ir,{open:n,onOpenChange:a,children:r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),r.jsxs("form",{onSubmit:_e,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Featured Image"}),r.jsxs("div",{className:"flex items-center gap-4",children:[g?r.jsx("img",{src:g,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):r.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:r.jsx(ec,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx(Ye,{type:"file",accept:"image/*",onChange:re})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Name *"}),r.jsx(Ye,{id:"name",value:i.name,onChange:Le=>d({...i,name:Le.target.value}),placeholder:"Resource Kit Name"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:i.description,onChange:Le=>d({...i,description:Le}),placeholder:"Brief description of this resource kit",minHeight:"120px"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"publish_date",children:"Publish Date"}),r.jsx(Ye,{id:"publish_date",type:"date",value:i.publish_date,onChange:Le=>d({...i,publish_date:Le.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Published"}),r.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[r.jsx(fn,{checked:i.is_published,onCheckedChange:Le=>d({...i,is_published:Le})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:i.is_published?"Visible to agents":"Hidden from agents"})]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(Ee,{children:"Resource Files"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:ae,children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),_.length===0?r.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.'}):r.jsx("div",{className:"space-y-3",children:_.map((Le,Ue)=>r.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[r.jsxs("div",{className:"flex justify-between items-start",children:[r.jsxs("span",{className:"text-sm font-medium",children:["File ",Ue+1]}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>oe(Ue),children:r.jsx(Xs,{className:"h-4 w-4"})})]}),r.jsx(Ye,{placeholder:"File name (e.g., Getting Started Guide)",value:Le.name,onChange:Ve=>se(Ue,"name",Ve.target.value)}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ye,{type:"file",onChange:Ve=>ce(Ue,Ve),className:"flex-1"}),Le.file_url&&!Le.file&&r.jsx("a",{href:Le.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Le.file&&r.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Ue))})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(Ee,{children:"Canva Links"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:pe,children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Canva Link"]})]}),w.length===0?r.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.'}):r.jsx("div",{className:"space-y-3",children:w.map((Le,Ue)=>r.jsxs("div",{className:"border rounded-md p-3 space-y-2",children:[r.jsxs("div",{className:"flex justify-between items-start",children:[r.jsxs("span",{className:"text-sm font-medium",children:["Canva Link ",Ue+1]}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ie(Ue),children:r.jsx(Xs,{className:"h-4 w-4"})})]}),r.jsx(Ye,{placeholder:"Link title (e.g., Social Media Post Template)",value:Le.title,onChange:Ve=>de(Ue,"title",Ve.target.value)}),r.jsx(Ye,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Le.canva_share_link,onChange:Ve=>de(Ue,"canva_share_link",Ve.target.value)})]},Ue))})]}),r.jsx(Eqe,{selectedTemplateIds:T,onChange:C}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),r.jsx(X,{type:"submit",disabled:ge.isPending,children:ge.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),r.jsx(Ir,{open:!!I,onOpenChange:()=>R(null),children:r.jsxs(Er,{className:"max-w-lg",children:[r.jsx(zr,{children:r.jsx(Fr,{children:I==null?void 0:I.name})}),r.jsxs("div",{className:"space-y-4",children:[(I==null?void 0:I.featured_image_url)&&r.jsx("img",{src:I.featured_image_url,alt:I.name,className:"w-full h-48 object-cover rounded-lg"}),(I==null?void 0:I.description)&&r.jsx("p",{className:"text-muted-foreground",children:I.description}),r.jsxs("div",{children:[r.jsxs("h4",{className:"font-medium mb-2",children:["Resource Files (",((Me=I==null?void 0:I.files)==null?void 0:Me.length)||0,")"]}),((Ze=I==null?void 0:I.files)==null?void 0:Ze.length)===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No files in this kit"}):r.jsx("div",{className:"space-y-2",children:(Ae=I==null?void 0:I.files)==null?void 0:Ae.map(Le=>r.jsxs("a",{href:Le.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[r.jsx(ya,{className:"h-4 w-4 text-primary"}),r.jsx("span",{className:"text-sm",children:Le.name})]},Le.id))})]}),(I==null?void 0:I.links)&&I.links.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"font-medium mb-2",children:["Canva Links (",I.links.length,")"]}),r.jsx("div",{className:"space-y-2",children:I.links.map(Le=>r.jsxs("a",{href:Le.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-2 rounded-md hover:bg-muted transition-colors",children:[r.jsx(Lo,{className:"h-4 w-4 text-primary"}),r.jsx("span",{className:"text-sm",children:Le.title})]},Le.id))})]})]})]})})]})})}const _At=()=>{const{user:e}=Gr(),{toast:t}=_i(),s=Rr(),[n,a]=A.useState(!1),[o,l]=A.useState(null),[i,d]=A.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[m,p]=A.useState(null),[g,v]=A.useState(""),{data:_=[],isLoading:k}=Ht({queryKey:["social-swag-admin"],queryFn:async()=>{const{data:q,error:W}=await Y.from("social_swag").select("*").order("publish_date",{ascending:!1});if(W)throw W;const{data:K,error:re}=await Y.from("social_swag_links").select("*").order("sort_order");if(re)throw re;return q.map(oe=>({...oe,links:(K==null?void 0:K.filter(se=>se.swag_id===oe.id))||[]}))}}),w=Qt({mutationFn:async q=>{let W=q.existingImageUrl;if(q.image){const pe=q.image.name.split(".").pop(),ie=`${Date.now()}-${Math.random().toString(36).substring(7)}.${pe}`,{error:de}=await Y.storage.from("template-previews").upload(ie,q.image);if(de)throw de;const{data:ce}=Y.storage.from("template-previews").getPublicUrl(ie);W=ce.publicUrl}const K={title:q.item.title,description:q.item.description||null,preview_image_url:W,publish_date:q.item.publish_date?new Date(q.item.publish_date).toISOString():new Date().toISOString(),is_published:q.item.is_published,created_by:e==null?void 0:e.id};let re=q.itemId;const ae=!re,oe=(o==null?void 0:o.is_published)||!1;if(re){const{error:pe}=await Y.from("social_swag").update(K).eq("id",re);if(pe)throw pe;await Y.from("social_swag_links").delete().eq("swag_id",re)}else{const{data:pe,error:ie}=await Y.from("social_swag").insert(K).select().single();if(ie)throw ie;re=pe.id}const se=q.item.links.filter(pe=>pe.title.trim()&&pe.canva_share_link.trim());if(se.length>0){const pe=se.map((de,ce)=>({swag_id:re,title:de.title.trim(),canva_share_link:de.canva_share_link.trim(),sort_order:ce})),{error:ie}=await Y.from("social_swag_links").insert(pe);if(ie)throw ie}return{itemId:re,itemTitle:q.item.title,isNewItem:ae,wasPublished:oe,isPublished:q.item.is_published}},onSuccess:q=>{s.invalidateQueries({queryKey:["social-swag-admin"]}),s.invalidateQueries({queryKey:["social-swag"]}),t({title:o?"Item updated":"Item created"}),q.isPublished&&(q.isNewItem||!q.wasPublished)&&vge(q.itemTitle,q.itemId),a(!1),T()},onError:q=>{t({title:"Error saving item",description:q.message,variant:"destructive"})}}),S=Qt({mutationFn:async q=>{const{error:W}=await Y.from("social_swag").delete().eq("id",q);if(W)throw W},onSuccess:()=>{s.invalidateQueries({queryKey:["social-swag-admin"]}),s.invalidateQueries({queryKey:["social-swag"]}),t({title:"Item deleted"})},onError:q=>{t({title:"Error deleting item",description:q.message,variant:"destructive"})}}),T=()=>{d({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),p(null),v(""),l(null)},C=q=>{l(q),d({title:q.title,description:q.description||"",publish_date:q.publish_date?new Date(q.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:q.is_published,links:q.links&&q.links.length>0?q.links.map(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(q.preview_image_url||""),a(!0)},I=q=>{var K;const W=(K=q.target.files)==null?void 0:K[0];W&&(p(W),v(URL.createObjectURL(W)))},R=()=>{d({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},D=q=>{if(i.links.length<=1)return;const W=i.links.filter((K,re)=>re!==q);d({...i,links:W})},B=(q,W,K)=>{const re=[...i.links];re[q]={...re[q],[W]:K},d({...i,links:re})},$=q=>{if(q.preventDefault(),!i.title.trim()){t({title:"Title is required",variant:"destructive"});return}w.mutate({item:i,image:m,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return r.jsx(Ur,{title:"Manage Social Swag",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Manage Social Swag",description:"Create and manage social media content"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:_.filter(q=>q.is_published).length})})]})]}),r.jsxs(Ir,{open:n,onOpenChange:q=>{a(q),q||T()},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Item"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:o?"Edit Item":"Add New Item"})}),r.jsxs("form",{onSubmit:$,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title *"}),r.jsx(Ye,{id:"title",value:i.title,onChange:q=>d({...i,title:q.target.value}),placeholder:"Enter title"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:i.description,onChange:q=>d({...i,description:q}),placeholder:"Enter description",minHeight:"120px"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"publish_date",children:"Publish Date"}),r.jsx(Ye,{id:"publish_date",type:"date",value:i.publish_date,onChange:q=>d({...i,publish_date:q.target.value})})]}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(fn,{id:"is_published",checked:i.is_published,onCheckedChange:q=>d({...i,is_published:q})}),r.jsx(Ee,{htmlFor:"is_published",children:"Published"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Preview Image"}),g?r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:g,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),r.jsx(X,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),v("")},children:r.jsx(Xs,{className:"h-3 w-3"})})]}):r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[r.jsx(Nl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),r.jsx(Ye,{type:"file",accept:"image/*",onChange:I,className:"cursor-pointer"})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Canva Links"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:R,children:[r.jsx(gs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((q,W)=>r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4 pb-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-sm font-medium text-muted-foreground",children:["Link ",W+1]}),i.links.length>1&&r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>D(W),children:r.jsx(Xs,{className:"h-3 w-3"})})]}),r.jsx(Ye,{placeholder:"Link title (e.g., Instagram Post)",value:q.title,onChange:K=>B(W,"title",K.target.value)}),r.jsx(Ye,{placeholder:"Canva share link",value:q.canva_share_link,onChange:K=>B(W,"canva_share_link",K.target.value)})]})},W))]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),r.jsx(X,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:k?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No items yet. Click "Add Item" to create your first one.'}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-16",children:"Preview"}),r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Links"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:_.map(q=>{var W;return r.jsxs(Nr,{children:[r.jsx(dt,{children:q.preview_image_url?r.jsx("img",{src:q.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):r.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:r.jsx(Nl,{className:"h-4 w-4 text-muted-foreground"})})}),r.jsx(dt,{className:"font-medium",children:q.title}),r.jsxs(dt,{children:[((W=q.links)==null?void 0:W.length)||0," links"]}),r.jsx(dt,{children:new Date(q.publish_date).toLocaleDateString()}),r.jsx(dt,{children:r.jsx(_t,{variant:q.is_published?"default":"secondary",children:q.is_published?"Published":"Draft"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>window.open(`/social-swag/${q.id}`,"_blank"),children:r.jsx(Ii,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>C(q),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&S.mutate(q.id)},children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},q.id)})})]})})})]})})};function bAt(){for(var e=arguments.length,t=new Array(e),s=0;sn=>{t.forEach(a=>a(n))},t)}const moe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function B3(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function v_e(e){return"nodeType"in e}function im(e){var t,s;return e?B3(e)?e:v_e(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function __e(e){const{Document:t}=im(e);return e instanceof t}function B6(e){return B3(e)?!1:e instanceof im(e).HTMLElement}function Iqe(e){return e instanceof im(e).SVGElement}function $3(e){return e?B3(e)?e.document:v_e(e)?__e(e)?e:B6(e)||Iqe(e)?e.ownerDocument:document:document:document}const Mx=moe?A.useLayoutEffect:A.useEffect;function b_e(e){const t=A.useRef(e);return Mx(()=>{t.current=e}),A.useCallback(function(){for(var s=arguments.length,n=new Array(s),a=0;a{e.current=setInterval(n,a)},[]),s=A.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function mP(e,t){t===void 0&&(t=[e]);const s=A.useRef(e);return Mx(()=>{s.current!==e&&(s.current=e)},t),s}function $6(e,t){const s=A.useRef();return A.useMemo(()=>{const n=e(s.current);return s.current=n,n},[...t])}function vne(e){const t=b_e(e),s=A.useRef(null),n=A.useCallback(a=>{a!==s.current&&(t==null||t(a,s.current)),s.current=a},[]);return[s,n]}function _ge(e){const t=A.useRef();return A.useEffect(()=>{t.current=e},[e]),t.current}let xhe={};function U6(e,t){return A.useMemo(()=>{if(t)return t;const s=xhe[e]==null?0:xhe[e]+1;return xhe[e]=s,e+"-"+s},[e,t])}function Pqe(e){return function(t){for(var s=arguments.length,n=new Array(s>1?s-1:0),a=1;a{const i=Object.entries(l);for(const[d,m]of i){const p=o[d];p!=null&&(o[d]=p+e*m)}return o},{...t})}}const J4=Pqe(1),fP=Pqe(-1);function jAt(e){return"clientX"in e&&"clientY"in e}function w_e(e){if(!e)return!1;const{KeyboardEvent:t}=im(e.target);return t&&e instanceof t}function kAt(e){if(!e)return!1;const{TouchEvent:t}=im(e.target);return t&&e instanceof t}function bge(e){if(kAt(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return jAt(e)?{x:e.clientX,y:e.clientY}:null}const pP=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[pP.Translate.toString(e),pP.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:n}=e;return t+" "+s+"ms "+n}}}),eMe="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function NAt(e){return e.matches(eMe)?e:e.querySelector(eMe)}const SAt={display:"none"};function CAt(e){let{id:t,value:s}=e;return lt.createElement("div",{id:t,style:SAt},s)}function MAt(e){let{id:t,announcement:s,ariaLiveType:n="assertive"}=e;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:t,style:a,role:"status","aria-live":n,"aria-atomic":!0},s)}function TAt(){const[e,t]=A.useState("");return{announce:A.useCallback(n=>{n!=null&&t(n)},[]),announcement:e}}const Lqe=A.createContext(null);function AAt(e){const t=A.useContext(Lqe);A.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)},[e,t])}function EAt(){const[e]=A.useState(()=>new Set),t=A.useCallback(n=>(e.add(n),()=>e.delete(n)),[e]);return[A.useCallback(n=>{let{type:a,event:o}=n;e.forEach(l=>{var i;return(i=l[a])==null?void 0:i.call(l,o)})},[e]),t]}const IAt={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. `},PAt={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was moved over droppable area "+s.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was dropped over droppable area "+s.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function LAt(e){let{announcements:t=PAt,container:s,hiddenTextDescribedById:n,screenReaderInstructions:a=IAt}=e;const{announce:o,announcement:l}=TAt(),i=U6("DndLiveRegion"),[d,m]=A.useState(!1);if(A.useEffect(()=>{m(!0)},[]),AAt(A.useMemo(()=>({onDragStart(g){let{active:v}=g;o(t.onDragStart({active:v}))},onDragMove(g){let{active:v,over:_}=g;t.onDragMove&&o(t.onDragMove({active:v,over:_}))},onDragOver(g){let{active:v,over:_}=g;o(t.onDragOver({active:v,over:_}))},onDragEnd(g){let{active:v,over:_}=g;o(t.onDragEnd({active:v,over:_}))},onDragCancel(g){let{active:v,over:_}=g;o(t.onDragCancel({active:v,over:_}))}}),[o,t])),!d)return null;const p=lt.createElement(lt.Fragment,null,lt.createElement(CAt,{id:n,value:a.draggable}),lt.createElement(MAt,{id:i,announcement:l}));return s?Hh.createPortal(p,s):p}var bd;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(bd||(bd={}));function _ne(){}function tMe(e,t){return A.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function DAt(){for(var e=arguments.length,t=new Array(e),s=0;s[...t].filter(n=>n!=null),[...t])}const fg=Object.freeze({x:0,y:0});function Dqe(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Oqe(e,t){let{data:{value:s}}=e,{data:{value:n}}=t;return s-n}function OAt(e,t){let{data:{value:s}}=e,{data:{value:n}}=t;return n-s}function rMe(e){let{left:t,top:s,height:n,width:a}=e;return[{x:t,y:s},{x:t+a,y:s},{x:t,y:s+n},{x:t+a,y:s+n}]}function Rqe(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function sMe(e,t,s){return t===void 0&&(t=e.left),s===void 0&&(s=e.top),{x:t+e.width*.5,y:s+e.height*.5}}const RAt=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:n}=e;const a=sMe(t,t.left,t.top),o=[];for(const l of n){const{id:i}=l,d=s.get(i);if(d){const m=Dqe(sMe(d),a);o.push({id:i,data:{droppableContainer:l,value:m}})}}return o.sort(Oqe)},FAt=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:n}=e;const a=rMe(t),o=[];for(const l of n){const{id:i}=l,d=s.get(i);if(d){const m=rMe(d),p=a.reduce((v,_,k)=>v+Dqe(m[k],_),0),g=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:g}})}}return o.sort(Oqe)};function zAt(e,t){const s=Math.max(t.top,e.top),n=Math.max(t.left,e.left),a=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),l=a-n,i=o-s;if(n{let{collisionRect:t,droppableRects:s,droppableContainers:n}=e;const a=[];for(const o of n){const{id:l}=o,i=s.get(l);if(i){const d=zAt(i,t);d>0&&a.push({id:l,data:{droppableContainer:o,value:d}})}}return a.sort(OAt)};function $At(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function Fqe(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:fg}function UAt(e){return function(s){for(var n=arguments.length,a=new Array(n>1?n-1:0),o=1;o({...l,top:l.top+e*i.y,bottom:l.bottom+e*i.y,left:l.left+e*i.x,right:l.right+e*i.x}),{...s})}}const VAt=UAt(1);function qAt(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function HAt(e,t,s){const n=qAt(t);if(!n)return e;const{scaleX:a,scaleY:o,x:l,y:i}=n,d=e.left-l-(1-a)*parseFloat(s),m=e.top-i-(1-o)*parseFloat(s.slice(s.indexOf(" ")+1)),p=a?e.width/a:e.width,g=o?e.height/o:e.height;return{width:p,height:g,top:m,right:d+p,bottom:m+g,left:d}}const WAt={ignoreTransform:!1};function U3(e,t){t===void 0&&(t=WAt);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:m,transformOrigin:p}=im(e).getComputedStyle(e);m&&(s=HAt(s,m,p))}const{top:n,left:a,width:o,height:l,bottom:i,right:d}=s;return{top:n,left:a,width:o,height:l,bottom:i,right:d}}function nMe(e){return U3(e,{ignoreTransform:!0})}function GAt(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function KAt(e,t){return t===void 0&&(t=im(e).getComputedStyle(e)),t.position==="fixed"}function ZAt(e,t){t===void 0&&(t=im(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const o=t[a];return typeof o=="string"?s.test(o):!1})}function foe(e,t){const s=[];function n(a){if(t!=null&&s.length>=t||!a)return s;if(__e(a)&&a.scrollingElement!=null&&!s.includes(a.scrollingElement))return s.push(a.scrollingElement),s;if(!B6(a)||Iqe(a)||s.includes(a))return s;const o=im(e).getComputedStyle(a);return a!==e&&ZAt(a,o)&&s.push(a),KAt(a,o)?s:n(a.parentNode)}return e?n(e):s}function zqe(e){const[t]=foe(e,1);return t??null}function yhe(e){return!moe||!e?null:B3(e)?e:v_e(e)?__e(e)||e===$3(e).scrollingElement?window:B6(e)?e:null:null}function Bqe(e){return B3(e)?e.scrollX:e.scrollLeft}function $qe(e){return B3(e)?e.scrollY:e.scrollTop}function wge(e){return{x:Bqe(e),y:$qe(e)}}var Vd;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Vd||(Vd={}));function Uqe(e){return!moe||!e?!1:e===document.scrollingElement}function Vqe(e){const t={x:0,y:0},s=Uqe(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},a=e.scrollTop<=t.y,o=e.scrollLeft<=t.x,l=e.scrollTop>=n.y,i=e.scrollLeft>=n.x;return{isTop:a,isLeft:o,isBottom:l,isRight:i,maxScroll:n,minScroll:t}}const YAt={x:.2,y:.2};function XAt(e,t,s,n,a){let{top:o,left:l,right:i,bottom:d}=s;n===void 0&&(n=10),a===void 0&&(a=YAt);const{isTop:m,isBottom:p,isLeft:g,isRight:v}=Vqe(e),_={x:0,y:0},k={x:0,y:0},w={height:t.height*a.y,width:t.width*a.x};return!m&&o<=t.top+w.height?(_.y=Vd.Backward,k.y=n*Math.abs((t.top+w.height-o)/w.height)):!p&&d>=t.bottom-w.height&&(_.y=Vd.Forward,k.y=n*Math.abs((t.bottom-w.height-d)/w.height)),!v&&i>=t.right-w.width?(_.x=Vd.Forward,k.x=n*Math.abs((t.right-w.width-i)/w.width)):!g&&l<=t.left+w.width&&(_.x=Vd.Backward,k.x=n*Math.abs((t.left+w.width-l)/w.width)),{direction:_,speed:k}}function QAt(e){if(e===document.scrollingElement){const{innerWidth:o,innerHeight:l}=window;return{top:0,left:0,right:o,bottom:l,width:o,height:l}}const{top:t,left:s,right:n,bottom:a}=e.getBoundingClientRect();return{top:t,left:s,right:n,bottom:a,width:e.clientWidth,height:e.clientHeight}}function qqe(e){return e.reduce((t,s)=>J4(t,wge(s)),fg)}function JAt(e){return e.reduce((t,s)=>t+Bqe(s),0)}function eEt(e){return e.reduce((t,s)=>t+$qe(s),0)}function tEt(e,t){if(t===void 0&&(t=U3),!e)return;const{top:s,left:n,bottom:a,right:o}=t(e);zqe(e)&&(a<=0||o<=0||s>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const rEt=[["x",["left","right"],JAt],["y",["top","bottom"],eEt]];class j_e{constructor(t,s){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=foe(s),a=qqe(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[o,l,i]of rEt)for(const d of l)Object.defineProperty(this,d,{get:()=>{const m=i(n),p=a[o]-m;return this.rect[d]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class lI{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...s)})},this.target=t}add(t,s,n){var a;(a=this.target)==null||a.addEventListener(t,s,n),this.listeners.push([t,s,n])}}function sEt(e){const{EventTarget:t}=im(e);return e instanceof t?e:$3(e)}function vhe(e,t){const s=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+n**2)>t:"x"in t&&"y"in t?s>t.x&&n>t.y:"x"in t?s>t.x:"y"in t?n>t.y:!1}var bf;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(bf||(bf={}));function aMe(e){e.preventDefault()}function nEt(e){e.stopPropagation()}var co;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(co||(co={}));const Hqe={start:[co.Space,co.Enter],cancel:[co.Esc],end:[co.Space,co.Enter,co.Tab]},aEt=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case co.Right:return{...s,x:s.x+25};case co.Left:return{...s,x:s.x-25};case co.Down:return{...s,y:s.y+25};case co.Up:return{...s,y:s.y-25}}};class k_e{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:s}}=t;this.props=t,this.listeners=new lI($3(s)),this.windowListeners=new lI(im(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(bf.Resize,this.handleCancel),this.windowListeners.add(bf.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(bf.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,n=t.node.current;n&&tEt(n),s(fg)}handleKeyDown(t){if(w_e(t)){const{active:s,context:n,options:a}=this.props,{keyboardCodes:o=Hqe,coordinateGetter:l=aEt,scrollBehavior:i="smooth"}=a,{code:d}=t;if(o.end.includes(d)){this.handleEnd(t);return}if(o.cancel.includes(d)){this.handleCancel(t);return}const{collisionRect:m}=n.current,p=m?{x:m.left,y:m.top}:fg;this.referenceCoordinates||(this.referenceCoordinates=p);const g=l(t,{active:s,context:n.current,currentCoordinates:p});if(g){const v=fP(g,p),_={x:0,y:0},{scrollableAncestors:k}=n.current;for(const w of k){const S=t.code,{isTop:T,isRight:C,isLeft:I,isBottom:R,maxScroll:D,minScroll:B}=Vqe(w),$=QAt(w),q={x:Math.min(S===co.Right?$.right-$.width/2:$.right,Math.max(S===co.Right?$.left:$.left+$.width/2,g.x)),y:Math.min(S===co.Down?$.bottom-$.height/2:$.bottom,Math.max(S===co.Down?$.top:$.top+$.height/2,g.y))},W=S===co.Right&&!C||S===co.Left&&!I,K=S===co.Down&&!R||S===co.Up&&!T;if(W&&q.x!==g.x){const re=w.scrollLeft+v.x,ae=S===co.Right&&re<=D.x||S===co.Left&&re>=B.x;if(ae&&!v.y){w.scrollTo({left:re,behavior:i});return}ae?_.x=w.scrollLeft-re:_.x=S===co.Right?w.scrollLeft-D.x:w.scrollLeft-B.x,_.x&&w.scrollBy({left:-_.x,behavior:i});break}else if(K&&q.y!==g.y){const re=w.scrollTop+v.y,ae=S===co.Down&&re<=D.y||S===co.Up&&re>=B.y;if(ae&&!v.x){w.scrollTo({top:re,behavior:i});return}ae?_.y=w.scrollTop-re:_.y=S===co.Down?w.scrollTop-D.y:w.scrollTop-B.y,_.y&&w.scrollBy({top:-_.y,behavior:i});break}}this.handleMove(t,J4(fP(g,this.referenceCoordinates),_))}}}handleMove(t,s){const{onMove:n}=this.props;t.preventDefault(),n(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}k_e.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:n=Hqe,onActivation:a}=t,{active:o}=s;const{code:l}=e.nativeEvent;if(n.start.includes(l)){const i=o.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),a==null||a({event:e.nativeEvent}),!0)}return!1}}];function iMe(e){return!!(e&&"distance"in e)}function oMe(e){return!!(e&&"delay"in e)}class N_e{constructor(t,s,n){var a;n===void 0&&(n=sEt(t.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=t,this.events=s;const{event:o}=t,{target:l}=o;this.props=t,this.events=s,this.document=$3(l),this.documentListeners=new lI(this.document),this.listeners=new lI(n),this.windowListeners=new lI(im(l)),this.initialCoordinates=(a=bge(o))!=null?a:fg,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:t,props:{options:{activationConstraint:s,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(bf.Resize,this.handleCancel),this.windowListeners.add(bf.DragStart,aMe),this.windowListeners.add(bf.VisibilityChange,this.handleCancel),this.windowListeners.add(bf.ContextMenu,aMe),this.documentListeners.add(bf.Keydown,this.handleKeydown),s){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(oMe(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(iMe(s)){this.handlePending(s);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(t,s){const{active:n,onPending:a}=this.props;a(n,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add(bf.Click,nEt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(bf.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:n,initialCoordinates:a,props:o}=this,{onMove:l,options:{activationConstraint:i}}=o;if(!a)return;const d=(s=bge(t))!=null?s:fg,m=fP(a,d);if(!n&&i){if(iMe(i)){if(i.tolerance!=null&&vhe(m,i.tolerance))return this.handleCancel();if(vhe(m,i.distance))return this.handleStart()}if(oMe(i)&&vhe(m,i.tolerance))return this.handleCancel();this.handlePending(i,m);return}t.cancelable&&t.preventDefault(),l(d)}handleEnd(){const{onAbort:t,onEnd:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleCancel(){const{onAbort:t,onCancel:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleKeydown(t){t.code===co.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const iEt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class S_e extends N_e{constructor(t){const{event:s}=t,n=$3(s.target);super(t,iEt,n)}}S_e.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:n}=t;return!s.isPrimary||s.button!==0?!1:(n==null||n({event:s}),!0)}}];const oEt={move:{name:"mousemove"},end:{name:"mouseup"}};var jge;(function(e){e[e.RightClick=2]="RightClick"})(jge||(jge={}));class lEt extends N_e{constructor(t){super(t,oEt,$3(t.event.target))}}lEt.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:n}=t;return s.button===jge.RightClick?!1:(n==null||n({event:s}),!0)}}];const _he={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class cEt extends N_e{constructor(t){super(t,_he)}static setup(){return window.addEventListener(_he.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(_he.move.name,t)};function t(){}}}cEt.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:n}=t;const{touches:a}=s;return a.length>1?!1:(n==null||n({event:s}),!0)}}];var cI;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(cI||(cI={}));var bne;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(bne||(bne={}));function dEt(e){let{acceleration:t,activator:s=cI.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=bne.TreeOrder,pointerCoordinates:d,scrollableAncestors:m,scrollableAncestorRects:p,delta:g,threshold:v}=e;const _=hEt({delta:g,disabled:!o}),[k,w]=wAt(),S=A.useRef({x:0,y:0}),T=A.useRef({x:0,y:0}),C=A.useMemo(()=>{switch(s){case cI.Pointer:return d?{top:d.y,bottom:d.y,left:d.x,right:d.x}:null;case cI.DraggableRect:return a}},[s,a,d]),I=A.useRef(null),R=A.useCallback(()=>{const B=I.current;if(!B)return;const $=S.current.x*T.current.x,q=S.current.y*T.current.y;B.scrollBy($,q)},[]),D=A.useMemo(()=>i===bne.TreeOrder?[...m].reverse():m,[i,m]);A.useEffect(()=>{if(!o||!m.length||!C){w();return}for(const B of D){if((n==null?void 0:n(B))===!1)continue;const $=m.indexOf(B),q=p[$];if(!q)continue;const{direction:W,speed:K}=XAt(B,q,C,t,v);for(const re of["x","y"])_[re][W[re]]||(K[re]=0,W[re]=0);if(K.x>0||K.y>0){w(),I.current=B,k(R,l),S.current=K,T.current=W;return}}S.current={x:0,y:0},T.current={x:0,y:0},w()},[t,R,n,w,o,l,JSON.stringify(C),JSON.stringify(_),k,m,D,p,JSON.stringify(v)])}const uEt={x:{[Vd.Backward]:!1,[Vd.Forward]:!1},y:{[Vd.Backward]:!1,[Vd.Forward]:!1}};function hEt(e){let{delta:t,disabled:s}=e;const n=_ge(t);return $6(a=>{if(s||!n||!a)return uEt;const o={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[Vd.Backward]:a.x[Vd.Backward]||o.x===-1,[Vd.Forward]:a.x[Vd.Forward]||o.x===1},y:{[Vd.Backward]:a.y[Vd.Backward]||o.y===-1,[Vd.Forward]:a.y[Vd.Forward]||o.y===1}}},[s,t,n])}function mEt(e,t){const s=t!=null?e.get(t):void 0,n=s?s.node.current:null;return $6(a=>{var o;return t==null?null:(o=n??a)!=null?o:null},[n,t])}function fEt(e,t){return A.useMemo(()=>e.reduce((s,n)=>{const{sensor:a}=n,o=a.activators.map(l=>({eventName:l.eventName,handler:t(l.handler,n)}));return[...s,...o]},[]),[e,t])}var gP;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(gP||(gP={}));var kge;(function(e){e.Optimized="optimized"})(kge||(kge={}));const lMe=new Map;function pEt(e,t){let{dragging:s,dependencies:n,config:a}=t;const[o,l]=A.useState(null),{frequency:i,measure:d,strategy:m}=a,p=A.useRef(e),g=S(),v=mP(g),_=A.useCallback(function(T){T===void 0&&(T=[]),!v.current&&l(C=>C===null?T:C.concat(T.filter(I=>!C.includes(I))))},[v]),k=A.useRef(null),w=$6(T=>{if(g&&!s)return lMe;if(!T||T===lMe||p.current!==e||o!=null){const C=new Map;for(let I of e){if(!I)continue;if(o&&o.length>0&&!o.includes(I.id)&&I.rect.current){C.set(I.id,I.rect.current);continue}const R=I.node.current,D=R?new j_e(d(R),R):null;I.rect.current=D,D&&C.set(I.id,D)}return C}return T},[e,o,s,g,d]);return A.useEffect(()=>{p.current=e},[e]),A.useEffect(()=>{g||_()},[s,g]),A.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),A.useEffect(()=>{g||typeof i!="number"||k.current!==null||(k.current=setTimeout(()=>{_(),k.current=null},i))},[i,g,_,...n]),{droppableRects:w,measureDroppableContainers:_,measuringScheduled:o!=null};function S(){switch(m){case gP.Always:return!1;case gP.BeforeDragging:return s;default:return!s}}}function Wqe(e,t){return $6(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function gEt(e,t){return Wqe(e,t)}function xEt(e){let{callback:t,disabled:s}=e;const n=b_e(t),a=A.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,s]);return A.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function poe(e){let{callback:t,disabled:s}=e;const n=b_e(t),a=A.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[s]);return A.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function yEt(e){return new j_e(U3(e),e)}function cMe(e,t,s){t===void 0&&(t=yEt);const[n,a]=A.useState(null);function o(){a(d=>{if(!e)return null;if(e.isConnected===!1){var m;return(m=d??s)!=null?m:null}const p=t(e);return JSON.stringify(d)===JSON.stringify(p)?d:p})}const l=xEt({callback(d){if(e)for(const m of d){const{type:p,target:g}=m;if(p==="childList"&&g instanceof HTMLElement&&g.contains(e)){o();break}}}}),i=poe({callback:o});return Mx(()=>{o(),e?(i==null||i.observe(e),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(i==null||i.disconnect(),l==null||l.disconnect())},[e]),n}function vEt(e){const t=Wqe(e);return Fqe(e,t)}const dMe=[];function _Et(e){const t=A.useRef(e),s=$6(n=>e?n&&n!==dMe&&e&&t.current&&e.parentNode===t.current.parentNode?n:foe(e):dMe,[e]);return A.useEffect(()=>{t.current=e},[e]),s}function bEt(e){const[t,s]=A.useState(null),n=A.useRef(e),a=A.useCallback(o=>{const l=yhe(o.target);l&&s(i=>i?(i.set(l,wge(l)),new Map(i)):null)},[]);return A.useEffect(()=>{const o=n.current;if(e!==o){l(o);const i=e.map(d=>{const m=yhe(d);return m?(m.addEventListener("scroll",a,{passive:!0}),[m,wge(m)]):null}).filter(d=>d!=null);s(i.length?new Map(i):null),n.current=e}return()=>{l(e),l(o)};function l(i){i.forEach(d=>{const m=yhe(d);m==null||m.removeEventListener("scroll",a)})}},[a,e]),A.useMemo(()=>e.length?t?Array.from(t.values()).reduce((o,l)=>J4(o,l),fg):qqe(e):fg,[e,t])}function uMe(e,t){t===void 0&&(t=[]);const s=A.useRef(null);return A.useEffect(()=>{s.current=null},t),A.useEffect(()=>{const n=e!==fg;n&&!s.current&&(s.current=e),!n&&s.current&&(s.current=null)},[e]),s.current?fP(e,s.current):fg}function wEt(e){A.useEffect(()=>{if(!moe)return;const t=e.map(s=>{let{sensor:n}=s;return n.setup==null?void 0:n.setup()});return()=>{for(const s of t)s==null||s()}},e.map(t=>{let{sensor:s}=t;return s}))}function jEt(e,t){return A.useMemo(()=>e.reduce((s,n)=>{let{eventName:a,handler:o}=n;return s[a]=l=>{o(l,t)},s},{}),[e,t])}function Gqe(e){return A.useMemo(()=>e?GAt(e):null,[e])}const hMe=[];function kEt(e,t){t===void 0&&(t=U3);const[s]=e,n=Gqe(s?im(s):null),[a,o]=A.useState(hMe);function l(){o(()=>e.length?e.map(d=>Uqe(d)?n:new j_e(t(d),d)):hMe)}const i=poe({callback:l});return Mx(()=>{i==null||i.disconnect(),l(),e.forEach(d=>i==null?void 0:i.observe(d))},[e]),a}function NEt(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return B6(t)?t:e}function SEt(e){let{measure:t}=e;const[s,n]=A.useState(null),a=A.useCallback(m=>{for(const{target:p}of m)if(B6(p)){n(g=>{const v=t(p);return g?{...g,width:v.width,height:v.height}:v});break}},[t]),o=poe({callback:a}),l=A.useCallback(m=>{const p=NEt(m);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?t(p):null)},[t,o]),[i,d]=vne(l);return A.useMemo(()=>({nodeRef:i,rect:s,setRef:d}),[s,i,d])}const CEt=[{sensor:S_e,options:{}},{sensor:k_e,options:{}}],MEt={current:{}},pre={draggable:{measure:nMe},droppable:{measure:nMe,strategy:gP.WhileDragging,frequency:kge.Optimized},dragOverlay:{measure:U3}};class dI extends Map{get(t){var s;return t!=null&&(s=super.get(t))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:s}=t;return!s})}getNodeFor(t){var s,n;return(s=(n=this.get(t))==null?void 0:n.node.current)!=null?s:void 0}}const TEt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new dI,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_ne},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:pre,measureDroppableContainers:_ne,windowRect:null,measuringScheduled:!1},AEt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_ne,draggableNodes:new Map,over:null,measureDroppableContainers:_ne},goe=A.createContext(AEt),Kqe=A.createContext(TEt);function EEt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new dI}}}function IEt(e,t){switch(t.type){case bd.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case bd.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case bd.DragEnd:case bd.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case bd.RegisterDroppable:{const{element:s}=t,{id:n}=s,a=new dI(e.droppable.containers);return a.set(n,s),{...e,droppable:{...e.droppable,containers:a}}}case bd.SetDroppableDisabled:{const{id:s,key:n,disabled:a}=t,o=e.droppable.containers.get(s);if(!o||n!==o.key)return e;const l=new dI(e.droppable.containers);return l.set(s,{...o,disabled:a}),{...e,droppable:{...e.droppable,containers:l}}}case bd.UnregisterDroppable:{const{id:s,key:n}=t,a=e.droppable.containers.get(s);if(!a||n!==a.key)return e;const o=new dI(e.droppable.containers);return o.delete(s),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function PEt(e){let{disabled:t}=e;const{active:s,activatorEvent:n,draggableNodes:a}=A.useContext(goe),o=_ge(n),l=_ge(s==null?void 0:s.id);return A.useEffect(()=>{if(!t&&!n&&o&&l!=null){if(!w_e(o)||document.activeElement===o.target)return;const i=a.get(l);if(!i)return;const{activatorNode:d,node:m}=i;if(!d.current&&!m.current)return;requestAnimationFrame(()=>{for(const p of[d.current,m.current]){if(!p)continue;const g=NAt(p);if(g){g.focus();break}}})}},[n,t,a,l,o]),null}function LEt(e,t){let{transform:s,...n}=t;return e!=null&&e.length?e.reduce((a,o)=>o({transform:a,...n}),s):s}function DEt(e){return A.useMemo(()=>({draggable:{...pre.draggable,...e==null?void 0:e.draggable},droppable:{...pre.droppable,...e==null?void 0:e.droppable},dragOverlay:{...pre.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function OEt(e){let{activeNode:t,measure:s,initialRect:n,config:a=!0}=e;const o=A.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;Mx(()=>{if(!l&&!i||!t){o.current=!1;return}if(o.current||!n)return;const m=t==null?void 0:t.node.current;if(!m||m.isConnected===!1)return;const p=s(m),g=Fqe(p,n);if(l||(g.x=0),i||(g.y=0),o.current=!0,Math.abs(g.x)>0||Math.abs(g.y)>0){const v=zqe(m);v&&v.scrollBy({top:g.y,left:g.x})}},[t,l,i,n,s])}const Zqe=A.createContext({...fg,scaleX:1,scaleY:1});var Iv;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Iv||(Iv={}));const REt=A.memo(function(t){var s,n,a,o;let{id:l,accessibility:i,autoScroll:d=!0,children:m,sensors:p=CEt,collisionDetection:g=BAt,measuring:v,modifiers:_,...k}=t;const w=A.useReducer(IEt,void 0,EEt),[S,T]=w,[C,I]=EAt(),[R,D]=A.useState(Iv.Uninitialized),B=R===Iv.Initialized,{draggable:{active:$,nodes:q,translate:W},droppable:{containers:K}}=S,re=$!=null?q.get($):null,ae=A.useRef({initial:null,translated:null}),oe=A.useMemo(()=>{var La;return $!=null?{id:$,data:(La=re==null?void 0:re.data)!=null?La:MEt,rect:ae}:null},[$,re]),se=A.useRef(null),[pe,ie]=A.useState(null),[de,ce]=A.useState(null),ge=mP(k,Object.values(k)),Te=U6("DndDescribedBy",l),_e=A.useMemo(()=>K.getEnabled(),[K]),ve=DEt(v),{droppableRects:Me,measureDroppableContainers:Ze,measuringScheduled:Ae}=pEt(_e,{dragging:B,dependencies:[W.x,W.y],config:ve.droppable}),Le=mEt(q,$),Ue=A.useMemo(()=>de?bge(de):null,[de]),Ve=xi(),Ie=gEt(Le,ve.draggable.measure);OEt({activeNode:$!=null?q.get($):null,config:Ve.layoutShiftCompensation,initialRect:Ie,measure:ve.draggable.measure});const We=cMe(Le,ve.draggable.measure,Ie),wt=cMe(Le?Le.parentElement:null),Pe=A.useRef({activatorEvent:null,active:null,activeNode:Le,collisionRect:null,collisions:null,droppableRects:Me,draggableNodes:q,draggingNode:null,draggingNodeRect:null,droppableContainers:K,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),st=K.getNodeFor((s=Pe.current.over)==null?void 0:s.id),ue=SEt({measure:ve.dragOverlay.measure}),$e=(n=ue.nodeRef.current)!=null?n:Le,tt=B?(a=ue.rect)!=null?a:We:null,rt=!!(ue.nodeRef.current&&ue.rect),je=vEt(rt?null:We),it=Gqe($e?im($e):null),Se=_Et(B?st??Le:null),et=kEt(Se),Qe=LEt(_,{transform:{x:W.x-je.x,y:W.y-je.y,scaleX:1,scaleY:1},activatorEvent:de,active:oe,activeNodeRect:We,containerNodeRect:wt,draggingNodeRect:tt,over:Pe.current.over,overlayNodeRect:ue.rect,scrollableAncestors:Se,scrollableAncestorRects:et,windowRect:it}),He=Ue?J4(Ue,W):null,ot=bEt(Se),ut=uMe(ot),ft=uMe(ot,[We]),ct=J4(Qe,ut),Tt=tt?VAt(tt,Qe):null,Ot=oe&&Tt?g({active:oe,collisionRect:Tt,droppableRects:Me,droppableContainers:_e,pointerCoordinates:He}):null,rr=Rqe(Ot,"id"),[Lr,cr]=A.useState(null),Mr=rt?Qe:J4(Qe,ft),As=$At(Mr,(o=Lr==null?void 0:Lr.rect)!=null?o:null,We),Et=A.useRef(null),Pt=A.useCallback((La,un)=>{let{sensor:ia,options:rn}=un;if(se.current==null)return;const Wn=q.get(se.current);if(!Wn)return;const Yn=La.nativeEvent,Pi=new ia({active:se.current,activeNode:Wn,event:Yn,options:rn,context:Pe,onAbort($a){if(!q.get($a))return;const{onDragAbort:Ei}=ge.current,Qs={id:$a};Ei==null||Ei(Qs),C({type:"onDragAbort",event:Qs})},onPending($a,xo,Ei,Qs){if(!q.get($a))return;const{onDragPending:Mc}=ge.current,No={id:$a,constraint:xo,initialCoordinates:Ei,offset:Qs};Mc==null||Mc(No),C({type:"onDragPending",event:No})},onStart($a){const xo=se.current;if(xo==null)return;const Ei=q.get(xo);if(!Ei)return;const{onDragStart:Qs}=ge.current,ao={activatorEvent:Yn,active:{id:xo,data:Ei.data,rect:ae}};Hh.unstable_batchedUpdates(()=>{Qs==null||Qs(ao),D(Iv.Initializing),T({type:bd.DragStart,initialCoordinates:$a,active:xo}),C({type:"onDragStart",event:ao}),ie(Et.current),ce(Yn)})},onMove($a){T({type:bd.DragMove,coordinates:$a})},onEnd:dr(bd.DragEnd),onCancel:dr(bd.DragCancel)});Et.current=Pi;function dr($a){return async function(){const{active:Ei,collisions:Qs,over:ao,scrollAdjustedTranslate:Mc}=Pe.current;let No=null;if(Ei&&Mc){const{cancelDrop:Tc}=ge.current;No={activatorEvent:Yn,active:Ei,collisions:Qs,delta:Mc,over:ao},$a===bd.DragEnd&&typeof Tc=="function"&&await Promise.resolve(Tc(No))&&($a=bd.DragCancel)}se.current=null,Hh.unstable_batchedUpdates(()=>{T({type:$a}),D(Iv.Uninitialized),cr(null),ie(null),ce(null),Et.current=null;const Tc=$a===bd.DragEnd?"onDragEnd":"onDragCancel";if(No){const nt=ge.current[Tc];nt==null||nt(No),C({type:Tc,event:No})}})}}},[q]),Sr=A.useCallback((La,un)=>(ia,rn)=>{const Wn=ia.nativeEvent,Yn=q.get(rn);if(se.current!==null||!Yn||Wn.dndKit||Wn.defaultPrevented)return;const Pi={active:Yn};La(ia,un.options,Pi)===!0&&(Wn.dndKit={capturedBy:un.sensor},se.current=rn,Pt(ia,un))},[q,Pt]),fs=fEt(p,Sr);wEt(p),Mx(()=>{We&&R===Iv.Initializing&&D(Iv.Initialized)},[We,R]),A.useEffect(()=>{const{onDragMove:La}=ge.current,{active:un,activatorEvent:ia,collisions:rn,over:Wn}=Pe.current;if(!un||!ia)return;const Yn={active:un,activatorEvent:ia,collisions:rn,delta:{x:ct.x,y:ct.y},over:Wn};Hh.unstable_batchedUpdates(()=>{La==null||La(Yn),C({type:"onDragMove",event:Yn})})},[ct.x,ct.y]),A.useEffect(()=>{const{active:La,activatorEvent:un,collisions:ia,droppableContainers:rn,scrollAdjustedTranslate:Wn}=Pe.current;if(!La||se.current==null||!un||!Wn)return;const{onDragOver:Yn}=ge.current,Pi=rn.get(rr),dr=Pi&&Pi.rect.current?{id:Pi.id,rect:Pi.rect.current,data:Pi.data,disabled:Pi.disabled}:null,$a={active:La,activatorEvent:un,collisions:ia,delta:{x:Wn.x,y:Wn.y},over:dr};Hh.unstable_batchedUpdates(()=>{cr(dr),Yn==null||Yn($a),C({type:"onDragOver",event:$a})})},[rr]),Mx(()=>{Pe.current={activatorEvent:de,active:oe,activeNode:Le,collisionRect:Tt,collisions:Ot,droppableRects:Me,draggableNodes:q,draggingNode:$e,draggingNodeRect:tt,droppableContainers:K,over:Lr,scrollableAncestors:Se,scrollAdjustedTranslate:ct},ae.current={initial:tt,translated:Tt}},[oe,Le,Ot,Tt,q,$e,tt,Me,K,Lr,Se,ct]),dEt({...Ve,delta:W,draggingRect:Tt,pointerCoordinates:He,scrollableAncestors:Se,scrollableAncestorRects:et});const Ws=A.useMemo(()=>({active:oe,activeNode:Le,activeNodeRect:We,activatorEvent:de,collisions:Ot,containerNodeRect:wt,dragOverlay:ue,draggableNodes:q,droppableContainers:K,droppableRects:Me,over:Lr,measureDroppableContainers:Ze,scrollableAncestors:Se,scrollableAncestorRects:et,measuringConfiguration:ve,measuringScheduled:Ae,windowRect:it}),[oe,Le,We,de,Ot,wt,ue,q,K,Me,Lr,Ze,Se,et,ve,Ae,it]),tn=A.useMemo(()=>({activatorEvent:de,activators:fs,active:oe,activeNodeRect:We,ariaDescribedById:{draggable:Te},dispatch:T,draggableNodes:q,over:Lr,measureDroppableContainers:Ze}),[de,fs,oe,We,T,Te,q,Lr,Ze]);return lt.createElement(Lqe.Provider,{value:I},lt.createElement(goe.Provider,{value:tn},lt.createElement(Kqe.Provider,{value:Ws},lt.createElement(Zqe.Provider,{value:As},m)),lt.createElement(PEt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),lt.createElement(LAt,{...i,hiddenTextDescribedById:Te}));function xi(){const La=(pe==null?void 0:pe.autoScrollEnabled)===!1,un=typeof d=="object"?d.enabled===!1:d===!1,ia=B&&!La&&!un;return typeof d=="object"?{...d,enabled:ia}:{enabled:ia}}}),FEt=A.createContext(null),mMe="button",zEt="Draggable";function BEt(e){let{id:t,data:s,disabled:n=!1,attributes:a}=e;const o=U6(zEt),{activators:l,activatorEvent:i,active:d,activeNodeRect:m,ariaDescribedById:p,draggableNodes:g,over:v}=A.useContext(goe),{role:_=mMe,roleDescription:k="draggable",tabIndex:w=0}=a??{},S=(d==null?void 0:d.id)===t,T=A.useContext(S?Zqe:FEt),[C,I]=vne(),[R,D]=vne(),B=jEt(l,t),$=mP(s);Mx(()=>(g.set(t,{id:t,key:o,node:C,activatorNode:R,data:$}),()=>{const W=g.get(t);W&&W.key===o&&g.delete(t)}),[g,t]);const q=A.useMemo(()=>({role:_,tabIndex:w,"aria-disabled":n,"aria-pressed":S&&_===mMe?!0:void 0,"aria-roledescription":k,"aria-describedby":p.draggable}),[n,_,w,S,k,p.draggable]);return{active:d,activatorEvent:i,activeNodeRect:m,attributes:q,isDragging:S,listeners:n?void 0:B,node:C,over:v,setNodeRef:I,setActivatorNodeRef:D,transform:T}}function $Et(){return A.useContext(Kqe)}const UEt="Droppable",VEt={timeout:25};function qEt(e){let{data:t,disabled:s=!1,id:n,resizeObserverConfig:a}=e;const o=U6(UEt),{active:l,dispatch:i,over:d,measureDroppableContainers:m}=A.useContext(goe),p=A.useRef({disabled:s}),g=A.useRef(!1),v=A.useRef(null),_=A.useRef(null),{disabled:k,updateMeasurementsFor:w,timeout:S}={...VEt,...a},T=mP(w??n),C=A.useCallback(()=>{if(!g.current){g.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{m(Array.isArray(T.current)?T.current:[T.current]),_.current=null},S)},[S]),I=poe({callback:C,disabled:k||!l}),R=A.useCallback((q,W)=>{I&&(W&&(I.unobserve(W),g.current=!1),q&&I.observe(q))},[I]),[D,B]=vne(R),$=mP(t);return A.useEffect(()=>{!I||!D.current||(I.disconnect(),g.current=!1,I.observe(D.current))},[D,I]),A.useEffect(()=>(i({type:bd.RegisterDroppable,element:{id:n,key:o,disabled:s,node:D,rect:v,data:$}}),()=>i({type:bd.UnregisterDroppable,key:o,id:n})),[n]),A.useEffect(()=>{s!==p.current.disabled&&(i({type:bd.SetDroppableDisabled,id:n,key:o,disabled:s}),p.current.disabled=s)},[n,o,s,i]),{active:l,rect:v,isOver:(d==null?void 0:d.id)===n,node:D,over:d,setNodeRef:B}}function C_e(e,t,s){const n=e.slice();return n.splice(s<0?n.length+s:s,0,n.splice(t,1)[0]),n}function HEt(e,t){return e.reduce((s,n,a)=>{const o=t.get(n);return o&&(s[a]=o),s},Array(e.length))}function YO(e){return e!==null&&e>=0}function WEt(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let s=0;s{let{rects:t,activeIndex:s,overIndex:n,index:a}=e;const o=C_e(t,n,s),l=t[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}},Yqe="Sortable",Xqe=lt.createContext({activeIndex:-1,containerId:Yqe,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:M_e,disabled:{draggable:!1,droppable:!1}});function KEt(e){let{children:t,id:s,items:n,strategy:a=M_e,disabled:o=!1}=e;const{active:l,dragOverlay:i,droppableRects:d,over:m,measureDroppableContainers:p}=$Et(),g=U6(Yqe,s),v=i.rect!==null,_=A.useMemo(()=>n.map(B=>typeof B=="object"&&"id"in B?B.id:B),[n]),k=l!=null,w=l?_.indexOf(l.id):-1,S=m?_.indexOf(m.id):-1,T=A.useRef(_),C=!WEt(_,T.current),I=S!==-1&&w===-1||C,R=GEt(o);Mx(()=>{C&&k&&p(_)},[C,_,k,p]),A.useEffect(()=>{T.current=_},[_]);const D=A.useMemo(()=>({activeIndex:w,containerId:g,disabled:R,disableTransforms:I,items:_,overIndex:S,useDragOverlay:v,sortedRects:HEt(_,d),strategy:a}),[w,g,R.draggable,R.droppable,I,_,S,d,v,a]);return lt.createElement(Xqe.Provider,{value:D},t)}const ZEt=e=>{let{id:t,items:s,activeIndex:n,overIndex:a}=e;return C_e(s,n,a).indexOf(t)},YEt=e=>{let{containerId:t,isSorting:s,wasDragging:n,index:a,items:o,newIndex:l,previousItems:i,previousContainerId:d,transition:m}=e;return!m||!n||i!==o&&a===l?!1:s?!0:l!==a&&t===d},XEt={duration:200,easing:"ease"},Qqe="transform",QEt=pP.Transition.toString({property:Qqe,duration:0,easing:"linear"}),JEt={roleDescription:"sortable"};function eIt(e){let{disabled:t,index:s,node:n,rect:a}=e;const[o,l]=A.useState(null),i=A.useRef(s);return Mx(()=>{if(!t&&s!==i.current&&n.current){const d=a.current;if(d){const m=U3(n.current,{ignoreTransform:!0}),p={x:d.left-m.left,y:d.top-m.top,scaleX:d.width/m.width,scaleY:d.height/m.height};(p.x||p.y)&&l(p)}}s!==i.current&&(i.current=s)},[t,s,n,a]),A.useEffect(()=>{o&&l(null)},[o]),o}function tIt(e){let{animateLayoutChanges:t=YEt,attributes:s,disabled:n,data:a,getNewIndex:o=ZEt,id:l,strategy:i,resizeObserverConfig:d,transition:m=XEt}=e;const{items:p,containerId:g,activeIndex:v,disabled:_,disableTransforms:k,sortedRects:w,overIndex:S,useDragOverlay:T,strategy:C}=A.useContext(Xqe),I=rIt(n,_),R=p.indexOf(l),D=A.useMemo(()=>({sortable:{containerId:g,index:R,items:p},...a}),[g,a,R,p]),B=A.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:$,node:q,isOver:W,setNodeRef:K}=qEt({id:l,data:D,disabled:I.droppable,resizeObserverConfig:{updateMeasurementsFor:B,...d}}),{active:re,activatorEvent:ae,activeNodeRect:oe,attributes:se,setNodeRef:pe,listeners:ie,isDragging:de,over:ce,setActivatorNodeRef:ge,transform:Te}=BEt({id:l,data:D,attributes:{...JEt,...s},disabled:I.draggable}),_e=bAt(K,pe),ve=!!re,Me=ve&&!k&&YO(v)&&YO(S),Ze=!T&&de,Ae=Ze&&Me?Te:null,Ue=Me?Ae??(i??C)({rects:w,activeNodeRect:oe,activeIndex:v,overIndex:S,index:R}):null,Ve=YO(v)&&YO(S)?o({id:l,items:p,activeIndex:v,overIndex:S}):R,Ie=re==null?void 0:re.id,We=A.useRef({activeId:Ie,items:p,newIndex:Ve,containerId:g}),wt=p!==We.current.items,Pe=t({active:re,containerId:g,isDragging:de,isSorting:ve,id:l,index:R,items:p,newIndex:We.current.newIndex,previousItems:We.current.items,previousContainerId:We.current.containerId,transition:m,wasDragging:We.current.activeId!=null}),st=eIt({disabled:!Pe,index:R,node:q,rect:$});return A.useEffect(()=>{ve&&We.current.newIndex!==Ve&&(We.current.newIndex=Ve),g!==We.current.containerId&&(We.current.containerId=g),p!==We.current.items&&(We.current.items=p)},[ve,Ve,g,p]),A.useEffect(()=>{if(Ie===We.current.activeId)return;if(Ie!=null&&We.current.activeId==null){We.current.activeId=Ie;return}const $e=setTimeout(()=>{We.current.activeId=Ie},50);return()=>clearTimeout($e)},[Ie]),{active:re,activeIndex:v,attributes:se,data:D,rect:$,index:R,newIndex:Ve,items:p,isOver:W,isSorting:ve,isDragging:de,listeners:ie,node:q,overIndex:S,over:ce,setNodeRef:_e,setActivatorNodeRef:ge,setDroppableNodeRef:K,setDraggableNodeRef:pe,transform:st??Ue,transition:ue()};function ue(){if(st||wt&&We.current.newIndex===R)return QEt;if(!(Ze&&!w_e(ae)||!m)&&(ve||Pe))return pP.Transition.toString({...m,property:Qqe})}}function rIt(e,t){var s,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(s=e==null?void 0:e.draggable)!=null?s:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}function wne(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const sIt=[co.Down,co.Right,co.Up,co.Left],nIt=(e,t)=>{let{context:{active:s,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=t;if(sIt.includes(e.code)){if(e.preventDefault(),!s||!n)return;const d=[];o.getEnabled().forEach(g=>{if(!g||g!=null&&g.disabled)return;const v=a.get(g.id);if(v)switch(e.code){case co.Down:n.topv.top&&d.push(g);break;case co.Left:n.left>v.left&&d.push(g);break;case co.Right:n.left1&&(p=m[1].id),p!=null){const g=o.get(s.id),v=o.get(p),_=v?a.get(v.id):null,k=v==null?void 0:v.node.current;if(k&&_&&g&&v){const S=foe(k).some((B,$)=>i[$]!==B),T=Jqe(g,v),C=aIt(g,v),I=S||!T?{x:0,y:0}:{x:C?n.width-_.width:0,y:C?n.height-_.height:0},R={x:_.left,y:_.top};return I.x&&I.y?R:fP(R,I)}}}};function Jqe(e,t){return!wne(e)||!wne(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function aIt(e,t){return!wne(e)||!wne(t)||!Jqe(e,t)?!1:e.data.current.sortable.indext(e),children:r.jsx(Qa,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"destructive",size:"icon",className:"h-7 w-7",onClick:()=>s(e),children:r.jsx(Os,{className:"h-3.5 w-3.5"})})]}),e.post_date&&r.jsx("div",{className:"absolute bottom-2 left-2",children:r.jsxs(_t,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[r.jsx(An,{className:"h-2.5 w-2.5"}),Xr(new Date(e.post_date+"T00:00:00"),"MMM d")]})})]}),r.jsxs(qe,{className:"p-3 space-y-2",children:[r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:e.caption}),r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"sm",className:Vt("w-full h-7 text-[11px] gap-1 justify-start font-normal",!e.post_date&&"text-muted-foreground"),children:[r.jsx(An,{className:"h-3 w-3"}),e.post_date?Xr(new Date(e.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),r.jsxs(Hc,{className:"w-auto p-0",align:"start",children:[r.jsx(ig,{mode:"single",selected:e.post_date?new Date(e.post_date+"T00:00:00"):void 0,onSelect:g=>n(e.id,g?Xr(g,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"}),e.post_date&&r.jsx("div",{className:"p-2 border-t",children:r.jsx(X,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>n(e.id,null),children:"Clear date"})})]})]})]})]})})}const oIt=()=>{const e=Rr(),[t,s]=A.useState("all"),[n,a]=A.useState(!1),[o,l]=A.useState(Xr(new Date,"yyyy-MM")),[i,d]=A.useState([]),[m,p]=A.useState(!1),[g,v]=A.useState(null),[_,k]=A.useState(null),[w,S]=A.useState(""),[T,C]=A.useState(null),[I,R]=A.useState(!1),[D,B]=A.useState(!1),[$,q]=A.useState(Xr(new Date,"yyyy-MM")),[W,K]=A.useState(null),[re,ae]=A.useState(""),[oe,se]=A.useState(""),[pe,ie]=A.useState(""),[de,ce]=A.useState(!1),ge=DAt(tMe(S_e,{activationConstraint:{distance:5}}),tMe(k_e,{coordinateGetter:nIt})),{data:Te=[],isLoading:_e}=Ht({queryKey:["admin-social-swag-2"],queryFn:async()=>{const{data:He,error:ot}=await Y.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(ot)throw ot;return He}}),{data:ve=[]}=Ht({queryKey:["admin-social-swag-2-months"],queryFn:async()=>{const{data:He,error:ot}=await Y.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(ot)throw ot;return He}}),{data:Me=[]}=Ht({queryKey:["admin-social-swag-2-reels"],queryFn:async()=>{const{data:He,error:ot}=await Y.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(ot)throw ot;return He}}),Ze=[...new Set(Te.map(He=>He.month))].sort((He,ot)=>ot.localeCompare(He)),Ae=t==="all"?Te:Te.filter(He=>He.month===t),Le=He=>{const ot=Ove(He,"yyyy-MM",new Date);return Xr(ot,"MMMM yyyy")},Ue=He=>{k(He),S(He.caption),C(He.post_date)},Ve=async()=>{if(_){R(!0);try{const{error:He}=await Y.from("social_swag_2").update({caption:w,post_date:T}).eq("id",_.id);if(He)throw He;we.success("Image updated"),k(null),e.invalidateQueries({queryKey:["admin-social-swag-2"]}),e.invalidateQueries({queryKey:["social-swag-2"]})}catch{we.error("Failed to update image")}finally{R(!1)}}},Ie=async He=>{const{active:ot,over:ut}=He;if(!ut||ot.id===ut.id)return;const ft=Ae,ct=ft.findIndex(rr=>rr.id===ot.id),Tt=ft.findIndex(rr=>rr.id===ut.id);if(ct===-1||Tt===-1)return;const Ot=C_e(ft,ct,Tt);e.setQueryData(["admin-social-swag-2"],rr=>{if(!rr)return rr;const Lr={};return Ot.forEach((cr,Mr)=>{Lr[cr.id]=Mr}),rr.map(cr=>Lr[cr.id]!==void 0?{...cr,sort_order:Lr[cr.id]}:cr).sort((cr,Mr)=>cr.month!==Mr.month?Mr.month.localeCompare(cr.month):cr.sort_order-Mr.sort_order)});try{await Promise.all(Ot.map((rr,Lr)=>Y.from("social_swag_2").update({sort_order:Lr}).eq("id",rr.id)))}catch{we.error("Failed to save order"),e.invalidateQueries({queryKey:["admin-social-swag-2"]})}},We=He=>{const ut=Array.from(He.target.files||[]).slice(0,16-i.length).map(ft=>({file:ft,preview:URL.createObjectURL(ft),caption:""}));d(ft=>[...ft,...ut].slice(0,16))},wt=He=>{d(ot=>{const ut=[...ot];return URL.revokeObjectURL(ut[He].preview),ut.splice(He,1),ut})},Pe=(He,ot)=>{d(ut=>{const ft=[...ut];return ft[He]={...ft[He],caption:ot},ft})},st=async()=>{if(i.length===0){we.error("Please add at least one image");return}if(i.filter(ot=>!ot.caption.trim()).length>0){we.error("Please add captions to all images");return}p(!0);try{for(let ot=0;ot{const ot=He.image_url.split("/social-swag-2/");ot[1]&&await Y.storage.from("social-swag-2").remove([ot[1]]);const{error:ut}=await Y.from("social_swag_2").delete().eq("id",He.id);if(ut)throw ut},onSuccess:()=>{we.success("Image deleted"),e.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>we.error("Failed to delete image")}),$e=Qt({mutationFn:async({id:He,postDate:ot})=>{const{error:ut}=await Y.from("social_swag_2").update({post_date:ot}).eq("id",He);if(ut)throw ut},onSuccess:()=>{we.success("Post date updated"),e.invalidateQueries({queryKey:["admin-social-swag-2"]}),e.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>we.error("Failed to update post date")}),tt=Qt({mutationFn:async({month:He,link:ot})=>{const{error:ut}=await Y.from("social_swag_2_months").upsert({month:He,canva_link:ot||null},{onConflict:"month"});if(ut)throw ut},onSuccess:()=>{we.success("Canva link updated"),v(null),e.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>we.error("Failed to update Canva link")}),rt=He=>{var ot;return((ot=ve.find(ut=>ut.month===He))==null?void 0:ot.canva_link)||""},je=He=>Me.find(ot=>ot.month===He)||null,it=He=>{var ut;const ot=(ut=He.target.files)==null?void 0:ut[0];ot&&(K(ot),ae(URL.createObjectURL(ot)))},Se=()=>{re&&URL.revokeObjectURL(re),K(null),ae(""),se(""),ie("")},et=async()=>{if(!W){we.error("Please select an image");return}ce(!0);try{const He=W.name.split(".").pop(),ot=`reels/${$}-${Date.now()}.${He}`,{error:ut}=await Y.storage.from("social-swag-2").upload(ot,W);if(ut)throw ut;const{data:{publicUrl:ft}}=Y.storage.from("social-swag-2").getPublicUrl(ot),{error:ct}=await Y.from("social_swag_2_reels").upsert({month:$,image_url:ft,canva_link:pe||null,caption:oe||null},{onConflict:"month"});if(ct)throw ct;we.success("Reel uploaded successfully!"),vge(`${Le($)} Reel`,"social-swag-2"),Se(),B(!1),e.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(He){console.error("Reel upload error:",He),we.error("Failed to upload reel")}finally{ce(!1)}},Qe=Qt({mutationFn:async He=>{const ot=He.image_url.split("/social-swag-2/");ot[1]&&await Y.storage.from("social-swag-2").remove([ot[1]]);const{error:ut}=await Y.from("social_swag_2_reels").delete().eq("id",He.id);if(ut)throw ut},onSuccess:()=>{we.success("Reel deleted"),e.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>we.error("Failed to delete reel")});return r.jsxs(Ur,{title:"Admin - Social Swag 2.0",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Social Swag 2.0"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage monthly social media images and captions"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(Ir,{open:n,onOpenChange:a,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Upload Images"]})}),r.jsxs(Er,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Upload Social Swag Images"})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Month"}),r.jsx(Ye,{type:"month",value:o,onChange:He=>l(He.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{children:["Images (",i.length,"/16)"]}),r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[r.jsx("input",{type:"file",accept:"image/*",multiple:!0,onChange:We,className:"hidden",id:"swag-upload",disabled:i.length>=16}),r.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[r.jsx(Xi,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select images (max 16)"})]})]})]}),i.length>0&&r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:i.map((He,ot)=>r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"relative aspect-[4/5] rounded-lg overflow-hidden bg-muted",children:[r.jsx("img",{src:He.preview,alt:`Upload ${ot+1}`,className:"w-full h-full object-cover"}),r.jsx(X,{variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-6 w-6",onClick:()=>wt(ot),children:r.jsx(Xs,{className:"h-3 w-3"})})]}),r.jsx(qs,{placeholder:"Caption...",value:He.caption,onChange:ut=>Pe(ot,ut.target.value),className:"text-xs h-20"})]},ot))}),r.jsx(X,{onClick:st,disabled:m||i.length===0,className:"w-full gap-2",children:m?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),r.jsxs(Ir,{open:D,onOpenChange:He=>{B(He),He||Se()},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:"gap-2",children:[r.jsx(Ud,{className:"h-4 w-4"}),"Upload Reel"]})}),r.jsxs(Er,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Upload Monthly Reel"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Month"}),r.jsx(Ye,{type:"month",value:$,onChange:He=>q(He.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Reel Preview Image"}),re?r.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[r.jsx("img",{src:re,alt:"Reel preview",className:"w-full h-full object-cover"}),r.jsx(X,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{URL.revokeObjectURL(re),K(null),ae("")},children:r.jsx(Xs,{className:"h-3 w-3"})})]}):r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[r.jsx("input",{type:"file",accept:"image/*",onChange:it,className:"hidden",id:"reel-upload"}),r.jsxs("label",{htmlFor:"reel-upload",className:"cursor-pointer",children:[r.jsx(Ud,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select reel preview image"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Canva Download Link"}),r.jsx(Ye,{value:pe,onChange:He=>ie(He.target.value),placeholder:"https://www.canva.com/..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Caption"}),r.jsx(qs,{value:oe,onChange:He=>se(He.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),r.jsx(X,{onClick:et,disabled:de||!W,className:"w-full gap-2",children:de?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx("div",{className:"text-2xl font-bold",children:Te.length}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx("div",{className:"text-2xl font-bold",children:Ze.length}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsx(ii,{value:t,onValueChange:s,children:r.jsxs(si,{children:[r.jsx(Kr,{value:"all",children:"All"}),Ze.map(He=>r.jsx(Kr,{value:He,children:Le(He)},He))]})}),t!=="all"&&r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(Lo,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("div",{className:"flex-1",children:[r.jsxs(Ee,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Le(t)]}),(g==null?void 0:g.month)===t?r.jsxs("div",{className:"flex gap-2 mt-1",children:[r.jsx(Ye,{value:g.link,onChange:He=>v({...g,link:He.target.value}),placeholder:"https://www.canva.com/..."}),r.jsx(X,{size:"sm",onClick:()=>tt.mutate(g),children:"Save"}),r.jsx(X,{size:"sm",variant:"outline",onClick:()=>v(null),children:"Cancel"})]}):r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx("span",{className:"text-sm",children:rt(t)||"No link set"}),r.jsx(X,{size:"sm",variant:"outline",onClick:()=>v({month:t,link:rt(t)}),children:"Edit"})]})]})]})})}),t!=="all"&&r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx(Ud,{className:"h-4 w-4 text-muted-foreground mt-1"}),r.jsxs("div",{className:"flex-1",children:[r.jsxs(Ee,{className:"text-sm text-muted-foreground",children:["Reel for ",Le(t)]}),(()=>{const He=je(t);return He?r.jsxs("div",{className:"flex items-center gap-4 mt-2",children:[r.jsx("img",{src:He.image_url,alt:"Reel preview",className:"w-16 h-28 object-cover rounded"}),r.jsxs("div",{className:"flex-1 text-sm",children:[r.jsx("p",{className:"line-clamp-2",children:He.caption||"No caption"}),He.canva_link&&r.jsx("a",{href:He.canva_link,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-xs",children:"View Canva Link"})]}),r.jsx(X,{variant:"destructive",size:"sm",onClick:()=>Qe.mutate(He),children:r.jsx(Os,{className:"h-4 w-4"})})]}):r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"No reel uploaded for this month"})})()]})]})})})]}),_e?r.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Ae.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Nl,{className:"h-12 w-12 mx-auto text-muted-foreground/50 mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"No images yet. Upload some!"})]}):r.jsx(REt,{sensors:ge,collisionDetection:RAt,onDragEnd:Ie,children:r.jsx(KEt,{items:Ae.map(He=>He.id),strategy:M_e,children:r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Ae.map(He=>r.jsx(iIt,{item:He,onEdit:Ue,onDelete:ot=>ue.mutate(ot),onDateChange:(ot,ut)=>$e.mutate({id:ot,postDate:ut})},He.id))})})})]}),r.jsx(Ir,{open:!!_,onOpenChange:He=>{He||k(null)},children:r.jsxs(Er,{className:"max-w-md",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Edit Image"})}),_&&r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"aspect-[4/5] max-h-48 w-full rounded-lg overflow-hidden bg-muted",children:r.jsx("img",{src:_.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Caption"}),r.jsx(qs,{value:w,onChange:He=>S(He.target.value),placeholder:"Enter caption...",className:"h-28"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Post Date"}),r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("flex-1 justify-start gap-2 font-normal",!T&&"text-muted-foreground"),children:[r.jsx(An,{className:"h-4 w-4"}),T?Xr(new Date(T+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:T?new Date(T+"T00:00:00"):void 0,onSelect:He=>C(He?Xr(He,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),T&&r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>C(null),children:r.jsx(Xs,{className:"h-4 w-4"})})]})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>k(null),children:"Cancel"}),r.jsx(X,{onClick:Ve,disabled:I,className:"gap-2",children:I?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},lIt=()=>{const{toast:e}=_i(),t=Rr(),[s,n]=A.useState("categories"),[a,o]=A.useState(!1),[l,i]=A.useState(null),[d,m]=A.useState({name:"",description:"",icon:""}),[p,g]=A.useState(!1),[v,_]=A.useState(null),[k,w]=A.useState({name:"",description:"",icon:""}),[S,T]=A.useState(!1),[C,I]=A.useState(null),[R,D]=A.useState(""),{data:B=[],isLoading:$}=Ht({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Ie,error:We}=await Y.from("community_categories").select("*").order("sort_order");if(We)throw We;return Ie}}),{data:q=[],isLoading:W}=Ht({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Ie,error:We}=await Y.from("community_private_groups").select("*").order("sort_order");if(We)throw We;return Ie}}),{data:K=[]}=Ht({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:Ie,error:We}=await Y.from("community_private_group_members").select("*").eq("group_id",C.id);if(We)throw We;return Ie},enabled:!!C}),{data:re=[]}=Ht({queryKey:["admin-all-profiles"],queryFn:async()=>{let We=[],wt=0,Pe=!0;for(;Pe;){const{data:st,error:ue}=await Y.from("profiles").select("id, name, email, brokerage_id").order("name").range(wt,wt+1e3-1);if(ue)throw ue;st&&st.length>0?(We=[...We,...st],wt+=1e3,Pe=st.length===1e3):Pe=!1}return We}}),{data:ae=[]}=Ht({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Ie,error:We}=await Y.from("brokerages").select("*").order("name");if(We)throw We;return Ie}}),oe=Qt({mutationFn:async Ie=>{if(Ie.id){const{error:We}=await Y.from("community_categories").update({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null}).eq("id",Ie.id);if(We)throw We}else{const We=Math.max(...B.map(Pe=>Pe.sort_order),0),{error:wt}=await Y.from("community_categories").insert({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null,sort_order:We+1});if(wt)throw wt}},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),m({name:"",description:"",icon:""}),e({title:l?"Category updated!":"Category created!"})},onError:Ie=>{e({title:"Error",description:Ie.message,variant:"destructive"})}}),se=Qt({mutationFn:async Ie=>{const{error:We}=await Y.from("community_categories").delete().eq("id",Ie);if(We)throw We},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-community-categories"]}),e({title:"Category deleted"})}}),pe=Qt({mutationFn:async({id:Ie,direction:We})=>{const wt=B.findIndex(Pe=>Pe.id===Ie);if(We==="up"&&wt>0){const Pe=B[wt-1],st=B[wt];await Y.from("community_categories").update({sort_order:st.sort_order}).eq("id",Pe.id),await Y.from("community_categories").update({sort_order:Pe.sort_order}).eq("id",st.id)}else if(We==="down"&&wtt.invalidateQueries({queryKey:["admin-community-categories"]})}),ie=Qt({mutationFn:async Ie=>{if(Ie.id){const{error:We}=await Y.from("community_private_groups").update({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null}).eq("id",Ie.id);if(We)throw We}else{const We=Math.max(...q.map(Pe=>Pe.sort_order),0),{error:wt}=await Y.from("community_private_groups").insert({name:Ie.name,description:Ie.description||null,icon:Ie.icon||null,sort_order:We+1});if(wt)throw wt}},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-private-groups"]}),g(!1),_(null),w({name:"",description:"",icon:""}),e({title:v?"Private group updated!":"Private group created!"})},onError:Ie=>{e({title:"Error",description:Ie.message,variant:"destructive"})}}),de=Qt({mutationFn:async Ie=>{const{error:We}=await Y.from("community_private_groups").delete().eq("id",Ie);if(We)throw We},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-private-groups"]}),e({title:"Private group deleted"})}}),ce=Qt({mutationFn:async({id:Ie,direction:We})=>{const wt=q.findIndex(Pe=>Pe.id===Ie);if(We==="up"&&wt>0){const Pe=q[wt-1],st=q[wt];await Y.from("community_private_groups").update({sort_order:st.sort_order}).eq("id",Pe.id),await Y.from("community_private_groups").update({sort_order:Pe.sort_order}).eq("id",st.id)}else if(We==="down"&&wtt.invalidateQueries({queryKey:["admin-private-groups"]})}),ge=Qt({mutationFn:async({groupId:Ie,userId:We,isMember:wt})=>{if(wt){const{error:Pe}=await Y.from("community_private_group_members").delete().eq("group_id",Ie).eq("user_id",We);if(Pe)throw Pe}else{const{error:Pe}=await Y.from("community_private_group_members").insert({group_id:Ie,user_id:We});if(Pe)throw Pe}},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),Te=Qt({mutationFn:async({groupId:Ie,brokerageId:We,isMember:wt})=>{if(wt){const{error:Pe}=await Y.from("community_private_group_members").delete().eq("group_id",Ie).eq("brokerage_id",We);if(Pe)throw Pe}else{const{error:Pe}=await Y.from("community_private_group_members").insert({group_id:Ie,brokerage_id:We});if(Pe)throw Pe}},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),_e=Ie=>{i(Ie),m({name:Ie.name,description:Ie.description||"",icon:Ie.icon||""}),o(!0)},ve=()=>{i(null),m({name:"",description:"",icon:""}),o(!0)},Me=Ie=>{_(Ie),w({name:Ie.name,description:Ie.description||"",icon:Ie.icon||""}),g(!0)},Ze=()=>{_(null),w({name:"",description:"",icon:""}),g(!0)},Ae=Ie=>{I(Ie),D(""),T(!0)},Le=Ie=>K.some(We=>We.user_id===Ie),Ue=Ie=>K.some(We=>We.brokerage_id===Ie),Ve=re.filter(Ie=>Ie.name.toLowerCase().includes(R.toLowerCase())||Ie.email.toLowerCase().includes(R.toLowerCase()));return r.jsx(Ur,{title:"Community Management",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),r.jsxs(ii,{value:s,onValueChange:n,children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"categories",children:"Public Categories"}),r.jsxs(Kr,{value:"private-groups",children:[r.jsx(Du,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),r.jsxs(hs,{value:"categories",className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Categories visible to all community members"}),r.jsxs(X,{onClick:ve,children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-[50px]",children:"Order"}),r.jsx(Mt,{className:"w-[80px]",children:"Icon"}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{className:"w-[100px]",children:"Actions"})]})}),r.jsx(Bn,{children:$?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):B.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):B.map((Ie,We)=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===0,onClick:()=>pe.mutate({id:Ie.id,direction:"up"}),children:"↑"}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===B.length-1,onClick:()=>pe.mutate({id:Ie.id,direction:"down"}),children:"↓"})]})}),r.jsx(dt,{className:"text-2xl",children:Ie.icon||"📁"}),r.jsx(dt,{className:"font-medium",children:Ie.name}),r.jsx(dt,{className:"text-muted-foreground",children:Ie.description||"—"}),r.jsx(dt,{children:r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>_e(Ie),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&se.mutate(Ie.id)},children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},Ie.id))})]})})})]}),r.jsxs(hs,{value:"private-groups",className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Private groups visible only to assigned members or brokerages"}),r.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r.jsx(Ni,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),r.jsxs(X,{onClick:Ze,children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-[50px]",children:"Order"}),r.jsx(Mt,{className:"w-[80px]",children:"Icon"}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{className:"w-[120px]",children:"Members"}),r.jsx(Mt,{className:"w-[140px]",children:"Actions"})]})}),r.jsx(Bn,{children:W?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):q.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No private groups yet. Create your first one!"})}):q.map((Ie,We)=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===0,onClick:()=>ce.mutate({id:Ie.id,direction:"up"}),children:"↑"}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:We===q.length-1,onClick:()=>ce.mutate({id:Ie.id,direction:"down"}),children:"↓"})]})}),r.jsx(dt,{className:"text-2xl",children:Ie.icon||"🔒"}),r.jsx(dt,{className:"font-medium",children:r.jsxs("div",{className:"flex items-center gap-2",children:[Ie.name,Ie.brokerage_id?r.jsxs(_t,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[r.jsx(Ni,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):r.jsxs(_t,{variant:"secondary",className:"text-xs",children:[r.jsx(Du,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),r.jsx(dt,{className:"text-muted-foreground",children:Ie.description||"—"}),r.jsx(dt,{children:r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>Ae(Ie),children:[r.jsx(ws,{className:"h-4 w-4 mr-1"}),"Manage"]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex gap-1",children:[!Ie.brokerage_id&&r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>Me(Ie),children:r.jsx(Qa,{className:"h-4 w-4"})}),!Ie.brokerage_id&&r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this private group? All posts in this group will be deleted.")&&de.mutate(Ie.id)},children:r.jsx(Os,{className:"h-4 w-4"})}),Ie.brokerage_id&&r.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Ie.id))})]})})})]})]}),r.jsx(Ir,{open:a,onOpenChange:o,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:l?"Edit Category":"Create Category"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),r.jsx(Ye,{value:d.icon,onChange:Ie=>m(We=>({...We,icon:Ie.target.value})),placeholder:"💬",className:"mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium",children:"Name *"}),r.jsx(Ye,{value:d.name,onChange:Ie=>m(We=>({...We,name:Ie.target.value})),placeholder:"Category name",className:"mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium",children:"Description"}),r.jsx(qs,{value:d.description,onChange:Ie=>m(We=>({...We,description:Ie.target.value})),placeholder:"Brief description of this category",className:"mt-1"})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),r.jsx(X,{onClick:()=>oe.mutate({...d,id:l==null?void 0:l.id}),disabled:!d.name.trim(),children:l?"Save Changes":"Create Category"})]})]})]})}),r.jsx(Ir,{open:p,onOpenChange:g,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:v?"Edit Private Group":"Create Private Group"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium",children:"Icon (emoji)"}),r.jsx(Ye,{value:k.icon,onChange:Ie=>w(We=>({...We,icon:Ie.target.value})),placeholder:"🔒",className:"mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium",children:"Name *"}),r.jsx(Ye,{value:k.name,onChange:Ie=>w(We=>({...We,name:Ie.target.value})),placeholder:"e.g., Pioneers",className:"mt-1"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium",children:"Description"}),r.jsx(qs,{value:k.description,onChange:Ie=>w(We=>({...We,description:Ie.target.value})),placeholder:"Brief description of this private group",className:"mt-1"})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>g(!1),children:"Cancel"}),r.jsx(X,{onClick:()=>ie.mutate({...k,id:v==null?void 0:v.id}),disabled:!k.name.trim(),children:v?"Save Changes":"Create Private Group"})]})]})]})}),r.jsx(Ir,{open:S,onOpenChange:T,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Manage Members: ",C==null?void 0:C.name]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs(ii,{defaultValue:"brokerages",children:[r.jsxs(si,{className:"w-full",children:[r.jsx(Kr,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),r.jsx(Kr,{value:"users",className:"flex-1",children:"Individual Users"})]}),r.jsxs(hs,{value:"brokerages",className:"space-y-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Select brokerages to grant all their agents access to this private group."}),r.jsx(To,{className:"h-[300px] border rounded-md p-4",children:r.jsxs("div",{className:"space-y-2",children:[ae.map(Ie=>r.jsxs("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Qo,{checked:Ue(Ie.id),onCheckedChange:()=>{C&&Te.mutate({groupId:C.id,brokerageId:Ie.id,isMember:Ue(Ie.id)})}}),r.jsx("span",{className:"font-medium",children:Ie.name})]}),r.jsxs(_t,{variant:"secondary",children:[re.filter(We=>We.brokerage_id===Ie.id).length," agents"]})]},Ie.id)),ae.length===0&&r.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),r.jsxs(hs,{value:"users",className:"space-y-4",children:[r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search users...",value:R,onChange:Ie=>D(Ie.target.value),className:"pl-9"})]}),r.jsx(To,{className:"h-[300px] border rounded-md p-4",children:r.jsxs("div",{className:"space-y-2",children:[Ve.map(Ie=>r.jsx("div",{className:"flex items-center justify-between p-2 hover:bg-muted rounded-md",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Qo,{checked:Le(Ie.id),onCheckedChange:()=>{C&&ge.mutate({groupId:C.id,userId:Ie.id,isMember:Le(Ie.id)})}}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:Ie.name}),r.jsx("div",{className:"text-sm text-muted-foreground",children:Ie.email})]})]})},Ie.id)),Ve.length===0&&r.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No users found"})]})})]})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx(X,{onClick:()=>T(!1),children:"Done"})})]})]})})]})})},fMe=e=>{switch(e){case"academy_video":return r.jsx(tc,{className:"h-3 w-3"});case"template":return r.jsx(ya,{className:"h-3 w-3"});case"toolbox":return r.jsx(ec,{className:"h-3 w-3"});case"newsletter":return r.jsx(Vy,{className:"h-3 w-3"});case"social_swag":return r.jsx(bn,{className:"h-3 w-3"});default:return r.jsx(jn,{className:"h-3 w-3"})}},cIt=e=>{switch(e){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 e}},dIt=e=>{switch(e){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 e}},uIt=()=>{const{toast:e}=_i(),[t,s]=A.useState([]),[n,a]=A.useState([]),[o,l]=A.useState([]),[i,d]=A.useState(!0),[m,p]=A.useState(""),[g,v]=A.useState(null),[_,k]=A.useState([]),[w,S]=A.useState([]);A.useEffect(()=>{T()},[]);const T=async()=>{try{d(!0);const{data:D,error:B}=await Y.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:q}=await Y.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(q)throw q;const W=[...new Set(($==null?void 0:$.map(ie=>ie.user_id))||[])],{data:K}=await Y.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",W),re=new Map((K==null?void 0:K.map(ie=>[ie.id,ie]))||[]),ae=(D==null?void 0:D.map(ie=>{var de,ce,ge,Te;return{id:ie.id,user_id:ie.user_id,app_name:ie.app_name,launched_at:ie.launched_at,user_name:((de=ie.profiles)==null?void 0:de.name)||"Unknown",user_email:((ce=ie.profiles)==null?void 0:ce.email)||"Unknown",brokerage_name:((Te=(ge=ie.profiles)==null?void 0:ge.brokerages)==null?void 0:Te.name)||null}}))||[],oe=($==null?void 0:$.map(ie=>{var ce;const de=re.get(ie.user_id);return{id:ie.id,user_id:ie.user_id,resource_type:ie.resource_type,resource_id:ie.resource_id,resource_title:ie.resource_title,action_type:ie.action_type,created_at:ie.created_at,user_name:(de==null?void 0:de.name)||"Unknown",user_email:(de==null?void 0:de.email)||"Unknown",brokerage_name:((ce=de==null?void 0:de.brokerages)==null?void 0:ce.name)||null}}))||[];s(ae),a(oe);const se=new Map;ae.forEach(ie=>{if(!se.has(ie.user_id))se.set(ie.user_id,{user_id:ie.user_id,user_name:ie.user_name,user_email:ie.user_email,brokerage_name:ie.brokerage_name,last_activity_type:"app",last_activity_name:ie.app_name,last_activity_at:ie.launched_at,total_app_launches:1,total_content_views:0});else{const de=se.get(ie.user_id);de.total_app_launches++,new Date(ie.launched_at)>new Date(de.last_activity_at)&&(de.last_activity_type="app",de.last_activity_name=ie.app_name,de.last_activity_at=ie.launched_at)}}),oe.forEach(ie=>{if(!se.has(ie.user_id))se.set(ie.user_id,{user_id:ie.user_id,user_name:ie.user_name,user_email:ie.user_email,brokerage_name:ie.brokerage_name,last_activity_type:ie.resource_type,last_activity_name:ie.resource_title,last_activity_at:ie.created_at,total_app_launches:0,total_content_views:1});else{const de=se.get(ie.user_id);de.total_content_views++,new Date(ie.created_at)>new Date(de.last_activity_at)&&(de.last_activity_type=ie.resource_type,de.last_activity_name=ie.resource_title,de.last_activity_at=ie.created_at)}});const pe=Array.from(se.values()).sort((ie,de)=>new Date(de.last_activity_at).getTime()-new Date(ie.last_activity_at).getTime());l(pe)}catch(D){console.error("Error loading activity:",D),e({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{d(!1)}},C=D=>{v({id:D.user_id,name:D.user_name,email:D.user_email});const B=t.filter(q=>q.user_id===D.user_id),$=n.filter(q=>q.user_id===D.user_id);k(B),S($)},I=()=>{v(null),k([]),S([])},R=o.filter(D=>{var $;if(!m)return!0;const B=m.toLowerCase();return D.user_name.toLowerCase().includes(B)||D.user_email.toLowerCase().includes(B)||(($=D.brokerage_name)==null?void 0:$.toLowerCase().includes(B))});return i?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"User Activity"}),r.jsx(Cs,{children:"App launches and content engagement - click to see full history"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"mb-4",children:r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name, email, or brokerage...",value:m,onChange:D=>p(D.target.value),className:"pl-9"})]})}),r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"User"}),r.jsx(Mt,{children:"Brokerage"}),r.jsx(Mt,{children:"Last Activity"}),r.jsx(Mt,{children:"Last Active"}),r.jsx(Mt,{className:"text-right",children:"Apps"}),r.jsx(Mt,{className:"text-right",children:"Content"})]})}),r.jsx(Bn,{children:R.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):R.map(D=>r.jsxs(Nr,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>C(D),children:[r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:D.user_name}),r.jsx("div",{className:"text-sm text-muted-foreground",children:D.user_email})]})}),r.jsx(dt,{children:D.brokerage_name?r.jsx(_t,{variant:"outline",children:D.brokerage_name}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),r.jsx(dt,{children:r.jsx("div",{className:"flex items-center gap-2",children:D.last_activity_type==="app"?r.jsxs(_t,{variant:"secondary",children:[r.jsx(jn,{className:"h-3 w-3 mr-1"}),D.last_activity_name]}):r.jsxs(_t,{variant:"outline",className:"flex items-center gap-1",children:[fMe(D.last_activity_type),r.jsx("span",{className:"max-w-32 truncate",children:D.last_activity_name})]})})}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:gu(new Date(D.last_activity_at),{addSuffix:!0})}),r.jsx(dt,{className:"text-right",children:r.jsx(_t,{variant:"outline",children:D.total_app_launches})}),r.jsx(dt,{className:"text-right",children:r.jsx(_t,{variant:"outline",children:D.total_content_views})})]},D.user_id))})]})})]})]}),r.jsx(Ir,{open:!!g,onOpenChange:D=>!D&&I(),children:r.jsxs(Er,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{children:[g==null?void 0:g.name,"'s Activity"]}),r.jsx(Zs,{children:g==null?void 0:g.email})]}),r.jsxs(ii,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[r.jsxs(si,{className:"grid w-full grid-cols-2",children:[r.jsxs(Kr,{value:"content",children:["Content (",w.length,")"]}),r.jsxs(Kr,{value:"apps",children:["App Launches (",_.length,")"]})]}),r.jsx(hs,{value:"content",className:"flex-1 overflow-auto mt-4",children:r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Type"}),r.jsx(Mt,{children:"Resource"}),r.jsx(Mt,{children:"Action"}),r.jsx(Mt,{children:"Time"})]})}),r.jsx(Bn,{children:w.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):w.map(D=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs(_t,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[fMe(D.resource_type),cIt(D.resource_type)]})}),r.jsx(dt,{className:"max-w-48",children:r.jsx("span",{className:"truncate block",children:D.resource_title})}),r.jsx(dt,{children:r.jsx(_t,{variant:"secondary",children:dIt(D.action_type)})}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:gu(new Date(D.created_at),{addSuffix:!0})})]},D.id))})]})})}),r.jsx(hs,{value:"apps",className:"flex-1 overflow-auto mt-4",children:r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"App"}),r.jsx(Mt,{children:"Time"})]})}),r.jsx(Bn,{children:_.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):_.map(D=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsx(_t,{variant:"secondary",children:D.app_name})}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:gu(new Date(D.launched_at),{addSuffix:!0})})]},D.id))})]})})})]})]})})]})},hIt=()=>{const{toast:e}=_i(),[t,s]=A.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=A.useState(!0);A.useEffect(()=>{o()},[]);const o=async()=>{try{a(!0);const{count:l}=await Y.from("profiles").select("*",{count:"exact",head:!0}),{count:i}=await Y.from("profiles").select("*",{count:"exact",head:!0}).not("last_login","is",null),d=(l||0)-(i||0),{count:m}=await Y.from("brokerages").select("*",{count:"exact",head:!0}),{count:p}=await Y.from("activity_logs").select("*",{count:"exact",head:!0}),g=new Date;g.setDate(g.getDate()-7);const{count:v}=await Y.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",g.toISOString()),_=new Date;_.setMonth(_.getMonth()-1);const{count:k}=await Y.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",_.toISOString()),{data:w}=await Y.from("activity_logs").select("user_id").gte("launched_at",g.toISOString()),S=new Set(w==null?void 0:w.map(T=>T.user_id)).size;s({totalUsers:l||0,activeUsers:i||0,pendingUsers:d,totalBrokerages:m||0,totalLaunches:p||0,launchesThisWeek:v||0,launchesThisMonth:k||0,uniqueActiveThisWeek:S})}catch(l){console.error("Error loading analytics:",l),e({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{a(!1)}};return n?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):r.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Total Users"}),r.jsx(ws,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.totalUsers}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.activeUsers," active, ",t.pendingUsers," pending"]})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Active Users"}),r.jsx(ui,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.activeUsers}),r.jsx("p",{className:"text-xs text-muted-foreground",children:t.totalUsers>0?`${Math.round(t.activeUsers/t.totalUsers*100)}% of total`:"0% of total"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Pending Invites"}),r.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.pendingUsers}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Brokerages"}),r.jsx(Ni,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.totalBrokerages}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Total brokerages"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Total App Launches"}),r.jsx(lx,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.totalLaunches}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Launches This Week"}),r.jsx(lx,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.launchesThisWeek}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Launches This Month"}),r.jsx(lx,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.launchesThisMonth}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Active This Week"}),r.jsx(pu,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:t.uniqueActiveThisWeek}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},pMe={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},gMe={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 eHe({brokerageOnly:e=!1,brokerageId:t}){const[s,n]=A.useState([]),[a,o]=A.useState(!0),[l,i]=A.useState(""),[d,m]=A.useState("all");A.useEffect(()=>{p()},[t]);const p=async()=>{o(!0);try{let T=[];if(e&&t){const{data:W}=await Y.from("profiles").select("id").eq("brokerage_id",t);if(T=(W==null?void 0:W.map(K=>K.id))||[],T.length===0){n([]),o(!1);return}}let C=Y.from("resource_shares").select("*").order("created_at",{ascending:!1});e&&T.length>0&&(C=C.or(`sender_id.in.(${T.join(",")}),recipient_id.in.(${T.join(",")})`));const{data:I,error:R}=await C;if(R)throw R;const D=new Set;I==null||I.forEach(W=>{D.add(W.sender_id),D.add(W.recipient_id)});const{data:B}=await Y.from("profiles").select("id, name, email").in("id",Array.from(D)),$=new Map((B==null?void 0:B.map(W=>[W.id,W]))||[]),q=(I==null?void 0:I.map(W=>({...W,sender:$.get(W.sender_id),recipient:$.get(W.recipient_id)})))||[];n(q)}catch(T){console.error("Error loading shares:",T)}finally{o(!1)}},g=s.filter(T=>{var R,D;const C=l===""||T.resource_title.toLowerCase().includes(l.toLowerCase())||((R=T.sender)==null?void 0:R.name.toLowerCase().includes(l.toLowerCase()))||((D=T.recipient)==null?void 0:D.name.toLowerCase().includes(l.toLowerCase())),I=d==="all"||T.resource_type===d;return C&&I}),v=s.length,_=new Set(s.map(T=>T.sender_id)).size,k=new Set(s.map(T=>T.recipient_id)).size,w=s.length>0?Math.round(s.filter(T=>T.is_read).length/s.length*100):0,S=s.reduce((T,C)=>(T[C.resource_type]=(T[C.resource_type]||0)+1,T),{});return a?r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[...Array(4)].map((T,C)=>r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(pr,{className:"h-4 w-20"})}),r.jsx(qe,{children:r.jsx(pr,{className:"h-8 w-16"})})]},C))}),r.jsx(ze,{children:r.jsx(qe,{className:"p-6",children:r.jsx(pr,{className:"h-[300px]"})})})]}):r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Total Shares"}),r.jsx(Uc,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:v})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Active Sharers"}),r.jsx(ws,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:_})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Recipients Reached"}),r.jsx(pu,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:k})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Read Rate"}),r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsx(qe,{children:r.jsxs("div",{className:"text-2xl font-bold",children:[w,"%"]})})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),r.jsx(qe,{children:r.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(S).map(([T,C])=>r.jsxs(_t,{variant:"secondary",className:gMe[T],children:[pMe[T],": ",C]},T)),Object.keys(S).length===0&&r.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Share History"}),r.jsxs(Cs,{children:["All resource shares ",e?"in your brokerage":"across the platform"]})]}),r.jsxs(qe,{children:[r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by resource, sender, or recipient...",value:l,onChange:T=>i(T.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:d,onValueChange:m,children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{placeholder:"Resource type"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Types"}),r.jsx(Ut,{value:"event",children:"Events"}),r.jsx(Ut,{value:"template",children:"Templates"}),r.jsx(Ut,{value:"academy_video",children:"Academy Videos"}),r.jsx(Ut,{value:"resource_kit",children:"Resource Kits"}),r.jsx(Ut,{value:"newsletter",children:"Newsletters"}),r.jsx(Ut,{value:"social_swag",children:"Social Swag"})]})]})]}),r.jsx(To,{className:"h-[400px]",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Resource"}),r.jsx(Mt,{children:"Type"}),r.jsx(Mt,{children:"Sender"}),r.jsx(Mt,{children:"Recipient"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Date"})]})}),r.jsx(Bn,{children:g.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):g.map(T=>{var C,I;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium max-w-[200px] truncate",children:T.resource_title}),r.jsx(dt,{children:r.jsx(_t,{variant:"secondary",className:gMe[T.resource_type],children:pMe[T.resource_type]})}),r.jsx(dt,{children:((C=T.sender)==null?void 0:C.name)||"Unknown"}),r.jsx(dt,{children:((I=T.recipient)==null?void 0:I.name)||"Unknown"}),r.jsx(dt,{children:r.jsx(_t,{variant:T.is_read?"default":"outline",children:T.is_read?"Read":"Unread"})}),r.jsx(dt,{className:"text-muted-foreground",children:Xr(new Date(T.created_at),"MMM d, yyyy")})]},T.id)})})]})})]})]})]})}const mIt=()=>r.jsx(Ur,{title:"Analytics",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Analytics & Activity"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Platform-wide usage statistics and user activity"})]}),r.jsxs(ii,{defaultValue:"analytics",className:"space-y-4",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"analytics",children:"Analytics"}),r.jsx(Kr,{value:"activity",children:"Activity"}),r.jsx(Kr,{value:"shares",children:"Shares"})]}),r.jsx(hs,{value:"analytics",className:"space-y-4",children:r.jsx(hIt,{})}),r.jsx(hs,{value:"activity",className:"space-y-4",children:r.jsx(uIt,{})}),r.jsx(hs,{value:"shares",className:"space-y-4",children:r.jsx(eHe,{})})]})]})});function fIt(){const e=Rr(),[t,s]=A.useState(!1),[n,a]=A.useState(null),[o,l]=A.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,d]=A.useState(null),[m,p]=A.useState(""),[g,v]=A.useState([]),[_,k]=A.useState([]),[w,S]=A.useState([]),[T,C]=A.useState(!1),[I,R]=A.useState(null),[D,B]=A.useState(""),{data:$,isLoading:q}=Ht({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:Pe,error:st}=await Y.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(st)throw st;return Pe}}),{data:W}=Ht({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:Pe,error:st}=await Y.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Pe}}),{data:K}=Ht({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:Pe,error:st}=await Y.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Pe}}),{data:re}=Ht({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:Pe,error:st}=await Y.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Pe}}),{data:ae,isLoading:oe}=Ht({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:Pe,error:st}=await Y.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(st)throw st;return Pe}}),se=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),d(null),p(""),v([]),k([]),S([]),a(null),B("")},pe=Pe=>{a(Pe),l({title:Pe.title,description:Pe.description||"",publish_date:Pe.publish_date.split("T")[0],is_published:Pe.is_published,category_id:Pe.category_id||""}),p(Pe.preview_image_url||""),B("");const st=(W==null?void 0:W.filter(tt=>tt.resource_id===Pe.id))||[];v(st.map(tt=>({id:tt.id,name:tt.name,file_url:tt.file_url,file_size:tt.file_size,sort_order:tt.sort_order})));const ue=(K==null?void 0:K.filter(tt=>tt.resource_id===Pe.id))||[];k(ue.map(tt=>({id:tt.id,title:tt.title,video_url:tt.video_url,sort_order:tt.sort_order})));const $e=(re==null?void 0:re.filter(tt=>tt.resource_id===Pe.id))||[];S($e.map(tt=>({id:tt.id,title:tt.title,canva_share_link:tt.canva_share_link,sort_order:tt.sort_order}))),s(!0)},ie=Pe=>{var ue;const st=(ue=Pe.target.files)==null?void 0:ue[0];st&&(d(st),p(URL.createObjectURL(st)))},de=()=>{v([...g,{name:"",file_url:"",sort_order:g.length}])},ce=Pe=>{v(g.filter((st,ue)=>ue!==Pe))},ge=(Pe,st,ue)=>{const $e=[...g];if(st==="file"&&ue instanceof File){const tt=ue.name.replace(/\.[^/.]+$/,"");$e[Pe]={...$e[Pe],file:ue,file_size:ue.size,name:$e[Pe].name||tt}}else $e[Pe]={...$e[Pe],[st]:ue};v($e)},Te=()=>{k([..._,{title:"",video_url:"",sort_order:_.length}])},_e=Pe=>{k(_.filter((st,ue)=>ue!==Pe))},ve=(Pe,st,ue)=>{const $e=[..._];st==="file"&&ue instanceof File?$e[Pe]={...$e[Pe],file:ue}:$e[Pe]={...$e[Pe],[st]:ue},k($e)},Me=()=>{S([...w,{title:"",canva_share_link:"",sort_order:w.length}])},Ze=Pe=>{S(w.filter((st,ue)=>ue!==Pe))},Ae=(Pe,st,ue)=>{const $e=[...w];$e[Pe]={...$e[Pe],[st]:ue},S($e)},Le=async(Pe,st)=>{try{const ue=await Y.functions.invoke("bunny-upload",{body:{action:"create",title:Pe.name}});if(ue.error)throw ue.error;const{videoId:$e,uploadUrl:tt,libraryId:rt}=ue.data,je=await Y.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:$e,libraryId:rt}});if(je.error)throw je.error;const{uploadUrl:it,apiKey:Se}=je.data,et=new XMLHttpRequest;return et.open("PUT",it,!0),et.setRequestHeader("AccessKey",Se),et.upload.onprogress=Qe=>{if(Qe.lengthComputable){const He=Math.round(Qe.loaded/Qe.total*100),ot=[..._];ot[st]={...ot[st],uploadProgress:He},k(ot)}},await new Promise((Qe,He)=>{et.onload=()=>et.status>=200&&et.status<300?Qe():He(new Error("Upload failed")),et.onerror=()=>He(new Error("Upload failed")),et.send(Pe)}),`https://iframe.mediadelivery.net/embed/${rt}/${$e}`}catch(ue){throw console.error("Bunny upload error:",ue),ue}},Ue=Qt({mutationFn:async Pe=>{const{data:st,error:ue}=await Y.from("brokerage_resource_categories").insert({name:Pe,sort_order:(ae==null?void 0:ae.length)||0}).select().single();if(ue)throw ue;return st},onSuccess:Pe=>{e.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:Pe.id}),B(""),we.success("Category created")},onError:Pe=>{we.error("Failed to create category: "+Pe.message)}}),Ve=Qt({mutationFn:async()=>{C(!0);let Pe=(n==null?void 0:n.preview_image_url)||null;if(i){const $e=i.name.split(".").pop(),tt=`${Date.now()}.${$e}`,{error:rt}=await Y.storage.from("brokerage-resources").upload(`previews/${tt}`,i);if(rt)throw rt;const{data:je}=Y.storage.from("brokerage-resources").getPublicUrl(`previews/${tt}`);Pe=je.publicUrl}const st={title:o.title,description:o.description||null,preview_image_url:Pe,publish_date:o.publish_date,is_published:o.is_published,category_id:o.category_id||null};let ue;if(n){const{error:$e}=await Y.from("brokerage_resources").update(st).eq("id",n.id);if($e)throw $e;ue=n.id;const tt=(W==null?void 0:W.filter(ut=>ut.resource_id===n.id).map(ut=>ut.id))||[],rt=g.filter(ut=>ut.id).map(ut=>ut.id),je=tt.filter(ut=>!rt.includes(ut));je.length>0&&await Y.from("brokerage_resource_pdfs").delete().in("id",je);const it=(K==null?void 0:K.filter(ut=>ut.resource_id===n.id).map(ut=>ut.id))||[],Se=_.filter(ut=>ut.id).map(ut=>ut.id),et=it.filter(ut=>!Se.includes(ut));et.length>0&&await Y.from("brokerage_resource_videos").delete().in("id",et);const Qe=(re==null?void 0:re.filter(ut=>ut.resource_id===n.id).map(ut=>ut.id))||[],He=w.filter(ut=>ut.id).map(ut=>ut.id),ot=Qe.filter(ut=>!He.includes(ut));ot.length>0&&await Y.from("brokerage_resource_links").delete().in("id",ot)}else{const{data:$e,error:tt}=await Y.from("brokerage_resources").insert(st).select().single();if(tt)throw tt;ue=$e.id}for(let $e=0;$e{e.invalidateQueries({queryKey:["brokerage-resources"]}),e.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),e.invalidateQueries({queryKey:["brokerage-resource-videos"]}),e.invalidateQueries({queryKey:["brokerage-resource-links"]}),we.success(n?"Resource updated":"Resource created"),s(!1),se(),C(!1)},onError:Pe=>{we.error("Failed to save resource: "+Pe.message),C(!1)}}),Ie=Qt({mutationFn:async Pe=>{const{error:st}=await Y.from("brokerage_resources").delete().eq("id",Pe);if(st)throw st},onSuccess:()=>{e.invalidateQueries({queryKey:["brokerage-resources"]}),e.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),e.invalidateQueries({queryKey:["brokerage-resource-videos"]}),e.invalidateQueries({queryKey:["brokerage-resource-links"]}),we.success("Resource deleted")},onError:Pe=>{we.error("Failed to delete: "+Pe.message)}}),We=Pe=>{if(Pe.preventDefault(),!o.title){we.error("Please enter a title");return}Ve.mutate()},wt=Pe=>{const st=(W==null?void 0:W.filter(tt=>tt.resource_id===Pe).length)||0,ue=(K==null?void 0:K.filter(tt=>tt.resource_id===Pe).length)||0,$e=(re==null?void 0:re.filter(tt=>tt.resource_id===Pe).length)||0;return{pdfCount:st,videoCount:ue,linkCount:$e}};return r.jsx(Ur,{title:"Brokerage Resources Management",description:"Create and manage resources for brokerage managers",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.length)||0})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:($==null?void 0:$.filter(Pe=>Pe.is_published).length)||0})})]})]}),r.jsxs(X,{onClick:()=>{se(),s(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Category"}),r.jsx(Mt,{children:"Content"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:q?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):($==null?void 0:$.length)===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):$==null?void 0:$.map(Pe=>{const{pdfCount:st,videoCount:ue,linkCount:$e}=wt(Pe.id),tt=ae==null?void 0:ae.find(rt=>rt.id===Pe.category_id);return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[Pe.preview_image_url?r.jsx("img",{src:Pe.preview_image_url,alt:Pe.title,className:"w-10 h-10 rounded object-cover"}):r.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:r.jsx(Pu,{className:"h-5 w-5 text-muted-foreground"})}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:Pe.title}),Pe.description&&r.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Pe.description})]})]})}),r.jsx(dt,{children:tt?r.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:tt.name}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ya,{className:"h-3.5 w-3.5"}),st]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ma,{className:"h-3.5 w-3.5"}),ue]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Lo,{className:"h-3.5 w-3.5"}),$e]})]})}),r.jsx(dt,{children:Xr(new Date(Pe.publish_date),"MMM d, yyyy")}),r.jsx(dt,{children:r.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${Pe.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,children:Pe.is_published?"Published":"Draft"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{const rt=(W==null?void 0:W.filter(Se=>Se.resource_id===Pe.id))||[],je=(K==null?void 0:K.filter(Se=>Se.resource_id===Pe.id))||[],it=(re==null?void 0:re.filter(Se=>Se.resource_id===Pe.id))||[];R({...Pe,pdfs:rt,videos:je,links:it})},children:r.jsx(Ii,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>pe(Pe),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Ie.mutate(Pe.id)},children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},Pe.id)})})]})})}),r.jsx(Ir,{open:t,onOpenChange:s,children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),r.jsxs("form",{onSubmit:We,className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Preview Image"}),r.jsxs("div",{className:"flex items-center gap-4",children:[m?r.jsx("img",{src:m,alt:"Preview",className:"w-24 h-24 rounded object-cover"}):r.jsx("div",{className:"w-24 h-24 rounded bg-muted flex items-center justify-center",children:r.jsx(Pu,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx(Ye,{type:"file",accept:"image/*",onChange:ie})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title *"}),r.jsx(Ye,{id:"title",value:o.title,onChange:Pe=>l({...o,title:Pe.target.value}),placeholder:"Resource Title"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{className:"flex items-center gap-2",children:[r.jsx(px,{className:"h-4 w-4"}),"Category"]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ds,{value:o.category_id,onValueChange:Pe=>l({...o,category_id:Pe}),children:[r.jsx(ls,{className:"flex-1",children:r.jsx(us,{placeholder:"Select a category"})}),r.jsx(cs,{children:ae==null?void 0:ae.map(Pe=>r.jsx(Ut,{value:Pe.id,children:Pe.name},Pe.id))})]}),o.category_id&&r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>l({...o,category_id:""}),children:r.jsx(Xs,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{placeholder:"Or create new category...",value:D,onChange:Pe=>B(Pe.target.value),className:"flex-1"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",disabled:!D.trim()||Ue.isPending,onClick:()=>Ue.mutate(D.trim()),children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:o.description,onChange:Pe=>l({...o,description:Pe}),placeholder:"Brief description of this resource",minHeight:"120px"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"publish_date",children:"Publish Date"}),r.jsx(Ye,{id:"publish_date",type:"date",value:o.publish_date,onChange:Pe=>l({...o,publish_date:Pe.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Published"}),r.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[r.jsx(fn,{checked:o.is_published,onCheckedChange:Pe=>l({...o,is_published:Pe})}),r.jsx("span",{className:"text-sm text-muted-foreground",children:o.is_published?"Visible to brokerage managers":"Hidden from brokerage managers"})]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Ee,{className:"flex items-center gap-2",children:[r.jsx(ya,{className:"h-4 w-4"}),"PDF Documents (",g.length,")"]}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:de,children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add PDF"]})]}),g.map((Pe,st)=>r.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[r.jsx(Ye,{placeholder:"PDF Name",value:Pe.name,onChange:ue=>ge(st,"name",ue.target.value),className:"flex-1"}),r.jsx(Ye,{type:"file",accept:".pdf",onChange:ue=>{var tt;const $e=(tt=ue.target.files)==null?void 0:tt[0];$e&&ge(st,"file",$e)},className:"flex-1"}),Pe.file_url&&!Pe.file&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"Uploaded"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>ce(st),children:r.jsx(Xs,{className:"h-4 w-4"})})]},st))]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Ee,{className:"flex items-center gap-2",children:[r.jsx(ma,{className:"h-4 w-4"}),"Videos (",_.length,")"]}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:Te,children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),_.map((Pe,st)=>r.jsxs("div",{className:"space-y-2 p-3 border rounded-lg bg-muted/50",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ye,{placeholder:"Video Title",value:Pe.title,onChange:ue=>ve(st,"title",ue.target.value),className:"flex-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>_e(st),children:r.jsx(Xs,{className:"h-4 w-4"})})]}),r.jsx(Ye,{type:"file",accept:"video/*",onChange:ue=>{var tt;const $e=(tt=ue.target.files)==null?void 0:tt[0];$e&&ve(st,"file",$e)}}),Pe.uploadProgress!==void 0&&Pe.uploadProgress>0&&r.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:r.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${Pe.uploadProgress}%`}})}),Pe.video_url&&!Pe.file&&r.jsx("span",{className:"text-xs text-muted-foreground",children:"Video uploaded"})]},st))]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Ee,{className:"flex items-center gap-2",children:[r.jsx(Lo,{className:"h-4 w-4"}),"Canva Links (",w.length,")"]}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:Me,children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),w.map((Pe,st)=>r.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg bg-muted/50",children:[r.jsx(Ye,{placeholder:"Link Title",value:Pe.title,onChange:ue=>Ae(st,"title",ue.target.value),className:"flex-1"}),r.jsx(Ye,{placeholder:"Canva Share Link",value:Pe.canva_share_link,onChange:ue=>Ae(st,"canva_share_link",ue.target.value),className:"flex-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ze(st),children:r.jsx(Xs,{className:"h-4 w-4"})})]},st))]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),r.jsx(X,{type:"submit",disabled:Ve.isPending||T,children:Ve.isPending||T?"Saving...":n?"Update":"Create"})]})]})]})}),r.jsx(Ir,{open:!!I,onOpenChange:()=>R(null),children:r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:I==null?void 0:I.title})}),I&&r.jsxs("div",{className:"space-y-4",children:[I.preview_image_url&&r.jsx("img",{src:I.preview_image_url,alt:I.title,className:"w-full h-48 object-cover rounded-lg"}),I.description&&r.jsx("p",{className:"text-muted-foreground",children:I.description}),I.pdfs&&I.pdfs.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[r.jsx(ya,{className:"h-4 w-4"}),"PDF Documents (",I.pdfs.length,")"]}),r.jsx("div",{className:"space-y-1",children:I.pdfs.map(Pe=>r.jsx("a",{href:Pe.file_url,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Pe.name},Pe.id))})]}),I.videos&&I.videos.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[r.jsx(ma,{className:"h-4 w-4"}),"Videos (",I.videos.length,")"]}),r.jsx("div",{className:"space-y-2",children:I.videos.map(Pe=>r.jsx("div",{className:"p-2 border rounded",children:r.jsx("p",{className:"font-medium text-sm",children:Pe.title})},Pe.id))})]}),I.links&&I.links.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[r.jsx(Lo,{className:"h-4 w-4"}),"Canva Links (",I.links.length,")"]}),r.jsx("div",{className:"space-y-1",children:I.links.map(Pe=>r.jsx("a",{href:Pe.canva_share_link,target:"_blank",rel:"noopener noreferrer",className:"block p-2 border rounded hover:bg-muted",children:Pe.title},Pe.id))})]})]})]})})]})})}const tHe=[{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 pIt(){const[e,t]=A.useState([]),[s,n]=A.useState(!0),[a,o]=A.useState(!1),[l,i]=A.useState(!1),[d,m]=A.useState(null),[p,g]=A.useState(!1),[v,_]=A.useState(!1),[k,w]=A.useState(""),[S,T]=A.useState(""),[C,I]=A.useState(""),[R,D]=A.useState(""),[B,$]=A.useState("Learn More"),[q,W]=A.useState("top"),[K,re]=A.useState(""),[ae,oe]=A.useState(!0),[se,pe]=A.useState(""),[ie,de]=A.useState("");A.useEffect(()=>{ce()},[]);const ce=async()=>{try{const{data:Ue,error:Ve}=await Y.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Ve)throw Ve;t(Ue||[])}catch(Ue){we.error("Failed to load banners: "+Ue.message)}finally{n(!1)}},ge=()=>{w(""),T(""),I(""),D(""),$("Learn More"),W("top"),re(""),oe(!0),pe(""),de(""),m(null)},Te=Ue=>{m(Ue),w(Ue.title),T(Ue.description||""),I(Ue.image_url),D(Ue.link_url||""),$(Ue.link_text||"Learn More"),W(Ue.placement),re(Ue.section_after||""),oe(Ue.is_active),pe(Ue.start_date?Xr(new Date(Ue.start_date),"yyyy-MM-dd'T'HH:mm"):""),de(Ue.end_date?Xr(new Date(Ue.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},_e=async Ue=>{var Ie;const Ve=(Ie=Ue.target.files)==null?void 0:Ie[0];if(Ve){g(!0);try{const We=Ve.name.split(".").pop(),wt=`${Date.now()}.${We}`,{error:Pe}=await Y.storage.from("banner-images").upload(wt,Ve);if(Pe)throw Pe;const{data:{publicUrl:st}}=Y.storage.from("banner-images").getPublicUrl(wt);I(st),we.success("Image uploaded successfully")}catch(We){we.error("Failed to upload image: "+We.message)}finally{g(!1)}}},ve=async()=>{if(!k.trim()||!C){we.error("Please fill in required fields (title and image)");return}_(!0);try{const Ue={title:k.trim(),description:S.trim()||null,image_url:C,link_url:R.trim()||null,link_text:B.trim()||"Learn More",placement:q,section_after:q==="between"?K:null,is_active:ae,start_date:se?new Date(se).toISOString():null,end_date:ie?new Date(ie).toISOString():null};if(d){const{error:Ve}=await Y.from("dashboard_banners").update(Ue).eq("id",d.id);if(Ve)throw Ve;we.success("Banner updated successfully")}else{const Ve=e.filter(We=>We.placement===q).length,{error:Ie}=await Y.from("dashboard_banners").insert({...Ue,sort_order:Ve});if(Ie)throw Ie;we.success("Banner created successfully")}o(!1),ge(),ce()}catch(Ue){we.error("Failed to save banner: "+Ue.message)}finally{_(!1)}},Me=async()=>{if(d)try{const{error:Ue}=await Y.from("dashboard_banners").delete().eq("id",d.id);if(Ue)throw Ue;we.success("Banner deleted successfully"),i(!1),m(null),ce()}catch(Ue){we.error("Failed to delete banner: "+Ue.message)}},Ze=async Ue=>{try{const{error:Ve}=await Y.from("dashboard_banners").update({is_active:!Ue.is_active}).eq("id",Ue.id);if(Ve)throw Ve;we.success(Ue.is_active?"Banner deactivated":"Banner activated"),ce()}catch(Ve){we.error("Failed to update banner: "+Ve.message)}},Ae=e.filter(Ue=>Ue.placement==="top"),Le=e.filter(Ue=>Ue.placement==="between");return s?r.jsx(Ur,{title:"Dashboard Management",children:r.jsx("div",{className:"flex items-center justify-center h-64",children:r.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):r.jsxs(Ur,{title:"Dashboard Management",description:"Configure dashboard modules and banners",children:[r.jsxs("div",{className:"space-y-8",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Nl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),r.jsx(Cs,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),r.jsxs(Ir,{open:a&&q==="top",onOpenChange:Ue=>{Ue||ge(),o(Ue),Ue&&W("top")},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{onClick:()=>{ge(),W("top")},children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Add Hero Banner"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{children:[d?"Edit":"Create"," Banner"]}),r.jsx(Zs,{children:"Configure the banner's content and display settings"})]}),r.jsx(xMe,{title:k,setTitle:w,description:S,setDescription:T,imageUrl:C,linkUrl:R,setLinkUrl:D,linkText:B,setLinkText:$,placement:q,setPlacement:W,sectionAfter:K,setSectionAfter:re,isActive:ae,setIsActive:oe,startDate:se,setStartDate:pe,endDate:ie,setEndDate:de,handleImageUpload:_e,uploading:p,showPlacementOptions:!1}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>{o(!1),ge()},children:"Cancel"}),r.jsx(X,{onClick:ve,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),r.jsx(qe,{children:Ae.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No hero banners yet. Add your first banner above."}):r.jsx("div",{className:"space-y-3",children:Ae.map(Ue=>r.jsx(yMe,{banner:Ue,onEdit:()=>Te(Ue),onDelete:()=>{m(Ue),i(!0)},onToggleActive:()=>Ze(Ue)},Ue.id))})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Nl,{className:"h-5 w-5"}),"Section Banners"]}),r.jsx(Cs,{children:"These banners appear between dashboard content sections"})]}),r.jsxs(Ir,{open:a&&q==="between",onOpenChange:Ue=>{Ue||ge(),o(Ue),Ue&&W("between")},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{onClick:()=>{ge(),W("between")},children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Add Section Banner"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{children:[d?"Edit":"Create"," Section Banner"]}),r.jsx(Zs,{children:"Configure where this banner appears between sections"})]}),r.jsx(xMe,{title:k,setTitle:w,description:S,setDescription:T,imageUrl:C,linkUrl:R,setLinkUrl:D,linkText:B,setLinkText:$,placement:q,setPlacement:W,sectionAfter:K,setSectionAfter:re,isActive:ae,setIsActive:oe,startDate:se,setStartDate:pe,endDate:ie,setEndDate:de,handleImageUpload:_e,uploading:p,showPlacementOptions:!0}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>{o(!1),ge()},children:"Cancel"}),r.jsx(X,{onClick:ve,disabled:v,children:v?"Saving...":d?"Update Banner":"Create Banner"})]})]})]})]}),r.jsx(qe,{children:Le.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No section banners yet. Add your first banner above."}):r.jsx("div",{className:"space-y-3",children:Le.map(Ue=>r.jsx(yMe,{banner:Ue,onEdit:()=>Te(Ue),onDelete:()=>{m(Ue),i(!0)},onToggleActive:()=>Ze(Ue),showSection:!0},Ue.id))})})]})]}),r.jsx(Ir,{open:l,onOpenChange:i,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Delete Banner"}),r.jsxs(Zs,{children:['Are you sure you want to delete "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),r.jsx(X,{variant:"destructive",onClick:Me,children:"Delete"})]})]})})]})}function xMe({title:e,setTitle:t,description:s,setDescription:n,imageUrl:a,linkUrl:o,setLinkUrl:l,linkText:i,setLinkText:d,placement:m,setPlacement:p,sectionAfter:g,setSectionAfter:v,isActive:_,setIsActive:k,startDate:w,setStartDate:S,endDate:T,setEndDate:C,handleImageUpload:I,uploading:R,showPlacementOptions:D}){return r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title *"}),r.jsx(Ye,{id:"title",placeholder:"Banner headline...",value:e,onChange:B=>t(B.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",placeholder:"Optional banner description...",value:s,onChange:B=>n(B.target.value),rows:2})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Banner Image *"}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(Ye,{type:"file",accept:"image/*",onChange:I,disabled:R,className:"flex-1"}),R&&r.jsx("span",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),a&&r.jsx("div",{className:"mt-2 relative rounded-lg overflow-hidden border",children:r.jsx("img",{src:a,alt:"Preview",className:"w-full h-40 object-cover"})})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"linkUrl",children:"Link URL (optional)"}),r.jsx(Ye,{id:"linkUrl",placeholder:"https://...",value:o,onChange:B=>l(B.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"linkText",children:"Button Text"}),r.jsx(Ye,{id:"linkText",placeholder:"Learn More",value:i,onChange:B=>d(B.target.value)})]})]}),D&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Placement"}),r.jsxs(ds,{value:g,onValueChange:v,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select section placement..."})}),r.jsx(cs,{children:tHe.map(B=>r.jsx(Ut,{value:B.value,children:B.label},B.value))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{htmlFor:"startDate",className:"flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4"}),"Start Date (optional)"]}),r.jsx(Ye,{id:"startDate",type:"datetime-local",value:w,onChange:B=>S(B.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{htmlFor:"endDate",className:"flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4"}),"End Date (optional)"]}),r.jsx(Ye,{id:"endDate",type:"datetime-local",value:T,onChange:B=>C(B.target.value)})]})]}),r.jsx("div",{className:"flex items-center justify-between pt-2",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"isActive",checked:_,onCheckedChange:k}),r.jsx(Ee,{htmlFor:"isActive",children:"Active"})]})})]})}function yMe({banner:e,onEdit:t,onDelete:s,onToggleActive:n,showSection:a=!1}){var l;const o=(l=tHe.find(i=>i.value===e.section_after))==null?void 0:l.label;return r.jsxs("div",{className:"flex items-center gap-4 p-3 border rounded-lg bg-card hover:bg-accent/50 transition-colors",children:[r.jsx(Df,{className:"h-5 w-5 text-muted-foreground cursor-grab"}),r.jsx("img",{src:e.image_url,alt:e.title,className:"w-24 h-14 object-cover rounded"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h4",{className:"font-medium truncate",children:e.title}),!e.is_active&&r.jsx(_t,{variant:"secondary",children:"Inactive"}),e.start_date&&new Date(e.start_date)>new Date&&r.jsx(_t,{variant:"outline",children:"Scheduled"})]}),e.description&&r.jsx("p",{className:"text-sm text-muted-foreground truncate",children:e.description}),a&&o&&r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[e.link_url&&r.jsx("a",{href:e.link_url,target:"_blank",rel:"noopener noreferrer",children:r.jsx(X,{variant:"ghost",size:"icon",children:r.jsx(jn,{className:"h-4 w-4"})})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:n,children:e.is_active?r.jsx(Ii,{className:"h-4 w-4"}):r.jsx(Lf,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:t,children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:s,children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})]})}const XO={open:{label:"Open",icon:Pa,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:Rl,color:"bg-blue-500"},resolved:{label:"Resolved",icon:ui,color:"bg-green-500"},closed:{label:"Closed",icon:Fc,color:"bg-muted-foreground"}},vMe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function gIt(){var B,$;const{user:e}=Gr(),t=Rr(),[s,n]=A.useState(null),[a,o]=A.useState(""),[l,i]=A.useState("all"),[d,m]=A.useState("all"),[p,g]=A.useState(!1),{data:v=[],isLoading:_}=Ht({queryKey:["admin-support-tickets",l,d],queryFn:async()=>{let q=Y.from("support_tickets").select("*, profiles!support_tickets_user_id_fkey(name, email)").order("created_at",{ascending:!1});l!=="all"&&(q=q.eq("status",l)),d!=="all"&&(q=q.eq("category",d));const{data:W,error:K}=await q;if(K)throw K;return W}}),{data:k=[]}=Ht({queryKey:["admin-users-notifications"],queryFn:async()=>{const{data:q,error:W}=await Y.from("user_roles").select("user_id").eq("role","admin");if(W)throw W;const K=q.map(ie=>ie.user_id),{data:re,error:ae}=await Y.from("profiles").select("id, name, email").in("id",K);if(ae)throw ae;const{data:oe,error:se}=await Y.from("support_notification_settings").select("user_id, receive_notifications");if(se)throw se;const pe=new Map((oe==null?void 0:oe.map(ie=>[ie.user_id,ie.receive_notifications]))||[]);return re.map(ie=>({...ie,receives_notifications:pe.get(ie.id)||!1}))}}),{data:w=[]}=Ht({queryKey:["admin-ticket-replies",s==null?void 0:s.id],queryFn:async()=>{if(!s)return[];const{data:q,error:W}=await Y.from("support_ticket_replies").select("*, profiles(name)").eq("ticket_id",s.id).order("created_at",{ascending:!0});if(W)throw W;return q},enabled:!!s}),S=Qt({mutationFn:async({userId:q,enabled:W})=>{const{data:K}=await Y.from("support_notification_settings").select("id").eq("user_id",q).maybeSingle();if(K){const{error:re}=await Y.from("support_notification_settings").update({receive_notifications:W}).eq("user_id",q);if(re)throw re}else{const{error:re}=await Y.from("support_notification_settings").insert({user_id:q,receive_notifications:W});if(re)throw re}},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-users-notifications"]}),we.success("Notification settings updated")},onError:()=>{we.error("Failed to update settings")}}),T=Qt({mutationFn:async({ticketId:q,status:W})=>{const{error:K}=await Y.from("support_tickets").update({status:W}).eq("id",q);if(K)throw K},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-support-tickets"]}),s&&n({...s,status:s.status}),we.success("Status updated")},onError:()=>{we.error("Failed to update status")}}),C=Qt({mutationFn:async({ticketId:q,assignedTo:W})=>{const{error:K}=await Y.from("support_tickets").update({assigned_to:W}).eq("id",q);if(K)throw K},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-support-tickets"]}),we.success("Ticket assigned")},onError:()=>{we.error("Failed to assign ticket")}}),I=Qt({mutationFn:async q=>{var K,re;if(!s||!e)throw new Error("Missing data");const{error:W}=await Y.from("support_ticket_replies").insert({ticket_id:s.id,user_id:e.id,content:q,is_admin_reply:!0});if(W)throw W;try{await Y.functions.invoke("support-reply-notify",{body:{ticketId:s.id,ticketSubject:s.subject,replyContent:q,userEmail:(K=s.profiles)==null?void 0:K.email,userName:(re=s.profiles)==null?void 0:re.name}})}catch(ae){console.error("Failed to send reply notification:",ae)}},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-ticket-replies",s==null?void 0:s.id]}),o(""),we.success("Reply sent!")},onError:()=>{we.error("Failed to send reply")}}),R=()=>{a.trim()&&I.mutate(a)};A.useEffect(()=>{const q=Y.channel("admin-tickets").on("postgres_changes",{event:"*",schema:"public",table:"support_tickets"},()=>{t.invalidateQueries({queryKey:["admin-support-tickets"]})}).subscribe();return()=>{Y.removeChannel(q)}},[t]);const D=v.filter(q=>q.status==="open").length;return s?(XO[s.status].icon,r.jsx(Ur,{children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>n(null),children:r.jsx(gi,{className:"h-5 w-5"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h1",{className:"text-2xl font-bold",children:s.subject}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx(_t,{variant:"secondary",children:vMe[s.category]}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((B=s.profiles)==null?void 0:B.name)||"Unknown"," (",($=s.profiles)==null?void 0:$.email,")"]})]})]})]}),r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm",children:"Status"})}),r.jsx(qe,{children:r.jsxs(ds,{value:s.status,onValueChange:q=>{T.mutate({ticketId:s.id,status:q}),n({...s,status:q})},children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"open",children:"Open"}),r.jsx(Ut,{value:"in_progress",children:"In Progress"}),r.jsx(Ut,{value:"resolved",children:"Resolved"}),r.jsx(Ut,{value:"closed",children:"Closed"})]})]})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm",children:"Assigned To"})}),r.jsx(qe,{children:r.jsxs(ds,{value:s.assigned_to||"unassigned",onValueChange:q=>{const W=q==="unassigned"?null:q;C.mutate({ticketId:s.id,assignedTo:W}),n({...s,assigned_to:W})},children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Unassigned"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"unassigned",children:"Unassigned"}),k.map(q=>r.jsx(Ut,{value:q.id,children:q.name},q.id))]})]})})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Cs,{children:["Created on ",Xr(new Date(s.created_at),"MMM d, yyyy 'at' h:mm a")]})}),r.jsx(qe,{children:r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Conversation"})}),r.jsxs(qe,{children:[r.jsx(To,{className:"h-[300px] pr-4",children:w.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No replies yet"}):r.jsx("div",{className:"space-y-4",children:w.map(q=>{var W,K;return r.jsxs("div",{className:`p-4 rounded-lg ${q.is_admin_reply?"bg-primary/10 ml-4":"bg-muted mr-4"}`,children:[r.jsxs("div",{className:"flex justify-between items-start mb-2",children:[r.jsx("span",{className:"font-medium text-sm",children:q.is_admin_reply?`${((W=q.profiles)==null?void 0:W.name)||"Admin"} (Support)`:((K=q.profiles)==null?void 0:K.name)||"User"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:Xr(new Date(q.created_at),"MMM d, h:mm a")})]}),r.jsx("p",{className:"text-sm whitespace-pre-wrap",children:q.content})]},q.id)})})}),r.jsx(kd,{className:"my-4"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(qs,{placeholder:"Type your reply...",value:a,onChange:q=>o(q.target.value),className:"min-h-[80px]"}),r.jsx(X,{onClick:R,disabled:!a.trim()||I.isPending,className:"self-end",children:r.jsx(ai,{className:"h-4 w-4"})})]})]})]})]})})):r.jsx(Ur,{children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Support Tickets"}),r.jsxs("p",{className:"text-muted-foreground",children:["Manage support requests from agents",D>0&&r.jsxs(_t,{variant:"destructive",className:"ml-2",children:[D," open"]})]})]}),r.jsxs(Ir,{open:p,onOpenChange:g,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",children:[r.jsx(ld,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Email Notification Settings"}),r.jsx(Zs,{children:"Choose which admins receive email notifications for new support tickets."})]}),r.jsx("div",{className:"space-y-4 mt-4",children:k.map(q=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:q.name}),r.jsx("p",{className:"text-sm text-muted-foreground",children:q.email})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[q.receives_notifications?r.jsx(tg,{className:"h-4 w-4 text-primary"}):r.jsx(mk,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(fn,{checked:q.receives_notifications,onCheckedChange:W=>S.mutate({userId:q.id,enabled:W})})]})]},q.id))})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-4 items-center",children:[r.jsx(ii,{value:l,onValueChange:i,className:"w-auto",children:r.jsxs(si,{children:[r.jsx(Kr,{value:"all",children:"All"}),r.jsx(Kr,{value:"open",children:"Open"}),r.jsx(Kr,{value:"in_progress",children:"In Progress"}),r.jsx(Kr,{value:"resolved",children:"Resolved"}),r.jsx(Kr,{value:"closed",children:"Closed"})]})}),r.jsxs(ds,{value:d,onValueChange:m,children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{placeholder:"All Categories"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Categories"}),r.jsx(Ut,{value:"general",children:"General Support"}),r.jsx(Ut,{value:"technology",children:"Technology Support"}),r.jsx(Ut,{value:"crm",children:"CRM Support"}),r.jsx(Ut,{value:"marketing",children:"Marketing Support"})]})]})]}),r.jsx("div",{className:"mt-4",children:_?r.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):v.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"text-center py-12",children:[r.jsx(Rl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No tickets found"}),r.jsx("p",{className:"text-muted-foreground",children:"No support tickets match the current filters."})]})}):r.jsx("div",{className:"space-y-3",children:v.map(q=>{var K,re;const W=XO[q.status].icon;return r.jsx(ze,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(q),children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-medium truncate",children:q.subject}),r.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[r.jsx(_t,{variant:"outline",className:"text-xs",children:vMe[q.category]}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[(K=q.profiles)==null?void 0:K.name," • ",Xr(new Date(q.created_at),"MMM d, yyyy")]}),q.assigned_to&&r.jsxs(_t,{variant:"secondary",className:"text-xs gap-1",children:[r.jsx(Fl,{className:"h-3 w-3"}),((re=k.find(ae=>ae.id===q.assigned_to))==null?void 0:re.name)||"Assigned"]})]})]}),r.jsxs(_t,{className:XO[q.status].color,children:[r.jsx(W,{className:"h-3 w-3 mr-1"}),XO[q.status].label]})]})})},q.id)})})})]})]})})}const xIt=yu.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});function yIt({content:e,onChange:t,variables:s}){const n=BUe({extensions:[WUe,rVe.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),sVe.configure({types:["heading","paragraph"]}),nVe,xIt],content:e,onUpdate:({editor:l})=>{t(l.getHTML())}});A.useEffect(()=>{n&&e!==n.getHTML()&&n.commands.setContent(e)},[e,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?r.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-muted/30",children:[r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBold().run(),className:n.isActive("bold")?"bg-muted":"",children:r.jsx(b4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleItalic().run(),className:n.isActive("italic")?"bg-muted":"",children:r.jsx(M4,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleBulletList().run(),className:n.isActive("bulletList")?"bg-muted":"",children:r.jsx(Rf,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleOrderedList().run(),className:n.isActive("orderedList")?"bg-muted":"",children:r.jsx(E4,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("left").run(),className:n.isActive({textAlign:"left"})?"bg-muted":"",children:r.jsx(y4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("center").run(),className:n.isActive({textAlign:"center"})?"bg-muted":"",children:r.jsx(x4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().setTextAlign("right").run(),className:n.isActive({textAlign:"right"})?"bg-muted":"",children:r.jsx(v4,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:o,className:n.isActive("link")?"bg-muted":"",children:r.jsx(Lo,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().toggleCodeBlock().run(),className:n.isActive("codeBlock")?"bg-muted":"",children:r.jsx(pk,{className:"h-4 w-4"})}),r.jsx("div",{className:"w-px h-6 bg-border mx-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().undo().run(),disabled:!n.can().undo(),children:r.jsx(z4,{className:"h-4 w-4"})}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:()=>n.chain().focus().redo().run(),disabled:!n.can().redo(),children:r.jsx(R4,{className:"h-4 w-4"})}),r.jsx("div",{className:"flex-1"}),s.length>0&&r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[r.jsx(VE,{className:"h-4 w-4"}),"Insert Variable"]})}),r.jsx(vu,{align:"end",className:"w-64",children:s.map(l=>r.jsxs(Ba,{onClick:()=>a(l),className:"flex flex-col items-start",children:[r.jsx("span",{className:"font-medium",children:l.label}),r.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:`{{${l.key}}}`}),l.description&&r.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:l.description})]},l.key))})]})]}),r.jsx(FUe,{editor:n,className:"prose prose-sm max-w-none p-4 min-h-[300px] focus:outline-none [&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[280px]"}),s.length>0&&r.jsxs("div",{className:"border-t p-3 bg-muted/20",children:[r.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Available variables (click to copy):"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(l=>r.jsx(_t,{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 vIt(){const e=Rr(),[t,s]=A.useState(null),[n,a]=A.useState(null),[o,l]=A.useState(""),[i,d]=A.useState(""),[m,p]=A.useState(""),[g,v]=A.useState(!0),[_,k]=A.useState("visual"),{data:w,isLoading:S}=Ht({queryKey:["email-templates"],queryFn:async()=>{const{data:D,error:B}=await Y.from("email_templates").select("*").order("name");if(B)throw B;return D.map($=>({...$,available_variables:$.available_variables||[]}))}}),T=Qt({mutationFn:async D=>{const{error:B}=await Y.from("email_templates").update({subject:D.subject,body_html:D.body_html,description:D.description,is_active:D.is_active}).eq("id",D.id);if(B)throw B},onSuccess:()=>{e.invalidateQueries({queryKey:["email-templates"]}),we.success("Email template updated successfully"),s(null)},onError:D=>{we.error("Failed to update template: "+D.message)}}),C=D=>{s(D),l(D.subject),d(D.body_html),p(D.description||""),v(D.is_active),k("visual")},I=()=>{t&&T.mutate({id:t.id,subject:o,body_html:i,description:m,is_active:g})},R=(D,B)=>{let $=D;return B.forEach(q=>{const W=`{{${q.key}}}`,K=`[${q.label}]`;$=$.replace(new RegExp(W.replace(/[{}]/g,"\\$&"),"g"),K)}),$};return t?r.jsxs(Ur,{title:"Edit Email Template",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(X,{variant:"ghost",onClick:()=>s(null),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Templates"]}),r.jsx("div",{className:"flex-1"}),r.jsxs(X,{variant:"outline",onClick:()=>a(t),children:[r.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Preview"]}),r.jsxs(X,{onClick:I,disabled:T.isPending,children:[r.jsx(zf,{className:"h-4 w-4 mr-2"}),T.isPending?"Saving...":"Save Changes"]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Vs,{className:"h-5 w-5"}),t.name]}),r.jsxs(Cs,{className:"mt-1",children:["Template slug: ",r.jsx("code",{className:"bg-muted px-1 rounded",children:t.slug})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ee,{htmlFor:"active-toggle",children:"Active"}),r.jsx(fn,{id:"active-toggle",checked:g,onCheckedChange:v})]})]})}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",value:m,onChange:D=>p(D.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"subject",children:"Email Subject"}),r.jsx(Ye,{id:"subject",value:o,onChange:D=>l(D.target.value),placeholder:"Email subject line"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["You can use variables like ","{{name}}"," in the subject"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Email Body"}),r.jsx(ii,{value:_,onValueChange:D=>k(D),children:r.jsxs(si,{className:"h-8",children:[r.jsxs(Kr,{value:"visual",className:"text-xs px-3 h-6",children:[r.jsx(jk,{className:"h-3 w-3 mr-1"}),"Visual"]}),r.jsxs(Kr,{value:"html",className:"text-xs px-3 h-6",children:[r.jsx(pk,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),_==="visual"?r.jsx(yIt,{content:i,onChange:d,variables:t.available_variables}):r.jsx(qs,{value:i,onChange:D=>d(D.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"HTML email body"})]})]})]})]}),r.jsx(Ir,{open:!!n,onOpenChange:()=>a(null),children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Email Preview"}),r.jsxs(Zs,{children:["Subject: ",o.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),r.jsx("div",{className:"border rounded-lg p-4 bg-white",children:r.jsx("div",{dangerouslySetInnerHTML:{__html:R(i,t.available_variables)}})})]})})]}):r.jsx(Ur,{title:"Email Templates",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Email Templates"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage and customize system email templates"})]}),S?r.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((D,B)=>r.jsx(ze,{children:r.jsxs(Wt,{children:[r.jsx(pr,{className:"h-5 w-48"}),r.jsx(pr,{className:"h-4 w-96"})]})},B))}):r.jsx("div",{className:"grid gap-4",children:w==null?void 0:w.map(D=>r.jsxs(ze,{className:"hover:shadow-md transition-shadow",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs(Zt,{className:"flex items-center gap-2 text-lg",children:[r.jsx(Vs,{className:"h-5 w-5 text-muted-foreground"}),D.name,!D.is_active&&r.jsx(_t,{variant:"secondary",children:"Inactive"})]}),r.jsx(Cs,{children:D.description})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>a(D),children:[r.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Preview"]}),r.jsxs(X,{size:"sm",onClick:()=>C(D),children:[r.jsx(Lc,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),r.jsx(qe,{children:r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Subject:"}),r.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-sm",children:D.subject})]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-muted-foreground",children:"Variables:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:D.available_variables.map(B=>r.jsx(_t,{variant:"outline",className:"font-mono text-xs",children:`{{${B.key}}}`},B.key))})]})]})})]},D.id))}),r.jsx(Ir,{open:!!n&&!t,onOpenChange:()=>a(null),children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-auto",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{children:["Email Preview: ",n==null?void 0:n.name]}),r.jsxs(Zs,{children:["Subject: ",n==null?void 0:n.subject.replace(/\{\{(\w+)\}\}/g,"[$1]")]})]}),n&&r.jsx("div",{className:"border rounded-lg p-4 bg-white",children:r.jsx("div",{dangerouslySetInnerHTML:{__html:R(n.body_html,n.available_variables)}})})]})})]})})}function _It(){const e=Rr(),[t,s]=A.useState("templates"),[n,a]=A.useState(null),[o,l]=A.useState(null),[i,d]=A.useState(!1),[m,p]=A.useState(!1),[g,v]=A.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[_,k]=A.useState({name:"",description:"",icon:"📧"}),{data:w=[]}=Ht({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:K,error:re}=await Y.from("email_template_categories").select("*").order("sort_order");if(re)throw re;return K}}),{data:S=[],isLoading:T}=Ht({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:K,error:re}=await Y.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(re)throw re;return K}}),C=Qt({mutationFn:async K=>{const re={title:K.title,subject:K.subject,body:K.body,description:K.description||null,tone:K.tone||null,category_id:K.category_id||null,is_active:K.is_active};if(K.id){const{error:ae}=await Y.from("agent_email_templates").update(re).eq("id",K.id);if(ae)throw ae}else{const{error:ae}=await Y.from("agent_email_templates").insert(re);if(ae)throw ae}},onSuccess:()=>{e.invalidateQueries({queryKey:["agent-email-templates-admin"]}),d(!1),we.success(n?"Template updated":"Template created")},onError:()=>we.error("Failed to save template")}),I=Qt({mutationFn:async K=>{const{error:re}=await Y.from("agent_email_templates").delete().eq("id",K);if(re)throw re},onSuccess:()=>{e.invalidateQueries({queryKey:["agent-email-templates-admin"]}),we.success("Template deleted")}}),R=Qt({mutationFn:async K=>{const re={name:K.name,description:K.description||null,icon:K.icon};if(K.id){const{error:ae}=await Y.from("email_template_categories").update(re).eq("id",K.id);if(ae)throw ae}else{const ae=w.length>0?Math.max(...w.map(se=>se.sort_order))+1:0,{error:oe}=await Y.from("email_template_categories").insert({...re,sort_order:ae});if(oe)throw oe}},onSuccess:()=>{e.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),we.success(o?"Category updated":"Category created")},onError:()=>we.error("Failed to save category")}),D=Qt({mutationFn:async K=>{const{error:re}=await Y.from("email_template_categories").delete().eq("id",K);if(re)throw re},onSuccess:()=>{e.invalidateQueries({queryKey:["agent-email-template-categories"]}),we.success("Category deleted")}}),B=()=>{a(null),v({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),d(!0)},$=K=>{a(K),v({title:K.title,subject:K.subject,body:K.body,description:K.description||"",tone:K.tone||"",category_id:K.category_id||"",is_active:K.is_active}),d(!0)},q=()=>{l(null),k({name:"",description:"",icon:"📧"}),p(!0)},W=K=>{l(K),k({name:K.name,description:K.description||"",icon:K.icon}),p(!0)};return r.jsx(Ur,{children:r.jsxs("div",{className:"space-y-6 animate-fade-in",children:[r.jsx(Hu,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),r.jsxs(ii,{value:t,onValueChange:s,children:[r.jsxs(si,{children:[r.jsxs(Kr,{value:"templates",className:"gap-2",children:[r.jsx(Vs,{className:"h-4 w-4"})," Templates"]}),r.jsxs(Kr,{value:"categories",className:"gap-2",children:[r.jsx(Jh,{className:"h-4 w-4"})," Categories"]})]}),r.jsxs(hs,{value:"templates",className:"space-y-4",children:[r.jsx("div",{className:"flex justify-end",children:r.jsxs(X,{onClick:B,className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"})," Add Template"]})}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Template"}),r.jsx(Mt,{className:"hidden md:table-cell",children:"Category"}),r.jsx(Mt,{className:"hidden md:table-cell",children:"Tone"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:T?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8",children:r.jsx($r,{className:"h-6 w-6 animate-spin mx-auto"})})}):S.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):S.map(K=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:K.title}),r.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[300px]",children:K.subject})]})}),r.jsx(dt,{className:"hidden md:table-cell",children:K.category?r.jsxs(_t,{variant:"outline",className:"gap-1",children:[K.category.icon," ",K.category.name]}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),r.jsx(dt,{className:"hidden md:table-cell",children:K.tone?r.jsx(_t,{variant:"secondary",children:K.tone}):"—"}),r.jsx(dt,{children:r.jsx(_t,{variant:K.is_active?"default":"secondary",children:K.is_active?"Active":"Inactive"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>$(K),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&I.mutate(K.id)},children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},K.id))})]})})})]}),r.jsxs(hs,{value:"categories",className:"space-y-4",children:[r.jsx("div",{className:"flex justify-end",children:r.jsxs(X,{onClick:q,className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"})," Add Category"]})}),r.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:w.map(K=>r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx("span",{className:"text-lg",children:K.icon})," ",K.name]}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>W(K),children:r.jsx(Qa,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{confirm("Delete this category?")&&D.mutate(K.id)},children:r.jsx(Os,{className:"h-3.5 w-3.5"})})]})]})}),r.jsxs(qe,{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:K.description||"No description"}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[S.filter(re=>re.category_id===K.id).length," templates"]})]})]},K.id))})]})]}),r.jsx(Ir,{open:i,onOpenChange:d,children:r.jsxs(Er,{className:"sm:max-w-[700px] max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:n?"Edit Template":"New Template"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Title"}),r.jsx(Ye,{value:g.title,onChange:K=>v(re=>({...re,title:K.target.value})),placeholder:"e.g. Quick Check-in"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Category"}),r.jsxs(ds,{value:g.category_id,onValueChange:K=>v(re=>({...re,category_id:K})),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select category"})}),r.jsx(cs,{children:w.map(K=>r.jsxs(Ut,{value:K.id,children:[K.icon," ",K.name]},K.id))})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Subject Line"}),r.jsx(Ye,{value:g.subject,onChange:K=>v(re=>({...re,subject:K.target.value})),placeholder:"e.g. Hey {{first_name}}, just checking in!"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Use ","{{first_name}}",", ","{{last_name}}",", ","{{full_name}}"," for merge variables"]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Email Body"}),r.jsx(qs,{value:g.body,onChange:K=>v(re=>({...re,body:K.target.value})),rows:12,placeholder:"Write your email template...",className:"resize-y"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Description (internal)"}),r.jsx(Ye,{value:g.description,onChange:K=>v(re=>({...re,description:K.target.value})),placeholder:"Short description for admin reference"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Tone"}),r.jsx(Ye,{value:g.tone,onChange:K=>v(re=>({...re,tone:K.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{checked:g.is_active,onCheckedChange:K=>v(re=>({...re,is_active:K}))}),r.jsx(Ee,{children:"Active"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),r.jsxs(X,{onClick:()=>C.mutate({...g,id:n==null?void 0:n.id}),disabled:C.isPending||!g.title||!g.subject||!g.body,children:[C.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),n?"Save Changes":"Create Template"]})]})]})}),r.jsx(Ir,{open:m,onOpenChange:p,children:r.jsxs(Er,{className:"sm:max-w-[450px]",children:[r.jsx(zr,{children:r.jsx(Fr,{children:o?"Edit Category":"New Category"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-[60px_1fr] gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Icon"}),r.jsx(Ye,{value:_.icon,onChange:K=>k(re=>({...re,icon:K.target.value})),className:"text-center text-lg"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Name"}),r.jsx(Ye,{value:_.name,onChange:K=>k(re=>({...re,name:K.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Description"}),r.jsx(Ye,{value:_.description,onChange:K=>k(re=>({...re,description:K.target.value})),placeholder:"Brief description of this category"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),r.jsxs(X,{onClick:()=>R.mutate({..._,id:o==null?void 0:o.id}),disabled:R.isPending||!_.name,children:[R.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const bIt=({brokerageId:e})=>{var No,Tc;const{toast:t}=_i(),[s,n]=A.useState([]),[a,o]=A.useState(!0),[l,i]=A.useState(""),[d,m]=A.useState("all"),[p,g]=A.useState(new Set),[v,_]=A.useState(!1),[k,w]=A.useState({}),[S,T]=A.useState(!1),[C,I]=A.useState(!1),[R,D]=A.useState({email:"",name:"",password:"",phone:""}),[B,$]=A.useState(!1),[q,W]=A.useState(null),[K,re]=A.useState(!1),[ae,oe]=A.useState(!1),[se,pe]=A.useState(!1),[ie,de]=A.useState(""),[ce,ge]=A.useState(!1),[Te,_e]=A.useState([]),[ve,Me]=A.useState(!1),[Ze,Ae]=A.useState(!1),[Le,Ue]=A.useState(null),[Ve,Ie]=A.useState({name:"",phone:"",email:""}),[We,wt]=A.useState(!1),[Pe,st]=A.useState(!1),[ue,$e]=A.useState(null),[tt,rt]=A.useState("asc"),[je,it]=A.useState(!1),[Se,et]=A.useState(null),[Qe,He]=A.useState(!1),[ot,ut]=A.useState(null),[ft,ct]=A.useState(""),[Tt,Ot]=A.useState(!1),[rr,Lr]=A.useState(null);A.useEffect(()=>{Mr(),cr()},[e]);const cr=async()=>{try{const{data:nt,error:ye}=await Y.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",e);if(ye)throw ye;_e((nt==null?void 0:nt.map(De=>De.user_id))||[])}catch(nt){console.error("Error loading brokerage managers:",nt)}},Mr=async()=>{try{o(!0);const{data:nt,error:ye}=await Y.functions.invoke("get-brokerage-agents",{body:{brokerageId:e}});if(ye)throw ye;const De=nt.agents||[];if(n(De),De.length>0){const Xe=De.map(jt=>jt.id),{data:Ct}=await Y.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",Xe);if(Ct&&Ct.length>0){const jt=Ct.map(Ft=>Ft.assistant_id),{data:Dt}=await Y.from("profiles").select("id, name, email").in("id",jt),Gt={};for(const Ft of Ct){const Yt=Dt==null?void 0:Dt.find(yr=>yr.id===Ft.assistant_id);Yt&&(Gt[Ft.agent_id]={name:Yt.name||"",email:Yt.email||""})}w(Gt)}else w({})}}catch(nt){console.error("Error loading agents:",nt),t({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{o(!1)}},As=async()=>{if(!R.email||!R.name||!R.password){t({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}I(!0);try{const{data:{session:nt}}=await Y.auth.getSession(),ye=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({...R,brokerageId:e})}),De=await ye.json();if(!ye.ok)throw new Error(De.error||"Failed to create agent");t({title:"Success",description:`Agent ${R.email} created successfully`}),D({email:"",name:"",password:"",phone:""}),T(!1),Mr()}catch(nt){console.error("Error creating agent:",nt),t({title:"Error",description:nt.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},Et=async nt=>{try{const{data:{session:ye}}=await Y.auth.getSession(),De=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ye==null?void 0:ye.access_token}`},body:JSON.stringify({userId:nt})}),Xe=await De.json();if(!De.ok)throw new Error(Xe.error||"Failed to resend welcome email");t({title:"Success",description:"Welcome email sent successfully"})}catch(ye){console.error("Error resending welcome email:",ye),t({title:"Error",description:ye.message||"Failed to resend welcome email",variant:"destructive"})}},Pt=async(nt,ye)=>{try{const{error:De}=await Y.functions.invoke("send-password-reset",{body:{email:nt,redirectTo:window.location.origin}});if(De)throw De;t({title:"Password Reset Sent",description:`Password reset email sent to ${ye}`})}catch(De){console.error("Error sending password reset:",De),t({title:"Error",description:De.message||"Failed to send password reset email",variant:"destructive"})}},Sr=nt=>{W(nt),$(!0)},fs=nt=>{Ue(nt),Ie({name:nt.name,phone:nt.phone||"",email:nt.email}),Ae(!0)},Ws=async()=>{if(!Le)return;if(!Ve.name.trim()){t({title:"Error",description:"Name is required",variant:"destructive"});return}const nt=Ve.email.trim().toLowerCase()!==Le.email.toLowerCase();wt(!0);try{if(nt){if(!Ve.email.trim())throw new Error("Email is required");st(!0);const{data:{session:De}}=await Y.auth.getSession(),Xe=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${De==null?void 0:De.access_token}`},body:JSON.stringify({agentId:Le.id,newEmail:Ve.email.trim(),brokerageId:e})}),Ct=await Xe.json();if(st(!1),!Xe.ok)throw new Error(Ct.error||"Failed to update email")}const{error:ye}=await Y.from("profiles").update({name:Ve.name.trim(),phone:Ve.phone.trim()||null}).eq("id",Le.id);if(ye)throw ye;t({title:"Success",description:"Agent profile updated successfully"}),Ae(!1),Ue(null),Mr()}catch(ye){console.error("Error updating agent:",ye),t({title:"Error",description:ye.message||"Failed to update agent",variant:"destructive"})}finally{wt(!1),st(!1)}},tn=async()=>{if(!ie){t({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}ge(!0);try{const{data:{session:nt}}=await Y.auth.getSession(),ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nt==null?void 0:nt.access_token}`},body:JSON.stringify({userId:ie,role:"brokerage_manager",action:"add",brokerageId:e})}),De=await ye.json();if(!ye.ok)throw new Error(De.error||"Failed to add brokerage manager");t({title:"Success",description:"Brokerage manager added successfully"}),pe(!1),de(""),cr()}catch(nt){console.error("Error adding brokerage manager:",nt),t({title:"Error",description:nt.message||"Failed to add brokerage manager",variant:"destructive"})}finally{ge(!1)}},xi=async nt=>{try{const{data:{session:ye}}=await Y.auth.getSession(),De=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ye==null?void 0:ye.access_token}`},body:JSON.stringify({userId:nt,role:"brokerage_manager",action:"remove",brokerageId:e})}),Xe=await De.json();if(!De.ok)throw new Error(Xe.error||"Failed to remove brokerage manager");t({title:"Success",description:"Brokerage manager role removed"}),cr()}catch(ye){console.error("Error removing brokerage manager:",ye),t({title:"Error",description:ye.message||"Failed to remove brokerage manager",variant:"destructive"})}},La=nt=>Te.includes(nt),un=nt=>{ut(nt),ct(""),He(!0)},ia=async()=>{if(!(!ot||!ft)){if(ft.length<6){t({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}Ot(!0);try{const{data:{session:nt}}=await Y.auth.getSession(),ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nt==null?void 0:nt.access_token}`},body:JSON.stringify({agentId:ot.id,brokerageId:e,action:"set_password",newPassword:ft})}),De=await ye.json();if(!ye.ok)throw new Error(De.error||"Failed to set password");t({title:"Success",description:`Password set for ${ot.name}`}),He(!1),ut(null),ct("")}catch(nt){console.error("Error setting password:",nt),t({title:"Error",description:nt.message||"Failed to set password",variant:"destructive"})}finally{Ot(!1)}}},rn=async nt=>{Lr(nt.id);try{const{data:{session:ye}}=await Y.auth.getSession(),De=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/update-agent-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ye==null?void 0:ye.access_token}`},body:JSON.stringify({agentId:nt.id,brokerageId:e,action:"claim_account"})}),Xe=await De.json();if(!De.ok)throw new Error(Xe.error||"Failed to claim account");t({title:"Success",description:`Account claimed for ${nt.name}`}),Mr()}catch(ye){console.error("Error claiming account:",ye),t({title:"Error",description:ye.message||"Failed to claim account",variant:"destructive"})}finally{Lr(null)}},Wn=async()=>{if(q){re(!0);try{const{data:{session:nt}}=await Y.auth.getSession(),ye=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nt==null?void 0:nt.access_token}`},body:JSON.stringify({userId:q.id,brokerageId:e})}),De=await ye.json();if(!ye.ok)throw new Error(De.error||"Failed to remove agent");t({title:"Success",description:`${q.name} has been removed from your brokerage`}),$(!1),W(null),Mr()}catch(nt){console.error("Error removing agent:",nt),t({title:"Error",description:nt.message||"Failed to remove agent",variant:"destructive"})}finally{re(!1)}}},Yn=nt=>{const ye=nt.trim().split(" ");return ye.length>1?ye[ye.length-1].toLowerCase():nt.toLowerCase()},Pi=nt=>{ue===nt?rt(tt==="asc"?"desc":"asc"):($e(nt),rt("asc"))},dr=nt=>ue!==nt?r.jsx(eg,{className:"ml-1 h-4 w-4"}):tt==="asc"?r.jsx(Pf,{className:"ml-1 h-4 w-4"}):r.jsx(Ly,{className:"ml-1 h-4 w-4"}),$a=s.filter(nt=>{if(d==="active"&&!nt.claimed||d==="pending"&&nt.claimed)return!1;if(!l)return!0;const ye=l.toLowerCase();return nt.name.toLowerCase().includes(ye)||nt.email.toLowerCase().includes(ye)}),xo=[...$a].sort((nt,ye)=>{if(!ue)return 0;let De=0;return ue==="name"?De=Yn(nt.name).localeCompare(Yn(ye.name)):ue==="status"&&(De=nt.claimed===ye.claimed?0:nt.claimed?-1:1),tt==="asc"?De:-De});$a.filter(nt=>nt.claimed&&!La(nt.id));const Ei=nt=>{g(ye=>{const De=new Set(ye);return De.has(nt)?De.delete(nt):De.add(nt),De})},Qs=()=>{p.size===xo.length?g(new Set):g(new Set(xo.map(nt=>nt.id)))},ao=()=>{g(new Set)},Mc=async()=>{const nt=Array.from(p);if(nt.length===0)return;_(!0);let ye=0,De=0;try{const{data:{session:Xe}}=await Y.auth.getSession();for(const Ct of nt)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xe==null?void 0:Xe.access_token}`},body:JSON.stringify({userId:Ct})})).ok?ye++:De++}catch{De++}ye>0?t({title:"Success",description:`Welcome emails sent to ${ye} agent${ye>1?"s":""}${De>0?` (${De} failed)`:""}`}):t({title:"Error",description:"Failed to send welcome emails",variant:"destructive"}),ao()}catch(Xe){console.error("Error bulk sending welcome emails:",Xe),t({title:"Error",description:Xe.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return a?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Agents"}),r.jsx(Cs,{children:"Manage your brokerage's agents"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"outline",onClick:()=>pe(!0),children:[r.jsx(Ou,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),r.jsxs(X,{variant:"outline",onClick:()=>oe(!0),children:[r.jsx(_1,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),r.jsxs(X,{onClick:()=>T(!0),children:[r.jsx(Kd,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),r.jsxs(qe,{children:[r.jsxs("div",{className:"mb-4 flex flex-col gap-4 sm:flex-row sm:items-center",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search agents...",value:l,onChange:nt=>i(nt.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:d,onValueChange:nt=>m(nt),children:[r.jsx(ls,{className:"w-[160px]",children:r.jsx(us,{placeholder:"Filter by status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Agents"}),r.jsx(Ut,{value:"active",children:"Active"}),r.jsx(Ut,{value:"pending",children:"Pending"})]})]})]}),p.size>0&&r.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border bg-muted/50 p-3",children:[r.jsxs("span",{className:"text-sm font-medium",children:[p.size," agent",p.size>1?"s":""," selected"]}),r.jsx("div",{className:"flex-1"}),r.jsxs(X,{size:"sm",variant:"outline",onClick:Mc,disabled:v,children:[r.jsx(Vs,{className:"mr-2 h-4 w-4"}),v?"Sending...":"Resend Welcome Email"]}),r.jsx(X,{size:"sm",variant:"ghost",onClick:ao,children:"Clear"})]}),r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-[40px]",children:r.jsx(Qo,{checked:xo.length>0&&p.size===xo.length,onCheckedChange:Qs,"aria-label":"Select all"})}),r.jsx(Mt,{children:r.jsxs(X,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>Pi("name"),children:["Name (Last)",dr("name")]})}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:r.jsxs(X,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>Pi("status"),children:["Status",dr("status")]})}),r.jsx(Mt,{children:"Actions"})]})}),r.jsx(Bn,{children:xo.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):xo.map(nt=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsx(Qo,{checked:p.has(nt.id),onCheckedChange:()=>Ei(nt.id),"aria-label":`Select ${nt.name}`})}),r.jsx(dt,{className:"font-medium",children:nt.name}),r.jsx(dt,{children:nt.email}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[nt.claimed?r.jsx(_t,{variant:"default",children:"Active"}):r.jsx(_t,{variant:"secondary",children:"Pending"}),La(nt.id)&&r.jsxs(_t,{variant:"outline",className:"border-primary text-primary",children:[r.jsx(DE,{className:"mr-1 h-3 w-3"}),"Manager"]}),k[nt.id]&&r.jsxs(_t,{variant:"outline",className:"text-xs",children:[r.jsx(ws,{className:"mr-1 h-3 w-3"}),"Asst: ",k[nt.id].name||k[nt.id].email]})]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>{et(nt),it(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:r.jsx(od,{className:"h-4 w-4"})}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>fs(nt),title:"Edit agent",children:r.jsx(Qa,{className:"h-4 w-4"})}),!nt.claimed&&r.jsxs(r.Fragment,{children:[r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>Et(nt.id),title:"Resend welcome email",children:r.jsx(Vs,{className:"h-4 w-4"})}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>rn(nt),title:"Claim account for agent",disabled:rr===nt.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:r.jsx(Ak,{className:"h-4 w-4"})})]}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>un(nt),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:r.jsx(Du,{className:"h-4 w-4"})}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>Pt(nt.email,nt.name),title:"Send password reset email",children:r.jsx(_k,{className:"h-4 w-4"})}),La(nt.id)&&r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>xi(nt.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:r.jsx(Ou,{className:"h-4 w-4"})}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>Sr(nt),className:"text-destructive hover:text-destructive",title:"Remove agent",children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},nt.id))})]})})]})]}),r.jsx(Ir,{open:S,onOpenChange:T,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Add New Agent"}),r.jsx(Zs,{children:"Create a new agent account. They'll receive an email to set up their account."})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",value:R.name,onChange:nt=>D({...R,name:nt.target.value}),placeholder:"John Doe"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"email",children:"Email"}),r.jsx(Ye,{id:"email",type:"email",value:R.email,onChange:nt=>D({...R,email:nt.target.value}),placeholder:"john@example.com"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"phone",children:"Phone (optional)"}),r.jsx(Ye,{id:"phone",type:"tel",value:R.phone,onChange:nt=>D({...R,phone:nt.target.value}),placeholder:"555-123-4567"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"password",children:"Temporary Password"}),r.jsx(Ye,{id:"password",type:"password",value:R.password,onChange:nt=>D({...R,password:nt.target.value}),placeholder:"Temporary password"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>T(!1),children:"Cancel"}),r.jsx(X,{onClick:As,disabled:C,children:C?"Creating...":"Create Agent"})]})]})}),r.jsx(Ir,{open:B,onOpenChange:$,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Remove Agent"}),r.jsxs(Zs,{children:["Are you sure you want to remove ",r.jsx("strong",{children:q==null?void 0:q.name})," from your brokerage? This will revoke their access to the dashboard."]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>$(!1),children:"Cancel"}),r.jsx(X,{variant:"destructive",onClick:Wn,disabled:K,children:K?"Removing...":"Remove Agent"})]})]})}),r.jsx(kqe,{open:ae,onOpenChange:oe,fixedBrokerageId:e,onSuccess:Mr}),r.jsx(Ir,{open:se,onOpenChange:pe,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Add Brokerage Manager"}),r.jsx(Zs,{children:"Promote an existing active agent to brokerage manager. They will be able to manage agents and view analytics."})]}),r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{children:[r.jsx(Ee,{children:"Select Agent"}),r.jsxs(cd,{open:ve,onOpenChange:Me,children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",role:"combobox","aria-expanded":ve,className:"w-full justify-between",children:[ie?((No=s.find(nt=>nt.id===ie))==null?void 0:No.name)+" ("+((Tc=s.find(nt=>nt.id===ie))==null?void 0:Tc.email)+")":"Select an agent to promote...",r.jsx(Ry,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),r.jsx(Hc,{className:"w-full p-0",align:"start",children:r.jsxs(a0,{children:[r.jsx(i0,{placeholder:"Search by name or email..."}),r.jsxs(o0,{className:"max-h-[200px]",children:[r.jsx(l0,{children:"No eligible agents found."}),r.jsx(c0,{children:s.filter(nt=>!La(nt.id)).map(nt=>r.jsxs(d0,{value:`${nt.name} ${nt.email}`,onSelect:()=>{de(nt.id),Me(!1)},children:[r.jsx(mi,{className:`mr-2 h-4 w-4 ${ie===nt.id?"opacity-100":"opacity-0"}`}),nt.name," (",nt.email,")"]},nt.id))})]})]})})]}),s.filter(nt=>!La(nt.id)).length===0&&r.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>pe(!1),children:"Cancel"}),r.jsx(X,{onClick:tn,disabled:ce||!ie,children:ce?"Adding...":"Add as Manager"})]})]})}),r.jsx(Ir,{open:Ze,onOpenChange:Ae,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Edit Agent"}),r.jsxs(Zs,{children:["Update profile information for ",Le==null?void 0:Le.name]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"edit-name",children:"Name"}),r.jsx(Ye,{id:"edit-name",value:Ve.name,onChange:nt=>Ie({...Ve,name:nt.target.value}),placeholder:"Agent name"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"edit-email",children:"Email"}),r.jsx(Ye,{id:"edit-email",type:"email",value:Ve.email,onChange:nt=>Ie({...Ve,email:nt.target.value}),placeholder:"agent@example.com"}),Ve.email.trim().toLowerCase()!==(Le==null?void 0:Le.email.toLowerCase())&&r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Changing email will update their login credentials"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"edit-phone",children:"Phone"}),r.jsx(Ye,{id:"edit-phone",type:"tel",value:Ve.phone,onChange:nt=>Ie({...Ve,phone:nt.target.value}),placeholder:"555-123-4567"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>Ae(!1),children:"Cancel"}),r.jsx(X,{onClick:Ws,disabled:We||Pe,children:Pe?"Updating email...":We?"Saving...":"Save Changes"})]})]})}),Se&&r.jsx(Nqe,{open:je,onOpenChange:nt=>{it(nt),nt||et(null)},userId:Se.id,userName:Se.name}),r.jsx(Ir,{open:Qe,onOpenChange:He,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Set Password"}),r.jsxs(Zs,{children:["Set a new password for ",ot==null?void 0:ot.name,". They will be able to log in with this password immediately."]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"new-password",children:"New Password"}),r.jsx(Ye,{id:"new-password",type:"password",value:ft,onChange:nt=>ct(nt.target.value),placeholder:"Enter new password (min 6 characters)"})]}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Make sure to communicate this password to the agent through a secure channel."})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>He(!1),children:"Cancel"}),r.jsx(X,{onClick:ia,disabled:Tt||!ft||ft.length<6,children:Tt?"Setting...":"Set Password"})]})]})})]})},wIt={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},jIt={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},kIt=e=>{switch(e){case"academy_video":return r.jsx(ma,{className:"h-4 w-4"});case"template":return r.jsx(ya,{className:"h-4 w-4"});case"toolbox":return r.jsx(ya,{className:"h-4 w-4"});case"newsletter":return r.jsx(Vy,{className:"h-4 w-4"});case"social_swag":return r.jsx(bn,{className:"h-4 w-4"});case"event":return r.jsx(An,{className:"h-4 w-4"});default:return r.jsx(jn,{className:"h-4 w-4"})}},NIt=({brokerageId:e})=>{const{toast:t}=_i(),[s,n]=A.useState([]),[a,o]=A.useState([]),[l,i]=A.useState([]),[d,m]=A.useState(!0),[p,g]=A.useState(null);A.useEffect(()=>{v()},[e]);const v=async()=>{try{m(!0);const{data:w,error:S}=await Y.from("profiles").select("id, name, email").eq("brokerage_id",e);if(S)throw S;const T=w.map(re=>re.id),C=new Map(w.map(re=>[re.id,re]));if(T.length===0){n([]),o([]),i([]);return}const{data:I,error:R}=await Y.from("activity_logs").select("*").in("user_id",T).order("launched_at",{ascending:!1});if(R)throw R;const D=I.map(re=>{var ae,oe;return{id:re.id,user_id:re.user_id,app_name:re.app_name,launched_at:re.launched_at,user_name:((ae=C.get(re.user_id))==null?void 0:ae.name)||"Unknown",user_email:((oe=C.get(re.user_id))==null?void 0:oe.email)||"Unknown"}});n(D);const{data:B,error:$}=await Y.from("content_engagement_logs").select("*").in("user_id",T).order("created_at",{ascending:!1});if($)throw $;const q=(B||[]).map(re=>{var ae,oe;return{id:re.id,user_id:re.user_id,resource_type:re.resource_type,resource_id:re.resource_id,resource_title:re.resource_title,action_type:re.action_type,created_at:re.created_at,user_name:((ae=C.get(re.user_id))==null?void 0:ae.name)||"Unknown",user_email:((oe=C.get(re.user_id))==null?void 0:oe.email)||"Unknown"}});o(q);const W=new Map;w.forEach(re=>{W.set(re.id,{user_id:re.id,user_name:re.name,user_email:re.email,app_launches:0,content_views:0,last_activity:""})}),D.forEach(re=>{const ae=W.get(re.user_id);ae&&(ae.app_launches++,(!ae.last_activity||new Date(re.launched_at)>new Date(ae.last_activity))&&(ae.last_activity=re.launched_at))}),q.forEach(re=>{const ae=W.get(re.user_id);ae&&(ae.content_views++,(!ae.last_activity||new Date(re.created_at)>new Date(ae.last_activity))&&(ae.last_activity=re.created_at))});const K=Array.from(W.values()).filter(re=>re.app_launches>0||re.content_views>0).sort((re,ae)=>new Date(ae.last_activity).getTime()-new Date(re.last_activity).getTime());i(K)}catch(w){console.error("Error loading activity:",w),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{m(!1)}},_=w=>s.filter(S=>S.user_id===w),k=w=>a.filter(S=>S.user_id===w);return d?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Agent Activity"}),r.jsx(Cs,{children:"Track app usage and content engagement - click an agent for details"})]}),r.jsx(qe,{children:r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{className:"text-center",children:"App Launches"}),r.jsx(Mt,{className:"text-center",children:"Content Views"}),r.jsx(Mt,{children:"Last Active"})]})}),r.jsx(Bn,{children:l.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(w=>r.jsxs(Nr,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>g({id:w.user_id,name:w.user_name,email:w.user_email}),children:[r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:w.user_name}),r.jsx("div",{className:"text-sm text-muted-foreground",children:w.user_email})]})}),r.jsx(dt,{className:"text-center",children:r.jsxs(_t,{variant:"outline",className:"gap-1",children:[r.jsx(tc,{className:"h-3 w-3"}),w.app_launches]})}),r.jsx(dt,{className:"text-center",children:r.jsxs(_t,{variant:"secondary",className:"gap-1",children:[r.jsx(ya,{className:"h-3 w-3"}),w.content_views]})}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:w.last_activity&&gu(new Date(w.last_activity),{addSuffix:!0})})]},w.user_id))})]})})})]}),r.jsx(Ir,{open:!!p,onOpenChange:w=>!w&&g(null),children:r.jsxs(Er,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{children:[p==null?void 0:p.name,"'s Activity"]}),r.jsx(Zs,{children:p==null?void 0:p.email})]}),r.jsxs(ii,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[r.jsxs(si,{className:"grid w-full grid-cols-2",children:[r.jsx(Kr,{value:"content",children:"Content Engagement"}),r.jsx(Kr,{value:"apps",children:"App Launches"})]}),r.jsx(hs,{value:"content",className:"flex-1 overflow-auto",children:r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Resource"}),r.jsx(Mt,{children:"Type"}),r.jsx(Mt,{children:"Action"}),r.jsx(Mt,{children:"Time"})]})}),r.jsx(Bn,{children:p&&k(p.id).length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&k(p.id).map(w=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"max-w-[200px] truncate font-medium",children:w.resource_title}),r.jsx(dt,{children:r.jsxs(_t,{variant:"outline",className:"gap-1",children:[kIt(w.resource_type),wIt[w.resource_type]||w.resource_type]})}),r.jsx(dt,{children:r.jsx("span",{className:"text-sm text-muted-foreground",children:jIt[w.action_type]||w.action_type})}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:gu(new Date(w.created_at),{addSuffix:!0})})]},w.id))})]})})}),r.jsx(hs,{value:"apps",className:"flex-1 overflow-auto",children:r.jsx("div",{className:"rounded-md border",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"App"}),r.jsx(Mt,{children:"Time"})]})}),r.jsx(Bn,{children:p&&_(p.id).length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&_(p.id).map(w=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsx(_t,{variant:"outline",children:w.app_name})}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:gu(new Date(w.launched_at),{addSuffix:!0})})]},w.id))})]})})})]})]})})]})},SIt=({brokerageId:e})=>{const{toast:t}=_i(),[s,n]=A.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=A.useState(!0);A.useEffect(()=>{l()},[e]);const l=async()=>{try{o(!0);const{data:i,error:d}=await Y.from("profiles").select("id").eq("brokerage_id",e);if(d)throw d;const m=i.map(D=>D.id),p=m.length;if(m.length===0){o(!1);return}const{data:g,error:v}=await Y.from("profiles").select("id, email").in("id",m);if(v)throw v;const{count:_}=await Y.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",e).not("last_login","is",null),k=_||0,w=p-k,{count:S}=await Y.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",m),T=new Date;T.setDate(T.getDate()-7);const{count:C}=await Y.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",m).gte("launched_at",T.toISOString()),I=new Date;I.setMonth(I.getMonth()-1);const{count:R}=await Y.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",m).gte("launched_at",I.toISOString());n({totalAgents:p,activeAgents:k,pendingAgents:w,totalLaunches:S||0,launchesThisWeek:C||0,launchesThisMonth:R||0})}catch(i){console.error("Error loading analytics:",i),t({title:"Error",description:"Failed to load analytics",variant:"destructive"})}finally{o(!1)}};return a?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):r.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Total Agents"}),r.jsx(ws,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:s.totalAgents}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.activeAgents," active, ",s.pendingAgents," pending"]})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Active Agents"}),r.jsx(ui,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:s.activeAgents}),r.jsx("p",{className:"text-xs text-muted-foreground",children:s.totalAgents>0?`${Math.round(s.activeAgents/s.totalAgents*100)}% of total`:"0% of total"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Pending Invites"}),r.jsx(Pa,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:s.pendingAgents}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting setup"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"Total App Launches"}),r.jsx(lx,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:s.totalLaunches}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"All time"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"This Week"}),r.jsx(lx,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisWeek}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 7 days"})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:"This Month"}),r.jsx(lx,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs(qe,{children:[r.jsx("div",{className:"text-2xl font-bold",children:s.launchesThisMonth}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]})]})]})},CIt=({brokerageId:e})=>{const[t,s]=A.useState([]),[n,a]=A.useState(!0),[o,l]=A.useState(!1),[i,d]=A.useState(!1),[m,p]=A.useState({description:"",maxUses:""});A.useEffect(()=>{g()},[e]);const g=async()=>{try{const{data:T,error:C}=await Y.from("invite_codes").select("*").eq("brokerage_id",e).order("created_at",{ascending:!1});if(C)throw C;s(T||[])}catch(T){console.error("Error loading invite codes:",T),we.error("Failed to load invite links")}finally{a(!1)}},v=()=>Math.random().toString(36).substring(2,8).toUpperCase(),_=async()=>{l(!0);try{const T=v(),{error:C}=await Y.from("invite_codes").insert({code:T,description:m.description||null,max_uses:m.maxUses?parseInt(m.maxUses):null,brokerage_id:e,is_active:!0});if(C)throw C;we.success("Invite link created!"),d(!1),p({description:"",maxUses:""}),g()}catch(T){console.error("Error creating invite code:",T),we.error("Failed to create invite link")}finally{l(!1)}},k=async T=>{try{const{error:C}=await Y.from("invite_codes").delete().eq("id",T);if(C)throw C;we.success("Invite link deleted"),s(t.filter(I=>I.id!==T))}catch(C){console.error("Error deleting invite code:",C),we.error("Failed to delete invite link")}},w=async(T,C)=>{try{const{error:I}=await Y.from("invite_codes").update({is_active:!C}).eq("id",T);if(I)throw I;s(t.map(R=>R.id===T?{...R,is_active:!C}:R)),we.success(`Invite link ${C?"deactivated":"activated"}`)}catch(I){console.error("Error toggling invite code:",I),we.error("Failed to update invite link")}},S=T=>{const C=`${window.location.origin}/join?code=${T}`;navigator.clipboard.writeText(C),we.success("Link copied to clipboard!")};return n?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center py-8",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Lo,{className:"h-5 w-5"}),"Agent Invite Links"]}),r.jsx(Cs,{children:"Create shareable links for agents to join your brokerage"})]}),r.jsxs(Ir,{open:i,onOpenChange:d,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{size:"sm",children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Create Link"]})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create Invite Link"}),r.jsx(Zs,{children:"Create a new invite link for agents to join your brokerage"})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description (optional)"}),r.jsx(Ye,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:m.description,onChange:T=>p({...m,description:T.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"maxUses",children:"Max Uses (optional)"}),r.jsx(Ye,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:m.maxUses,onChange:T=>p({...m,maxUses:T.target.value})})]}),r.jsx(X,{onClick:_,disabled:o,className:"w-full",children:o?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),r.jsx(qe,{children:t.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(Lo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No invite links yet"}),r.jsx("p",{className:"text-sm",children:"Create one to start inviting agents"})]}):r.jsx("div",{className:"space-y-3",children:t.map(T=>r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono bg-muted px-2 py-0.5 rounded",children:T.code}),r.jsx(_t,{variant:T.is_active?"default":"secondary",children:T.is_active?"Active":"Inactive"})]}),T.description&&r.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:T.description}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[T.uses_count," uses",T.max_uses&&` / ${T.max_uses} max`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>S(T.code),title:"Copy link",children:r.jsx(uo,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>w(T.id,T.is_active),title:T.is_active?"Deactivate":"Activate",children:T.is_active?"Disable":"Enable"}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>k(T.id),className:"text-destructive hover:text-destructive",title:"Delete",children:r.jsx(Os,{className:"h-4 w-4"})})]})]},T.id))})})]})},MIt=({open:e,onOpenChange:t,referralCode:s,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,d]=A.useState(""),[m,p]=A.useState([]),[g,v]=A.useState(""),[_,k]=A.useState(!1),w=R=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(R),S=()=>{const R=i.trim().toLowerCase();if(R&&w(R)&&!m.includes(R)){if(m.length>=10){we.error("Maximum 10 emails per invite");return}p([...m,R]),d("")}else R&&!w(R)?we.error("Please enter a valid email address"):m.includes(R)&&we.error("Email already added")},T=R=>{p(m.filter(D=>D!==R))},C=R=>{(R.key==="Enter"||R.key===",")&&(R.preventDefault(),S())},I=async()=>{if(m.length===0){we.error("Please add at least one email address");return}k(!0);try{const{data:R,error:D}=await Y.functions.invoke("send-referral-invite",{body:{emails:m,personalMessage:g.trim()||void 0,referralCode:s,brokerageId:n,senderName:a,brokerageName:o}});if(D)throw D;R.successCount===R.totalCount?we.success(`${R.successCount} invite${R.successCount>1?"s":""} sent successfully!`):we.warning(`${R.successCount} of ${R.totalCount} invites sent. Some failed.`),p([]),v(""),t(!1),l==null||l()}catch(R){console.error("Error sending invites:",R),we.error("Failed to send invites. Please try again.")}finally{k(!1)}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-[550px]",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Vs,{className:"h-5 w-5 text-primary"}),"Invite Broker Friends"]}),r.jsx(Zs,{children:"Send a personalized email invitation to broker owners you know. They'll receive a beautiful email highlighting LevelUp's features."})]}),r.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:[r.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:r.jsx(po,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-sm",children:"Earn $25/month for each referral!"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"When they sign up and stay for 30 days, you save on your membership forever."})]})]}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"email",children:"Email Addresses (up to 10)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{id:"email",type:"email",placeholder:"Enter email and press Enter",value:i,onChange:R=>d(R.target.value),onKeyDown:C,onBlur:S}),r.jsx(X,{type:"button",variant:"secondary",onClick:S,children:"Add"})]}),m.length>0&&r.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:m.map(R=>r.jsxs(_t,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[R,r.jsx("button",{type:"button",onClick:()=>T(R),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:r.jsx(Xs,{className:"h-3 w-3"})})]},R))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"message",children:"Personal Message (optional)"}),r.jsx(qs,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:g,onChange:R=>v(R.target.value),rows:3,maxLength:500}),r.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[g.length,"/500 characters"]})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r.jsx(bn,{className:"h-4 w-4 text-primary"}),"What they'll receive:"]}),r.jsxs("ul",{className:"text-xs text-muted-foreground space-y-1",children:[r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Beautiful branded email from you"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Your personal message (if added)"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Key LevelUp features for brokerages"]}),r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary"}),"Direct signup link with your referral code"]})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsx(X,{onClick:I,disabled:m.length===0||_,children:_?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent mr-2"}),"Sending..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Send ",m.length>0&&`(${m.length})`," Invite",m.length!==1?"s":""]})})]})]})})},TIt=({brokerageId:e,refreshTrigger:t})=>{const[s,n]=A.useState([]),[a,o]=A.useState(!0);A.useEffect(()=>{l()},[e,t]);const l=async()=>{try{const{data:d,error:m}=await Y.from("referral_invites").select("*").eq("referrer_brokerage_id",e).order("sent_at",{ascending:!1}).limit(20);if(m)throw m;n(d||[])}catch(d){console.error("Error fetching invites:",d)}finally{o(!1)}},i=d=>{switch(d){case"signed_up":return r.jsxs(_t,{className:"bg-green-100 text-green-800 gap-1",children:[r.jsx(ui,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return r.jsxs(_t,{variant:"outline",className:"text-muted-foreground gap-1",children:[r.jsx(Fc,{className:"h-3 w-3"}),"Expired"]});default:return r.jsxs(_t,{variant:"secondary",className:"gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),"Pending"]})}};return a?r.jsx("div",{className:"flex justify-center py-4",children:r.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):s.length===0?r.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[r.jsx(Vs,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:"No invites sent yet"}),r.jsx("p",{className:"text-xs",children:"Start inviting broker friends to earn rewards!"})]}):r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm font-medium mb-3",children:"Recent Invites"}),s.map(d=>r.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:d.recipient_email}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sent ",Xr(new Date(d.sent_at),"MMM d, yyyy")]})]}),i(d.status)]},d.id))]})},AIt=()=>{const{brokerageId:e,user:t}=Gr(),[s,n]=A.useState(null),[a,o]=A.useState(""),[l,i]=A.useState(""),[d,m]=A.useState([]),[p,g]=A.useState(!0),[v,_]=A.useState(!1),[k,w]=A.useState(0);A.useEffect(()=>{e&&S()},[e]);const S=async()=>{try{const[B,$]=await Promise.all([Y.from("brokerages").select("name").eq("id",e).single(),t?Y.from("profiles").select("name").eq("id",t.id).single():Promise.resolve({data:null})]);B.data&&o(B.data.name),$.data&&i($.data.name||"A LevelUp Member");const{data:q}=await Y.from("referral_codes").select("code").eq("brokerage_id",e).single();if(q)n(q.code);else{const K=`REF${e==null?void 0:e.slice(0,8).toUpperCase()}`;await Y.from("referral_codes").insert({brokerage_id:e,code:K}),n(K)}const{data:W}=await Y.from("referrals").select(` *, referred_user:profiles!referred_user_id(name, email), referred_brokerage:brokerages!referred_brokerage_id(name) `).eq("referrer_brokerage_id",e).order("created_at",{ascending:!1});m(W||[])}catch(B){console.error("Error fetching referral data:",B)}finally{g(!1)}},T=()=>{const B=`https://dashboard.relevelup.com/?ref=${s}`;navigator.clipboard.writeText(B),we.success("Referral link copied to clipboard!")},C=d.filter(B=>B.status==="qualified").length,I=d.filter(B=>B.status==="pending").length,R=C*25,D=Math.max(0,Math.ceil((299-R)/25));return p?null:r.jsxs(r.Fragment,{children:[r.jsxs(ze,{className:"overflow-hidden",children:[r.jsx("div",{className:"bg-gradient-to-r from-primary/10 via-primary/5 to-background border-b",children:r.jsxs("div",{className:"px-6 py-6",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[r.jsx("div",{className:"bg-primary/20 rounded-full p-2",children:r.jsx(po,{className:"h-6 w-6 text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-bold",children:"Referral Rewards Program"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Earn $25/month off your membership for every broker you refer"})]})]}),r.jsx("div",{className:"mt-4 bg-background/80 rounded-lg p-4 border",children:r.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"text-center",children:[r.jsxs("p",{className:"text-3xl font-bold text-primary",children:["$",R]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),R>0&&r.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[r.jsx(ui,{className:"h-4 w-4"}),r.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),D>0&&R<299&&r.jsxs("div",{className:"text-right",children:[r.jsxs("p",{className:"text-sm font-medium",children:["Refer ",D," more = ",r.jsx("span",{className:"text-primary",children:"FREE membership!"})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Your membership could cost $0/month"})]}),R>=299&&r.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[r.jsx(bn,{className:"h-5 w-5"}),r.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),r.jsxs(qe,{className:"pt-6 space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[r.jsxs(X,{onClick:()=>_(!0),className:"w-full",size:"lg",children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),r.jsxs(X,{onClick:T,variant:"outline",className:"w-full",size:"lg",children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Copy Referral Link"]})]}),r.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[r.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Your Referral Link"}),r.jsxs("code",{className:"block px-3 py-2 bg-background rounded border text-sm break-all",children:["https://dashboard.relevelup.com/?ref=",s]})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.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:[r.jsx(Sd,{className:"h-5 w-5 mx-auto text-green-600 mb-1"}),r.jsxs("p",{className:"text-2xl font-bold text-green-700 dark:text-green-400",children:["$",R]}),r.jsx("p",{className:"text-xs text-green-600 dark:text-green-500",children:"Monthly Savings"})]}),r.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg border border-primary/20",children:[r.jsx(ws,{className:"h-5 w-5 mx-auto text-primary mb-1"}),r.jsx("p",{className:"text-2xl font-bold",children:C}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified Referrals"})]}),r.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:[r.jsx(Pa,{className:"h-5 w-5 mx-auto text-amber-600 mb-1"}),r.jsx("p",{className:"text-2xl font-bold text-amber-700 dark:text-amber-400",children:I}),r.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-500",children:"Pending (30 days)"})]})]}),r.jsxs("div",{className:"bg-muted/30 rounded-lg p-4",children:[r.jsx("h4",{className:"font-semibold text-sm mb-3",children:"How It Works"}),r.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[r.jsxs("div",{className:"flex items-start gap-2",children:[r.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"}),r.jsx("p",{children:"Share your referral link or send an invite email to broker friends"})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.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"}),r.jsx("p",{children:"They sign up and subscribe to LevelUp"})]}),r.jsxs("div",{className:"flex items-start gap-2",children:[r.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"}),r.jsx("p",{children:"After 30 days, you get $25/month off your membership - forever!"})]})]})]}),r.jsx(TIt,{brokerageId:e,refreshTrigger:k}),d.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm font-medium",children:"Your Referrals"}),d.slice(0,5).map(B=>{var $,q;return r.jsxs("div",{className:"flex items-center justify-between p-2.5 bg-muted/30 rounded-lg",children:[r.jsx("span",{className:"text-sm truncate",children:(($=B.referred_brokerage)==null?void 0:$.name)||((q=B.referred_user)==null?void 0:q.email)||"Pending setup"}),r.jsxs(_t,{variant:B.status==="qualified"?"default":B.status==="pending"?"secondary":"destructive",className:B.status==="qualified"?"bg-green-600":"",children:[B.status==="qualified"&&r.jsx(ui,{className:"h-3 w-3 mr-1"}),B.status]})]},B.id)})]})]})]}),r.jsx(MIt,{open:v,onOpenChange:_,referralCode:s||"",brokerageId:e||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>w(B=>B+1)})]})},EIt=({brokerageId:e})=>{const t=Ks(),{teams:s,isLoading:n}=jN(e),{data:a,isLoading:o}=Ht({queryKey:["team-aggregate-stats",e,s.map(p=>p.id)],queryFn:async()=>{if(s.length===0)return[];const p=s.map(B=>B.id),{data:g}=await Y.from("team_members").select("team_id, user_id, role").in("team_id",p);if(!g||g.length===0)return s.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:k}=await Y.from("profiles").select("id, name, avatar_url").in("id",_),w=new Map((k||[]).map(B=>[B.id,B])),{data:S}=await Y.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",v),{data:T}=await Y.from("deal_pipeline").select("owner_user_id").in("owner_user_id",v),{data:C}=await Y.from("agent_videos").select("owner_user_id").in("owner_user_id",v).eq("is_deleted",!1),I=new Map;(S||[]).forEach(B=>{I.set(B.owner_user_id,(I.get(B.owner_user_id)||0)+1)});const R=new Map;(T||[]).forEach(B=>{R.set(B.owner_user_id,(R.get(B.owner_user_id)||0)+1)});const D=new Map;return(C||[]).forEach(B=>{D.set(B.owner_user_id,(D.get(B.owner_user_id)||0)+1)}),s.map(B=>{const $=g.filter(se=>se.team_id===B.id),q=$.find(se=>se.role==="team_leader"),W=q?w.get(q.user_id):null,K=$.map(se=>se.user_id),re=K.reduce((se,pe)=>se+(I.get(pe)||0),0),ae=K.reduce((se,pe)=>se+(R.get(pe)||0),0),oe=K.reduce((se,pe)=>se+(D.get(pe)||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:re,total_deals:ae,total_videos:oe}})},enabled:s.length>0});if(n||o)return r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(p=>r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(pr,{className:"h-5 w-32"})}),r.jsx(qe,{children:r.jsx(pr,{className:"h-24 w-full"})})]},p))});if(s.length===0)return r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ws,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Create teams to organize your agents and track their performance."}),r.jsx(X,{onClick:()=>t("/brokerage/teams"),children:"Manage Teams"})]})});const i=(a||[]).reduce((p,g)=>p+g.member_count,0),d=(a||[]).reduce((p,g)=>p+g.total_contacts,0),m=(a||[]).reduce((p,g)=>p+g.total_deals,0);return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[r.jsx(ws,{className:"h-4 w-4"})," Teams"]}),r.jsx("p",{className:"text-2xl font-bold",children:s.length})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[r.jsx(ws,{className:"h-4 w-4"})," Total Members"]}),r.jsx("p",{className:"text-2xl font-bold",children:i})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[r.jsx(xk,{className:"h-4 w-4"})," Total Contacts"]}),r.jsx("p",{className:"text-2xl font-bold",children:d.toLocaleString()})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[r.jsx(Pu,{className:"h-4 w-4"})," Total Deals"]}),r.jsx("p",{className:"text-2xl font-bold",children:m.toLocaleString()})]})})]}),r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:(a||[]).map(p=>r.jsxs(ze,{className:"hover:shadow-md transition-shadow",children:[r.jsxs(Wt,{className:"pb-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Zt,{className:"text-lg",children:p.team_name}),r.jsxs(_t,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&r.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[r.jsxs(cn,{className:"h-6 w-6",children:[r.jsx(xa,{src:p.leader_avatar||""}),r.jsx(dn,{className:"text-xs",children:p.leader_name.charAt(0).toUpperCase()})]}),r.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[r.jsx(_h,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),r.jsx(qe,{children:r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-lg font-semibold",children:p.total_contacts.toLocaleString()}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Contacts"})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-lg font-semibold",children:p.total_deals.toLocaleString()}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Deals"})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-lg font-semibold",children:p.total_videos.toLocaleString()}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Videos"})]})]})})]},p.team_id))}),r.jsx("div",{className:"flex justify-end",children:r.jsx(X,{variant:"outline",onClick:()=>t("/brokerage/teams"),children:"Manage Teams →"})})]})},IIt=()=>{const{user:e,isBrokerageManager:t,brokerageId:s,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Gr(),i=Ks(),{toast:d}=_i(),[m,p]=A.useState(""),[g,v]=A.useState(!0),_=o||(a.length>0?a[0].id:s);A.useEffect(()=>{if(!e||!t&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),_?k():a.length===0&&!s&&v(!1)},[e,t,n,_,i,a,o]);const k=async()=>{if(!_){v(!1);return}try{const{data:w,error:S}=await Y.from("brokerages").select("name").eq("id",_).single();if(S)throw S;p(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?r.jsx(Ur,{title:"Manage Brokerages",description:"Loading brokerage information...",children:r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):_?r.jsx(Ur,{title:m||"Manage Brokerages",description:"Brokerage Management Dashboard",children:r.jsxs("div",{className:"space-y-6",children:[a.length>1&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:"Managing:"}),r.jsxs(ds,{value:o||"",onValueChange:l,children:[r.jsxs(ls,{className:"w-[280px]",children:[r.jsx(Ni,{className:"mr-2 h-4 w-4"}),r.jsx(us,{placeholder:"Select brokerage"})]}),r.jsx(cs,{children:a.map(w=>r.jsx(Ut,{value:w.id,children:w.name},w.id))})]})]}),r.jsxs(ii,{defaultValue:"agents",className:"space-y-4",children:[r.jsxs(si,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[r.jsx(Kr,{value:"agents",children:"Agents"}),r.jsx(Kr,{value:"teams",children:"Teams"}),r.jsx(Kr,{value:"invite",children:"Invite Links"}),r.jsx(Kr,{value:"referrals",children:"Referrals"}),r.jsx(Kr,{value:"leaderboard",children:"Leaderboard"}),r.jsx(Kr,{value:"activity",children:"Activity"}),r.jsx(Kr,{value:"analytics",children:"Analytics"}),r.jsx(Kr,{value:"shares",children:"Shares"})]}),r.jsx(hs,{value:"agents",className:"space-y-4",children:r.jsx(bIt,{brokerageId:_})}),r.jsx(hs,{value:"teams",className:"space-y-4",children:r.jsx(EIt,{brokerageId:_})}),r.jsx(hs,{value:"invite",className:"space-y-4",children:r.jsx(CIt,{brokerageId:_})}),r.jsx(hs,{value:"referrals",className:"space-y-4",children:r.jsx(AIt,{})}),r.jsx(hs,{value:"leaderboard",className:"space-y-4",children:r.jsx(VVe,{brokerageId:_,title:`${m} Event Leaderboard`,showUserStats:!1})}),r.jsx(hs,{value:"activity",className:"space-y-4",children:r.jsx(NIt,{brokerageId:_})}),r.jsx(hs,{value:"analytics",className:"space-y-4",children:r.jsx(SIt,{brokerageId:_})}),r.jsx(hs,{value:"shares",className:"space-y-4",children:r.jsx(eHe,{brokerageOnly:!0,brokerageId:_})})]})]})}):r.jsx(Ur,{title:"Manage Brokerages",description:"Brokerage Management",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Ni,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),r.jsx("p",{className:"text-muted-foreground",children:"You don't have any brokerages to manage."})]})})};function PIt({brokerageId:e,canManage:t}){const{user:s}=Gr(),[n,a]=A.useState([]),[o,l]=A.useState(!0),[i,d]=A.useState(!1),[m,p]=A.useState(null),[g,v]=A.useState(null),[_,k]=A.useState(!1),[w,S]=A.useState(""),[T,C]=A.useState(""),[I,R]=A.useState(!1),D=async()=>{try{const{data:K,error:re}=await Y.from("brokerage_announcements").select("*").eq("brokerage_id",e).order("is_pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1});if(re)throw re;const ae=K;if(ae&&ae.length>0){const oe=[...new Set(ae.map(de=>de.created_by))],{data:se}=await Y.from("profiles").select("id, name, avatar_url").in("id",oe),pe=new Map((se==null?void 0:se.map(de=>[de.id,de]))||[]),ie=ae.map(de=>({...de,author:pe.get(de.created_by)||{name:"Unknown",avatar_url:null}}));a(ie)}else a([])}catch(K){console.error("Error fetching announcements:",K)}finally{l(!1)}};A.useEffect(()=>{D()},[e]);const B=()=>{S(""),C(""),R(!1),p(null)},$=K=>{K?(p(K),S(K.title),C(K.content),R(K.is_pinned)):B(),d(!0)},q=async()=>{if(!w.trim()||!T.trim()){we.error("Please fill in all fields");return}k(!0);try{if(m){const{error:K}=await Y.from("brokerage_announcements").update({title:w.trim(),content:T.trim(),is_pinned:I,pinned_at:I?new Date().toISOString():null}).eq("id",m.id);if(K)throw K;we.success("Announcement updated")}else{const{error:K}=await Y.from("brokerage_announcements").insert({brokerage_id:e,created_by:s==null?void 0:s.id,title:w.trim(),content:T.trim(),is_pinned:I,pinned_at:I?new Date().toISOString():null});if(K)throw K;we.success("Announcement created")}d(!1),B(),D()}catch(K){console.error("Error saving announcement:",K),we.error("Failed to save announcement")}finally{k(!1)}},W=async()=>{if(g)try{const{error:K}=await Y.from("brokerage_announcements").delete().eq("id",g);if(K)throw K;we.success("Announcement deleted"),D()}catch(K){console.error("Error deleting announcement:",K),we.error("Failed to delete announcement")}finally{v(null)}};return o?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ag,{className:"h-5 w-5"}),"Announcements"]})}),r.jsx(qe,{children:r.jsx("div",{className:"animate-pulse space-y-3",children:r.jsx("div",{className:"h-20 bg-muted rounded"})})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ag,{className:"h-5 w-5 text-primary"}),"Announcements"]}),t&&r.jsxs(X,{size:"sm",onClick:()=>$(),className:"gap-1",children:[r.jsx(gs,{className:"h-4 w-4"}),"New"]})]}),r.jsx(qe,{children:n.length===0?r.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No announcements yet"}):r.jsx("div",{className:"space-y-4",children:n.map(K=>{var re,ae,oe,se;return r.jsx("div",{className:`p-4 rounded-lg border ${K.is_pinned?"bg-primary/5 border-primary/20":"bg-muted/30"}`,children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[K.is_pinned&&r.jsx(S1,{className:"h-3.5 w-3.5 text-primary shrink-0"}),r.jsx("h4",{className:"font-semibold truncate",children:K.title})]}),r.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:K.content}),r.jsxs("div",{className:"flex items-center gap-2 mt-3 text-xs text-muted-foreground",children:[r.jsxs(cn,{className:"h-5 w-5",children:[r.jsx(xa,{src:((re=K.author)==null?void 0:re.avatar_url)||void 0}),r.jsx(dn,{className:"text-[10px]",children:((oe=(ae=K.author)==null?void 0:ae.name)==null?void 0:oe.charAt(0))||"?"})]}),r.jsx("span",{children:(se=K.author)==null?void 0:se.name}),r.jsx("span",{children:"•"}),r.jsx("span",{children:Xr(new Date(K.created_at),"MMM d, yyyy")})]})]}),t&&r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>$(K),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>v(K.id),children:r.jsx(Os,{className:"h-4 w-4"})})]})]})},K.id)})})})]}),r.jsx(Ir,{open:i,onOpenChange:d,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:m?"Edit Announcement":"New Announcement"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title"}),r.jsx(Ye,{id:"title",value:w,onChange:K=>S(K.target.value),placeholder:"Announcement title..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"content",children:"Content"}),r.jsx(qs,{id:"content",value:T,onChange:K=>C(K.target.value),placeholder:"Write your announcement...",rows:4})]}),r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"pinned",checked:I,onCheckedChange:R}),r.jsxs(Ee,{htmlFor:"pinned",className:"flex items-center gap-1 cursor-pointer",children:[r.jsx(S1,{className:"h-4 w-4"}),"Pin to top"]})]})}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),r.jsx(X,{onClick:q,disabled:_,children:_?"Saving...":m?"Update":"Create"})]})]})]})}),r.jsx($c,{open:!!g,onOpenChange:()=>v(null),children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Delete Announcement"}),r.jsx(bc,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:W,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function LIt({brokerageId:e}){const[t,s]=A.useState([]),[n,a]=A.useState(!0),[o,l]=A.useState(""),[i,d]=A.useState(new Set);A.useEffect(()=>{(async()=>{try{const{data:g,error:v}=await Y.from("profiles").select("id, name, email, phone, avatar_url, title, bio, areas_served, years_experience, instagram_url, facebook_url, linkedin_url").eq("brokerage_id",e).order("name");if(v)throw v;if(s(g||[]),g&&g.length>0){const _=g.map(w=>w.id),{data:k}=await Y.from("agent_assistant_assignments").select("agent_id").in("agent_id",_);k&&d(new Set(k.map(w=>w.agent_id)))}}catch(g){console.error("Error fetching agents:",g)}finally{a(!1)}})()},[e]);const m=t.filter(p=>{var g,v;return p.name.toLowerCase().includes(o.toLowerCase())||p.email.toLowerCase().includes(o.toLowerCase())||((g=p.title)==null?void 0:g.toLowerCase().includes(o.toLowerCase()))||((v=p.areas_served)==null?void 0:v.toLowerCase().includes(o.toLowerCase()))});return n?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"Agent Roster"]})}),r.jsx(qe,{children:r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:[1,2,3,4].map(p=>r.jsx("div",{className:"animate-pulse",children:r.jsx("div",{className:"h-48 bg-muted rounded-lg"})},p))})})]}):r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5 text-primary"}),"Agent Roster",r.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",t.length,")"]})]}),r.jsxs("div",{className:"relative w-full sm:w-64",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search agents...",value:o,onChange:p=>l(p.target.value),className:"pl-9"})]})]}),r.jsx(qe,{children:m.length===0?r.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"}):r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:m.map(p=>r.jsx(DIt,{agent:p,hasAssistant:i.has(p.id)},p.id))})})]})}function DIt({agent:e,hasAssistant:t}){const s=e.name.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2);return r.jsxs("div",{className:"group relative bg-card border rounded-xl p-4 hover:shadow-md transition-shadow",children:[r.jsxs("div",{className:"flex flex-col items-center text-center mb-3",children:[r.jsxs(cn,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[r.jsx(xa,{src:e.avatar_url||void 0,alt:e.name}),r.jsx(dn,{className:"text-lg bg-primary/10 text-primary",children:s})]}),r.jsx("h3",{className:"font-semibold text-sm leading-tight",children:e.name}),e.title&&r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.title}),t&&r.jsx(_t,{variant:"outline",className:"text-[10px] mt-1",children:"Has Assistant"})]}),e.bio&&r.jsx("p",{className:"text-xs text-muted-foreground text-center line-clamp-2 mb-3",children:e.bio}),r.jsxs("div",{className:"space-y-1.5 mb-3",children:[e.areas_served&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(Yi,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{className:"truncate",children:e.areas_served})]}),e.years_experience&&r.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[e.years_experience," ",e.years_experience===1?"year":"years"," experience"]})]}),r.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.phone&&r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:r.jsx("a",{href:`tel:${e.phone}`,title:`Call ${e.name}`,children:r.jsx(fi,{className:"h-4 w-4"})})}),r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:r.jsx("a",{href:`mailto:${e.email}`,title:`Email ${e.name}`,children:r.jsx(Vs,{className:"h-4 w-4"})})}),e.linkedin_url&&r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:r.jsx("a",{href:e.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:"LinkedIn",children:r.jsx(zm,{className:"h-4 w-4"})})}),e.instagram_url&&r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",asChild:!0,children:r.jsx("a",{href:e.instagram_url,target:"_blank",rel:"noopener noreferrer",title:"Instagram",children:r.jsx(Lu,{className:"h-4 w-4"})})})]})]})}function OIt({brokerageId:e}){const[t,s]=A.useState([]),[n,a]=A.useState(!0);if(A.useEffect(()=>{(async()=>{try{const{data:d,error:m}=await Y.from("profiles").select("id, name, avatar_url").eq("brokerage_id",e);if(m)throw m;if(!d||d.length===0){s([]),a(!1);return}const p=d.map(w=>w.id),{data:g,error:v}=await Y.from("agent_attendance_stats").select("user_id, total_points").in("user_id",p).order("total_points",{ascending:!1});if(v)throw v;const _=new Map(d.map(w=>[w.id,w])),k=(g||[]).filter(w=>w.total_points>0).map(w=>{const S=_.get(w.user_id);return{user_id:w.user_id,total_points:w.total_points,name:(S==null?void 0:S.name)||"Unknown",avatar_url:(S==null?void 0:S.avatar_url)||null}});s(k)}catch(d){console.error("Error fetching leaderboard:",d)}finally{a(!1)}})()},[e]),n)return r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(go,{className:"h-5 w-5"}),"Team Leaderboard"]})}),r.jsx(qe,{children:r.jsx("div",{className:"animate-pulse space-y-3",children:[1,2,3].map(i=>r.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?r.jsx(Uy,{className:Vt("h-5 w-5",o(i))}):r.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(go,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),r.jsx(qe,{children:t.length===0?r.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No points earned yet. Attend events to earn points!"}):r.jsx("div",{className:"space-y-2",children:t.slice(0,10).map((i,d)=>{const m=i.name.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2),p=d+1;return r.jsxs("div",{className:Vt("flex items-center gap-3 p-2 rounded-lg",p<=3&&"bg-muted/50"),children:[r.jsx("div",{className:"w-6 flex justify-center",children:l(p)}),r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:i.avatar_url||void 0}),r.jsx(dn,{className:"text-xs",children:m})]}),r.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:i.name}),r.jsxs("span",{className:"text-sm font-semibold text-primary",children:[i.total_points.toLocaleString()," pts"]})]},i.user_id)})})})]})}function RIt({brokerageId:e}){const t=Ks(),[s,n]=A.useState([]),[a,o]=A.useState(!0);A.useEffect(()=>{(async()=>{try{const{data:d,error:m}=await Y.from("profiles").select("id, name, avatar_url").eq("brokerage_id",e);if(m)throw m;if(!d||d.length===0){n([]),o(!1);return}const p=d.map(w=>w.id),g=new Map(d.map(w=>[w.id,w])),{data:v,error:_}=await Y.from("listings").select(` id, slug, property_address, city, price, property_type, agent_id, listing_photos(photo_url) `).in("agent_id",p).eq("status","active").order("created_at",{ascending:!1}).limit(6);if(_)throw _;const k=(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(k)}catch(d){console.error("Error fetching listings:",d)}finally{o(!1)}})()},[e]);const l=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(i);return a?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Vn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),r.jsx(qe,{children:r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[1,2].map(i=>r.jsx("div",{className:"animate-pulse",children:r.jsx("div",{className:"h-32 bg-muted rounded-lg"})},i))})})]}):r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Vn,{className:"h-5 w-5 text-primary"}),"Brokerage Listings"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>t("/mission-control/listings"),className:"gap-1",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Listing"]})]}),r.jsxs(qe,{children:[s.length===0?r.jsxs("div",{className:"text-center py-8",children:[r.jsx(Vn,{className:"h-10 w-10 text-muted-foreground mx-auto mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No active listings from your brokerage yet"}),r.jsxs(X,{size:"sm",onClick:()=>t("/mission-control/listings/new"),className:"gap-1",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Your First Listing"]})]}):r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:s.map(i=>r.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:[r.jsxs("div",{className:"relative h-24 bg-muted",children:[i.photos&&i.photos.length>0?r.jsx("img",{src:i.photos[0].photo_url,alt:i.property_address||"Listing",className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(Vn,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx("div",{className:"absolute top-2 left-2",children:r.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("_"," ")})})]}),r.jsxs("div",{className:"p-2.5",children:[r.jsx("p",{className:"font-semibold text-sm text-primary",children:l(i.price)}),r.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:i.property_address||"Address not available"}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.city}),i.agent&&r.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1.5 truncate",children:["Listed by ",i.agent.name]})]})]},i.id))}),s.length>0&&r.jsxs(X,{variant:"ghost",size:"sm",className:"w-full mt-3",onClick:()=>t("/mission-control/listings"),children:["View All Listings",r.jsx(jn,{className:"h-3 w-3 ml-1"})]})]})]})}function FIt(){const{user:e,isAdmin:t,isBrokerageManager:s}=Gr(),n=Ks(),[a,o]=A.useState(!0),[l,i]=A.useState(null),[d,m]=A.useState(""),[p,g]=A.useState(0),[v,_]=A.useState(!1),[k,w]=A.useState(!1);return A.useEffect(()=>{(async()=>{if(e)try{const{data:T}=await Y.from("profiles").select("brokerage_id").eq("id",e.id).maybeSingle();if(!(T!=null&&T.brokerage_id)){o(!1);return}i(T.brokerage_id);const{data:C}=await Y.from("brokerages").select("name").eq("id",T.brokerage_id).maybeSingle();C&&m(C.name);const{count:I}=await Y.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",T.brokerage_id);if(g(I||0),t)_(!0),w(!0);else if(s){const{data:R}=await Y.from("brokerage_manager_assignments").select("id").eq("user_id",e.id).eq("brokerage_id",T.brokerage_id).maybeSingle();_(!!R),w(!!R)}}catch(T){console.error("Error fetching brokerage info:",T)}finally{o(!1)}})()},[e,t,s]),a?r.jsx(Ur,{title:"My Brokerage",description:"Loading...",children:r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})}):l?r.jsx(Ur,{title:d||"My Brokerage",description:"Team Hub",children:r.jsxs("div",{className:"space-y-8",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-2 bg-muted/50 rounded-lg px-4 py-2",children:[r.jsx(ws,{className:"h-5 w-5 text-primary"}),r.jsxs("span",{className:"font-medium",children:[p," ",p===1?"Agent":"Agents"]})]}),k&&r.jsxs(X,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[r.jsx(Vn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),r.jsx(PIt,{brokerageId:l,canManage:v}),r.jsx(LIt,{brokerageId:l}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[r.jsx(OIt,{brokerageId:l}),r.jsx(RIt,{brokerageId:l})]})]})}):r.jsx(Ur,{title:"My Brokerage",description:"Team Hub",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Ni,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Brokerage Assigned"}),r.jsx("p",{className:"text-muted-foreground",children:"You're not currently part of a brokerage team."})]})})}function zIt(){const e=Ks(),[t,s]=A.useState(""),[n,a]=A.useState("grid"),{data:o,isLoading:l}=Ht({queryKey:["newsletters"],queryFn:async()=>{const{data:I,error:R}=await Y.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(R)throw R;return I}}),{data:i}=Ht({queryKey:["newsletter-likes-all"],queryFn:async()=>{const{data:I}=await Y.from("newsletter_likes").select("newsletter_id");return I||[]}}),{data:d}=Ht({queryKey:["newsletter-comments-all"],queryFn:async()=>{const{data:I}=await Y.from("newsletter_comments").select("newsletter_id");return I||[]}}),{data:m}=Ht({queryKey:["newsletter-resource-counts"],queryFn:async()=>{const[I,R,D,B]=await Promise.all([Y.from("newsletter_canva_links").select("newsletter_id"),Y.from("newsletter_pdfs").select("newsletter_id"),Y.from("newsletter_videos").select("newsletter_id"),Y.from("newsletter_drive_links").select("newsletter_id")]);return{canva:I.data||[],pdfs:R.data||[],videos:D.data||[],drives:B.data||[]}}}),p=I=>(i==null?void 0:i.filter(R=>R.newsletter_id===I).length)||0,g=I=>(d==null?void 0:d.filter(R=>R.newsletter_id===I).length)||0,v=I=>{var R;return((R=m==null?void 0:m.canva)==null?void 0:R.filter(D=>D.newsletter_id===I).length)||0},_=I=>{var R;return((R=m==null?void 0:m.pdfs)==null?void 0:R.filter(D=>D.newsletter_id===I).length)||0},k=I=>{var R;return((R=m==null?void 0:m.videos)==null?void 0:R.filter(D=>D.newsletter_id===I).length)||0},w=I=>{var R;return((R=m==null?void 0:m.drives)==null?void 0:R.filter(D=>D.newsletter_id===I).length)||0},S=I=>v(I)+_(I)+k(I)+w(I),T=o==null?void 0:o.filter(I=>{var R;return I.title.toLowerCase().includes(t.toLowerCase())||((R=I.description)==null?void 0:R.toLowerCase().includes(t.toLowerCase()))}),C=I=>{e(`/newsletters/${I}`)};return r.jsx(Ur,{title:"Newsletter Content",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"font-bold text-foreground text-5xl",children:"Newsletter Content"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Monthly newsletter templates and resources"})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search newsletters...",value:t,onChange:I=>s(I.target.value),className:"pl-9"})]}),r.jsxs("div",{className:"flex gap-2",children:[t&&r.jsx(X,{variant:"outline",size:"sm",onClick:()=>s(""),children:"Clear"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:n==="grid"?"secondary":"outline",size:"icon",onClick:()=>a("grid"),className:"rounded-full",children:r.jsx(Of,{className:"h-4 w-4"})}),r.jsx(X,{variant:n==="list"?"secondary":"outline",size:"icon",onClick:()=>a("list"),className:"rounded-full",children:r.jsx(Rf,{className:"h-4 w-4"})})]})]})]}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[(T==null?void 0:T.length)||0," item",(T==null?void 0:T.length)!==1?"s":""," found"]}),l&&r.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((I,R)=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-0",children:[r.jsx(pr,{className:"aspect-[3/2] w-full"}),r.jsxs("div",{className:"p-4 space-y-2",children:[r.jsx(pr,{className:"h-5 w-3/4"}),r.jsx(pr,{className:"h-4 w-full"})]})]})},R))}),!l&&(T==null?void 0:T.length)===0&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx(ya,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("div",{className:"text-muted-foreground mb-4",children:t?"No newsletters match your search":"No newsletters available yet"}),t&&r.jsx(X,{variant:"outline",onClick:()=>s(""),children:"Clear Search"})]}),!l&&T&&T.length>0&&r.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:T.map(I=>{const R=S(I.id),D=v(I.id),B=_(I.id),$=k(I.id);return n==="grid"?r.jsxs(ze,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(I.id),children:[r.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:I.preview_image_url?r.jsx("img",{src:I.preview_image_url,alt:I.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:r.jsx(ya,{className:"h-16 w-16"})})}),r.jsxs(qe,{className:"p-4 space-y-3",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:I.title}),r.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(I.publish_date),"MMM d, yyyy")]})]}),I.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:I.description.replace(/<[^>]*>/g,"")}),R>0&&r.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[D>0&&r.jsxs(_t,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(id,{className:"h-3 w-3"})," ",D," Template",D>1?"s":""]}),B>0&&r.jsxs(_t,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(Fi,{className:"h-3 w-3"})," ",B," PDF",B>1?"s":""]}),$>0&&r.jsxs(_t,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[r.jsx(tc,{className:"h-3 w-3"})," ",$," Video",$>1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground pt-1 border-t border-border/50",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Cd,{className:"h-3 w-3"})," ",p(I.id)]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Rl,{className:"h-3 w-3"})," ",g(I.id)]})]})]})]},I.id):r.jsx(ze,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(I.id),children:r.jsxs("div",{className:"flex flex-row",children:[r.jsx("div",{className:"relative overflow-hidden bg-muted w-40 sm:w-48 shrink-0",children:I.preview_image_url?r.jsx("img",{src:I.preview_image_url,alt:I.title,className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground min-h-[100px]",children:r.jsx(ya,{className:"h-10 w-10"})})}),r.jsxs(qe,{className:"p-4 flex-1 flex flex-col justify-center gap-2",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"font-semibold text-foreground line-clamp-1",children:I.title}),r.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(I.publish_date),"MMM d, yyyy")]})]}),I.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:I.description.replace(/<[^>]*>/g,"")}),r.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[R>0&&r.jsxs("span",{children:[R," resource",R>1?"s":""]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Cd,{className:"h-3 w-3"})," ",p(I.id)]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Rl,{className:"h-3 w-3"})," ",g(I.id)]})]})]})]})},I.id)})})]})})}function BIt({rows:e}){if(!e||e.length===0)return null;const t=e.filter(s=>s.columns.some(n=>n.title||n.description||n.image_url));return t.length===0?null:r.jsx("div",{className:"space-y-6",children:t.map((s,n)=>{const a=s.columns.filter(o=>o.title||o.description||o.image_url);return a.length===0?null:r.jsx("div",{className:"grid gap-4",style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((o,l)=>r.jsxs(ze,{className:"overflow-hidden border-border/50",children:[o.image_url&&r.jsx("img",{src:o.image_url,alt:o.title||"",className:"w-full h-40 object-cover"}),r.jsxs(qe,{className:"p-4 space-y-2",children:[o.title&&r.jsx("h4",{className:"font-semibold text-foreground",children:o.title}),o.description&&r.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})]},l))},n)})})}function $It(){const{id:e}=Bl(),t=Ks(),{user:s}=Gr(),{toast:n}=_i(),a=Rr(),{trackEngagement:o}=L6(),[l,i]=A.useState(""),{data:d,isLoading:m}=Ht({queryKey:["newsletter",e],queryFn:async()=>{const{data:D,error:B}=await Y.from("newsletter_content").select("*").eq("id",e).single();if(B)throw B;return D},enabled:!!e});A.useEffect(()=>{d&&o("newsletter",d.id,d.title,"view")},[d==null?void 0:d.id]);const{data:p}=Ht({queryKey:["newsletter-drives",e],queryFn:async()=>{const{data:D}=await Y.from("newsletter_drive_links").select("*").eq("newsletter_id",e).order("sort_order");return D||[]},enabled:!!e}),{data:g}=Ht({queryKey:["newsletter-pdfs",e],queryFn:async()=>{const{data:D}=await Y.from("newsletter_pdfs").select("*").eq("newsletter_id",e).order("sort_order");return D||[]},enabled:!!e}),{data:v}=Ht({queryKey:["newsletter-videos",e],queryFn:async()=>{const{data:D}=await Y.from("newsletter_videos").select("*").eq("newsletter_id",e).order("sort_order");return D||[]},enabled:!!e}),{data:_}=Ht({queryKey:["newsletter-canva-links",e],queryFn:async()=>{const{data:D}=await Y.from("newsletter_canva_links").select("*").eq("newsletter_id",e).order("sort_order");return D||[]},enabled:!!e}),{data:k}=Ht({queryKey:["newsletter-likes",e],queryFn:async()=>{const{data:D}=await Y.from("newsletter_likes").select("*").eq("newsletter_id",e);return D||[]},enabled:!!e}),{data:w}=Ht({queryKey:["newsletter-comments",e],queryFn:async()=>{const{data:D}=await Y.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",e).order("created_at",{ascending:!1});return D||[]},enabled:!!e}),S=k==null?void 0:k.some(D=>D.user_id===(s==null?void 0:s.id)),T=Qt({mutationFn:async()=>{S?await Y.from("newsletter_likes").delete().eq("newsletter_id",e).eq("user_id",s==null?void 0:s.id):await Y.from("newsletter_likes").insert({newsletter_id:e,user_id:s==null?void 0:s.id})},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-likes",e]})}}),C=Qt({mutationFn:async D=>{const{error:B}=await Y.from("newsletter_comments").insert({newsletter_id:e,user_id:s==null?void 0:s.id,content:D});if(B)throw B},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",e]}),i(""),n({title:"Comment added"})}}),I=Qt({mutationFn:async D=>{const{error:B}=await Y.from("newsletter_comments").delete().eq("id",D);if(B)throw B},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",e]}),n({title:"Comment deleted"})}}),R=D=>{if(D.includes("player.mediadelivery.net")||D.includes("iframe.mediadelivery.net")){const B=D.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(B)return r.jsx("div",{className:"relative w-full pt-[56.25%]",children:r.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(D.includes("youtube.com")||D.includes("youtu.be")){const B=D.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(B)return r.jsx("div",{className:"relative w-full pt-[56.25%]",children:r.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 r.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[r.jsx(tc,{className:"h-4 w-4"})," Watch Video"]})};return m?r.jsx(Ur,{title:"",description:"",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-8 w-32"}),r.jsx(pr,{className:"h-64 w-full"}),r.jsx(pr,{className:"h-32 w-full"})]})}):d?r.jsx(Ur,{title:"",description:"",children:r.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[r.jsxs(X,{variant:"ghost",onClick:()=>t("/newsletters"),className:"mb-4",children:[r.jsx(gi,{className:"mr-2 h-4 w-4"})," Back to Newsletters"]}),d.preview_image_url&&r.jsx("img",{src:d.preview_image_url,alt:d.title,className:"w-full h-64 md:h-80 object-cover rounded-lg"}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-bold",children:d.title}),r.jsx("p",{className:"text-muted-foreground mt-1",children:Xr(new Date(d.publish_date),"MMMM d, yyyy")})]}),d.description&&r.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}}),r.jsx(BIt,{rows:d.content_blocks||[]}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(F3,{resourceType:"newsletter",resourceId:d.id,resourceTitle:d.title}),r.jsxs(X,{variant:S?"default":"outline",size:"sm",onClick:()=>T.mutate(),children:[r.jsx(Ai,{className:`h-4 w-4 mr-1 ${S?"fill-current":""}`}),(k==null?void 0:k.length)||0," ",(k==null?void 0:k.length)===1?"Like":"Likes"]})]}),_&&_.length>0&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Canva Templates"})}),r.jsx(qe,{className:"space-y-2",children:_.map(D=>r.jsxs("a",{href:D.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:[r.jsx(id,{className:"h-5 w-5 text-purple-500"}),r.jsx("span",{className:"font-medium",children:D.title}),r.jsx(jn,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},D.id))})]}),p&&p.length>0&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Google Drive Files"})}),r.jsx(qe,{className:"space-y-2",children:p.map(D=>r.jsxs("a",{href:D.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:[r.jsx(jn,{className:"h-5 w-5 text-primary"}),r.jsx("span",{className:"font-medium",children:D.title})]},D.id))})]}),g&&g.length>0&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"PDF Downloads"})}),r.jsx(qe,{className:"space-y-2",children:g.map(D=>r.jsxs("a",{href:D.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:[r.jsx(ya,{className:"h-5 w-5 text-red-500"}),r.jsx("span",{className:"font-medium flex-1",children:D.name}),r.jsx(Fi,{className:"h-4 w-4 text-muted-foreground"})]},D.id))})]}),v&&v.length>0&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Videos"})}),r.jsx(qe,{className:"space-y-6",children:v.map(D=>r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"font-medium",children:D.title}),R(D.video_url)]},D.id))})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"text-lg",children:["Comments (",(w==null?void 0:w.length)||0,")"]})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-3",children:[r.jsx(qs,{placeholder:"Write a comment...",value:l,onChange:D=>i(D.target.value),className:"flex-1"}),r.jsx(X,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:r.jsx(ai,{className:"h-4 w-4"})})]}),r.jsx("div",{className:"space-y-4",children:w==null?void 0:w.map(D=>{var B,$,q;return r.jsxs("div",{className:"flex gap-3",children:[r.jsx(cn,{className:"h-8 w-8",children:r.jsx(dn,{children:(($=(B=D.profiles)==null?void 0:B.name)==null?void 0:$[0])||"U"})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-medium text-sm",children:((q=D.profiles)==null?void 0:q.name)||"User"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:Xr(new Date(D.created_at),"MMM d, yyyy")}),D.user_id===(s==null?void 0:s.id)&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>I.mutate(D.id),children:r.jsx(Os,{className:"h-3 w-3"})})]})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:D.content})]})]},D.id)})})]})]})]})}):r.jsx(Ur,{title:"Not Found",description:"",children:r.jsxs("div",{className:"text-center py-12",children:[r.jsx("p",{className:"text-muted-foreground",children:"Newsletter not found"}),r.jsx(X,{variant:"link",onClick:()=>t("/newsletters"),children:"Back to Newsletters"})]})})}function UIt({rows:e,onChange:t}){const[s,n]=A.useState(null),a=()=>{t([...e,{columns:[{title:"",description:""},{title:"",description:""},{title:"",description:""}]}])},o=m=>{t(e.filter((p,g)=>g!==m))},l=(m,p,g,v)=>{const _=[...e];_[m]={..._[m],columns:_[m].columns.map((k,w)=>w===p?{...k,[g]:v}:k)},t(_)},i=async(m,p,g)=>{var k;const v=(k=g.target.files)==null?void 0:k[0];if(!v)return;const _=`${m}-${p}`;n(_);try{const w=`content-blocks/${Date.now()}-${v.name}`,{error:S}=await Y.storage.from("newsletter-content").upload(w,v);if(!S){const{data:T}=Y.storage.from("newsletter-content").getPublicUrl(w);l(m,p,"image_url",T.publicUrl)}}finally{n(null)}},d=(m,p)=>{l(m,p,"image_url","")};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-base font-medium",children:"Content Blocks (3-Column Rows)"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:a,children:[r.jsx(gs,{className:"mr-1 h-3 w-3"})," Add Row"]})]}),e.length===0&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No content block rows yet. Add a row to create a 3-column layout."}),e.map((m,p)=>r.jsxs(ze,{className:"relative",children:[r.jsx(X,{type:"button",variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-destructive",onClick:()=>o(p),children:r.jsx(Xs,{className:"h-4 w-4"})}),r.jsxs(qe,{className:"p-4 pt-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx(Df,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:["Row ",p+1]})]}),r.jsx("div",{className:"grid grid-cols-3 gap-3",children:m.columns.map((g,v)=>{const _=`${p}-${v}`;return r.jsxs("div",{className:"space-y-2 border border-border/50 rounded-md p-3 bg-muted/20",children:[r.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:["Column ",v+1]}),g.image_url?r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:g.image_url,alt:"",className:"w-full h-20 object-cover rounded"}),r.jsx(X,{type:"button",variant:"destructive",size:"icon",className:"absolute top-1 right-1 h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>d(p,v),children:r.jsx(Xs,{className:"h-3 w-3"})})]}):r.jsxs("div",{children:[r.jsx(Ye,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${_}`,onChange:k=>i(p,v,k)}),r.jsx(X,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:s===_,asChild:!0,children:r.jsx("label",{htmlFor:`block-img-${_}`,className:"cursor-pointer",children:s===_?"Uploading...":r.jsxs(r.Fragment,{children:[r.jsx(Nl,{className:"h-3 w-3 mr-1"})," Image"]})})})]}),r.jsx(Ye,{placeholder:"Title",value:g.title,onChange:k=>l(p,v,"title",k.target.value),className:"h-8 text-sm"}),r.jsx(qs,{placeholder:"Description",value:g.description,onChange:k=>l(p,v,"description",k.target.value),className:"text-sm min-h-[60px] resize-none"})]},v)})})]})]},p))]})}function VIt(){const{toast:e}=_i(),t=Rr(),[s,n]=A.useState(!1),[a,o]=A.useState(null),[l,i]=A.useState({title:"",description:"",publish_date:Xr(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[d,m]=A.useState(null),[p,g]=A.useState(null),[v,_]=A.useState([]),[k,w]=A.useState([]),[S,T]=A.useState([]),[C,I]=A.useState([]),[R,D]=A.useState([]),[B,$]=A.useState([]),[q,W]=A.useState(!1),{data:K,isLoading:re}=Ht({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Ae,error:Le}=await Y.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Le)throw Le;return Ae}}),ae=Qt({mutationFn:async Ae=>{const{data:Le,error:Ue}=await Y.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(Ue)throw Ue;return Le},onSuccess:async Ae=>{await pe(Ae.id),t.invalidateQueries({queryKey:["admin-newsletters"]}),e({title:"Newsletter created successfully"}),Ae.is_published&&fAt(Ae.title,Ae.id),ce()},onError:Ae=>{e({title:"Error creating newsletter",description:Ae.message,variant:"destructive"})}}),oe=Qt({mutationFn:async Ae=>{const{error:Le}=await Y.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(Le)throw Le;return Ae.id},onSuccess:async Ae=>{await pe(Ae),t.invalidateQueries({queryKey:["admin-newsletters"]}),e({title:"Newsletter updated successfully"}),ce()},onError:Ae=>{e({title:"Error updating newsletter",description:Ae.message,variant:"destructive"})}}),se=Qt({mutationFn:async Ae=>{const{error:Le}=await Y.from("newsletter_content").delete().eq("id",Ae);if(Le)throw Le},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-newsletters"]}),e({title:"Newsletter deleted successfully"})},onError:Ae=>{e({title:"Error deleting newsletter",description:Ae.message,variant:"destructive"})}}),pe=async Ae=>{await Y.from("newsletter_drive_links").delete().eq("newsletter_id",Ae),await Y.from("newsletter_pdfs").delete().eq("newsletter_id",Ae),await Y.from("newsletter_videos").delete().eq("newsletter_id",Ae),await Y.from("newsletter_canva_links").delete().eq("newsletter_id",Ae);for(const Le of B){const Ue=`${Ae}/${Date.now()}-${Le.file.name}`,{error:Ve}=await Y.storage.from("newsletter-content").upload(Ue,Le.file);if(!Ve){const{data:Ie}=Y.storage.from("newsletter-content").getPublicUrl(Ue);k.push({name:Le.name,file_url:Ie.publicUrl,file_size:Le.file.size,sort_order:k.length})}}v.length>0&&await Y.from("newsletter_drive_links").insert(v.map((Le,Ue)=>({newsletter_id:Ae,title:Le.title,drive_url:Le.drive_url,sort_order:Ue}))),k.length>0&&await Y.from("newsletter_pdfs").insert(k.map((Le,Ue)=>({newsletter_id:Ae,name:Le.name,file_url:Le.file_url,file_size:Le.file_size||null,sort_order:Ue}))),S.length>0&&await Y.from("newsletter_videos").insert(S.map((Le,Ue)=>({newsletter_id:Ae,title:Le.title,video_url:Le.video_url,sort_order:Ue}))),C.length>0&&await Y.from("newsletter_canva_links").insert(C.map((Le,Ue)=>({newsletter_id:Ae,title:Le.title,canva_share_link:Le.canva_share_link,sort_order:Ue})))},ie=async Ae=>{o(Ae),i({title:Ae.title,description:Ae.description||"",publish_date:Xr(new Date(Ae.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Ae.is_published}),g(Ae.preview_image_url),D(Ae.content_blocks||[]);const[Le,Ue,Ve,Ie]=await Promise.all([Y.from("newsletter_drive_links").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Y.from("newsletter_pdfs").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Y.from("newsletter_videos").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Y.from("newsletter_canva_links").select("*").eq("newsletter_id",Ae.id).order("sort_order")]);_(Le.data||[]),w(Ue.data||[]),T(Ve.data||[]),I(Ie.data||[]),$([]),n(!0)},de=async Ae=>{const[Le,Ue,Ve,Ie]=await Promise.all([Y.from("newsletter_drive_links").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Y.from("newsletter_pdfs").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Y.from("newsletter_videos").select("*").eq("newsletter_id",Ae.id).order("sort_order"),Y.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:Xr(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),g(Ae.preview_image_url),D(Ae.content_blocks||[]),_((Le.data||[]).map(({id:We,...wt})=>wt)),w((Ue.data||[]).map(({id:We,...wt})=>wt)),T((Ve.data||[]).map(({id:We,...wt})=>wt)),I((Ie.data||[]).map(({id:We,...wt})=>wt)),$([]),n(!0)},ce=()=>{n(!1),o(null),i({title:"",description:"",publish_date:Xr(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),m(null),g(null),_([]),w([]),T([]),I([]),D([]),$([])},ge=async Ae=>{var Ue;const Le=(Ue=Ae.target.files)==null?void 0:Ue[0];Le&&(m(Le),g(URL.createObjectURL(Le)))},Te=async()=>{if(!l.title){e({title:"Title is required",variant:"destructive"});return}W(!0);let Ae=p;if(d){const Le=`previews/${Date.now()}-${d.name}`,{error:Ue}=await Y.storage.from("newsletter-content").upload(Le,d);if(!Ue){const{data:Ve}=Y.storage.from("newsletter-content").getPublicUrl(Le);Ae=Ve.publicUrl}}a?oe.mutate({id:a.id,...l,preview_image_url:Ae,content_blocks:R}):ae.mutate({...l,preview_image_url:Ae,content_blocks:R}),W(!1)},_e=()=>_([...v,{title:"",drive_url:"",sort_order:v.length}]),ve=()=>T([...S,{title:"",video_url:"",sort_order:S.length}]),Me=()=>I([...C,{title:"",canva_share_link:"",sort_order:C.length}]),Ze=Ae=>{const Le=Ae.target.files;if(!Le)return;const Ue=Array.from(Le).map(Ve=>({file:Ve,name:Ve.name.replace(/\.[^/.]+$/,"")}));$([...B,...Ue])};return r.jsx(Ur,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Newsletter Content",description:"Manage monthly newsletter templates and resources"}),r.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:(K==null?void 0:K.length)||0})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:(K==null?void 0:K.filter(Ae=>Ae.is_published).length)||0})})]})]}),r.jsxs(Ir,{open:s,onOpenChange:Ae=>!Ae&&ce(),children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{onClick:()=>n(!0),children:[r.jsx(gs,{className:"mr-2 h-4 w-4"})," Add Newsletter"]})}),r.jsxs(Er,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:a?"Edit Newsletter":"Add Newsletter"})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Title *"}),r.jsx(Ye,{value:l.title,onChange:Ae=>i({...l,title:Ae.target.value}),placeholder:"Newsletter title"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Publish Date"}),r.jsx(Ye,{type:"datetime-local",value:l.publish_date,onChange:Ae=>i({...l,publish_date:Ae.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:l.description,onChange:Ae=>i({...l,description:Ae}),placeholder:"Newsletter description",minHeight:"120px"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Preview Image"}),r.jsxs("div",{className:"flex items-center gap-4",children:[p&&r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:p,alt:"Preview",className:"h-20 w-32 object-cover rounded-md"}),r.jsx(X,{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:()=>{m(null),g(null)},children:r.jsx(Xs,{className:"h-3 w-3"})})]}),r.jsxs("div",{children:[r.jsx(Ye,{type:"file",accept:"image/*",onChange:ge,className:"hidden",id:"preview-upload"}),r.jsx(X,{variant:"outline",asChild:!0,children:r.jsxs("label",{htmlFor:"preview-upload",className:"cursor-pointer",children:[r.jsx(Xi,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{checked:l.is_published,onCheckedChange:Ae=>i({...l,is_published:Ae})}),r.jsx(Ee,{children:"Published"})]}),r.jsx(UIt,{rows:R,onChange:D}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-base font-medium",children:"Canva Links"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:Me,children:[r.jsx(gs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),C.map((Ae,Le)=>r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx(Ye,{placeholder:"Link title",value:Ae.title,onChange:Ue=>{const Ve=[...C];Ve[Le].title=Ue.target.value,I(Ve)},className:"w-1/3"}),r.jsx(Ye,{placeholder:"Canva share link",value:Ae.canva_share_link,onChange:Ue=>{const Ve=[...C];Ve[Le].canva_share_link=Ue.target.value,I(Ve)},className:"flex-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>I(C.filter((Ue,Ve)=>Ve!==Le)),children:r.jsx(Xs,{className:"h-4 w-4"})})]},Le))]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-base font-medium",children:"Google Drive Links"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[r.jsx(gs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),v.map((Ae,Le)=>r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx(Ye,{placeholder:"Link title",value:Ae.title,onChange:Ue=>{const Ve=[...v];Ve[Le].title=Ue.target.value,_(Ve)},className:"w-1/3"}),r.jsx(Ye,{placeholder:"Google Drive URL",value:Ae.drive_url,onChange:Ue=>{const Ve=[...v];Ve[Le].drive_url=Ue.target.value,_(Ve)},className:"flex-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(v.filter((Ue,Ve)=>Ve!==Le)),children:r.jsx(Xs,{className:"h-4 w-4"})})]},Le))]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-base font-medium",children:"PDF Files"}),r.jsxs("div",{children:[r.jsx(Ye,{type:"file",accept:".pdf",multiple:!0,onChange:Ze,className:"hidden",id:"pdf-upload"}),r.jsx(X,{variant:"outline",size:"sm",asChild:!0,children:r.jsxs("label",{htmlFor:"pdf-upload",className:"cursor-pointer",children:[r.jsx(Xi,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),k.map((Ae,Le)=>r.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"flex-1 text-sm",children:Ae.name}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>w(k.filter((Ue,Ve)=>Ve!==Le)),children:r.jsx(Xs,{className:"h-4 w-4"})})]},`existing-${Le}`)),B.map((Ae,Le)=>r.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{value:Ae.name,onChange:Ue=>{const Ve=[...B];Ve[Le].name=Ue.target.value,$(Ve)},className:"flex-1 h-8",placeholder:"PDF name"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"(new)"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>$(B.filter((Ue,Ve)=>Ve!==Le)),children:r.jsx(Xs,{className:"h-4 w-4"})})]},`pending-${Le}`))]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-base font-medium",children:"Video Links"}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:ve,children:[r.jsx(gs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),S.map((Ae,Le)=>r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx(Ye,{placeholder:"Video title",value:Ae.title,onChange:Ue=>{const Ve=[...S];Ve[Le].title=Ue.target.value,T(Ve)},className:"w-1/3"}),r.jsx(Ye,{placeholder:"Video URL",value:Ae.video_url,onChange:Ue=>{const Ve=[...S];Ve[Le].video_url=Ue.target.value,T(Ve)},className:"flex-1"}),r.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>T(S.filter((Ue,Ve)=>Ve!==Le)),children:r.jsx(Xs,{className:"h-4 w-4"})})]},Le))]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[r.jsx(X,{variant:"outline",onClick:ce,children:"Cancel"}),r.jsx(X,{onClick:Te,disabled:q||ae.isPending||oe.isPending,children:q?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:re?r.jsx(Nr,{children:r.jsx(dt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(K==null?void 0:K.length)===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No newsletters yet. Create your first one!"})}):K==null?void 0:K.map(Ae=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[Ae.preview_image_url?r.jsx("img",{src:Ae.preview_image_url,alt:Ae.title,className:"w-10 h-10 rounded object-cover"}):r.jsx("div",{className:"w-10 h-10 rounded bg-muted flex items-center justify-center",children:r.jsx(ya,{className:"h-5 w-5 text-muted-foreground"})}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:Ae.title}),Ae.description&&r.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ae.description.replace(/<[^>]*>/g,"")})]})]})}),r.jsx(dt,{children:Xr(new Date(Ae.publish_date),"MMM d, yyyy")}),r.jsx(dt,{children:r.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"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>ie(Ae),title:"Edit",children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>de(Ae),title:"Duplicate",children:r.jsx(uo,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",title:"Delete",onClick:()=>{confirm("Are you sure you want to delete this newsletter?")&&se.mutate(Ae.id)},children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},Ae.id))})]})})})]})})}const _Me={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 qIt(){const{user:e}=Gr(),{toast:t}=_i(),s=Ks(),n=Rr(),[a,o]=A.useState(""),[l,i]=A.useState("popular"),[d,m]=A.useState(!1),[p,g]=A.useState(""),[v,_]=A.useState(""),[k,w]=A.useState(!1),{data:S=[],isLoading:T}=Ht({queryKey:["wishlist-items",l,k],queryFn:async()=>{let B=Y.from("wishlist_items").select("*");k&&e&&(B=B.eq("user_id",e.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:q}=await B;if(q)throw q;const W=[...new Set(($==null?void 0:$.map(ie=>ie.user_id))||[])],{data:K}=await Y.from("profiles").select("id, name").in("id",W),re=new Map((K==null?void 0:K.map(ie=>[ie.id,ie]))||[]);let ae=[];if(e){const{data:ie}=await Y.from("wishlist_votes").select("item_id").eq("user_id",e.id);ae=(ie==null?void 0:ie.map(de=>de.item_id))||[]}const oe=($==null?void 0:$.map(ie=>ie.id))||[],{data:se}=await Y.from("wishlist_comments").select("item_id").in("item_id",oe),pe=new Map;return se==null||se.forEach(ie=>{pe.set(ie.item_id,(pe.get(ie.item_id)||0)+1)}),$==null?void 0:$.map(ie=>{const de=re.get(ie.user_id),ce=(de==null?void 0:de.name)||"Unknown";return{...ie,user_name:ce,user_initials:ce.split(" ").map(ge=>ge[0]).join("").toUpperCase().slice(0,2),has_voted:ae.includes(ie.id),comment_count:pe.get(ie.id)||0}})}}),C=Qt({mutationFn:async({title:B,description:$})=>{const{error:q}=await Y.from("wishlist_items").insert({user_id:e.id,title:B,description:$});if(q)throw q},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),m(!1),g(""),_(""),t({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:B=>{t({title:"Error",description:B.message,variant:"destructive"})}}),I=Qt({mutationFn:async({itemId:B,hasVoted:$})=>{if($){const{error:q}=await Y.from("wishlist_votes").delete().eq("item_id",B).eq("user_id",e.id);if(q)throw q;return{itemId:B,wasAdded:!1}}else{const{error:q}=await Y.from("wishlist_votes").insert({item_id:B,user_id:e.id});if(q)throw q;return{itemId:B,wasAdded:!0}}},onSuccess:async B=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),B!=null&&B.wasAdded){const $=S.find(W=>W.id===B.itemId),q=(($==null?void 0:$.vote_count)||0)+1;Y.functions.invoke("wishlist-notify",{body:{itemId:B.itemId,voteCount:q}}).catch(console.error)}},onError:B=>{t({title:"Error",description:B.message,variant:"destructive"})}}),R=S.filter(B=>B.title.toLowerCase().includes(a.toLowerCase())||B.description.toLowerCase().includes(a.toLowerCase())),D=()=>{if(!p.trim()||!v.trim()){t({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}C.mutate({title:p.trim(),description:v.trim()})};return r.jsx(Ur,{title:"Wishlist",children:r.jsxs("div",{className:"max-w-4xl mx-auto",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx($y,{className:"h-6 w-6 text-primary"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-5xl font-bold",children:"Wishlist"}),r.jsx("p",{className:"text-muted-foreground text-sm",children:"Share ideas and vote on what we build next"})]})]}),r.jsxs(Ir,{open:d,onOpenChange:m,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Idea"]})}),r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Submit a New Idea"})}),r.jsxs("div",{className:"space-y-4 pt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title"}),r.jsx(Ye,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:B=>g(B.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{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})]}),r.jsx(X,{onClick:D,className:"w-full",disabled:C.isPending,children:C.isPending?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Submitting..."]}):"Submit Idea"})]})]})]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-6",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search ideas...",value:a,onChange:B=>o(B.target.value),className:"pl-10"})]}),r.jsx("div",{className:"flex gap-2",children:r.jsx(ii,{value:l,onValueChange:B=>i(B),children:r.jsxs(si,{children:[r.jsx(Kr,{value:"popular",children:"Most Popular"}),r.jsx(Kr,{value:"latest",children:"Latest"}),r.jsx(Kr,{value:"trending",children:"Trending"})]})})})]}),r.jsx("div",{className:"flex items-center gap-2 mb-4",children:r.jsx(X,{variant:k?"default":"outline",size:"sm",onClick:()=>w(!k),children:k?"Show All Ideas":"My Ideas"})}),T?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):R.length===0?r.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[r.jsx($y,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No ideas yet"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to submit an idea!"}),r.jsxs(X,{onClick:()=>m(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Idea"]})]}):r.jsx("div",{className:"space-y-3",children:R.map(B=>r.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>s(`/wishlist/${B.id}`),children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsxs("button",{onClick:$=>{$.stopPropagation(),I.mutate({itemId:B.id,hasVoted:B.has_voted||!1})},className:Vt("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:[r.jsx(Pf,{className:Vt("h-4 w-4",B.has_voted&&"fill-current")}),r.jsx("span",{className:"text-sm font-semibold",children:B.vote_count})]}),r.jsx(cn,{className:"h-10 w-10 bg-primary/20",children:r.jsx(dn,{className:"bg-primary/20 text-primary text-sm font-medium",children:B.user_initials})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("h3",{className:"font-semibold text-foreground",children:B.title}),r.jsx(_t,{className:Vt("text-xs",_Me[B.status].color),children:_Me[B.status].label})]}),r.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:B.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:B.user_name}),r.jsx("span",{children:"•"}),r.jsx("span",{children:new Date(B.created_at).toLocaleDateString()})]})]}),r.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Vo,{className:"h-4 w-4"}),r.jsx("span",{className:"text-sm",children:B.comment_count})]})]})},B.id))})]})})}const bMe={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 HIt(){const{itemId:e}=Bl(),t=Ks(),{user:s}=Gr(),{toast:n}=_i(),a=Rr(),[o,l]=A.useState(""),{data:i=!1}=Ht({queryKey:["user-is-admin",s==null?void 0:s.id],queryFn:async()=>{if(!s)return!1;const{data:S,error:T}=await Y.from("user_roles").select("role").eq("user_id",s.id).eq("role","admin").maybeSingle();return!T&&!!S},enabled:!!s}),{data:d,isLoading:m}=Ht({queryKey:["wishlist-item",e],queryFn:async()=>{const{data:S,error:T}=await Y.from("wishlist_items").select("*").eq("id",e).single();if(T)throw T;const{data:C}=await Y.from("profiles").select("name").eq("id",S.user_id).single();let I=!1;if(s){const{data:R}=await Y.from("wishlist_votes").select("id").eq("item_id",e).eq("user_id",s.id).maybeSingle();I=!!R}return{...S,user_name:(C==null?void 0:C.name)||"Unknown",user_initials:((C==null?void 0:C.name)||"U").split(" ").map(R=>R[0]).join("").toUpperCase().slice(0,2),has_voted:I}}}),{data:p=[],isLoading:g}=Ht({queryKey:["wishlist-comments",e],queryFn:async()=>{const{data:S,error:T}=await Y.from("wishlist_comments").select("*").eq("item_id",e).order("created_at",{ascending:!0});if(T)throw T;const C=[...new Set((S==null?void 0:S.map(D=>D.user_id))||[])],{data:I}=await Y.from("profiles").select("id, name").in("id",C),R=new Map((I==null?void 0:I.map(D=>[D.id,D]))||[]);return S==null?void 0:S.map(D=>{const B=R.get(D.user_id),$=(B==null?void 0:B.name)||"Unknown";return{...D,user_name:$,user_initials:$.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2)}})}}),v=Qt({mutationFn:async S=>{if(S){const{error:T}=await Y.from("wishlist_votes").delete().eq("item_id",e).eq("user_id",s.id);if(T)throw T;return{wasAdded:!1}}else{const{error:T}=await Y.from("wishlist_votes").insert({item_id:e,user_id:s.id});if(T)throw T;return{wasAdded:!0}}},onSuccess:async S=>{if(a.invalidateQueries({queryKey:["wishlist-item",e]}),a.invalidateQueries({queryKey:["wishlist-items"]}),S!=null&&S.wasAdded&&d){const T=(d.vote_count||0)+1;Y.functions.invoke("wishlist-notify",{body:{itemId:e,voteCount:T}}).catch(console.error)}},onError:S=>{n({title:"Error",description:S.message,variant:"destructive"})}}),_=Qt({mutationFn:async S=>{const{error:T}=await Y.from("wishlist_comments").insert({item_id:e,user_id:s.id,content:S});if(T)throw T},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",e]}),l(""),n({title:"Comment added!"})},onError:S=>{n({title:"Error",description:S.message,variant:"destructive"})}}),k=Qt({mutationFn:async S=>{const{error:T}=await Y.from("wishlist_comments").delete().eq("id",S);if(T)throw T},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",e]}),n({title:"Comment deleted"})},onError:S=>{n({title:"Error",description:S.message,variant:"destructive"})}}),w=()=>{o.trim()&&_.mutate(o.trim())};return m?r.jsx(Ur,{title:"Wishlist",children:r.jsxs("div",{className:"max-w-3xl mx-auto",children:[r.jsx(pr,{className:"h-8 w-32 mb-6"}),r.jsx(pr,{className:"h-48 w-full mb-6"}),r.jsx(pr,{className:"h-32 w-full"})]})}):d?r.jsx(Ur,{title:"Wishlist",children:r.jsxs("div",{className:"max-w-3xl mx-auto",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>t("/wishlist"),className:"mb-4",children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Wishlist"]}),r.jsx("div",{className:"bg-card border rounded-lg p-6 mb-6",children:r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsxs("button",{onClick:()=>v.mutate(d.has_voted),className:Vt("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:[r.jsx(Pf,{className:Vt("h-5 w-5",d.has_voted&&"fill-current")}),r.jsx("span",{className:"text-lg font-bold",children:d.vote_count}),r.jsx("span",{className:"text-xs",children:"votes"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("h1",{className:"text-xl font-bold",children:d.title}),r.jsx(_t,{className:Vt("text-xs",bMe[d.status].color),children:bMe[d.status].label})]}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap mb-4",children:d.description}),r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(cn,{className:"h-6 w-6",children:r.jsx(dn,{className:"bg-primary/20 text-primary text-xs",children:d.user_initials})}),r.jsx("span",{children:d.user_name}),r.jsx("span",{children:"•"}),r.jsx("span",{children:new Date(d.created_at).toLocaleDateString()})]})]})]})}),r.jsxs("div",{className:"bg-card border rounded-lg p-6",children:[r.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Comments (",p.length,")"]}),r.jsxs("div",{className:"flex gap-3 mb-6",children:[r.jsx(yne,{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}),r.jsx(X,{onClick:w,disabled:!o.trim()||_.isPending,size:"icon",className:"h-auto",children:_.isPending?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(ai,{className:"h-4 w-4"})})]}),g?r.jsx("div",{className:"space-y-4",children:[1,2].map(S=>r.jsx(pr,{className:"h-20 w-full"},S))}):p.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No comments yet. Be the first to share your thoughts!"}):r.jsx("div",{className:"space-y-4",children:p.map(S=>r.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[r.jsx(cn,{className:"h-8 w-8",children:r.jsx(dn,{className:"bg-primary/20 text-primary text-xs",children:S.user_initials})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"font-medium text-sm",children:S.user_name}),r.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(S.created_at).toLocaleDateString()})]}),r.jsx(g_e,{content:S.content,className:"text-sm text-foreground"})]}),(s==null?void 0:s.id)===S.user_id&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>k.mutate(S.id),children:r.jsx(Os,{className:"h-4 w-4"})})]},S.id))})]})]})}):r.jsx(Ur,{title:"Wishlist",children:r.jsxs("div",{className:"max-w-3xl mx-auto text-center py-12",children:[r.jsx("p",{className:"text-muted-foreground",children:"Item not found"}),r.jsx(X,{variant:"link",onClick:()=>t("/wishlist"),children:"Go back to Wishlist"})]})})}const wMe={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"}},jMe=["open","under_review","planned","in_progress","launched","declined"];function WIt(){const{toast:e}=_i(),t=Ks(),s=Rr(),[n,a]=A.useState(""),[o,l]=A.useState("all"),[i,d]=A.useState(!1),[m,p]=A.useState(null),{data:g=[],isLoading:v}=Ht({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:T,error:C}=await Y.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const I=[...new Set((T==null?void 0:T.map(W=>W.user_id))||[])],{data:R}=await Y.from("profiles").select("id, name, email").in("id",I),D=new Map((R==null?void 0:R.map(W=>[W.id,W]))||[]),B=(T==null?void 0:T.map(W=>W.id))||[],{data:$}=await Y.from("wishlist_comments").select("item_id").in("item_id",B),q=new Map;return $==null||$.forEach(W=>{q.set(W.item_id,(q.get(W.item_id)||0)+1)}),T==null?void 0:T.map(W=>{const K=D.get(W.user_id);return{...W,user_name:(K==null?void 0:K.name)||"Unknown",user_email:(K==null?void 0:K.email)||"",comment_count:q.get(W.id)||0}})}}),_=Qt({mutationFn:async({itemId:T,status:C})=>{const{error:I}=await Y.from("wishlist_items").update({status:C}).eq("id",T);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-wishlist-items"]}),e({title:"Status updated!"})},onError:T=>{e({title:"Error",description:T.message,variant:"destructive"})}}),k=Qt({mutationFn:async T=>{const{error:C}=await Y.from("wishlist_items").delete().eq("id",T);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-wishlist-items"]}),d(!1),p(null),e({title:"Item deleted!"})},onError:T=>{e({title:"Error",description:T.message,variant:"destructive"})}}),w=g.filter(T=>{const C=T.title.toLowerCase().includes(n.toLowerCase())||T.description.toLowerCase().includes(n.toLowerCase())||T.user_name.toLowerCase().includes(n.toLowerCase()),I=o==="all"||T.status===o;return C&&I}),S={total:g.length,open:g.filter(T=>T.status==="open").length,inProgress:g.filter(T=>T.status==="in_progress").length,launched:g.filter(T=>T.status==="launched").length,highVotes:g.filter(T=>T.vote_count>=10).length};return r.jsx(Ur,{title:"Admin - Wishlist",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>t("/admin"),children:r.jsx(gi,{className:"h-5 w-5"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Wishlist Management"}),r.jsx("p",{className:"text-muted-foreground",children:"Review and manage community ideas"})]})]}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[r.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Ideas"}),r.jsx("p",{className:"text-2xl font-bold",children:S.total})]}),r.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Open"}),r.jsx("p",{className:"text-2xl font-bold text-blue-600",children:S.open})]}),r.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),r.jsx("p",{className:"text-2xl font-bold text-orange-600",children:S.inProgress})]}),r.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Launched"}),r.jsx("p",{className:"text-2xl font-bold text-green-600",children:S.launched})]}),r.jsxs("div",{className:"bg-card border rounded-lg p-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"10+ Votes"}),r.jsx("p",{className:"text-2xl font-bold text-primary",children:S.highVotes})]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search ideas, users...",value:n,onChange:T=>a(T.target.value),className:"pl-10"})]}),r.jsxs(ds,{value:o,onValueChange:T=>l(T),children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{placeholder:"Filter by status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Statuses"}),jMe.map(T=>r.jsx(Ut,{value:T,children:wMe[T].label},T))]})]})]}),v?r.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(T=>r.jsx(pr,{className:"h-16 w-full"},T))}):r.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-[60px]",children:"Votes"}),r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{className:"hidden md:table-cell",children:"Submitted By"}),r.jsx(Mt,{className:"hidden sm:table-cell",children:"Comments"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"w-[100px]",children:"Actions"})]})}),r.jsx(Bn,{children:w.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):w.map(T=>r.jsxs(Nr,{className:Vt(T.vote_count>=10&&"bg-primary/5"),children:[r.jsx(dt,{children:r.jsx(_t,{variant:T.vote_count>=10?"default":"secondary",children:T.vote_count})}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium line-clamp-1",children:T.title}),r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:T.description})]})}),r.jsx(dt,{className:"hidden md:table-cell",children:r.jsxs("div",{children:[r.jsx("p",{className:"text-sm",children:T.user_name}),r.jsx("p",{className:"text-xs text-muted-foreground",children:T.user_email})]})}),r.jsx(dt,{className:"hidden sm:table-cell",children:T.comment_count}),r.jsx(dt,{children:r.jsxs(ds,{value:T.status,onValueChange:C=>_.mutate({itemId:T.id,status:C}),children:[r.jsx(ls,{className:"w-[140px] h-8",children:r.jsx(us,{})}),r.jsx(cs,{children:jMe.map(C=>r.jsx(Ut,{value:C,children:wMe[C].label},C))})]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>window.open(`/wishlist/${T.id}`,"_blank"),children:r.jsx(jn,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(T.id),d(!0)},children:r.jsx(Os,{className:"h-4 w-4"})})]})})]},T.id))})]})}),r.jsx(Ir,{open:i,onOpenChange:d,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Delete Wishlist Item"})}),r.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this idea? This will also delete all votes and comments."}),r.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[r.jsx(X,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),r.jsx(X,{variant:"destructive",onClick:()=>m&&k.mutate(m),disabled:k.isPending,children:k.isPending?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function GIt(){const{user:e}=Gr(),[t,s]=A.useState([]),[n,a]=A.useState(!0),[o,l]=A.useState(!1),[i,d]=A.useState(null),[m,p]=A.useState(!1),[g,v]=A.useState(null),[_,k]=A.useState(""),[w,S]=A.useState(""),[T,C]=A.useState(""),[I,R]=A.useState(""),[D,B]=A.useState(""),[$,q]=A.useState(!1),[W,K]=A.useState(""),[re,ae]=A.useState("once"),[oe,se]=A.useState([]),[pe,ie]=A.useState([]),[de,ce]=A.useState(!1),[ge,Te]=A.useState(!1),[_e,ve]=A.useState([]),[Me,Ze]=A.useState({total:0,dismissed:0});A.useEffect(()=>{Ae()},[]);const Ae=async()=>{const{data:He,error:ot}=await Y.from("levelup_briefs").select("*").order("created_at",{ascending:!1});ot?(we.error("Failed to fetch briefs"),console.error(ot)):s(He||[]),a(!1)},Le=()=>{k(""),S(""),C(""),R(""),B(""),q(!1),K(new Date().toISOString().slice(0,16)),ae("once"),se([]),ie([]),d(null)},Ue=()=>{Le(),l(!0)},Ve=async He=>{d(He),k(He.title),S(He.description||""),C(He.video_url||""),R(He.graphic_url||""),B(He.graphic_link_url||""),q(He.is_published),K(He.publish_date.slice(0,16)),ae(He.show_frequency);const{data:ot}=await Y.from("levelup_brief_links").select("*").eq("brief_id",He.id).order("sort_order");se((ot==null?void 0:ot.map(ft=>({title:ft.title,url:ft.url})))||[]);const{data:ut}=await Y.from("levelup_brief_polls").select("*").eq("brief_id",He.id).order("sort_order");if(ut){const ft=[];for(const ct of ut){const{data:Tt}=await Y.from("levelup_brief_poll_options").select("*").eq("poll_id",ct.id).order("sort_order");ft.push({question:ct.question,poll_type:ct.poll_type,options:(Tt==null?void 0:Tt.map(Ot=>Ot.option_text))||[]})}ie(ft)}l(!0)},Ie=async He=>{var ut;const ot=(ut=He.target.files)==null?void 0:ut[0];if(ot){ce(!0);try{const ft=await Y.functions.invoke("bunny-upload",{body:{action:"create",title:ot.name.replace(/\.[^/.]+$/,"")}});if(ft.error)throw ft.error;const{videoId:ct,libraryId:Tt}=ft.data,Ot=await Y.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:ct}});if(Ot.error)throw Ot.error;const{uploadUrl:rr,apiKey:Lr}=Ot.data,cr=new XMLHttpRequest;await new Promise((As,Et)=>{cr.upload.addEventListener("progress",Pt=>{if(Pt.lengthComputable){const Sr=Math.round(Pt.loaded/Pt.total*100);console.log("Upload progress:",Sr)}}),cr.addEventListener("load",()=>{cr.status>=200&&cr.status<300?As():Et(new Error(`Upload failed with status ${cr.status}`))}),cr.addEventListener("error",()=>Et(new Error("Upload failed"))),cr.open("PUT",rr),cr.setRequestHeader("AccessKey",Lr),cr.send(ot)});const Mr=`https://player.mediadelivery.net/embed/${Tt}/${ct}`;C(Mr),we.success("Video uploaded successfully! It may take a few minutes to process.")}catch(ft){console.error("Upload error:",ft),we.error("Failed to upload video")}finally{ce(!1)}}},We=async()=>{if(!_.trim()){we.error("Title is required");return}try{let He;if(i){const{error:ot}=await Y.from("levelup_briefs").update({title:_,description:w||null,video_url:T||null,graphic_url:I||null,graphic_link_url:D||null,is_published:$,publish_date:W,show_frequency:re}).eq("id",i.id);if(ot)throw ot;He=i.id,await Y.from("levelup_brief_links").delete().eq("brief_id",He);const{data:ut}=await Y.from("levelup_brief_polls").select("id").eq("brief_id",He);if(ut)for(const ft of ut)await Y.from("levelup_brief_poll_options").delete().eq("poll_id",ft.id);await Y.from("levelup_brief_polls").delete().eq("brief_id",He)}else{const{data:ot,error:ut}=await Y.from("levelup_briefs").insert({title:_,description:w||null,video_url:T||null,graphic_url:I||null,graphic_link_url:D||null,is_published:$,publish_date:W,show_frequency:re,created_by:e==null?void 0:e.id}).select().single();if(ut)throw ut;He=ot.id}if(oe.length>0){const ot=oe.map((ut,ft)=>({brief_id:He,title:ut.title,url:ut.url,sort_order:ft}));await Y.from("levelup_brief_links").insert(ot)}for(let ot=0;ot0){const Tt=ut.options.map((Ot,rr)=>({poll_id:ft.id,option_text:Ot,sort_order:rr}));await Y.from("levelup_brief_poll_options").insert(Tt)}}we.success(i?"Brief updated":"Brief created"),l(!1),Le(),Ae()}catch(He){console.error("Error saving brief:",He),we.error("Failed to save brief")}},wt=async He=>{if(confirm("Are you sure you want to delete this brief?"))try{const{error:ot}=await Y.from("levelup_briefs").delete().eq("id",He);if(ot)throw ot;we.success("Brief deleted"),Ae()}catch(ot){console.error("Error deleting brief:",ot),we.error("Failed to delete brief")}},Pe=async He=>{v(He);const{count:ot}=await Y.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",He.id),{count:ut}=await Y.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",He.id).not("dismissed_at","is",null);Ze({total:ot||0,dismissed:ut||0});const{data:ft}=await Y.from("levelup_brief_polls").select("*").eq("brief_id",He.id).order("sort_order");if(ft){const ct=[];for(const Tt of ft){const{data:Ot}=await Y.from("levelup_brief_poll_options").select("*").eq("poll_id",Tt.id).order("sort_order"),{data:rr}=await Y.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",Tt.id),Lr=[...new Set((rr==null?void 0:rr.map(Pt=>Pt.user_id))||[])];let cr={};if(Lr.length>0){const{data:Pt}=await Y.from("profiles").select("id, name, email").in("id",Lr);Pt&&Pt.forEach(Sr=>{cr[Sr.id]=Sr.name||Sr.email||"Unknown"})}const Mr=(rr||[]).map(Pt=>({optionId:Pt.option_id,userName:cr[Pt.user_id]||"Unknown",userId:Pt.user_id})),As={};let Et=0;Ot&&Ot.forEach(Pt=>{const Sr=(rr==null?void 0:rr.filter(fs=>fs.option_id===Pt.id).length)||0;As[Pt.id]=Sr,Et+=Sr}),ct.push({...Tt,options:Ot||[],results:As,respondents:Mr,totalResponses:Tt.poll_type==="single"?new Set(rr==null?void 0:rr.map(Pt=>Pt.user_id)).size:Et})}ve(ct)}p(!0)},st=()=>{se([...oe,{title:"",url:""}])},ue=(He,ot,ut)=>{const ft=[...oe];ft[He][ot]=ut,se(ft)},$e=He=>{se(oe.filter((ot,ut)=>ut!==He))},tt=()=>{ie([...pe,{question:"",poll_type:"single",options:["",""]}])},rt=(He,ot)=>{const ut=[...pe];ut[He].question=ot,ie(ut)},je=(He,ot)=>{const ut=[...pe];ut[He].poll_type=ot,ie(ut)},it=He=>{const ot=[...pe];ot[He].options.push(""),ie(ot)},Se=(He,ot,ut)=>{const ft=[...pe];ft[He].options[ot]=ut,ie(ft)},et=(He,ot)=>{const ut=[...pe];ut[He].options=ut[He].options.filter((ft,ct)=>ct!==ot),ie(ut)},Qe=He=>{ie(pe.filter((ot,ut)=>ut!==He))};return r.jsxs(Ur,{title:"The LevelUp Brief",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:r.jsxs(X,{onClick:Ue,children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Frequency"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:n?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):t.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):t.map(He=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:He.title}),r.jsx(dt,{children:r.jsx(_t,{variant:He.is_published?"default":"secondary",children:He.is_published?"Published":"Draft"})}),r.jsx(dt,{className:"capitalize",children:He.show_frequency.replace("_"," ")}),r.jsx(dt,{children:Xr(new Date(He.publish_date),"MMM d, yyyy h:mm a")}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>Pe(He),children:r.jsx(Rc,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>Ve(He),children:r.jsx(Lc,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>wt(He.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},He.id))})]})})})]}),r.jsx(Ir,{open:o,onOpenChange:l,children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:i?"Edit Brief":"Create New Brief"})}),r.jsxs(ii,{defaultValue:"content",className:"w-full",children:[r.jsxs(si,{className:"grid w-full grid-cols-4",children:[r.jsx(Kr,{value:"content",children:"Content"}),r.jsx(Kr,{value:"media",children:"Media"}),r.jsx(Kr,{value:"links",children:"Links"}),r.jsx(Kr,{value:"polls",children:"Polls"})]}),r.jsxs(hs,{value:"content",className:"space-y-4 mt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Title *"}),r.jsx(Ye,{value:_,onChange:He=>k(He.target.value),placeholder:"What's happening at LevelUp..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:w,onChange:He=>S(He),placeholder:"Brief overview for agents...",minHeight:"120px"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Publish Date"}),r.jsx(Ye,{type:"datetime-local",value:W,onChange:He=>K(He.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Show Frequency"}),r.jsxs(ds,{value:re,onValueChange:ae,children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"once",children:"Once (until dismissed)"}),r.jsx(Ut,{value:"every_login",children:"Every login"}),r.jsx(Ut,{value:"daily",children:"Daily"})]})]})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(fn,{checked:$,onCheckedChange:q}),r.jsx(Ee,{children:"Publish immediately"})]})]}),r.jsxs(hs,{value:"media",className:"space-y-6 mt-4",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Video (optional)"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Upload Video to Bunny.net"}),r.jsx("div",{className:"flex gap-2",children:r.jsx(Ye,{type:"file",accept:"video/*",onChange:Ie,disabled:de})}),de&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Or paste embed URL"}),r.jsx(Ye,{value:T,onChange:He=>C(He.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),T&&r.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:r.jsx("iframe",{src:T,className:"w-full h-full",allow:"autoplay; fullscreen",allowFullScreen:!0})})]}),r.jsxs("div",{className:"border-t pt-4 space-y-4",children:[r.jsx("h4",{className:"font-semibold text-sm text-foreground",children:"Graphic / Image (optional)"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Upload Image"}),r.jsx("div",{className:"flex gap-2",children:r.jsx(Ye,{type:"file",accept:"image/*",onChange:async He=>{var ut;const ot=(ut=He.target.files)==null?void 0:ut[0];if(ot){Te(!0);try{const ft=ot.name.split(".").pop(),ct=`brief-graphics/${Date.now()}.${ft}`,{error:Tt}=await Y.storage.from("banner-images").upload(ct,ot,{upsert:!0});if(Tt)throw Tt;const{data:Ot}=Y.storage.from("banner-images").getPublicUrl(ct);R(Ot.publicUrl),we.success("Image uploaded!")}catch(ft){console.error(ft),we.error("Failed to upload image")}finally{Te(!1)}}},disabled:ge})}),ge&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Or paste Image URL"}),r.jsx(Ye,{value:I,onChange:He=>R(He.target.value),placeholder:"https://example.com/image.png"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Click-through Link (optional)"}),r.jsx(Ye,{value:D,onChange:He=>B(He.target.value),placeholder:"https://example.com/landing-page"})]}),I&&r.jsx("div",{className:"rounded-lg overflow-hidden bg-muted border",children:r.jsx("img",{src:I,alt:"Brief graphic preview",className:"w-full object-contain max-h-64"})})]})]}),r.jsxs(hs,{value:"links",className:"space-y-4 mt-4",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(Ee,{children:"Quick Links"}),r.jsxs(X,{variant:"outline",size:"sm",onClick:st,children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),oe.map((He,ot)=>r.jsxs("div",{className:"flex gap-2 items-start",children:[r.jsx(Ye,{value:He.title,onChange:ut=>ue(ot,"title",ut.target.value),placeholder:"Link title",className:"flex-1"}),r.jsx(Ye,{value:He.url,onChange:ut=>ue(ot,"url",ut.target.value),placeholder:"https://...",className:"flex-[2]"}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>$e(ot),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]},ot)),oe.length===0&&r.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),r.jsxs(hs,{value:"polls",className:"space-y-4 mt-4",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(Ee,{children:"Polls"}),r.jsxs(X,{variant:"outline",size:"sm",onClick:tt,children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),pe.map((He,ot)=>r.jsx(ze,{className:"p-4",children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(Ye,{value:He.question,onChange:ut=>rt(ot,ut.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),r.jsxs(ds,{value:He.poll_type,onValueChange:ut=>je(ot,ut),children:[r.jsx(ls,{className:"w-32",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"single",children:"Single"}),r.jsx(Ut,{value:"multi",children:"Multi-select"})]})]}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>Qe(ot),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]}),r.jsxs("div",{className:"space-y-2 pl-4",children:[He.options.map((ut,ft)=>r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:ut,onChange:ct=>Se(ot,ft,ct.target.value),placeholder:`Option ${ft+1}`}),He.options.length>2&&r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>et(ot,ft),children:r.jsx(Os,{className:"h-4 w-4 text-muted-foreground"})})]},ft)),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>it(ot),children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Option"]})]})]})},ot)),pe.length===0&&r.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls added yet"})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[r.jsx(X,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),r.jsx(X,{onClick:We,children:i?"Update Brief":"Create Brief"})]})]})}),r.jsx(Ir,{open:m,onOpenChange:p,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Results: ",g==null?void 0:g.title]})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),r.jsx(qe,{children:r.jsx("p",{className:"text-2xl font-bold",children:Me.total})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),r.jsx(qe,{children:r.jsx("p",{className:"text-2xl font-bold",children:Me.dismissed})})]})]}),_e.length>0?r.jsxs("div",{className:"space-y-4",children:[r.jsx("h3",{className:"font-semibold",children:"Poll Results"}),_e.map(He=>r.jsxs(ze,{className:"p-4",children:[r.jsx("h4",{className:"font-medium mb-3",children:He.question}),r.jsx("div",{className:"space-y-2",children:He.options.map(ot=>{const ut=He.results[ot.id]||0,ft=He.totalResponses>0?Math.round(ut/He.totalResponses*100):0;return r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{children:ot.option_text}),r.jsxs("span",{className:"text-muted-foreground",children:[ut," (",ft,"%)"]})]}),r.jsx("div",{className:"h-2 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${ft}%`}})}),ut>0&&r.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(He.respondents||[]).filter(ct=>ct.optionId===ot.id).map((ct,Tt)=>r.jsx(_t,{variant:"secondary",className:"text-xs font-normal",children:ct.userName},Tt))})]},ot.id)})})]},He.id))]}):r.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const KIt=()=>{const{user:e}=Gr(),{toast:t}=_i(),s=Rr(),[n,a]=A.useState(!1),[o,l]=A.useState(null),[i,d]=A.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[m,p]=A.useState(null),[g,v]=A.useState(""),{data:_=[],isLoading:k}=Ht({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:D,error:B}=await Y.from("additional_services").select("*").order("publish_date",{ascending:!1});if(B)throw B;return D}}),w=Qt({mutationFn:async D=>{let B=D.existingImageUrl;if(D.image){const q=D.image.name.split(".").pop(),W=`${Date.now()}-${Math.random().toString(36).substring(7)}.${q}`,{error:K}=await Y.storage.from("service-images").upload(W,D.image);if(K)throw K;const{data:re}=Y.storage.from("service-images").getPublicUrl(W);B=re.publicUrl}const $={name:D.item.name,description:D.item.description||null,preview_image_url:B,signup_link_url:D.item.signup_link_url,publish_date:D.item.publish_date?new Date(D.item.publish_date).toISOString():new Date().toISOString(),is_published:D.item.is_published,created_by:e==null?void 0:e.id};if(D.itemId){const{error:q}=await Y.from("additional_services").update($).eq("id",D.itemId);if(q)throw q}else{const{error:q}=await Y.from("additional_services").insert($);if(q)throw q}},onSuccess:()=>{s.invalidateQueries({queryKey:["additional-services-admin"]}),s.invalidateQueries({queryKey:["additional-services"]}),t({title:o?"Service updated":"Service created"}),a(!1),T()},onError:D=>{t({title:"Error saving service",description:D.message,variant:"destructive"})}}),S=Qt({mutationFn:async D=>{const{error:B}=await Y.from("additional_services").delete().eq("id",D);if(B)throw B},onSuccess:()=>{s.invalidateQueries({queryKey:["additional-services-admin"]}),s.invalidateQueries({queryKey:["additional-services"]}),t({title:"Service deleted"})},onError:D=>{t({title:"Error deleting service",description:D.message,variant:"destructive"})}}),T=()=>{d({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),v(""),l(null)},C=D=>{l(D),d({name:D.name,description:D.description||"",signup_link_url:D.signup_link_url,publish_date:D.publish_date?new Date(D.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:D.is_published}),v(D.preview_image_url||""),a(!0)},I=D=>{var $;const B=($=D.target.files)==null?void 0:$[0];B&&(p(B),v(URL.createObjectURL(B)))},R=D=>{if(D.preventDefault(),!i.name.trim()){t({title:"Name is required",variant:"destructive"});return}if(!i.signup_link_url.trim()){t({title:"Signup link URL is required",variant:"destructive"});return}w.mutate({item:i,image:m,existingImageUrl:(o==null?void 0:o.preview_image_url)||null,itemId:o==null?void 0:o.id})};return r.jsx(Ur,{title:"Manage Additional Services",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:_.length})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),r.jsx(qe,{children:r.jsx("div",{className:"text-2xl font-bold",children:_.filter(D=>D.is_published).length})})]})]}),r.jsxs(Ir,{open:n,onOpenChange:D=>{a(D),D||T()},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Service"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:o?"Edit Service":"Add New Service"})}),r.jsxs("form",{onSubmit:R,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Name *"}),r.jsx(Ye,{id:"name",value:i.name,onChange:D=>d({...i,name:D.target.value}),placeholder:"Enter service name"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(yg,{content:i.description,onChange:D=>d({...i,description:D}),placeholder:"Enter description",minHeight:"120px"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),r.jsx(Ye,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:D=>d({...i,signup_link_url:D.target.value}),placeholder:"https://example.com/signup"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"publish_date",children:"Publish Date"}),r.jsx(Ye,{id:"publish_date",type:"date",value:i.publish_date,onChange:D=>d({...i,publish_date:D.target.value})})]}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsx(fn,{id:"is_published",checked:i.is_published,onCheckedChange:D=>d({...i,is_published:D})}),r.jsx(Ee,{htmlFor:"is_published",children:"Published"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Preview Image"}),g?r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:g,alt:"Preview",className:"w-full max-h-48 object-contain rounded-lg border"}),r.jsx(X,{type:"button",variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-6 w-6",onClick:()=>{p(null),v("")},children:r.jsx(Xs,{className:"h-3 w-3"})})]}):r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[r.jsx(Nl,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),r.jsx(Ye,{type:"file",accept:"image/*",onChange:I,className:"cursor-pointer"})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),r.jsx(X,{type:"submit",disabled:w.isPending,children:w.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:k?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):_.length===0?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:'No services yet. Click "Add Service" to create your first one.'}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-16",children:"Preview"}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Signup Link"}),r.jsx(Mt,{children:"Publish Date"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:_.map(D=>r.jsxs(Nr,{children:[r.jsx(dt,{children:D.preview_image_url?r.jsx("img",{src:D.preview_image_url,alt:"",className:"w-12 h-12 object-cover rounded"}):r.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:r.jsx(Nl,{className:"h-5 w-5 text-muted-foreground"})})}),r.jsx(dt,{className:"font-medium",children:D.name}),r.jsx(dt,{children:r.jsxs("a",{href:D.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[r.jsx(jn,{className:"h-3 w-3"}),"Link"]})}),r.jsx(dt,{children:new Date(D.publish_date).toLocaleDateString()}),r.jsx(dt,{children:r.jsx(_t,{variant:D.is_published?"default":"secondary",children:D.is_published?"Published":"Draft"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>C(D),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&S.mutate(D.id)},children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},D.id))})]})})})]})})};function ZIt(){const{toast:e}=_i(),[t,s]=A.useState([]),[n,a]=A.useState(!0),[o,l]=A.useState(!1),[i,d]=A.useState(!1),[m,p]=A.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});A.useEffect(()=>{g()},[]);const g=async()=>{try{const{data:S,error:T}=await Y.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(T)throw T;s(S.coupons||[])}catch(S){console.error("Error fetching coupons:",S),e({title:"Error",description:"Failed to load coupons",variant:"destructive"})}finally{a(!1)}},v=async()=>{if(!m.name){e({title:"Error",description:"Please enter a coupon name",variant:"destructive"});return}if(m.discountType==="percent"&&!m.percentOff){e({title:"Error",description:"Please enter a percent off value",variant:"destructive"});return}if(m.discountType==="amount"&&!m.amountOff){e({title:"Error",description:"Please enter an amount off value",variant:"destructive"});return}if(m.duration==="repeating"&&!m.durationInMonths){e({title:"Error",description:"Please enter duration in months",variant:"destructive"});return}l(!0);try{const S={action:"create",name:m.name,duration:m.duration,promotion_code:m.promotionCode.trim()||void 0};m.discountType==="percent"?S.percent_off=parseFloat(m.percentOff):(S.amount_off=Math.round(parseFloat(m.amountOff)*100),S.currency="usd"),m.duration==="repeating"&&(S.duration_in_months=parseInt(m.durationInMonths));const{data:T,error:C}=await Y.functions.invoke("stripe-manage-coupons",{body:S});if(C)throw C;e({title:"Success",description:"Coupon created successfully"}),d(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),g()}catch(S){console.error("Error creating coupon:",S),e({title:"Error",description:S.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},_=async S=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:T}=await Y.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:S}});if(T)throw T;e({title:"Success",description:"Coupon deleted successfully"}),g()}catch(T){console.error("Error deleting coupon:",T),e({title:"Error",description:T.message||"Failed to delete coupon",variant:"destructive"})}},k=S=>S.percent_off?`${S.percent_off}% off`:S.amount_off?`$${(S.amount_off/100).toFixed(2)} off`:"N/A",w=S=>{switch(S.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${S.duration_in_months} months`;default:return S.duration}};return r.jsx(Ur,{title:"Subscription Discounts",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Subscription Discounts",description:"Create and manage discount coupons for subscriptions",children:r.jsxs(Ir,{open:i,onOpenChange:d,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Create Coupon"]})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create New Coupon"}),r.jsx(Zs,{children:"Create a discount coupon that can be applied to subscriptions"})]}),r.jsxs("div",{className:"space-y-4 pt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Promotion Code (what users will type)"}),r.jsx(Ye,{placeholder:"e.g., BROKERAGE50",value:m.promotionCode,onChange:S=>p({...m,promotionCode:S.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")}),className:"font-mono uppercase"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Letters and numbers only. This is the code users enter at checkout."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Coupon Name (internal label)"}),r.jsx(Ye,{placeholder:"e.g., 50% Off Brokerage Launch",value:m.name,onChange:S=>p({...m,name:S.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Discount Type"}),r.jsxs(ds,{value:m.discountType,onValueChange:S=>{const T=S==="amount"&&m.duration==="forever"?"once":m.duration;p({...m,discountType:S,duration:T})},children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"percent",children:r.jsxs("span",{className:"flex items-center",children:[r.jsx(O4,{className:"mr-2 h-4 w-4"}),"Percentage Off"]})}),r.jsx(Ut,{value:"amount",children:r.jsxs("span",{className:"flex items-center",children:[r.jsx(Sd,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),m.discountType==="percent"?r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Percent Off"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ye,{type:"number",min:"1",max:"100",placeholder:"20",value:m.percentOff,onChange:S=>p({...m,percentOff:S.target.value})}),r.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}):r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Amount Off (USD)"}),r.jsxs("div",{className:"relative",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),r.jsx(Ye,{type:"number",min:"1",placeholder:"10.00",className:"pl-7",value:m.amountOff,onChange:S=>p({...m,amountOff:S.target.value})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Duration"}),r.jsxs(ds,{value:m.duration,onValueChange:S=>p({...m,duration:S}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"once",children:"Once (first payment only)"}),r.jsx(Ut,{value:"repeating",children:"Multiple months"}),r.jsxs(Ut,{value:"forever",disabled:m.discountType==="amount",children:["Forever ",m.discountType==="amount"&&"(% discounts only)"]})]})]}),m.discountType==="amount"&&r.jsx("p",{className:"text-xs text-muted-foreground",children:'Note: "Forever" duration is only available for percentage-based discounts.'})]}),m.duration==="repeating"&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Number of Months"}),r.jsx(Ye,{type:"number",min:"1",placeholder:"3",value:m.durationInMonths,onChange:S=>p({...m,durationInMonths:S.target.value})})]}),r.jsx(X,{onClick:v,disabled:o,className:"w-full",children:o?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Active Coupons"}),r.jsx(Cs,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),r.jsx(qe,{children:n?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t.length===0?r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No coupons created yet. Create your first coupon to get started."}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Promo Code"}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Discount"}),r.jsx(Mt,{children:"Duration"}),r.jsx(Mt,{children:"Redemptions"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:t.map(S=>{var T;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-mono font-medium",children:((T=S.promotion_codes)==null?void 0:T.length)>0?S.promotion_codes.join(", "):r.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),r.jsx(dt,{children:S.name||"-"}),r.jsx(dt,{children:k(S)}),r.jsx(dt,{children:w(S)}),r.jsx(dt,{children:S.times_redeemed}),r.jsx(dt,{children:r.jsx(_t,{variant:S.valid?"default":"secondary",children:S.valid?"Active":"Inactive"})}),r.jsx(dt,{className:"text-right",children:r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>_(S.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})})]},S.id)})})]})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"How to Use Coupons"})}),r.jsxs(qe,{className:"text-sm text-muted-foreground space-y-2",children:[r.jsx("p",{children:"1. Create a coupon above with your desired discount."}),r.jsx("p",{children:'2. Share the coupon code (shown in the "Code" column) with users.'}),r.jsx("p",{children:"3. Users can enter the code during checkout to receive the discount."}),r.jsx("p",{children:"4. Alternatively, you can create a promotion code in Stripe dashboard for public-facing promotions."})]})]})]})})}const bhe={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 YIt(){const[e,t]=A.useState(""),[s,n]=A.useState("all"),[a,o]=A.useState(null),{data:l,isLoading:i,refetch:d}=Ht({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:k,error:w}=await Y.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(w)throw w;return k}}),{data:m}=Ht({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:k,error:w}=await Y.from("brokerages").select("*").order("name");if(w)throw w;return await Promise.all((k||[]).map(async T=>{const{data:C}=await Y.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",T.id),{data:I}=await Y.from("user_roles").select("user_id").eq("role","brokerage_manager"),R=(I==null?void 0:I.map($=>$.user_id))||[],D=(C==null?void 0:C.filter($=>R.includes($.id)))||[],B=(C==null?void 0:C.length)||0;return{...T,managers:D,agentCount:B}}))}}),p=k=>{if(k.is_grandfathered)return{status:"Grandfathered",badge:"Legacy",variant:"secondary"};if(k.brokerage_id&&!k.subscription_product_id)return{status:"Brokerage",badge:"Team Member",variant:"outline"};if(k.is_trial&&k.trial_expires_at)return new Date(k.trial_expires_at)>new Date?{status:"Trial",badge:"Active Trial",variant:"default"}:{status:"Trial Expired",badge:"Expired",variant:"destructive"};if(k.subscription_status==="active"||k.subscription_status==="trialing"){const w=bhe[k.subscription_product_id];return{status:(w==null?void 0:w.name)||"Active",badge:k.subscription_status==="trialing"?"Trial":"Active",variant:"default"}}return k.subscription_status==="canceled"||k.subscription_status==="past_due"?{status:"Canceled",badge:"Inactive",variant:"destructive"}:{status:"None",badge:"No Subscription",variant:"outline"}},g=l==null?void 0:l.filter(k=>{var S,T;if(!(((S=k.name)==null?void 0:S.toLowerCase().includes(e.toLowerCase()))||((T=k.email)==null?void 0:T.toLowerCase().includes(e.toLowerCase()))))return!1;switch(p(k),s){case"active":return k.subscription_status==="active";case"trialing":return k.subscription_status==="trialing"||k.is_trial&&new Date(k.trial_expires_at)>new Date;case"grandfathered":return k.is_grandfathered;case"brokerage":return k.brokerage_id&&!k.subscription_product_id&&!k.is_grandfathered;case"expired":return k.subscription_status==="canceled"||k.subscription_status==="past_due"||k.is_trial&&new Date(k.trial_expires_at)<=new Date;case"none":return!k.subscription_status||k.subscription_status==="none";default:return!0}}),v={totalUsers:(l==null?void 0:l.length)||0,activeSubscriptions:(l==null?void 0:l.filter(k=>k.subscription_status==="active").length)||0,trials:(l==null?void 0:l.filter(k=>k.subscription_status==="trialing"||k.is_trial&&new Date(k.trial_expires_at)>new Date).length)||0,grandfathered:(l==null?void 0:l.filter(k=>k.is_grandfathered).length)||0,brokerageMembers:(l==null?void 0:l.filter(k=>k.brokerage_id&&!k.subscription_product_id&&!k.is_grandfathered).length)||0,individualSubscribers:(l==null?void 0:l.filter(k=>k.subscription_status==="active"&&k.subscription_product_id==="prod_Tc07cYplXUGNkm").length)||0,brokerageSubscribers:(l==null?void 0:l.filter(k=>k.subscription_status==="active"&&(k.subscription_product_id==="prod_Tc08MupgoVySDG"||k.subscription_product_id==="prod_Tc09N1tJ4RrAFn")).length)||0},_=k=>{window.open(`https://dashboard.stripe.com/customers/${k}`,"_blank")};return r.jsx(Ur,{title:"Subscription Management",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Subscription Management",description:"Track and manage all subscriptions",children:r.jsxs(X,{onClick:()=>d(),variant:"outline",size:"sm",children:[r.jsx(Yo,{className:"h-4 w-4 mr-2"}),"Refresh"]})}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-7 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Users"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:v.totalUsers})]})}),r.jsx(ze,{className:"border-green-500/50",children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Dm,{className:"h-4 w-4 text-green-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Active Paid"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1 text-green-600",children:v.activeSubscriptions})]})}),r.jsx(ze,{className:"border-blue-500/50",children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Pa,{className:"h-4 w-4 text-blue-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Trials"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1 text-blue-600",children:v.trials})]})}),r.jsx(ze,{className:"border-purple-500/50",children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(_h,{className:"h-4 w-4 text-purple-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Grandfathered"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1 text-purple-600",children:v.grandfathered})]})}),r.jsx(ze,{className:"border-orange-500/50",children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ni,{className:"h-4 w-4 text-orange-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Members"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1 text-orange-600",children:v.brokerageMembers})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ak,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Individual"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:v.individualSubscribers})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ni,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Brokerage Subs"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:v.brokerageSubscribers})]})})]}),r.jsxs(ii,{defaultValue:"users",className:"space-y-4",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"users",children:"All Users"}),r.jsx(Kr,{value:"brokerages",children:"Brokerages"})]}),r.jsxs(hs,{value:"users",className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name or email...",value:e,onChange:k=>t(k.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:s,onValueChange:k=>n(k),children:[r.jsx(ls,{className:"w-[200px]",children:r.jsx(us,{placeholder:"Filter by status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Users"}),r.jsx(Ut,{value:"active",children:"Active Subscriptions"}),r.jsx(Ut,{value:"trialing",children:"Trials"}),r.jsx(Ut,{value:"grandfathered",children:"Grandfathered"}),r.jsx(Ut,{value:"brokerage",children:"Brokerage Members"}),r.jsx(Ut,{value:"expired",children:"Expired/Canceled"}),r.jsx(Ut,{value:"none",children:"No Subscription"})]})]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"User"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Plan"}),r.jsx(Mt,{children:"Brokerage"}),r.jsx(Mt,{children:"End Date"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:i?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(g==null?void 0:g.length)===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No users found"})}):g==null?void 0:g.map(k=>{var T,C;const w=p(k),S=bhe[k.subscription_product_id];return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:k.name}),r.jsx("p",{className:"text-sm text-muted-foreground",children:k.email})]})}),r.jsx(dt,{children:r.jsx(_t,{variant:w.variant,children:w.badge})}),r.jsx(dt,{children:r.jsx("span",{className:"text-sm",children:k.is_grandfathered?"Legacy Access":k.brokerage_id&&!k.subscription_product_id?"Brokerage Subscription":(S==null?void 0:S.name)||w.status})}),r.jsx(dt,{children:(T=k.brokerages)!=null&&T.name?r.jsx("span",{className:"text-sm",children:k.brokerages.name}):r.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),r.jsx(dt,{children:k.subscription_end_date?r.jsx("span",{className:"text-sm",children:Xr(new Date(k.subscription_end_date),"MMM d, yyyy")}):k.trial_expires_at?r.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",Xr(new Date(k.trial_expires_at),"MMM d, yyyy")]}):r.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[k.stripe_customer_id&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>_(k.stripe_customer_id),children:r.jsx(jn,{className:"h-4 w-4"})}),r.jsxs(Ir,{children:[r.jsx(Qi,{asChild:!0,children:r.jsx(X,{variant:"outline",size:"sm",onClick:()=>o(k),children:"Details"})}),r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Subscription Details"}),r.jsxs(Zs,{children:[k.name," (",k.email,")"]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Status"}),r.jsx(_t,{variant:w.variant,className:"mt-1",children:w.badge})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Plan"}),r.jsx("p",{className:"font-medium",children:k.is_grandfathered?"Grandfathered (Legacy)":k.brokerage_id&&!k.subscription_product_id?"Brokerage Subscription":(S==null?void 0:S.name)||"None"})]}),k.brokerage_id&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Brokerage"}),r.jsx("p",{className:"font-medium",children:((C=k.brokerages)==null?void 0:C.name)||"Unknown"})]}),k.subscription_end_date&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Current Period End"}),r.jsx("p",{className:"font-medium",children:Xr(new Date(k.subscription_end_date),"MMMM d, yyyy")})]}),k.trial_expires_at&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Trial Expires"}),r.jsx("p",{className:"font-medium",children:Xr(new Date(k.trial_expires_at),"MMMM d, yyyy")})]}),k.stripe_customer_id&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Stripe Customer ID"}),r.jsx("p",{className:"font-mono text-sm",children:k.stripe_customer_id})]})]}),k.stripe_customer_id&&r.jsxs(X,{className:"w-full",onClick:()=>_(k.stripe_customer_id),children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},k.id)})})]})})})]}),r.jsx(hs,{value:"brokerages",className:"space-y-4",children:r.jsx("div",{className:"grid gap-4",children:m==null?void 0:m.map(k=>{var S,T;const w=(S=k.managers)==null?void 0:S.some(C=>C.subscription_status==="active"&&(C.subscription_product_id==="prod_Tc08MupgoVySDG"||C.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:r.jsx(Ni,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-lg",children:k.name}),r.jsxs(Cs,{children:[k.agentCount," agents"]})]})]}),r.jsx(_t,{variant:w?"default":"outline",children:w?"Active Subscription":"No Active Subscription"})]})}),r.jsx(qe,{children:((T=k.managers)==null?void 0:T.length)>0?r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Managers:"}),k.managers.map(C=>{const I=bhe[C.subscription_product_id];return r.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:C.name}),r.jsx("p",{className:"text-sm text-muted-foreground",children:C.email})]}),r.jsx("div",{className:"text-right",children:I?r.jsxs("div",{children:[r.jsx(_t,{variant:"default",children:I.name}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:I.price})]}):r.jsx(_t,{variant:"outline",children:"No Subscription"})})]},C.id)})]}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},k.id)})})})]})]})})}function XIt(){const[e,t]=A.useState([]),[s,n]=A.useState(!0),[a,o]=A.useState(""),[l,i]=A.useState("all"),[d,m]=A.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});A.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:k,error:w}=await Y.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;t(k||[]);const S=(k==null?void 0:k.filter(I=>I.status==="qualified").length)||0,T=(k==null?void 0:k.filter(I=>I.status==="pending").length)||0,C=(k==null?void 0:k.filter(I=>I.status==="cancelled").length)||0;m({total:(k==null?void 0:k.length)||0,qualified:S,pending:T,cancelled:C,totalDiscounts:S*25})}catch(k){console.error("Error fetching referrals:",k),we.error("Failed to load referrals")}finally{n(!1)}},g=async()=>{try{we.loading("Processing qualifications...");const{error:k}=await Y.functions.invoke("process-referral-qualifications");if(k)throw k;we.dismiss(),we.success("Qualifications processed successfully"),p()}catch(k){we.dismiss(),console.error("Error processing qualifications:",k),we.error("Failed to process qualifications")}},v=e.filter(k=>{var T,C,I,R,D,B;const w=((C=(T=k.referrer_brokerage)==null?void 0:T.name)==null?void 0:C.toLowerCase().includes(a.toLowerCase()))||((R=(I=k.referred_brokerage)==null?void 0:I.name)==null?void 0:R.toLowerCase().includes(a.toLowerCase()))||((B=(D=k.referred_user)==null?void 0:D.email)==null?void 0:B.toLowerCase().includes(a.toLowerCase())),S=l==="all"||k.status===l;return w&&S}),_=k=>{switch(k){case"qualified":return r.jsxs(_t,{className:"bg-green-100 text-green-800",children:[r.jsx(ui,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return r.jsxs(_t,{variant:"secondary",children:[r.jsx(Pa,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return r.jsxs(_t,{variant:"destructive",children:[r.jsx(Fc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return r.jsx(_t,{children:k})}};return r.jsx(Ur,{title:"Referral Program",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Referral Program",description:"Track and manage brokerage referrals",children:r.jsxs(X,{onClick:g,variant:"outline",children:[r.jsx(Yo,{className:"h-4 w-4 mr-2"}),"Process Qualifications"]})}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5 text-muted-foreground"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:d.total}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Referrals"})]})]})})}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ui,{className:"h-5 w-5 text-green-600"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:d.qualified}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Qualified"})]})]})})}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Pa,{className:"h-5 w-5 text-amber-600"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:d.pending}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Pending"})]})]})})}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Fc,{className:"h-5 w-5 text-red-600"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:d.cancelled}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Cancelled"})]})]})})}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Sd,{className:"h-5 w-5 text-green-600"}),r.jsxs("div",{children:[r.jsxs("p",{className:"text-2xl font-bold",children:["$",d.totalDiscounts]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Discounts"})]})]})})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"All Referrals"}),r.jsx(Cs,{children:"View and manage all referral relationships"})]}),r.jsxs(qe,{children:[r.jsxs("div",{className:"flex gap-4 mb-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by brokerage or email...",value:a,onChange:k=>o(k.target.value),className:"pl-10"})]}),r.jsxs(ds,{value:l,onValueChange:i,children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{placeholder:"Filter by status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Statuses"}),r.jsx(Ut,{value:"pending",children:"Pending"}),r.jsx(Ut,{value:"qualified",children:"Qualified"}),r.jsx(Ut,{value:"cancelled",children:"Cancelled"})]})]})]}),s?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Referrer"}),r.jsx(Mt,{children:"Referred"}),r.jsx(Mt,{children:"Signup Date"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Qualified Date"}),r.jsx(Mt,{children:"Discount"})]})}),r.jsx(Bn,{children:v.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):v.map(k=>{var w,S,T,C;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:((w=k.referrer_brokerage)==null?void 0:w.name)||"Unknown"}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("p",{children:((S=k.referred_brokerage)==null?void 0:S.name)||((T=k.referred_user)==null?void 0:T.name)||"Pending setup"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:(C=k.referred_user)==null?void 0:C.email})]})}),r.jsx(dt,{children:Xr(new Date(k.signup_date),"MMM d, yyyy")}),r.jsx(dt,{children:_(k.status)}),r.jsx(dt,{children:k.qualified_date?Xr(new Date(k.qualified_date),"MMM d, yyyy"):"-"}),r.jsx(dt,{children:k.discount_applied?r.jsx(_t,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):r.jsx("span",{className:"text-muted-foreground",children:"-"})})]},k.id)})})]})]})]})]})})}const whe=[{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"}],QIt=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function JIt(){const[e,t]=A.useState([]),[s,n]=A.useState(!0),[a,o]=A.useState(!1),[l,i]=A.useState(null),[d,m]=A.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});A.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:C,error:I}=await Y.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(I)throw I;t(C||[])}catch(C){console.error("Error fetching checklist items:",C),we.error("Failed to load checklist items")}finally{n(!1)}},g=()=>{i(null),m({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0}),o(!0)},v=C=>{i(C),m({title:C.title,description:C.description||"",action_type:C.action_type,target_role:C.target_role,is_active:C.is_active}),o(!0)},_=async()=>{if(!d.title.trim()){we.error("Title is required");return}try{if(l){const{error:C}=await Y.from("onboarding_checklist_items").update({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active}).eq("id",l.id);if(C)throw C;we.success("Checklist item updated")}else{const C=e.filter(R=>R.target_role===d.target_role).reduce((R,D)=>Math.max(R,D.sort_order),-1),{error:I}=await Y.from("onboarding_checklist_items").insert({title:d.title,description:d.description||null,action_type:d.action_type,target_role:d.target_role,is_active:d.is_active,sort_order:C+1});if(I)throw I;we.success("Checklist item created")}o(!1),p()}catch(C){console.error("Error saving checklist item:",C),we.error("Failed to save checklist item")}},k=async C=>{if(confirm("Are you sure you want to delete this checklist item?"))try{const{error:I}=await Y.from("onboarding_checklist_items").delete().eq("id",C);if(I)throw I;we.success("Checklist item deleted"),p()}catch(I){console.error("Error deleting checklist item:",I),we.error("Failed to delete checklist item")}},w=async C=>{try{const{error:I}=await Y.from("onboarding_checklist_items").update({is_active:!C.is_active}).eq("id",C.id);if(I)throw I;we.success(C.is_active?"Item deactivated":"Item activated"),p()}catch(I){console.error("Error toggling item:",I),we.error("Failed to update item")}},S=e.filter(C=>C.target_role==="brokerage_manager"),T=e.filter(C=>C.target_role==="agent");return r.jsxs(Ur,{title:"Onboarding Checklist",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold",children:"Onboarding Checklist"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage checklist items shown to new users on their dashboard"})]}),r.jsxs(X,{onClick:g,className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Add Item"]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(_t,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),r.jsx(qe,{children:S.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-12",children:"#"}),r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Action Type"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:S.map((C,I)=>{var R;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"text-muted-foreground",children:I+1}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:C.title}),C.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),r.jsx(dt,{children:r.jsx(_t,{variant:"outline",children:((R=whe.find(D=>D.value===C.action_type))==null?void 0:R.label)||C.action_type})}),r.jsx(dt,{children:r.jsx(fn,{checked:C.is_active,onCheckedChange:()=>w(C)})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>v(C),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>k(C.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(_t,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),r.jsx(qe,{children:T.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-12",children:"#"}),r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Action Type"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:T.map((C,I)=>{var R;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"text-muted-foreground",children:I+1}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:C.title}),C.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),r.jsx(dt,{children:r.jsx(_t,{variant:"outline",children:((R=whe.find(D=>D.value===C.action_type))==null?void 0:R.label)||C.action_type})}),r.jsx(dt,{children:r.jsx(fn,{checked:C.is_active,onCheckedChange:()=>w(C)})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>v(C),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>k(C.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]})]}),r.jsx(Ir,{open:a,onOpenChange:o,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:l?"Edit Checklist Item":"Add Checklist Item"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title *"}),r.jsx(Ye,{id:"title",value:d.title,onChange:C=>m({...d,title:C.target.value}),placeholder:"e.g., Watch your first academy video"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",value:d.description,onChange:C=>m({...d,description:C.target.value}),placeholder:"Optional description for the checklist item",rows:2})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Target Role"}),r.jsxs(ds,{value:d.target_role,onValueChange:C=>m({...d,target_role:C}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:QIt.map(C=>r.jsx(Ut,{value:C.value,children:C.label},C.value))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Action Type"}),r.jsxs(ds,{value:d.action_type,onValueChange:C=>m({...d,action_type:C}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:whe.map(C=>r.jsx(Ut,{value:C.value,children:C.label},C.value))})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"is_active",checked:d.is_active,onCheckedChange:C=>m({...d,is_active:C})}),r.jsx(Ee,{htmlFor:"is_active",children:"Active"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),r.jsx(X,{onClick:_,children:l?"Save Changes":"Create Item"})]})]})})]})}function ePt(){const[e,t]=A.useState(""),[s,n]=A.useState("all"),[a,o]=A.useState("name"),[l,i]=A.useState("asc"),[d,m]=A.useState(""),[p,g]=A.useState(""),[v,_]=A.useState(""),[k,w]=A.useState(""),{data:S}=Ht({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:K,error:re}=await Y.from("brokerages").select("id, name").order("name");if(re)throw re;return K}}),T=async K=>{let ae=[],oe=0,se=!0;for(;se;){const{data:pe,error:ie}=await K(oe,oe+1e3-1);if(ie)throw ie;pe&&pe.length>0?(ae=[...ae,...pe],oe+=1e3,se=pe.length===1e3):se=!1}return ae},{data:C,isLoading:I}=Ht({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const K=await T((Ve,Ie)=>Y.from("profiles").select("id, name, email, brokerage_id, created_at").range(Ve,Ie)),{data:re}=await Y.from("brokerages").select("id, name"),ae=new Map((re==null?void 0:re.map(Ve=>[Ve.id,Ve.name]))||[]),[{data:oe},{data:se},{data:pe},{data:ie},{data:de},{data:ce},{data:ge}]=await Promise.all([Y.rpc("get_admin_contact_counts"),Y.rpc("get_admin_video_counts"),Y.rpc("get_admin_popby_counts"),Y.rpc("get_admin_listing_counts"),Y.rpc("get_admin_deal_counts"),Y.rpc("get_admin_portal_counts"),Y.rpc("get_admin_sendable_card_counts")]),Te=new Map;oe==null||oe.forEach(Ve=>Te.set(Ve.owner_user_id,Ve.contact_count));const _e=new Map;se==null||se.forEach(Ve=>_e.set(Ve.owner_user_id,Ve.video_count));const ve=new Map;pe==null||pe.forEach(Ve=>ve.set(Ve.owner_user_id,Ve.popby_count));const Me=new Map;ie==null||ie.forEach(Ve=>Me.set(Ve.agent_id,Ve.listing_count));const Ze=new Map;de==null||de.forEach(Ve=>Ze.set(Ve.owner_user_id,Ve.deal_count));const Ae=new Map;ce==null||ce.forEach(Ve=>Ae.set(Ve.owner_user_id,{total:Ve.portal_count,active:Ve.active_portal_count}));const Le=new Map;return ge==null||ge.forEach(Ve=>Le.set(Ve.owner_user_id,{total:Ve.card_count,sent:Ve.sent_card_count,views:Ve.total_card_views})),K.map(Ve=>{const Ie=Ae.get(Ve.id),We=Le.get(Ve.id);return{id:Ve.id,name:Ve.name||"Unknown",email:Ve.email||"",brokerage_id:Ve.brokerage_id,brokerage_name:Ve.brokerage_id&&ae.get(Ve.brokerage_id)||null,contact_count:Te.get(Ve.id)||0,video_count:_e.get(Ve.id)||0,popby_count:ve.get(Ve.id)||0,listing_count:Me.get(Ve.id)||0,deal_count:Ze.get(Ve.id)||0,portal_count:(Ie==null?void 0:Ie.total)||0,active_portal_count:(Ie==null?void 0:Ie.active)||0,card_count:(We==null?void 0:We.total)||0,sent_card_count:(We==null?void 0:We.sent)||0,total_card_views:(We==null?void 0:We.views)||0,created_at:Ve.created_at}})}}),R=A.useMemo(()=>{if(!C)return[];let K=C.filter(re=>{const ae=e.toLowerCase(),oe=!e||re.name.toLowerCase().includes(ae)||re.email.toLowerCase().includes(ae),se=s==="all"||s==="none"&&!re.brokerage_id||re.brokerage_id===s,pe=parseInt(d)||0,ie=parseInt(p)||0,de=parseInt(v)||0,ce=parseInt(k)||0,ge=re.contact_count>=pe&&re.video_count>=ie&&re.popby_count>=de&&re.listing_count>=ce;return oe&&se&&ge});return K.sort((re,ae)=>{let oe=0;return a==="name"?oe=re.name.localeCompare(ae.name):oe=re[a]-ae[a],l==="asc"?oe:-oe}),K},[C,e,s,a,l,d,p,v,k]),D=K=>{a===K?i(l==="asc"?"desc":"asc"):(o(K),i("desc"))},B=()=>{const K=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],re=R.map(ie=>[ie.name,ie.email,ie.brokerage_name||"None",ie.contact_count,ie.video_count,ie.popby_count,ie.listing_count,ie.deal_count,`${ie.portal_count} (${ie.active_portal_count})`,ie.card_count,ie.sent_card_count,ie.total_card_views]),ae=[K.join(","),...re.map(ie=>ie.map(de=>`"${de}"`).join(","))].join(` `),oe=new Blob([ae],{type:"text/csv"}),se=URL.createObjectURL(oe),pe=document.createElement("a");pe.href=se,pe.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,pe.click(),URL.revokeObjectURL(se)},$=A.useMemo(()=>R.length?R.reduce((K,re)=>({contacts:K.contacts+re.contact_count,videos:K.videos+re.video_count,popbys:K.popbys+re.popby_count,listings:K.listings+re.listing_count,deals:K.deals+re.deal_count,portals:K.portals+re.portal_count,activePortals:K.activePortals+re.active_portal_count,cards:K.cards+re.card_count,sentCards:K.sentCards+re.sent_card_count,cardViews:K.cardViews+re.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},[R]),q=A.useMemo(()=>R.length?{portals:R.filter(K=>K.portal_count>0).length,cards:R.filter(K=>K.card_count>0).length}:{portals:0,cards:0},[R]),W=({field:K,children:re})=>r.jsx(Mt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>D(K),children:r.jsxs("div",{className:"flex items-center gap-1",children:[re,r.jsx(eg,{className:`h-3 w-3 ${a===K?"text-primary":"text-muted-foreground"}`})]})});return r.jsx(xN,{children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsxs(ze,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"text-sm font-medium flex items-center gap-2",children:[r.jsx(Fy,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),r.jsx(qe,{children:r.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold",children:q.portals}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold",children:$.portals}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Portals"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.activePortals}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),r.jsxs(ze,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"text-sm font-medium flex items-center gap-2",children:[r.jsx(Vs,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),r.jsx(qe,{children:r.jsxs("div",{className:"grid grid-cols-4 gap-3 text-center",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold",children:q.cards}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Agents Using"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold",children:$.cards}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Created"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-emerald-600",children:$.sentCards}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Cards Sent"})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-2xl font-bold text-blue-600",children:$.cardViews}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"User Activity Analytics"]}),r.jsx(Cs,{children:"View all users and their Agent OS usage metrics"})]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:B,children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"grid gap-4 md:grid-cols-6",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name or email...",value:e,onChange:K=>t(K.target.value),className:"pl-9"})]})}),r.jsx("div",{children:r.jsxs(ds,{value:s,onValueChange:n,children:[r.jsxs(ls,{children:[r.jsx(Ni,{className:"h-4 w-4 mr-2 text-muted-foreground"}),r.jsx(us,{placeholder:"Brokerage"})]}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Brokerages"}),r.jsx(Ut,{value:"none",children:"No Brokerage"}),S==null?void 0:S.map(K=>r.jsx(Ut,{value:K.id,children:K.name},K.id))]})]})}),r.jsx("div",{children:r.jsx(Ye,{type:"number",placeholder:"Min contacts",value:d,onChange:K=>m(K.target.value),min:"0"})}),r.jsx("div",{children:r.jsx(Ye,{type:"number",placeholder:"Min videos",value:p,onChange:K=>g(K.target.value),min:"0"})}),r.jsx("div",{children:r.jsx(Ye,{type:"number",placeholder:"Min popbys",value:v,onChange:K=>_(K.target.value),min:"0"})})]}),r.jsxs("div",{className:"grid gap-4 md:grid-cols-8 text-sm",children:[r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:R.length}),r.jsx("div",{className:"text-muted-foreground",children:"Users"})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:$.contacts.toLocaleString()}),r.jsx("div",{className:"text-muted-foreground",children:"Contacts"})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:$.videos.toLocaleString()}),r.jsx("div",{className:"text-muted-foreground",children:"Videos"})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:$.popbys.toLocaleString()}),r.jsx("div",{className:"text-muted-foreground",children:"Popbys"})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:$.listings.toLocaleString()}),r.jsx("div",{className:"text-muted-foreground",children:"Listings"})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:$.deals.toLocaleString()}),r.jsx("div",{className:"text-muted-foreground",children:"Deals"})]}),r.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:$.portals.toLocaleString()}),r.jsx("div",{className:"text-muted-foreground",children:"Portals"})]}),r.jsxs("div",{className:"bg-violet-500/10 rounded-lg p-3 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:$.cards.toLocaleString()}),r.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),I?r.jsx("div",{className:"flex justify-center py-12",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.jsx("div",{className:"rounded-md border overflow-x-auto",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(W,{field:"name",children:"Name"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Brokerage"}),r.jsx(W,{field:"contact_count",children:"Contacts"}),r.jsx(W,{field:"video_count",children:"Videos"}),r.jsx(W,{field:"popby_count",children:"Popbys"}),r.jsx(W,{field:"listing_count",children:"Listings"}),r.jsx(W,{field:"deal_count",children:"Deals"}),r.jsx(W,{field:"portal_count",children:r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Fy,{className:"h-3 w-3 text-blue-500"}),"Portals"]})}),r.jsx(W,{field:"card_count",children:r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Vs,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),r.jsx(Bn,{children:R.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):R.map(K=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:K.name}),r.jsx(dt,{className:"text-muted-foreground",children:K.email}),r.jsx(dt,{children:K.brokerage_name?r.jsx(_t,{variant:"secondary",children:K.brokerage_name}):r.jsx("span",{className:"text-muted-foreground",children:"—"})}),r.jsx(dt,{children:r.jsx(_t,{variant:K.contact_count>0?"default":"outline",children:K.contact_count})}),r.jsx(dt,{children:r.jsx(_t,{variant:K.video_count>0?"default":"outline",children:K.video_count})}),r.jsx(dt,{children:r.jsx(_t,{variant:K.popby_count>0?"default":"outline",children:K.popby_count})}),r.jsx(dt,{children:r.jsx(_t,{variant:K.listing_count>0?"default":"outline",children:K.listing_count})}),r.jsx(dt,{children:r.jsx(_t,{variant:K.deal_count>0?"default":"outline",children:K.deal_count})}),r.jsx(dt,{children:K.portal_count>0?r.jsxs(Gh,{children:[r.jsx(Kh,{children:r.jsxs(_t,{variant:"default",className:"bg-blue-600 hover:bg-blue-700",children:[K.portal_count,K.active_portal_count>0&&r.jsxs("span",{className:"ml-1 opacity-75",children:["(",K.active_portal_count," active)"]})]})}),r.jsxs(dh,{children:[r.jsxs("p",{children:[K.portal_count," total portals"]}),r.jsxs("p",{children:[K.active_portal_count," currently active"]})]})]}):r.jsx(_t,{variant:"outline",children:"0"})}),r.jsx(dt,{children:K.card_count>0?r.jsxs(Gh,{children:[r.jsx(Kh,{children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(_t,{variant:"default",className:"bg-violet-600 hover:bg-violet-700",children:K.card_count}),K.sent_card_count>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-emerald-600",children:[r.jsx(ai,{className:"h-3 w-3"}),K.sent_card_count]}),K.total_card_views>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-xs text-muted-foreground",children:[r.jsx(Ii,{className:"h-3 w-3"}),K.total_card_views]})]})}),r.jsxs(dh,{children:[r.jsxs("p",{children:[K.card_count," cards created"]}),r.jsxs("p",{children:[K.sent_card_count," sent"]}),r.jsxs("p",{children:[K.total_card_views," total views"]})]})]}):r.jsx(_t,{variant:"outline",children:"0"})})]},K.id))})]})})]})]})]})})}function tPt(){_i(),Rr();const[e,t]=A.useState("user-analytics"),{data:s}=Ht({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:_,error:k}=await Y.from("feature_flags").select("*").order("key");if(k)throw k;return _}}),{data:n,isLoading:a}=Ht({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:_,error:k}=await Y.from("relationship_types").select("*").order("sort_order");if(k)throw k;return _}}),{data:o,isLoading:l}=Ht({queryKey:["admin-action-types"],queryFn:async()=>{const{data:_,error:k}=await Y.from("action_types").select("*").order("sort_order");if(k)throw k;return _}}),{data:i,isLoading:d}=Ht({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:_,error:k}=await Y.from("action_scripts").select("*, action_type:action_types(*)");if(k)throw k;return _}}),{data:m,isLoading:p}=Ht({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:_,error:k}=await Y.from("touchpoint_plans").select("*").order("name");if(k)throw k;return _}}),{data:g,isLoading:v}=Ht({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:_,error:k}=await Y.from("popby_items").select("*").is("owner_user_id",null).order("name");if(k)throw k;return _}});return r.jsx(Ur,{title:"Agent OS Control Center",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),r.jsxs(ii,{value:e,onValueChange:t,children:[r.jsxs(si,{className:"grid w-full grid-cols-9",children:[r.jsxs(Kr,{value:"user-analytics",className:"gap-2",children:[r.jsx(Rc,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),r.jsxs(Kr,{value:"relationship-types",className:"gap-2",children:[r.jsx(ws,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),r.jsxs(Kr,{value:"action-types",className:"gap-2",children:[r.jsx(fi,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),r.jsxs(Kr,{value:"scripts",className:"gap-2",children:[r.jsx(ya,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),r.jsxs(Kr,{value:"video-scripts",className:"gap-2",children:[r.jsx(Ud,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),r.jsxs(Kr,{value:"plans",className:"gap-2",children:[r.jsx(An,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),r.jsxs(Kr,{value:"popbys",className:"gap-2",children:[r.jsx(po,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),r.jsxs(Kr,{value:"settings",className:"gap-2",children:[r.jsx(ld,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),r.jsxs(Kr,{value:"feature-flags",className:"gap-2",children:[r.jsx(zy,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),r.jsx(hs,{value:"user-analytics",className:"mt-6",children:r.jsx(ePt,{})}),r.jsx(hs,{value:"relationship-types",className:"mt-6",children:r.jsx(rPt,{types:n||[],isLoading:a})}),r.jsx(hs,{value:"action-types",className:"mt-6",children:r.jsx(sPt,{types:o||[],isLoading:l})}),r.jsx(hs,{value:"scripts",className:"mt-6",children:r.jsx(nPt,{scripts:i||[],actionTypes:o||[],isLoading:d})}),r.jsx(hs,{value:"video-scripts",className:"mt-6",children:r.jsx(lPt,{})}),r.jsx(hs,{value:"plans",className:"mt-6",children:r.jsx(aPt,{plans:m||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),r.jsx(hs,{value:"popbys",className:"mt-6",children:r.jsx(oPt,{items:g||[],isLoading:v})}),r.jsx(hs,{value:"settings",className:"mt-6",children:r.jsx(cPt,{})}),r.jsx(hs,{value:"feature-flags",className:"mt-6",children:r.jsx(iPt,{flags:s||[]})})]})]})})}function rPt({types:e,isLoading:t}){const{toast:s}=_i(),n=Rr(),[a,o]=A.useState(null),[l,i]=A.useState(!1),d=Qt({mutationFn:async p=>{if(p.id){const{error:g}=await Y.from("relationship_types").update({name:p.name,description:p.description,icon:p.icon}).eq("id",p.id);if(g)throw g}else{const{error:g}=await Y.from("relationship_types").insert([{name:p.name,description:p.description,icon:p.icon,sort_order:e.length}]);if(g)throw g}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-relationship-types"]}),i(!1),o(null),s({title:"Saved successfully"})},onError:p=>{s({title:"Error",description:p.message,variant:"destructive"})}}),m=async p=>{await Y.from("relationship_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-relationship-types"]})};return r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Relationship Types"}),r.jsx(Cs,{children:"Define the relationship categories for InnerCircle contacts"})]}),r.jsxs(X,{onClick:()=>{o(null),i(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Type"]})]}),r.jsx(qe,{children:t?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-12"}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"w-24",children:"Actions"})]})}),r.jsx(Bn,{children:e.map(p=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsx(Df,{className:"h-4 w-4 text-muted-foreground cursor-grab"})}),r.jsx(dt,{className:"font-medium",children:p.name}),r.jsx(dt,{className:"text-muted-foreground",children:p.description}),r.jsx(dt,{children:r.jsx(fn,{checked:p.active,onCheckedChange:()=>m(p)})}),r.jsx(dt,{children:r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:r.jsx(Qa,{className:"h-4 w-4"})})})]},p.id))})]})}),r.jsx(Ir,{open:l,onOpenChange:i,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsxs(Fr,{children:[a?"Edit":"Add"," Relationship Type"]})}),r.jsxs("form",{onSubmit:p=>{p.preventDefault();const g=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description"),icon:g.get("icon")})},children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"icon",children:"Icon"}),r.jsx(Ye,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., star, heart, user"})]})]}),r.jsxs(Rn,{className:"mt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:d.isPending,children:[d.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function sPt({types:e,isLoading:t}){const{toast:s}=_i(),n=Rr(),[a,o]=A.useState(null),[l,i]=A.useState(!1),d=Qt({mutationFn:async p=>{if(p.id){const{error:g}=await Y.from("action_types").update({name:p.name,description:p.description,icon:p.icon,color:p.color}).eq("id",p.id);if(g)throw g}else{const{error:g}=await Y.from("action_types").insert([{name:p.name,description:p.description,icon:p.icon,color:p.color,sort_order:e.length}]);if(g)throw g}},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-action-types"]}),i(!1),o(null),s({title:"Saved successfully"})},onError:p=>{s({title:"Error",description:p.message,variant:"destructive"})}}),m=async p=>{await Y.from("action_types").update({active:!p.active}).eq("id",p.id),n.invalidateQueries({queryKey:["admin-action-types"]})};return r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Action Types"}),r.jsx(Cs,{children:"Define the types of touchpoint actions agents can take"})]}),r.jsxs(X,{onClick:()=>{o(null),i(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Action"]})]}),r.jsx(qe,{children:t?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{children:"Color"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"w-24",children:"Actions"})]})}),r.jsx(Bn,{children:e.map(p=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:p.name}),r.jsx(dt,{className:"text-muted-foreground",children:p.description}),r.jsx(dt,{children:p.color&&r.jsx("div",{className:"w-6 h-6 rounded",style:{backgroundColor:p.color}})}),r.jsx(dt,{children:r.jsx(fn,{checked:p.active,onCheckedChange:()=>m(p)})}),r.jsx(dt,{children:r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{o(p),i(!0)},children:r.jsx(Qa,{className:"h-4 w-4"})})})]},p.id))})]})}),r.jsx(Ir,{open:l,onOpenChange:i,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsxs(Fr,{children:[a?"Edit":"Add"," Action Type"]})}),r.jsxs("form",{onSubmit:p=>{p.preventDefault();const g=new FormData(p.currentTarget);d.mutate({id:a==null?void 0:a.id,name:g.get("name"),description:g.get("description"),icon:g.get("icon"),color:g.get("color")})},children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"icon",children:"Icon"}),r.jsx(Ye,{id:"icon",name:"icon",defaultValue:(a==null?void 0:a.icon)||"",placeholder:"e.g., phone, message"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"color",children:"Color"}),r.jsx(Ye,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),r.jsxs(Rn,{className:"mt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:d.isPending,children:[d.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function nPt({scripts:e,actionTypes:t,isLoading:s}){const{toast:n}=_i(),a=Rr(),[o,l]=A.useState(null),[i,d]=A.useState(!1),m=Qt({mutationFn:async g=>{if(g.id){const{error:v}=await Y.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 Y.from("action_scripts").insert([{title:g.title,action_type_id:g.action_type_id,tone:g.tone,script_body:g.script_body,active:!0}]);if(v)throw v}},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),d(!1),l(null),n({title:"Saved successfully"})},onError:g=>{n({title:"Error",description:g.message,variant:"destructive"})}}),p=Qt({mutationFn:async g=>{const{error:v}=await Y.from("action_scripts").delete().eq("id",g);if(v)throw v},onSuccess:()=>{a.invalidateQueries({queryKey:["admin-action-scripts"]}),n({title:"Deleted successfully"})}});return r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Script Library"}),r.jsx(Cs,{children:"Create and manage scripts for each action type"})]}),r.jsxs(X,{onClick:()=>{l(null),d(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),r.jsx(qe,{children:s?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Action Type"}),r.jsx(Mt,{children:"Tone"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"w-24",children:"Actions"})]})}),r.jsx(Bn,{children:e.map(g=>{var v;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:g.title}),r.jsx(dt,{children:r.jsx(_t,{variant:"outline",children:((v=g.action_type)==null?void 0:v.name)||"Unknown"})}),r.jsx(dt,{className:"text-muted-foreground",children:g.tone}),r.jsx(dt,{children:r.jsx(_t,{variant:g.active?"default":"secondary",children:g.active?"Active":"Inactive"})}),r.jsxs(dt,{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{l(g),d(!0)},children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>p.mutate(g.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})]},g.id)})})]})}),r.jsx(Ir,{open:i,onOpenChange:d,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:[o?"Edit":"Add"," Script"]})}),r.jsxs("form",{onSubmit:g=>{g.preventDefault();const v=new FormData(g.currentTarget);m.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:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"title",children:"Title"}),r.jsx(Ye,{id:"title",name:"title",defaultValue:o==null?void 0:o.title,required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"action_type_id",children:"Action Type"}),r.jsxs(ds,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select action type"})}),r.jsx(cs,{children:t.map(g=>r.jsx(Ut,{value:g.id,children:g.name},g.id))})]})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"tone",children:"Tone (optional)"}),r.jsx(Ye,{id:"tone",name:"tone",defaultValue:(o==null?void 0:o.tone)||"",placeholder:"e.g., Friendly, Professional, Casual"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script_body",children:"Script Body"}),r.jsx(qs,{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...`})]})]}),r.jsxs(Rn,{className:"mt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>d(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:m.isPending,children:[m.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function aPt({plans:e,actionTypes:t,scripts:s,isLoading:n}){const{toast:a}=_i(),o=Rr(),[l,i]=A.useState(null),[d,m]=A.useState(!1),[p,g]=A.useState(null),[v,_]=A.useState(!1),[k,w]=A.useState(null),[S,T]=A.useState(null),{data:C}=Ht({queryKey:["plan-items",p],queryFn:async()=>{if(!p)return[];const{data:W,error:K}=await Y.from("touchpoint_plan_items").select("*").eq("plan_id",p).order("month_number");if(K)throw K;return W},enabled:!!p}),I=Qt({mutationFn:async W=>{if(W.id){const{error:K}=await Y.from("touchpoint_plans").update({name:W.name,description:W.description,active:W.active}).eq("id",W.id);if(K)throw K}else{const{error:K}=await Y.from("touchpoint_plans").insert([{name:W.name,description:W.description,active:!0}]);if(K)throw K}},onSuccess:()=>{o.invalidateQueries({queryKey:["admin-touchpoint-plans"]}),m(!1),i(null),a({title:"Saved successfully"})},onError:W=>{a({title:"Error",description:W.message,variant:"destructive"})}}),R=Qt({mutationFn:async W=>{if(W.id){const{error:K}=await Y.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(K)throw K}else{const{error:K}=await Y.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(K)throw K}},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]}),a({title:"Item saved"})}}),D=Qt({mutationFn:async W=>{const{error:K}=await Y.from("touchpoint_plan_items").delete().eq("id",W);if(K)throw K},onSuccess:()=>{o.invalidateQueries({queryKey:["plan-items",p]})}}),B=Qt({mutationFn:async W=>{const{data:K,error:re}=await Y.from("action_scripts").insert([{...W,active:!0}]).select().single();if(re)throw re;return K},onSuccess:async W=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),k&&await R.mutateAsync({id:k.itemId,plan_id:p,month_number:k.month,action_type_id:k.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,K,re)=>{w({month:W,actionTypeId:K,itemId:re}),_(!0)},q=W=>s.find(K=>K.id===W);return r.jsxs("div",{className:"space-y-6",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Touchpoint Plans"}),r.jsx(Cs,{children:"Create annual touchpoint plans that agents can apply to their contacts"})]}),r.jsxs(X,{onClick:()=>{i(null),m(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Plan"]})]}),r.jsx(qe,{children:n?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:e.map(W=>r.jsxs(ze,{className:`cursor-pointer transition-colors ${p===W.id?"border-primary":""}`,onClick:()=>g(W.id),children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Zt,{className:"text-base",children:W.name}),r.jsx(X,{variant:"ghost",size:"icon",onClick:K=>{K.stopPropagation(),i(W),m(!0)},children:r.jsx(Qa,{className:"h-4 w-4"})})]})}),r.jsxs(qe,{children:[r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:W.description}),r.jsx(_t,{variant:W.active?"default":"secondary",className:"mt-2",children:W.active?"Active":"Inactive"})]})]},W.id))})})]}),p&&r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Plan Schedule"}),r.jsx(Cs,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),r.jsx(qe,{children:r.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(W,K)=>K+1).map(W=>{const K=C==null?void 0:C.find(oe=>oe.month_number===W),re=K!=null&&K.default_script_id?q(K.default_script_id):null,ae=s.filter(oe=>oe.action_type_id===(K==null?void 0:K.action_type_id)&&oe.active);return r.jsxs("div",{className:"p-4 border rounded-lg space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"w-20 font-medium text-sm",children:["Month ",W]}),r.jsxs(ds,{value:(K==null?void 0:K.action_type_id)||"none",onValueChange:oe=>{oe==="none"&&K?D.mutate(K.id):oe!=="none"&&R.mutate({id:K==null?void 0:K.id,plan_id:p,month_number:W,action_type_id:oe,default_script_id:null})},children:[r.jsx(ls,{className:"w-40",children:r.jsx(us,{placeholder:"No action"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No action"}),t.filter(oe=>oe.active).map(oe=>r.jsx(Ut,{value:oe.id,children:r.jsxs("span",{className:"flex items-center gap-2",children:[oe.color&&r.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:oe.color}}),oe.name]})},oe.id))]})]}),K&&r.jsxs(r.Fragment,{children:[r.jsxs(ds,{value:K.default_script_id||"none",onValueChange:oe=>{T(null),R.mutate({id:K.id,default_script_id:oe==="none"?null:oe})},children:[r.jsx(ls,{className:"w-56",children:r.jsx(us,{placeholder:"Select script"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No default script"}),ae.map(oe=>r.jsxs(Ut,{value:oe.id,children:[oe.title," ",oe.tone&&`(${oe.tone})`]},oe.id))]})]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>$(W,K.action_type_id,K.id),children:[r.jsx(gs,{className:"h-3 w-3 mr-1"}),"New Script"]}),re&&r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>T((S==null?void 0:S.id)===re.id?null:re),children:(S==null?void 0:S.id)===re.id?"Hide":"Preview"})]})]}),S&&(K==null?void 0:K.default_script_id)===S.id&&r.jsxs("div",{className:"ml-24 p-3 bg-muted rounded-lg text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(_t,{variant:"outline",children:S.title}),S.tone&&r.jsx(_t,{variant:"secondary",children:S.tone})]}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:S.script_body})]})]},W)})})})]}),r.jsx(Ir,{open:d,onOpenChange:m,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsxs(Fr,{children:[l?"Edit":"Add"," Touchpoint Plan"]})}),r.jsxs("form",{onSubmit:W=>{W.preventDefault();const K=new FormData(W.currentTarget);I.mutate({id:l==null?void 0:l.id,name:K.get("name"),description:K.get("description"),active:!0})},children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",name:"name",defaultValue:l==null?void 0:l.name,required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),r.jsxs(Rn,{className:"mt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>m(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:I.isPending,children:[I.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),r.jsx(Ir,{open:v,onOpenChange:_,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create New Script"}),r.jsxs(Zs,{children:["Create a script for Month ",k==null?void 0:k.month,". Use ","{{FirstName}}",", ","{{LastName}}",", and ","{{AgentName}}"," as placeholders."]})]}),r.jsxs("form",{onSubmit:W=>{W.preventDefault();const K=new FormData(W.currentTarget);B.mutate({title:K.get("title"),action_type_id:k.actionTypeId,tone:K.get("tone"),script_body:K.get("script_body")})},children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script_title",children:"Title"}),r.jsx(Ye,{id:"script_title",name:"title",placeholder:"e.g., Warm Check-In",required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script_tone",children:"Tone"}),r.jsx(Ye,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script_body",children:"Script Body"}),r.jsx(qs,{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..."})]})]}),r.jsxs(Rn,{className:"mt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>_(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:B.isPending,children:[B.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function iPt({flags:e}){const{toast:t}=_i(),s=Rr(),n=async(a,o)=>{const{error:l}=await Y.from("feature_flags").update({...o,updated_at:new Date().toISOString()}).eq("id",a.id);l?t({title:"Error",description:l.message,variant:"destructive"}):(s.invalidateQueries({queryKey:["admin-feature-flags"]}),t({title:"Flag updated"}))};return r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Feature Flags"}),r.jsx(Cs,{children:"Control which features are enabled for members"})]}),r.jsx(qe,{children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Flag"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Notes"}),r.jsx(Mt,{children:"Last Updated"})]})}),r.jsx(Bn,{children:e.map(a=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-mono text-sm",children:a.key}),r.jsx(dt,{children:r.jsx(fn,{checked:a.enabled,onCheckedChange:o=>n(a,{enabled:o})})}),r.jsx(dt,{children:r.jsx(Ye,{defaultValue:a.notes||"",placeholder:"Add notes...",className:"max-w-xs",onBlur:o=>{o.target.value!==a.notes&&n(a,{notes:o.target.value})}})}),r.jsx(dt,{className:"text-muted-foreground text-sm",children:new Date(a.updated_at).toLocaleDateString()})]},a.id))})]})})]})}function oPt({items:e,isLoading:t}){const{toast:s}=_i(),n=Rr(),[a,o]=A.useState(null),[l,i]=A.useState(!1),d=Qt({mutationFn:async g=>{if(g.id){const{error:v}=await Y.from("popby_items").update({name:g.name,description:g.description}).eq("id",g.id);if(v)throw v}else{const{error:v}=await Y.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),s({title:"Saved successfully"})},onError:g=>{s({title:"Error",description:g.message,variant:"destructive"})}}),m=async g=>{await Y.from("popby_items").update({is_active:!g.is_active}).eq("id",g.id),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]})},p=async g=>{await Y.from("popby_items").delete().eq("id",g),n.invalidateQueries({queryKey:["admin-popby-items"]}),n.invalidateQueries({queryKey:["popby-items"]}),s({title:"Deleted successfully"})};return r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Popby Ideas"}),r.jsx(Cs,{children:"Manage global popby ideas that all agents can see"})]}),r.jsxs(X,{onClick:()=>{o(null),i(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),r.jsx(qe,{children:t?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(po,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),r.jsx("p",{children:"No popby ideas yet. Add your first one!"})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"w-24",children:"Actions"})]})}),r.jsx(Bn,{children:e.map(g=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:g.name}),r.jsx(dt,{className:"text-muted-foreground",children:g.description}),r.jsx(dt,{children:r.jsx(fn,{checked:g.is_active,onCheckedChange:()=>m(g)})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{o(g),i(!0)},children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>p(g.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},g.id))})]})}),r.jsx(Ir,{open:l,onOpenChange:i,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsxs(Fr,{children:[a?"Edit":"Add"," Popby Idea"]})}),r.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:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",name:"name",defaultValue:a==null?void 0:a.name,required:!0,placeholder:"e.g., Homemade Cookies"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),r.jsxs(Rn,{className:"mt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:d.isPending,children:[d.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function lPt(){var _;const{toast:e}=_i(),t=Rr(),[s,n]=A.useState(null),[a,o]=A.useState(!1),{data:l,isLoading:i}=Ht({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:k,error:w}=await Y.from("video_script_categories").select("*").order("sort_order");if(w)throw w;return k}}),{data:d,isLoading:m}=Ht({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:k,error:w}=await Y.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(w)throw w;return k}}),p=Qt({mutationFn:async k=>{var w,S;if(k.id){const{error:T}=await Y.from("video_scripts").update({title:k.title,script_text:k.script_text,category_id:k.category_id,tags:((w=k.tags)==null?void 0:w.split(",").map(C=>C.trim()).filter(Boolean))||[]}).eq("id",k.id);if(T)throw T}else{const{error:T}=await Y.from("video_scripts").insert([{title:k.title,script_text:k.script_text,category_id:k.category_id||null,tags:((S=k.tags)==null?void 0:S.split(",").map(C=>C.trim()).filter(Boolean))||[]}]);if(T)throw T}},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-video-scripts"]}),o(!1),n(null),e({title:"Video script saved!"})},onError:k=>e({title:"Error",description:k.message,variant:"destructive"})}),g=async k=>{await Y.from("video_scripts").update({is_active:!k.is_active}).eq("id",k.id),t.invalidateQueries({queryKey:["admin-video-scripts"]})},v=async k=>{confirm("Delete this video script?")&&(await Y.from("video_scripts").delete().eq("id",k),t.invalidateQueries({queryKey:["admin-video-scripts"]}),e({title:"Script deleted"}))};return r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Video Scripts"}),r.jsx(Cs,{children:"Manage teleprompter scripts for Quick Video Touch"})]}),r.jsxs(X,{onClick:()=>{n(null),o(!0)},children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Script"]})]}),r.jsx(qe,{children:m?r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Title"}),r.jsx(Mt,{children:"Category"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"w-24",children:"Actions"})]})}),r.jsx(Bn,{children:d==null?void 0:d.map(k=>{var w;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:k.title}),r.jsx(dt,{className:"text-muted-foreground",children:((w=k.category)==null?void 0:w.name)||"Uncategorized"}),r.jsx(dt,{children:r.jsx(fn,{checked:k.is_active,onCheckedChange:()=>g(k)})}),r.jsxs(dt,{className:"flex gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>{n(k),o(!0)},children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>v(k.id),children:r.jsx(Os,{className:"h-4 w-4"})})]})]},k.id)})})]})}),r.jsx(Ir,{open:a,onOpenChange:o,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:[s?"Edit":"Add"," Video Script"]})}),r.jsxs("form",{onSubmit:k=>{k.preventDefault();const w=new FormData(k.currentTarget);p.mutate({id:s==null?void 0:s.id,title:w.get("title"),script_text:w.get("script_text"),category_id:w.get("category_id")||null,tags:w.get("tags")})},children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"title",children:"Title"}),r.jsx(Ye,{id:"title",name:"title",defaultValue:s==null?void 0:s.title,required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"category_id",children:"Category"}),r.jsxs(ds,{name:"category_id",defaultValue:(s==null?void 0:s.category_id)||"",children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select category"})}),r.jsx(cs,{children:l==null?void 0:l.map(k=>r.jsx(Ut,{value:k.id,children:k.name},k.id))})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script_text",children:"Script Text"}),r.jsx(qs,{id:"script_text",name:"script_text",defaultValue:s==null?void 0:s.script_text,rows:6,required:!0,placeholder:"Enter the teleprompter script..."})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"tags",children:"Tags (comma-separated)"}),r.jsx(Ye,{id:"tags",name:"tags",defaultValue:((_=s==null?void 0:s.tags)==null?void 0:_.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),r.jsxs(Rn,{className:"mt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>o(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:p.isPending,children:[p.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function cPt(){const{toast:e}=_i(),[t,s]=A.useState(""),[n,a]=A.useState(!0),[o,l]=A.useState(!1);A.useEffect(()=>{(async()=>{a(!0);try{const{data:m}=await Y.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();m!=null&&m.value&&s(m.value)}catch(m){console.error("Error fetching settings:",m)}a(!1)})()},[]);const i=async()=>{l(!0);try{await Y.from("settings").upsert({key:"mapbox_public_token",value:t.trim()}),e({title:"Mapbox token saved!"})}catch{e({title:"Error saving token",variant:"destructive"})}l(!1)};return n?r.jsx(ze,{children:r.jsx(qe,{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):r.jsx("div",{className:"space-y-6",children:r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Yi,{className:"h-5 w-5"}),"Popby Map Settings"]}),r.jsx(Cs,{children:"Configure the map feature for popbys"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"mapbox-token",children:"Mapbox Public Token"}),r.jsx(Ye,{id:"mapbox-token",placeholder:"pk.eyJ1I...",value:t,onChange:d=>s(d.target.value)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",r.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."]})]}),r.jsxs(X,{onClick:i,disabled:o,children:[o&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),t&&r.jsx(_t,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const dPt=()=>{const[e,t]=A.useState(""),[s,n]=A.useState("grid"),a=Ks(),{data:o=[],isLoading:l}=Ht({queryKey:["additional-services"],queryFn:async()=>{const{data:d,error:m}=await Y.from("additional_services").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(m)throw m;return d}}),i=o.filter(d=>{var p;return d.name.toLowerCase().includes(e.toLowerCase())||((p=d.description)==null?void 0:p.toLowerCase().includes(e.toLowerCase()))});return r.jsx(Ur,{title:"Additional Services",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Additional Services"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Explore our additional services and offerings"})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search services...",value:e,onChange:d=>t(d.target.value),className:"pl-9"})]}),r.jsxs("div",{className:"flex gap-2",children:[e&&r.jsx(X,{variant:"outline",size:"sm",onClick:()=>t(""),children:"Clear"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:s==="grid"?"secondary":"outline",size:"icon",onClick:()=>n("grid"),className:"rounded-full",children:r.jsx(Of,{className:"h-4 w-4"})}),r.jsx(X,{variant:s==="list"?"secondary":"outline",size:"icon",onClick:()=>n("list"),className:"rounded-full",children:r.jsx(Rf,{className:"h-4 w-4"})})]})]})]}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[i.length," service",i.length!==1?"s":""," found"]}),l&&r.jsx("div",{className:s==="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,m)=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx(pr,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),r.jsx(pr,{className:"h-5 w-3/4 mb-2"}),r.jsx(pr,{className:"h-4 w-full mb-4"})]})},m))}),!l&&i.length===0&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"text-muted-foreground mb-4",children:e?"No services match your search":"No additional services available yet"}),e&&r.jsx(X,{variant:"outline",onClick:()=>t(""),children:"Clear Search"})]}),!l&&i.length>0&&r.jsx("div",{className:s==="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=>r.jsxs(ze,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${s==="list"?"flex flex-row":""}`,onClick:()=>a(`/additional-services/${d.id}`),children:[r.jsx("div",{className:`relative overflow-hidden bg-muted ${s==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:d.preview_image_url?r.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"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:r.jsx(bn,{className:"h-8 w-8"})})}),r.jsxs(qe,{className:`p-4 flex flex-col ${s==="list"?"flex-1":""}`,children:[r.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:d.name}),d.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 flex-1",children:Zae(d.description)})]})]},d.id))})]})})},uPt=()=>{const{serviceId:e}=Bl(),t=Ks(),{data:s,isLoading:n}=Ht({queryKey:["additional-service",e],queryFn:async()=>{const{data:a,error:o}=await Y.from("additional_services").select("*").eq("id",e).eq("is_published",!0).single();if(o)throw o;return a},enabled:!!e});return n?r.jsx(Ur,{title:"Loading...",children:r.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[r.jsx(pr,{className:"h-8 w-48"}),r.jsx(pr,{className:"h-64 w-full rounded-lg"}),r.jsx(pr,{className:"h-24 w-full"})]})}):s?r.jsx(Ur,{title:s.name,children:r.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[r.jsxs(X,{variant:"ghost",onClick:()=>t("/additional-services"),className:"gap-2",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Services"]}),r.jsx(ze,{className:"overflow-hidden",children:r.jsx("div",{className:"relative bg-muted",children:s.preview_image_url?r.jsx("img",{src:s.preview_image_url,alt:s.name,className:"w-full h-auto max-h-[500px] object-contain mx-auto"}):r.jsx("div",{className:"w-full h-64 flex items-center justify-center text-muted-foreground",children:r.jsx(bn,{className:"h-16 w-16"})})})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-6 space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:s.name}),r.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[r.jsx(An,{className:"h-4 w-4 mr-1"}),"Published ",Xr(new Date(s.publish_date),"MMMM d, yyyy")]})]}),s.description&&r.jsx("div",{className:"prose prose-sm max-w-none text-muted-foreground [&_a]:text-primary [&_a]:underline",dangerouslySetInnerHTML:{__html:s.description}}),r.jsx("div",{className:"pt-4 border-t",children:r.jsxs(X,{size:"lg",className:"gap-2",onClick:()=>window.open(s.signup_link_url,"_blank"),children:[r.jsx(jn,{className:"h-5 w-5"}),"Sign Up Now"]})})]})})]})}):r.jsx(Ur,{title:"Not Found",children:r.jsxs("div",{className:"max-w-4xl mx-auto text-center py-12",children:[r.jsx("h2",{className:"text-2xl font-bold text-foreground mb-4",children:"Service Not Found"}),r.jsx("p",{className:"text-muted-foreground mb-6",children:"The service you're looking for doesn't exist or has been removed."}),r.jsxs(X,{onClick:()=>t("/additional-services"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},bA=[{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 hPt(){const[e,t]=A.useState(bA[0].id),s=bA.find(n=>n.id===e)||bA[0];return r.jsx(Ur,{title:"AI Toolkit",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(w4,{className:"h-6 w-6 text-primary"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"AI Toolkit"}),r.jsx("p",{className:"text-muted-foreground",children:"Powerful AI tools to boost your real estate business"})]})]}),r.jsx("div",{className:"md:hidden",children:r.jsxs(ds,{value:e,onValueChange:t,children:[r.jsx(ls,{className:"w-full",children:r.jsx(us,{placeholder:"Select a tool"})}),r.jsx(cs,{children:bA.map(n=>r.jsx(Ut,{value:n.id,children:n.name},n.id))})]})}),r.jsx("div",{className:"hidden md:block",children:r.jsx(ii,{value:e,onValueChange:t,className:"w-full",children:r.jsx(si,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:bA.map(n=>r.jsx(Kr,{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))})})}),r.jsx("div",{className:"flex justify-center",children:r.jsx("div",{className:"w-full max-w-[700px]",dangerouslySetInnerHTML:{__html:s.iframe}})})]})})}const kMe="agent-os-onboarding-completed",QO=[{icon:hx,iconColor:"text-white",bgGradient:"from-primary via-primary/80 to-purple-600",title:"Welcome to Agent OS",description:"You've unlocked a powerful new tool designed to help you build stronger relationships and close more deals. Agent OS is currently in beta, and we're excited for you to try it!",highlights:["Manage your most important relationships","Stay in touch with automated reminders","Track your transactions and goals","Maximize referrals from your sphere"]},{icon:gx,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:ws,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:sg,iconColor:"text-white",bgGradient:"from-emerald-500 via-teal-500 to-cyan-500",title:"Touchpoint Plans",description:"Assign automated touchpoint schedules to your contact groups. Each plan tells you exactly who to reach out to and when—with pre-written scripts to make it easy.",highlights:["Pre-built 12-month plans","Create your own custom plans","Scripts for calls, texts, and emails","Automatic daily action items"]},{icon:po,iconColor:"text-white",bgGradient:"from-orange-500 via-amber-500 to-yellow-500",title:"Popbys",description:"Pop-by visits are one of the most powerful ways to stay top-of-mind. Track your gift drop-offs and see who's due for a visit on the map.",highlights:["Track pop-by gift ideas","Set visit frequency by contact type","Log completed pop-bys","Map view for route planning"]},{icon:Rc,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"]}],mPt=()=>{const[e,t]=A.useState(!1),[s,n]=A.useState(0),[a,o]=A.useState(!1);A.useEffect(()=>{if(!localStorage.getItem(kMe)){const k=setTimeout(()=>t(!0),500);return()=>clearTimeout(k)}},[]);const l=()=>{s{n(s+1),o(!1)},150)):d()},i=()=>{d()},d=()=>{localStorage.setItem(kMe,"true"),t(!1)},m=QO[s],p=m.icon,g=s===QO.length-1,v=_=>{_||d(),t(_)};return r.jsx(Ir,{open:e,onOpenChange:v,children:r.jsxs(Er,{className:"sm:max-w-lg overflow-hidden p-0 gap-0",children:[r.jsxs("div",{className:`relative bg-gradient-to-br ${m.bgGradient} p-8 pb-12 transition-all duration-500`,children:[r.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[r.jsx("div",{className:"absolute -top-4 -right-4 w-32 h-32 bg-white/10 rounded-full blur-2xl animate-pulse"}),r.jsx("div",{className:"absolute -bottom-8 -left-8 w-40 h-40 bg-white/10 rounded-full blur-3xl animate-pulse",style:{animationDelay:"1s"}}),r.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"})]}),r.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:[r.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-2xl blur-xl"}),r.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:r.jsx(p,{className:`h-10 w-10 ${m.iconColor} drop-shadow-lg`})})]}),s===0&&r.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:[r.jsx(bn,{className:"h-3 w-3"}),"Beta"]})]}),r.jsxs("div",{className:"p-6 pt-4",children:[r.jsxs(zr,{className:"text-center sm:text-center pb-2",children:[r.jsx(Fr,{className:`text-2xl font-bold transition-all duration-300 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:m.title}),r.jsx(Zs,{className:`text-base pt-2 transition-all duration-300 delay-75 ${a?"translate-y-2 opacity-0":"translate-y-0 opacity-100"}`,children:m.description})]}),m.highlights&&r.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:m.highlights.map((_,k)=>r.jsxs("div",{className:"flex items-center gap-3 group",style:{transitionDelay:`${150+k*50}ms`},children:[r.jsx("div",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-gradient-to-br ${m.bgGradient} shadow-sm`,children:r.jsx(mi,{className:"h-3.5 w-3.5 text-white"})}),r.jsx("span",{className:"text-sm text-muted-foreground group-hover:text-foreground transition-colors",children:_})]},k))}),r.jsx("div",{className:"flex justify-center gap-2 py-4",children:QO.map((_,k)=>r.jsx("button",{onClick:()=>{k!==s&&(o(!0),setTimeout(()=>{n(k),o(!1)},150))},className:`h-2 rounded-full transition-all duration-300 ${k===s?"w-8 bg-gradient-to-r "+m.bgGradient:k{const{user:e}=Gr();return Ht({queryKey:["contact-snoozes",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("contact_snoozes").select("*").gte("snoozed_until",new Date().toISOString());if(s)throw s;return t},enabled:!!e})},pPt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async({contactId:s,days:n})=>{if(!(t!=null&&t.id))throw new Error("Not authenticated");const a=dc(new Date,n);await Y.from("contact_snoozes").delete().eq("contact_id",s);const{error:o}=await Y.from("contact_snoozes").insert({contact_id:s,owner_user_id:t.id,snoozed_until:a.toISOString()});if(o)throw o},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-snoozes"]}),e.invalidateQueries({queryKey:["today-actions"]}),e.invalidateQueries({queryKey:["popby-logs"]}),ta({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:s=>{ta({title:"Error snoozing contact",description:s.message,variant:"destructive"})}})},gPt=()=>{const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("contact_snoozes").delete().eq("contact_id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-snoozes"]}),ta({title:"Snooze cancelled"})},onError:t=>{ta({title:"Error cancelling snooze",description:t.message,variant:"destructive"})}})},xPt=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function xoe({open:e,onOpenChange:t,contactId:s,contactName:n}){const[a,o]=A.useState(null),l=pPt(),i=async()=>{a&&(await l.mutateAsync({contactId:s,days:a}),o(null),t(!1))},d=m=>Xr(dc(new Date,m),"MMM d, yyyy");return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Pa,{className:"h-5 w-5"}),"Snooze Touch"]}),r.jsxs(Zs,{children:["Postpone the next scheduled touch for ",n,". Select how long to snooze."]})]}),r.jsx("div",{className:"space-y-3 py-4",children:xPt.map(m=>r.jsxs("button",{type:"button",onClick:()=>o(m.days),className:Vt("w-full flex items-center justify-between p-3 rounded-lg border transition-colors",a===m.days?"border-primary bg-primary/5":"border-border hover:border-primary/50 hover:bg-accent/50"),children:[r.jsx("span",{className:"font-medium",children:m.label}),r.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[r.jsx(An,{className:"h-3.5 w-3.5"}),"Until ",d(m.days)]})]},m.days))}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsx(X,{onClick:i,disabled:!a||l.isPending,children:l.isPending?"Snoozing...":"Snooze Touch"})]})]})})}const yPt={Crown:_h,FileText:ya,Users:ws,Globe:ux,Star:Dn,Phone:fi,MessageSquare:Vo,PenTool:Nk,Video:ma,Gift:po};function vPt({actions:e,onMarkComplete:t,onViewScript:s,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=Ks(),[d,m]=A.useState("name"),[p,g]=A.useState("asc"),[v,_]=A.useState(null),[k,w]=A.useState(""),S=D=>{d===D?g(B=>B==="asc"?"desc":"asc"):(m(D),g("asc"))},T=A.useMemo(()=>[...e].sort((D,B)=>{var q,W;let $=0;switch(d){case"name":{const K=`${D.contact.first_name} ${D.contact.last_name||""}`.toLowerCase(),re=`${B.contact.first_name} ${B.contact.last_name||""}`.toLowerCase();$=K.localeCompare(re);break}case"relationship_type":$=(D.relationshipTypeName||"").localeCompare(B.relationshipTypeName||"");break;case"action_type":$=(((q=D.actionType)==null?void 0:q.name)||"").localeCompare(((W=B.actionType)==null?void 0:W.name)||"");break;case"last_touch":$=(D.monthNumber||0)-(B.monthNumber||0);break}return p==="asc"?$:-$}),[e,d,p]),C=D=>yPt[D||"Phone"]||fi,I=({field:D,children:B})=>r.jsxs(X,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>S(D),children:[B,d===D?p==="asc"?r.jsx(Pf,{className:"ml-2 h-4 w-4"}):r.jsx(Ly,{className:"ml-2 h-4 w-4"}):r.jsx(eg,{className:"ml-2 h-4 w-4 opacity-50"})]}),R=(D,B,$)=>{_(D),w(`${B} ${$||""}`.trim())};return e.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx("p",{children:"No actions scheduled for today."}),r.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"border rounded-lg overflow-hidden",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/50",children:[r.jsx(Mt,{className:"w-[180px]",children:r.jsx(I,{field:"name",children:"Contact"})}),r.jsx(Mt,{className:"w-[130px]",children:r.jsx(I,{field:"relationship_type",children:"Type"})}),r.jsx(Mt,{className:"w-[120px]",children:r.jsx(I,{field:"action_type",children:"Action"})}),r.jsx(Mt,{className:"w-[130px]",children:"Phone"}),r.jsx(Mt,{className:"w-[200px]",children:"Quick Actions"})]})}),r.jsx(Bn,{children:T.map((D,B)=>{var ae,oe,se,pe,ie,de;const $=D.isSpecialDate,q=D.specialDateType,W=$?q==="birthday"?Lm:Vn:C(((ae=D.actionType)==null?void 0:ae.icon)||null),K=D.contact.phone,re=D.contact.email;return r.jsxs(Nr,{className:Vt("hover:bg-muted/50 transition-colors",$&&q==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",$&&q==="anniversary"&&"bg-purple-50/50 dark:bg-purple-950/20"),children:[r.jsx(dt,{className:"font-medium",children:r.jsx("div",{children:r.jsxs("button",{onClick:()=>i(`/mission-control/contacts/${D.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[D.contact.first_name," ",D.contact.last_name]})})}),r.jsx(dt,{children:D.relationshipTypeName?r.jsx(_t,{variant:"secondary",className:"text-xs",children:D.relationshipTypeName}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),r.jsx(dt,{children:r.jsx("div",{className:"flex items-center gap-1.5",children:$?r.jsx(_t,{className:Vt("gap-1",q==="birthday"&&"bg-pink-500 hover:bg-pink-600",q==="anniversary"&&"bg-purple-500 hover:bg-purple-600"),children:q==="birthday"?r.jsxs(r.Fragment,{children:[r.jsx(Lm,{className:"h-3 w-3"})," Birthday"]}):r.jsxs(r.Fragment,{children:[r.jsx(Vn,{className:"h-3 w-3"})," Anniversary"]})}):r.jsxs(_t,{variant:"outline",className:"gap-1",children:[r.jsx(W,{className:"h-3 w-3"}),(oe=D.actionType)==null?void 0:oe.name]})})}),r.jsx(dt,{children:K?r.jsx("span",{className:"text-sm font-mono",children:D.contact.phone}):r.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-1",children:[K&&r.jsx("a",{href:`tel:${D.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:r.jsx(fi,{className:"h-3.5 w-3.5"})}),K&&r.jsx("a",{href:a(D.contact.phone,(se=D.script)==null?void 0:se.script_body,D.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:r.jsx(Vo,{className:"h-3.5 w-3.5"})}),re&&(l?r.jsx("button",{onClick:()=>l({id:D.contact.id,first_name:D.contact.first_name,last_name:D.contact.last_name,email:D.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:r.jsx(Vs,{className:"h-3.5 w-3.5"})}):r.jsx("a",{href:o(D.contact.email,(pe=D.script)==null?void 0:pe.script_body,(ie=D.script)==null?void 0:ie.email_subject,(de=D.actionType)==null?void 0:de.name,D.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:r.jsx(Vs,{className:"h-3.5 w-3.5"})})),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:()=>R(D.contact.id,D.contact.first_name,D.contact.last_name),title:"Snooze",children:r.jsx(Bm,{className:"h-3.5 w-3.5"})}),r.jsxs(X,{variant:"default",size:"sm",className:"h-7 px-2 text-xs ml-1",onClick:()=>{var ce;return t(D.contact.id,D.actionType.id,(ce=D.script)==null?void 0:ce.id)},disabled:n,children:[r.jsx(Ri,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${D.contact.id}-${B}`)})})]})}),r.jsx(xoe,{open:!!v,onOpenChange:D=>!D&&_(null),contactId:v||"",contactName:k})]})}function kN(){const{data:e,isLoading:t}=Ht({queryKey:["gmail-integration"],queryFn:async()=>{const{data:a,error:o}=await Y.from("gmail_integrations").select("*").maybeSingle();if(o)throw o;return a}}),s=!!(e!=null&&e.is_active),n=(e==null?void 0:e.gmail_email)||null;return{isGmailConnected:s,gmailEmail:n,isLoading:t}}function _Pt({onSelect:e}){const[t,s]=A.useState(null),{data:n=[],isLoading:a}=Ht({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:d,error:m}=await Y.from("email_template_categories").select("*").order("sort_order");if(m)throw m;return d}}),{data:o=[],isLoading:l}=Ht({queryKey:["agent-email-templates",t],queryFn:async()=>{let d=Y.from("agent_email_templates").select("*").eq("is_active",!0).order("sort_order");t&&(d=d.eq("category_id",t));const{data:m,error:p}=await d;if(p)throw p;return m}}),i=n.find(d=>d.id===t);return a?r.jsx("div",{className:"flex items-center justify-center py-6",children:r.jsx($r,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):t?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("button",{onClick:()=>s(null),className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[r.jsx(jc,{className:"h-3.5 w-3.5"}),"Back to categories"]}),r.jsxs("p",{className:"text-xs font-medium flex items-center gap-1.5",children:[r.jsx("span",{children:i==null?void 0:i.icon})," ",i==null?void 0:i.name]}),l?r.jsx("div",{className:"flex items-center justify-center py-6",children:r.jsx($r,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):o.length===0?r.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No templates in this category"}):r.jsx(To,{className:"max-h-[280px]",children:r.jsx("div",{className:"space-y-1",children:o.map(d=>r.jsxs("button",{onClick:()=>e(d),className:"w-full p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"font-medium text-sm",children:d.title}),d.tone&&r.jsx(_t,{variant:"secondary",className:"text-[10px] shrink-0",children:d.tone})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:d.subject})]},d.id))})})]}):r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground px-1 mb-2",children:"Select a category"}),r.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:n.map(d=>r.jsxs("button",{onClick:()=>s(d.id),className:"w-full flex items-center justify-between p-2.5 rounded-lg border hover:bg-accent transition-colors text-left",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("span",{className:"text-lg",children:d.icon}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:d.name}),d.description&&r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:d.description})]})]}),r.jsx(Zi,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},d.id))})]})}const bPt=5*1024*1024,wPt=["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 jPt(e){return e<1024?e+" B":e<1024*1024?(e/1024).toFixed(1)+" KB":(e/(1024*1024)).toFixed(1)+" MB"}function kPt(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>{const a=n.result;t(a.split(",")[1])},n.onerror=s,n.readAsDataURL(e)})}function wA(e,t){return e.replace(/\{\{first_name\}\}/gi,t.first_name).replace(/\{\{last_name\}\}/gi,t.last_name||"").replace(/\{\{full_name\}\}/gi,`${t.first_name} ${t.last_name||""}`.trim())}function yoe({open:e,onOpenChange:t,contact:s,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const d=!!n&&n.length>0,m=d?n:s?[s]:[],p=m[0],[g,v]=A.useState((p==null?void 0:p.email)||""),[_,k]=A.useState(a),[w,S]=A.useState(o),[T,C]=A.useState(!1),[I,R]=A.useState(!1),[D,B]=A.useState([]);A.useEffect(()=>{e&&(v((p==null?void 0:p.email)||""),k(wA(a,p||{first_name:""})),S(wA(o,p||{first_name:""})),R(!a&&!o),B([]))},[e,p,a,o]);const $=async oe=>{const se=oe.target.files;if(!se)return;const pe=D.reduce((de,ce)=>de+ce.size,0),ie=[];for(const de of Array.from(se)){if(!wPt.includes(de.type)){we.error(`${de.name}: Unsupported file type`);continue}if(pe+de.size>bPt){we.error("Total attachments exceed 20MB limit");break}try{const ce=await kPt(de);ie.push({name:de.name,type:de.type,size:de.size,data:ce})}catch{we.error(`Failed to read ${de.name}`)}}B(de=>[...de,...ie]),oe.target.value=""},q=oe=>{B(se=>se.filter((pe,ie)=>ie!==oe))},W=oe=>{k(wA(oe.subject,p||{first_name:""})),S(wA(oe.body,p||{first_name:""})),R(!1)},K=oe=>oe.split(/\n\n+/).map(se=>`

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

`).join(""),re=async oe=>{if(!_||!w)return we.error("Please fill in subject and message"),!1;const se=wA(w,oe),pe=K(se);try{const{data:ie,error:de}=await Y.functions.invoke("gmail-send",{body:{to:oe.email,subject:_,body:pe,contactId:oe.id,attachments:D.map(({name:ce,type:ge,data:Te})=>({name:ce,type:ge,data:Te}))}});if(de)throw de;if(!(ie!=null&&ie.success))throw new Error((ie==null?void 0:ie.error)||"Failed to send");return!0}catch(ie){return console.error("Gmail send error:",ie),we.error("Failed to send to "+oe.first_name+": "+(ie instanceof Error?ie.message:"Unknown error")),!1}},ae=async()=>{if(!_||!w){we.error("Please fill in subject and message");return}if(d&&m.length>50){we.error("Maximum 50 recipients per bulk send");return}C(!0);try{if(d){let oe=0;for(const se of m)await re(se)&&oe++,await new Promise(ie=>setTimeout(ie,100));we.success(`Sent ${oe} of ${m.length} emails`)}else await re(p)&&we.success("Email sent successfully!");t(!1),i==null||i()}catch(oe){console.error("Bulk send error:",oe),we.error("Error sending emails")}finally{C(!1)}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Vs,{className:"h-5 w-5 text-red-500"}),d?`Send to ${m.length} Contacts`:"Compose Email"]}),l&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",r.jsx("span",{className:"font-medium",children:l})]})]}),r.jsxs("div",{className:"space-y-4",children:[I?r.jsxs("div",{className:"border rounded-lg p-3 bg-muted/30 max-h-[50vh] overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("p",{className:"text-sm font-medium flex items-center gap-1.5",children:[r.jsx(ya,{className:"h-4 w-4"})," Choose a Template"]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>R(!1),className:"h-7 px-2 text-xs",children:[r.jsx(Xs,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),r.jsx(_Pt,{onSelect:W})]}):r.jsxs(X,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>R(!0),children:[r.jsx(ya,{className:"h-4 w-4"}),"Browse Templates"]}),r.jsx(kd,{}),r.jsx("div",{className:"space-y-1.5",children:d?r.jsxs(r.Fragment,{children:[r.jsx(Ee,{children:"Recipients"}),r.jsx("div",{className:"bg-muted p-3 rounded-md space-y-1 max-h-24 overflow-y-auto text-muted-foreground",children:m.map(oe=>r.jsxs("div",{className:"text-sm",children:[oe.first_name," ",oe.last_name," — ",oe.email]},oe.id))})]}):r.jsxs(r.Fragment,{children:[r.jsx(Ee,{htmlFor:"gmail-to",children:"To"}),r.jsx(Ye,{id:"gmail-to",value:g,onChange:oe=>v(oe.target.value),placeholder:"recipient@example.com"})]})}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"gmail-subject",children:"Subject"}),r.jsx(Ye,{id:"gmail-subject",value:_,onChange:oe=>k(oe.target.value),placeholder:"Enter subject..."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{htmlFor:"gmail-body",children:"Message"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(_t,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>S(oe=>oe+"{{first_name}}"),children:"{{first_name}}"}),r.jsx(_t,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>S(oe=>oe+"{{last_name}}"),children:"{{last_name}}"})]})]}),r.jsx(qs,{id:"gmail-body",value:w,onChange:oe=>S(oe.target.value),placeholder:"Write your message...",rows:10,className:"resize-y"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{type:"button",variant:"outline",size:"sm",className:"gap-2",onClick:()=>{var oe;return(oe=document.getElementById("gmail-attachments"))==null?void 0:oe.click()},disabled:T,children:[r.jsx(kk,{className:"h-4 w-4"}),"Attach Files"]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"PDF, images, Word, Excel (max 5MB total)"}),r.jsx("input",{id:"gmail-attachments",type:"file",multiple:!0,accept:".pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx,.xls,.xlsx,.csv",className:"hidden",onChange:$})]}),D.length>0&&r.jsx("div",{className:"flex flex-wrap gap-2",children:D.map((oe,se)=>r.jsxs(_t,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[r.jsx(kk,{className:"h-3 w-3"}),r.jsx("span",{className:"max-w-[140px] truncate text-xs",children:oe.name}),r.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["(",jPt(oe.size),")"]}),r.jsx("button",{type:"button",onClick:()=>q(se),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:r.jsx(Xs,{className:"h-3 w-3"})})]},se))})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),disabled:T,children:"Cancel"}),r.jsxs(X,{onClick:ae,disabled:T||!_||!w,className:"gap-2",children:[T?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(ai,{className:"h-4 w-4"}),T?"Sending...":d?`Send to ${m.length}`:"Send Email"]})]})]})]})})}const NMe={Crown:_h,FileText:ya,Users:ws,Globe:ux,Star:Dn,Phone:fi,MessageSquare:Vo,PenTool:Nk,Video:ma,Gift:po},NPt={"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 SPt(){const e=Ks(),{user:t}=Gr(),{data:s}=gg(),{data:n}=r9e(),{data:a}=Xf(),{data:o}=h1e(),{data:l}=c9e(),i=Pbt(),d=l9e(),m=Ebt(90),p=a9e(),[g,v]=A.useState(null),[_,k]=A.useState(null),[w,S]=A.useState(!1),[T,C]=A.useState(""),[I,R]=A.useState(!1),[D,B]=A.useState(""),[$,q]=A.useState(Cse()),[W,K]=A.useState("cards"),[re,ae]=A.useState(!1),[oe,se]=A.useState(null),[pe,ie]=A.useState(null),[de,ce]=A.useState(""),{isGmailConnected:ge,gmailEmail:Te}=kN(),_e=()=>{const Se=parseInt(D,10);if(isNaN(Se)||Se<1){ta({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}q(Se),o9e(Se),R(!1),ta({title:"Goal updated",description:`Weekly touch goal set to ${Se}`})},ve=()=>{B($.toString()),R(!0)};A.useEffect(()=>{(async()=>{if(!(t!=null&&t.id))return;const{data:et}=await Y.from("profiles").select("name").eq("id",t.id).single();et!=null&&et.name&&C(et.name.split(" ")[0])})()},[t==null?void 0:t.id]),A.useEffect(()=>{i.mutate()},[]);const Me=Wm(new Date),Ze=dc(Me,7),Ae=Se=>{if(!Se)return null;const et=Se.split(/[-/T]/);if(et.length<3)return null;const Qe=parseInt(et[1],10)-1,He=parseInt(et[2],10);return isNaN(Qe)||isNaN(He)?null:new Date(Me.getFullYear(),Qe,He)},Le=(a==null?void 0:a.filter(Se=>{const et=Ae(Se.birthday),Qe=Ae(Se.home_anniversary);return et&&Xl(et,Me)||Qe&&Xl(Qe,Me)}))||[],Ue=(a==null?void 0:a.filter(Se=>{if(!Se.birthday&&!Se.home_anniversary)return!1;const et=Qe=>{if(!Qe)return!1;const He=Ae(Qe);return He?use(He,Me)&&kie(He,Ze):!1};return et(Se.birthday)||et(Se.home_anniversary)}).slice(0,5))||[],Ve=Le.map(Se=>{var ot,ut,ft;const et=Ae(Se.birthday),Qe=et&&Xl(et,Me),He=(o==null?void 0:o.find(ct=>ct.name==="Call"))||(o==null?void 0:o[0]);return{contact:Se,actionType:He||{id:"special-date",name:Qe?"Birthday Call":"Anniversary Call",icon:Qe?"Cake":"Home",color:Qe?"#EC4899":"#8B5CF6",description:Qe?"Wish them happy birthday!":"Celebrate their home anniversary!",active:!0,sort_order:0,created_at:"",updated_at:""},planName:Qe?"🎂 Birthday Today!":"🏠 Home Anniversary!",relationshipTypeName:((ft=(ut=(ot=Se.tags)==null?void 0:ot[0])==null?void 0:ut.relationship_type)==null?void 0:ft.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:Qe?"birthday":"anniversary"}}),We=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Se,et)=>{var He,ot,ut;const Qe=o==null?void 0:o[et%((o==null?void 0:o.length)||1)];return Qe?{contact:Se,actionType:Qe,planName:"Quick Touch",relationshipTypeName:((ut=(ot=(He=Se.tags)==null?void 0:He[0])==null?void 0:ot.relationship_type)==null?void 0:ut.name)||"",monthNumber:0}:null}).filter(Boolean))||[],wt=[...Ve,...We],Pe=async(Se,et,Qe)=>{await p.mutateAsync({contactId:Se,actionTypeId:et,scriptUsedId:Qe}),S(!1),k(null)},st=Se=>{Se.script?(k(Se),S(!0)):Pe(Se.contact.id,Se.actionType.id)},ue=Se=>NMe[Se||"Phone"]||fi,$e=Se=>NMe[Se||"Users"]||ws,tt=(Se,et)=>Se.replace(/\{\{FirstName\}\}/g,et.first_name).replace(/\{\{LastName\}\}/g,et.last_name||"").replace(/\{\{AgentName\}\}/g,T||"there"),rt=(Se,et)=>({Call:`Thinking of you, ${et}!`,Text:`Quick hello, ${et}`,Email:`Checking in, ${et}`,"Handwritten Note":`A note for ${et}`,Video:`Video message for ${et}`,Gift:`Something special for you, ${et}`})[Se]||`Hello ${et}!`,je=(Se,et,Qe)=>{const He=`sms:${Se}`;if(et&&Qe){const ot=tt(et,Qe);return`${He}?body=${encodeURIComponent(ot)}`}return He},it=(Se,et,Qe,He,ot)=>{const ut=`mailto:${Se}`,ft=[];if(ot){const ct=Qe||rt(He||"Email",ot.first_name);if(ft.push(`subject=${encodeURIComponent(ct)}`),et){const Tt=tt(et,ot);ft.push(`body=${encodeURIComponent(Tt)}`)}}return ft.length>0?`${ut}?${ft.join("&")}`:ut};return r.jsxs(r.Fragment,{children:[r.jsxs(Ur,{title:"Mission Control",description:"Your relationship-first contact system",children:[r.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Mission Control"}),r.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"})]}),r.jsxs("section",{children:[r.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Your Sphere"}),r.jsx("div",{className:"flex flex-wrap gap-3",children:s==null?void 0:s.filter(Se=>Se.active).map(Se=>{const et=$e(Se.icon),Qe=(n==null?void 0:n[Se.id])||0,He=g===Se.id,ot=NPt[Se.name]||"bg-secondary text-secondary-foreground";return r.jsxs("button",{onClick:()=>{He?(v(null),e("/mission-control/contacts")):(v(Se.id),e(`/mission-control/contacts?type=${Se.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${He?ot:"bg-card hover:bg-accent"} `,children:[r.jsx(et,{className:"h-5 w-5"}),r.jsxs("div",{className:"text-left",children:[r.jsx("div",{className:"font-medium",children:Se.name}),r.jsxs("div",{className:`text-sm ${He?"opacity-90":"text-muted-foreground"}`,children:[Qe," Contacts"]})]})]},Se.id)})})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[r.jsxs(X,{onClick:()=>e("/mission-control/video/record"),className:"w-full bg-gradient-to-r from-primary to-primary/80",children:[r.jsx(Ud,{className:"h-4 w-4 mr-1"}),"Quick Video"]}),r.jsxs(X,{onClick:()=>e("/mission-control/contacts"),className:"w-full",variant:"outline",children:["View Contacts",r.jsx(Zi,{className:"h-4 w-4 ml-1"})]}),r.jsx(X,{variant:"outline",onClick:()=>e("/mission-control/video-library"),className:"w-full",children:"Video Library"}),r.jsx(X,{variant:"outline",onClick:()=>e("/mission-control/plans"),className:"w-full",children:"Manage Plans"})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[r.jsx("h2",{className:"text-xl font-semibold",children:"Today in Your InnerCircle"}),l!==void 0&&r.jsxs(_t,{variant:"outline",className:"gap-1",children:[r.jsx(bn,{className:"h-3 w-3"}),"Plan-based"]}),r.jsxs("div",{className:"ml-auto flex items-center gap-1 border rounded-lg p-0.5",children:[r.jsx(X,{variant:W==="cards"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>K("cards"),title:"Card view",children:r.jsx(Of,{className:"h-4 w-4"})}),r.jsx(X,{variant:W==="table"?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>K("table"),title:"Table view",children:r.jsx(Rf,{className:"h-4 w-4"})})]})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:wt.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx("p",{children:"No actions scheduled for today."}),r.jsx("p",{className:"text-sm mt-1",children:"Add contacts and enable touchpoint plans to get started."}),r.jsx(X,{variant:"outline",className:"mt-4",onClick:()=>e("/mission-control/plans"),children:"Manage Plans"})]}):W==="table"?r.jsx(vPt,{actions:wt,onMarkComplete:Pe,onViewScript:st,isLoading:p.isPending,buildSmsLink:je,buildEmailLink:it,onGmailCompose:ge?Se=>{se(Se),ae(!0)}:void 0}):r.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[wt.map((Se,et)=>{var Ot,rr,Lr,cr,Mr,As,Et;const Qe=Se.isSpecialDate,He=Se.specialDateType,ot=Qe?He==="birthday"?Lm:Vn:ue(((Ot=Se.actionType)==null?void 0:Ot.icon)||null),ut=Se.contact.phone,ft=Se.contact.email,ct=Qe?He==="birthday"?"#EC4899":"#8B5CF6":((rr=Se.actionType)==null?void 0:rr.color)||"#3B82F6",Tt=Qe?He==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(Lr=Se.actionType)==null?void 0:Lr.name;return r.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${Qe?"ring-2 ring-offset-2":""}`,style:Qe?{"--tw-ring-color":ct}:void 0,children:[r.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:ct},children:[r.jsx(ot,{className:"h-4 w-4"}),r.jsx("span",{className:"font-medium text-sm",children:Tt})]}),r.jsxs("div",{className:"p-3 space-y-2",children:[r.jsxs("button",{onClick:()=>e(`/mission-control/contacts/${Se.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Se.contact.first_name," ",Se.contact.last_name]}),r.jsxs("div",{className:"flex gap-1.5",children:[ut&&r.jsxs(r.Fragment,{children:[r.jsxs("a",{href:`tel:${Se.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:[r.jsx(fi,{className:"h-3 w-3"}),"Call"]}),r.jsxs("a",{href:je(Se.contact.phone,(cr=Se.script)==null?void 0:cr.script_body,Se.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:[r.jsx(Vo,{className:"h-3 w-3"}),"Text"]})]}),ft&&(ge?r.jsxs("button",{onClick:()=>{se({id:Se.contact.id,first_name:Se.contact.first_name,last_name:Se.contact.last_name,email:Se.contact.email}),ae(!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:[r.jsx(Vs,{className:"h-3 w-3"}),"Email"]}):r.jsxs("a",{href:it(Se.contact.email,(Mr=Se.script)==null?void 0:Mr.script_body,(As=Se.script)==null?void 0:As.email_subject,(Et=Se.actionType)==null?void 0:Et.name,Se.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:[r.jsx(Vs,{className:"h-3 w-3"}),"Email"]}))]}),Qe&&r.jsxs("button",{onClick:()=>{const Pt=`${Se.contact.first_name}${Se.contact.last_name?" "+Se.contact.last_name:""}`,Sr=He==="birthday"?"birthday":"home_anniversary",fs=new URLSearchParams({cardType:Sr,contactId:Se.contact.id,name:Pt,...Se.contact.address?{address:Se.contact.address}:{},...He==="anniversary"&&Se.contact.home_anniversary?{date:Se.contact.home_anniversary}:{}});e(`/mission-control/card-studio?${fs.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:[r.jsx(Vs,{className:"h-3 w-3"}),"Send ",He==="birthday"?"Birthday":"Anniversary"," Card"]}),!ut&&!ft&&r.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),r.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Se.relationshipTypeName&&r.jsx(_t,{variant:"secondary",className:"text-xs",children:Se.relationshipTypeName}),Se.monthNumber>0&&r.jsxs(_t,{variant:"outline",className:"text-xs",children:["Month ",Se.monthNumber]})]}),Se.script&&r.jsx(X,{size:"sm",variant:"outline",className:"w-full",onClick:()=>st(Se),children:"View Script"}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsxs(X,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>{ie(Se.contact.id),ce(`${Se.contact.first_name} ${Se.contact.last_name||""}`.trim())},children:[r.jsx(Bm,{className:"h-3.5 w-3.5"}),"Snooze"]}),r.jsx(X,{size:"sm",className:"flex-1",onClick:()=>{var Pt;return Pe(Se.contact.id,Se.actionType.id,(Pt=Se.script)==null?void 0:Pt.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Se.contact.id+et)}),r.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{variant:"ghost",className:"h-full w-full",children:[r.jsx(Nf,{className:"h-5 w-5 mr-2"}),"More"]})}),r.jsx(vu,{children:r.jsx(Ba,{onClick:()=>e("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[r.jsxs(ze,{className:"md:col-span-2",children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Zt,{className:"text-lg",children:"Momentum"}),r.jsxs(Ir,{open:I,onOpenChange:R,children:[r.jsx(Qi,{asChild:!0,children:r.jsx("button",{onClick:ve,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:r.jsx(ld,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),r.jsxs(Er,{className:"sm:max-w-[360px]",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Set Weekly Goal"}),r.jsx(Zs,{children:"How many touches do you want to complete each week?"})]}),r.jsxs("div",{className:"space-y-4 pt-2",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),r.jsx(Ye,{id:"weekly-goal-ic",type:"number",min:"1",value:D,onChange:Se=>B(Se.target.value),placeholder:"20",onKeyDown:Se=>{Se.key==="Enter"&&_e()}})]}),r.jsx(X,{onClick:_e,className:"w-full",children:"Save Goal"})]})]})]})]})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsx(zl,{value:Math.min(d.actionsThisWeek/$*100,100),className:"h-3 w-full max-w-full"}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Om,{className:"h-5 w-5 text-orange-500"}),r.jsxs("span",{className:"font-medium",children:[d.actionsThisWeek," / ",$]}),r.jsx("span",{className:"text-muted-foreground",children:"Actions Completed This Week"})]}),d.streak>0&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx("span",{className:"text-lg",children:"🔥"}),r.jsx("span",{className:"font-medium",children:"Great Job!"}),r.jsxs("span",{className:"text-muted-foreground",children:["Keep Your Streak Going! (",d.streak," days)"]})]})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-lg",children:"Upcoming Reminders"})}),r.jsxs(qe,{className:"space-y-3",children:[Ue.length>0?Ue.map(Se=>{const et=Se.birthday,Qe=Se.home_anniversary;return r.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[et?r.jsx("span",{className:"text-lg",children:"🎂"}):r.jsx("span",{className:"text-lg",children:"🏠"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("span",{className:"font-medium",children:[Se.first_name,"'s"]}),r.jsxs("span",{className:"text-muted-foreground",children:[" ",et?"Birthday":"Home Anniversary"]}),r.jsxs("div",{className:"text-xs text-muted-foreground",children:[et&&Se.birthday&&(()=>{const He=Se.birthday.split(/[-/T]/);return Xr(new Date(new Date().getFullYear(),parseInt(He[1],10)-1,parseInt(He[2],10)),"MMM d")})(),et&&Qe&&" · ",Qe&&Se.home_anniversary&&(()=>{const He=Se.home_anniversary.split(/[-/T]/);return Xr(new Date(new Date().getFullYear(),parseInt(He[1],10)-1,parseInt(He[2],10)),"MMM d")})()]})]}),r.jsxs("button",{onClick:()=>{const He=`${Se.first_name}${Se.last_name?" "+Se.last_name:""}`,ot=et?"birthday":"home_anniversary",ut=new URLSearchParams({cardType:ot,contactId:Se.id,name:He,...Se.address?{address:Se.address}:{},...!et&&Se.home_anniversary?{date:Se.home_anniversary}:{}});e(`/mission-control/card-studio?${ut.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:[r.jsx(Vs,{className:"h-3 w-3"}),"Send Card"]})]},Se.id)}):r.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming reminders"}),m.count>0&&r.jsxs("button",{onClick:()=>e("/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:[r.jsx(Pa,{className:"h-4 w-4 text-orange-500 mt-0.5"}),r.jsxs("div",{children:[r.jsxs("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:[m.count," Contact",m.count!==1?"s":""]}),r.jsx("span",{className:"text-muted-foreground",children:" Not Reached in 90+ Days"})]}),r.jsx(Zi,{className:"h-4 w-4 text-muted-foreground ml-auto mt-0.5"})]})]})]}),r.jsx(k9e,{})]})]}),r.jsx(Ir,{open:w,onOpenChange:S,children:r.jsxs(Er,{className:"max-w-md",children:[r.jsx(zr,{children:r.jsx(Fr,{className:"flex items-center gap-2",children:_&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:_.actionType.color||"#3B82F6"}}),_.actionType.name," Script"]})})}),_&&_.script&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"text-sm text-muted-foreground",children:["For: ",r.jsxs("span",{className:"font-medium text-foreground",children:[_.contact.first_name," ",_.contact.last_name]})]}),r.jsx("div",{className:"bg-muted p-4 rounded-lg",children:r.jsx("p",{className:"whitespace-pre-wrap",children:tt(_.script.script_body,_.contact)})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"outline",className:"flex-1",onClick:()=>S(!1),children:"Close"}),r.jsx(X,{className:"flex-1",onClick:()=>{var Se;return Pe(_.contact.id,_.actionType.id,(Se=_.script)==null?void 0:Se.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),r.jsx(mPt,{})]}),ge&&oe&&r.jsx(yoe,{open:re,onOpenChange:ae,contact:oe,gmailEmail:Te}),r.jsx(xoe,{open:!!pe,onOpenChange:Se=>!Se&&ie(null),contactId:pe||"",contactName:de})]})}const rHe=()=>{const{user:e}=Gr();return Ht({queryKey:["popby-items",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("popby_items").select("*").or(`owner_user_id.is.null,owner_user_id.eq.${e==null?void 0:e.id}`).eq("is_active",!0).order("name");if(s)throw s;return t},enabled:!!e})},voe=e=>{const{user:t}=Gr();return Ht({queryKey:["popby-logs",t==null?void 0:t.id,e],queryFn:async()=>{let s=Y.from("popby_logs").select("*").order("completed_at",{ascending:!1});if(e){const o=new Date;o.setDate(o.getDate()-e),s=s.gte("completed_at",o.toISOString())}const{data:n,error:a}=await s;if(a)throw a;return n},enabled:!!t})},T_e=()=>{const{user:e}=Gr();return Ht({queryKey:["relationship-type-popby-defaults",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("relationship_type_popby_defaults").select("*");if(s)throw s;return t},enabled:!!e})},sHe=()=>{const{user:e}=Gr();return Ht({queryKey:["contact-popby-settings",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("contact_popby_settings").select("*");if(s)throw s;return t},enabled:!!e})},nHe=()=>{const{data:e}=Xf(),{data:t}=gg(),{data:s}=voe(),{data:n}=sHe(),{data:a}=T_e(),o=new Map;s==null||s.forEach(p=>{const g=o.get(p.contact_id);(!g||new Date(p.completed_at)>new Date(g))&&o.set(p.contact_id,p.completed_at)});const l=new Map;a==null||a.forEach(p=>l.set(p.relationship_type_id,p.frequency_days));const i=new Map;n==null||n.filter(p=>p.is_active).forEach(p=>{i.set(p.contact_id,p.frequency_days)});const d=Wm(new Date);return(e||[]).map(p=>{let g=90;if(i.has(p.id))g=i.get(p.id);else if(p.tags&&p.tags.length>0){const S=p.tags.map(T=>l.get(T.relationship_type_id)).filter(T=>T!==void 0);S.length>0&&(g=Math.min(...S))}const v=o.get(p.id)||null,_=v?jx(d,Wm(new Date(v))):null,k=_===null||_>=g,w=k&&_!==null?_-g:0;return{...p,lastPopby:v,daysSinceLastPopby:_,frequencyDays:g,isDue:k,daysOverdue:w}}).sort((p,g)=>g.daysOverdue-p.daysOverdue)},aHe=()=>nHe().filter(t=>t.isDue),CPt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{error:n}=await Y.from("popby_items").insert({...s,owner_user_id:t==null?void 0:t.id});if(n)throw n},onSuccess:()=>{e.invalidateQueries({queryKey:["popby-items"]}),ta({title:"Popby item created!"})},onError:s=>{ta({title:"Error creating popby item",description:s.message,variant:"destructive"})}})},iHe=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{error:n}=await Y.from("popby_logs").insert({...s,owner_user_id:t==null?void 0:t.id});if(n)throw n},onSuccess:()=>{e.invalidateQueries({queryKey:["popby-logs"]}),ta({title:"Popby logged!"})},onError:s=>{ta({title:"Error logging popby",description:s.message,variant:"destructive"})}})},MPt=()=>{const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async s=>{const{error:n}=await Y.from("relationship_type_popby_defaults").upsert({...s,owner_user_id:t==null?void 0:t.id},{onConflict:"relationship_type_id,owner_user_id"});if(n)throw n},onSuccess:()=>{e.invalidateQueries({queryKey:["relationship-type-popby-defaults"]}),ta({title:"Frequency updated!"})},onError:s=>{ta({title:"Error updating frequency",description:s.message,variant:"destructive"})}})},TPt=()=>{const{data:e}=voe(30),t=aHe(),s=new Date;s.setDate(s.getDate()-7);const n=(e==null?void 0:e.filter(o=>new Date(o.completed_at)>=s).length)||0,a=(e==null?void 0:e.length)||0;return{thisWeekCount:n,thisMonthCount:a,dueCount:t.length}};function APt(){const{user:e}=Gr();return Ht({queryKey:["contact-touch-logs",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("contact_touch_logs").select("*").order("completed_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function oHe(e){const{data:t}=APt(),{data:s}=sHe(),{data:n}=T_e(),{data:a}=fPt();return A.useMemo(()=>{const o=a==null?void 0:a.find(S=>S.contact_id===e.id),l=o?new Date(o.snoozed_until):null,i=Wm(new Date);if(l&&!kie(l,i))return{nextTouchDate:l,daysUntil:jx(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const m=((t==null?void 0:t.filter(S=>S.contact_id===e.id))||[]).sort((S,T)=>new Date(T.completed_at).getTime()-new Date(S.completed_at).getTime())[0],p=m?new Date(m.completed_at):null;let g=90;const v=s==null?void 0:s.find(S=>S.contact_id===e.id&&S.is_active);if(v)g=v.frequency_days;else if(e.tags&&e.tags.length>0){const S=e.tags.map(T=>{const C=n==null?void 0:n.find(I=>I.relationship_type_id===T.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(T=>T!==void 0);S.length>0&&(g=Math.min(...S))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:g,lastTouchDate:null,snoozedUntil:null};const _=dc(Wm(p),g),k=jx(_,i);let w;return k<0?w="overdue":k<=7?w="due-soon":w="on-track",{nextTouchDate:_,daysUntil:k,status:w,frequencyDays:g,lastTouchDate:p,snoozedUntil:null}},[e,t,s,n,a])}function Nge({contact:e}){const t=oHe(e),n=(()=>{switch(t.status){case"overdue":return{variant:"destructive",icon:kl,text:`${Math.abs(t.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:Pa,text:t.daysUntil===0?"Due today":`Due in ${t.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:Ri,text:`Next touch in ${t.daysUntil} days`,className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/30 dark:text-emerald-400"};case"snoozed":return{variant:"secondary",icon:Bm,text:`Snoozed until ${Xr(t.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:An,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return r.jsxs(_t,{variant:n.variant,className:Vt("gap-1",n.className),children:[r.jsx(a,{className:"h-3 w-3"}),n.text]})}function EPt({contact:e,onLogTouch:t,onSnooze:s}){const n=oHe(e),a=gPt(),[o,l]=A.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 r.jsx(kl,{className:"h-5 w-5 text-destructive"});case"due-soon":return r.jsx(Pa,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return r.jsx(Ri,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return r.jsx(Bm,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return r.jsx(An,{className:"h-5 w-5 text-muted-foreground"})}},m=()=>{switch(n.status){case"overdue":return`${Math.abs(n.daysUntil)} days overdue`;case"due-soon":return n.daysUntil===0?"Due today!":`Due in ${n.daysUntil} days`;case"on-track":return`On track - ${n.daysUntil} days remaining`;case"snoozed":return`Snoozed for ${n.daysUntil} more days`;case"never-touched":return"No touches logged yet"}},p=async()=>{await a.mutateAsync(e.id)};return r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"text-sm font-medium flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4"}),"Next Touch"]})}),r.jsxs(qe,{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[d(),r.jsx("span",{className:Vt("font-medium",i()),children:m()})]}),n.status==="snoozed"&&n.snoozedUntil&&r.jsxs("div",{className:"text-sm text-muted-foreground",children:[r.jsx("span",{className:"font-medium",children:"Snoozed until:"})," ",Xr(n.snoozedUntil,"MMMM d, yyyy")]}),n.status!=="snoozed"&&n.nextTouchDate&&r.jsxs("div",{className:"text-sm text-muted-foreground",children:[r.jsx("span",{className:"font-medium",children:"Scheduled:"})," ",Xr(n.nextTouchDate,"MMMM d, yyyy")]}),n.lastTouchDate&&r.jsxs("div",{className:"text-sm text-muted-foreground",children:[r.jsx("span",{className:"font-medium",children:"Last touch:"})," ",Xr(n.lastTouchDate,"MMM d, yyyy")]}),n.status!=="snoozed"&&r.jsxs("div",{className:"text-xs text-muted-foreground border-t pt-2",children:["Touch frequency: Every ",n.frequencyDays," days"]}),n.status==="snoozed"&&r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsxs(X,{size:"sm",variant:"outline",className:"flex-1",onClick:p,disabled:a.isPending,children:[r.jsx(Xs,{className:"h-4 w-4 mr-1"}),"Cancel Snooze"]}),t&&r.jsx(X,{size:"sm",className:"flex-1",onClick:t,children:"Log Touch"})]}),n.status!=="snoozed"&&r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsxs(X,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>l(!0),children:[r.jsx(Bm,{className:"h-4 w-4 mr-1"}),"Snooze"]}),(n.status==="overdue"||n.status==="due-soon"||n.status==="never-touched")&&t&&r.jsx(X,{size:"sm",className:"flex-1",variant:n.status==="overdue"?"default":"outline",onClick:t,children:"Log Touch"})]})]})]}),r.jsx(xoe,{open:o,onOpenChange:l,contactId:e.id,contactName:`${e.first_name} ${e.last_name||""}`.trim()})]})}const jhe=768;function V3(){const[e,t]=A.useState(void 0);return A.useEffect(()=>{const s=window.matchMedia(`(max-width: ${jhe-1}px)`),n=()=>{t(window.innerWidths.removeEventListener("change",n)},[]),!!e}const IPt={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"}},PPt={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 khe({score:e,showScore:t=!1,showTooltip:s=!0,size:n="sm",className:a}){const o=IPt[e.status],l=PPt[n],i=r.jsxs("div",{className:Vt("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[r.jsx("span",{className:Vt("rounded-full",o.bgClass,l.dot)}),t?r.jsx("span",{children:e.score}):r.jsx("span",{children:o.label})]});return s?r.jsx(xN,{children:r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:i}),r.jsx(dh,{side:"top",className:"w-64 p-3",children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-semibold",children:"Relationship Score"}),r.jsxs("span",{className:Vt("font-bold",o.textClass),children:[e.score,"/100"]})]}),r.jsx(zl,{value:e.score,className:"h-2"}),r.jsxs("div",{className:"space-y-1.5 text-xs",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-muted-foreground",children:"Recency"}),r.jsxs("span",{children:[e.breakdown.recency,"/40"]})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-muted-foreground",children:"Touchpoints (12mo)"}),r.jsxs("span",{children:[e.breakdown.touchpoints,"/30"]})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-muted-foreground",children:"Transactions"}),r.jsxs("span",{children:[e.breakdown.transactions,"/20"]})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-muted-foreground",children:"Referrals"}),r.jsxs("span",{children:[e.breakdown.referrals,"/10"]})]})]}),e.daysSinceTouch!==null&&r.jsxs("p",{className:"text-xs text-muted-foreground pt-1 border-t",children:["Last contact: ",e.daysSinceTouch===0?"Today":`${e.daysSinceTouch} days ago`]}),e.daysSinceTouch===null&&r.jsx("p",{className:"text-xs text-muted-foreground pt-1 border-t italic",children:"Never contacted"})]})})]})}):i}const LPt=[{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}],DPt=({open:e,onOpenChange:t,relationshipTypes:s,onSuccess:n})=>{const{user:a}=Gr(),{toast:o}=_i(),l=A.useRef(null),[i,d]=A.useState("upload"),[m,p]=A.useState([]),[g,v]=A.useState([]),[_,k]=A.useState({}),[w,S]=A.useState([]),[T,C]=A.useState([]),[I,R]=A.useState(!1),[D,B]=A.useState(null),$=()=>{d("upload"),p([]),v([]),k({}),S([]),C([]),B(null),l.current&&(l.current.value="")},q=()=>{$(),t(!1)},W=de=>{const ce=de.split(` `).map(ve=>ve.trim()).filter(ve=>ve);if(ce.length===0)return{headers:[],data:[]};const ge=ve=>{const Me=[];let Ze="",Ae=!1;for(let Le=0;Le{var Te;const ce=(Te=de.target.files)==null?void 0:Te[0];if(!ce)return;const ge=new FileReader;ge.onload=_e=>{var Le;const ve=(Le=_e.target)==null?void 0:Le.result,{headers:Me,data:Ze}=W(ve);if(Me.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Me),v(Ze);const Ae={};Me.forEach(Ue=>{const Ve=Ue.toLowerCase().replace(/[_\s-]/g,"");Ve.includes("firstname")||Ve==="first"?Ae.first_name=Ue:Ve.includes("lastname")||Ve==="last"?Ae.last_name=Ue:Ve.includes("email")?Ae.email=Ue:Ve.includes("phone")||Ve.includes("mobile")||Ve.includes("cell")?Ae.phone=Ue:Ve.includes("address")||Ve.includes("street")?Ae.address=Ue:Ve==="city"?Ae.city=Ue:Ve==="state"||Ve==="province"?Ae.state=Ue:Ve==="zip"||Ve==="zipcode"||Ve==="postalcode"?Ae.zip=Ue:Ve.includes("spouse")&&Ve.includes("email")?Ae.spouse_email=Ue:Ve.includes("spouse")||Ve.includes("partner")?Ae.spouse_name=Ue:Ve.includes("company")||Ve.includes("organization")||Ve.includes("business")?Ae.company_name=Ue:Ve.includes("jobtitle")||Ve.includes("title")||Ve.includes("position")?Ae.job_title=Ue:Ve.includes("birthday")||Ve.includes("dob")||Ve.includes("birthdate")?Ae.birthday=Ue:Ve.includes("anniversary")||Ve.includes("homeanniversary")?Ae.home_anniversary=Ue:(Ve.includes("notes")||Ve.includes("comment"))&&(Ae.notes=Ue)}),k(Ae),d("mapping")},ge.readAsText(ce)},re=(de,ce)=>{k(ge=>{if(ce==="none"){const{[de]:Te,..._e}=ge;return _e}return{...ge,[de]:ce}})},ae=de=>{S(ce=>ce.includes(de)?ce.filter(ge=>ge!==de):[...ce,de])},oe=()=>{const de=g.map(ce=>{const ge=ve=>{const Me=_[ve];if(!Me)return"";const Ze=m.indexOf(Me);return Ze>=0?(ce[Ze]||"").trim():""},Te=ge("first_name"),_e=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:_e,error:_e?void 0:"First name is required"}});C(de),d("preview")},se=async()=>{if(!(a!=null&&a.id))return;const de=T.filter(_e=>_e.isValid);if(de.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}R(!0);let ce=0,ge=0,Te=0;try{for(const _e of de)try{let ve=null;if(_e.email){const{data:Ze}=await Y.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",_e.email).maybeSingle();ve=Ze}if(!ve&&_e.phone){const{data:Ze}=await Y.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("phone",_e.phone).maybeSingle();ve=Ze}const Me={owner_user_id:a.id,first_name:_e.first_name,last_name:_e.last_name||null,email:_e.email||null,phone:_e.phone||null,address:_e.address||null,city:_e.city||null,state:_e.state||null,zip:_e.zip||null,spouse_name:_e.spouse_name||null,spouse_email:_e.spouse_email||null,company_name:_e.company_name||null,job_title:_e.job_title||null,birthday:_e.birthday||null,home_anniversary:_e.home_anniversary||null,notes:_e.notes||null};if(ve)await Y.from("innercircle_contacts").update(Me).eq("id",ve.id),ge++;else{const{data:Ze}=await Y.from("innercircle_contacts").insert(Me).select("id").single();Ze&&w.length>0&&await Y.from("innercircle_contact_tags").insert(w.map(Ae=>({contact_id:Ze.id,relationship_type_id:Ae}))),ce++}}catch(ve){console.error("Error importing contact:",ve),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(_e){console.error("Import error:",_e),o({title:"Import Failed",description:_e.message||"Failed to import contacts",variant:"destructive"})}finally{R(!1)}},pe=T.filter(de=>de.isValid).length,ie=T.filter(de=>!de.isValid).length;return r.jsx(Ir,{open:e,onOpenChange:q,children:r.jsxs(Er,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(_1,{className:"h-5 w-5"}),"Import Contacts from CSV"]}),r.jsx(Zs,{children:"Upload a CSV file with your contacts. You can map columns and select relationship types."})]}),i==="upload"&&r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-8 text-center",children:[r.jsx("input",{type:"file",accept:".csv,.txt",ref:l,onChange:K,className:"hidden"}),r.jsx(Xi,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click to upload or drag and drop a CSV file"}),r.jsx(X,{onClick:()=>{var de;return(de=l.current)==null?void 0:de.click()},children:"Select CSV File"})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 text-sm",children:[r.jsx("p",{className:"font-medium mb-2",children:"Supported Fields:"}),r.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"}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>{const de=`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([de],{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:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Download Template"]})]})]}),i==="mapping"&&r.jsxs("div",{className:"flex-1 overflow-auto space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),r.jsx("div",{className:"grid gap-3",children:LPt.map(de=>r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs(Ee,{className:"w-40 text-sm",children:[de.label,de.required&&r.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),r.jsxs(ds,{value:_[de.key]||"none",onValueChange:ce=>re(de.key,ce),children:[r.jsx(ls,{className:"w-48",children:r.jsx(us,{placeholder:"Select column..."})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"-- Not mapped --"}),m.map(ce=>r.jsx(Ut,{value:ce,children:ce},ce))]})]})]},de.key))})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(de=>r.jsx(_t,{variant:w.includes(de.id)?"default":"outline",className:"cursor-pointer",onClick:()=>ae(de.id),children:de.name},de.id))})]}),r.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:r.jsxs("p",{className:"text-muted-foreground",children:["Preview: ",g.length," row(s) found in CSV"]})})]}),i==="preview"&&r.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ri,{className:"h-4 w-4 text-green-500"}),r.jsxs("span",{children:[pe," valid"]})]}),ie>0&&r.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[r.jsx(kl,{className:"h-4 w-4"}),r.jsxs("span",{children:[ie," invalid"]})]})]}),r.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/30",children:[r.jsx(Mt,{children:"First Name"}),r.jsx(Mt,{children:"Last Name"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Phone"}),r.jsx(Mt,{children:"Status"})]})}),r.jsx(Bn,{children:T.slice(0,100).map((de,ce)=>r.jsxs(Nr,{children:[r.jsx(dt,{children:de.first_name}),r.jsx(dt,{children:de.last_name}),r.jsx(dt,{children:de.email}),r.jsx(dt,{children:de.phone}),r.jsx(dt,{children:de.isValid?r.jsx(_t,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):r.jsx(_t,{variant:"destructive",children:de.error||"Invalid"})})]},ce))})]}),T.length>100&&r.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",T.length," contacts"]})]})]}),i==="result"&&D&&r.jsxs("div",{className:"space-y-4 py-4 text-center",children:[r.jsx(Ri,{className:"h-12 w-12 mx-auto text-green-500"}),r.jsx("h3",{className:"text-lg font-semibold",children:"Import Complete"}),r.jsxs("p",{className:"text-muted-foreground",children:[D.created," contact(s) created, ",D.updated," updated"]}),D.failed>0&&r.jsxs("p",{className:"text-destructive",children:[D.failed," failed to import"]})]}),r.jsxs(Rn,{children:[i==="upload"&&r.jsx(X,{variant:"outline",onClick:q,children:"Cancel"}),i==="mapping"&&r.jsxs(r.Fragment,{children:[r.jsx(X,{variant:"outline",onClick:$,children:"Back"}),r.jsx(X,{onClick:oe,disabled:!_.first_name,children:"Continue"})]}),i==="preview"&&r.jsxs(r.Fragment,{children:[r.jsx(X,{variant:"outline",onClick:()=>d("mapping"),children:"Back"}),r.jsx(X,{onClick:se,disabled:I||pe===0,children:I?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${pe} Contact${pe!==1?"s":""}`})]}),i==="result"&&r.jsx(X,{onClick:q,children:"Done"})]})]})})};function OPt(){return"contacts"in navigator&&"ContactsManager"in window}function RPt(e){const t=[],s=e.split("BEGIN:VCARD").filter(n=>n.trim());for(const n of s){const a=n.split(/\r?\n/);let o="",l="",i="",d="",m="";for(const p of a){const g=p.replace(/^\s+/,"");if(g.startsWith("N:")||g.startsWith("N;")){const _=g.substring(g.indexOf(":")+1).split(";");l=(_[0]||"").trim(),o=(_[1]||"").trim()}if((g.startsWith("FN:")||g.startsWith("FN;"))&&!o){const _=g.substring(g.indexOf(":")+1).trim().split(" ");o=_[0]||"",l=_.slice(1).join(" ")}(g.startsWith("EMAIL")||g.match(/^item\d+\.EMAIL/i))&&!i&&(i=g.substring(g.indexOf(":")+1).trim()),(g.startsWith("TEL")||g.match(/^item\d+\.TEL/i))&&!d&&(d=g.substring(g.indexOf(":")+1).trim()),(g.startsWith("ADR")||g.match(/^item\d+\.ADR/i))&&!m&&(m=g.substring(g.indexOf(":")+1).split(";").map(k=>k.trim()).filter(Boolean).join(", "))}(o||l)&&t.push({first_name:o,last_name:l,email:i,phone:d,address:m})}return t}function FPt({open:e,onOpenChange:t,onComplete:s}){const{user:n}=Gr(),{data:a}=Xf(),o=d1e(),l=A.useRef(null),[i,d]=A.useState("choose"),[m,p]=A.useState([]),[g,v]=A.useState(new Set),[_,k]=A.useState(0),[w,S]=A.useState(0),T=OPt(),C=A.useCallback(re=>{if(!a)return re;const ae=new Set(a.filter(se=>se.email).map(se=>se.email.toLowerCase())),oe=new Set(a.filter(se=>se.phone).map(se=>se.phone.replace(/\D/g,"")));return re.map(se=>{var de,ce;const pe=(de=se.email)==null?void 0:de.toLowerCase(),ie=(ce=se.phone)==null?void 0:ce.replace(/\D/g,"");return pe&&ae.has(pe)?{...se,isDuplicate:!0,duplicateField:"email"}:ie&&ie.length>=7&&oe.has(ie)?{...se,isDuplicate:!0,duplicateField:"phone"}:se})},[a]),I=async()=>{try{const re=["name","email","tel","address"],ae=await navigator.contacts.select(re,{multiple:!0});if(!ae||ae.length===0)return;const oe=ae.map(ie=>{var ge,Te,_e,ve;const ce=(((ge=ie.name)==null?void 0:ge[0])||"").split(" ");return{first_name:ce[0]||"",last_name:ce.slice(1).join(" "),email:((Te=ie.email)==null?void 0:Te[0])||"",phone:((_e=ie.tel)==null?void 0:_e[0])||"",address:(ve=ie.address)!=null&&ve[0]?[ie.address[0].streetAddress,ie.address[0].city,ie.address[0].region,ie.address[0].postalCode].filter(Boolean).join(", "):""}}),se=C(oe);p(se);const pe=new Set;se.forEach((ie,de)=>{ie.isDuplicate||pe.add(de)}),v(pe),d("preview")}catch(re){console.error("Contact Picker error:",re),ta({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},R=re=>{var se;const ae=(se=re.target.files)==null?void 0:se[0];if(!ae)return;const oe=new FileReader;oe.onload=pe=>{var Te;const ie=(Te=pe.target)==null?void 0:Te.result,de=RPt(ie);if(de.length===0){ta({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const ce=C(de);p(ce);const ge=new Set;ce.forEach((_e,ve)=>{_e.isDuplicate||ge.add(ve)}),v(ge),d("preview")},oe.readAsText(ae),l.current&&(l.current.value="")},D=async()=>{const re=m.filter((oe,se)=>g.has(se));if(re.length===0)return;d("importing");let ae=0;for(const oe of re)try{await o.mutateAsync({first_name:oe.first_name,last_name:oe.last_name||void 0,email:oe.email||void 0,phone:oe.phone||void 0,address:oe.address||void 0}),ae++,S(Math.round(ae/re.length*100))}catch(se){console.error(`Failed to import ${oe.first_name} ${oe.last_name}:`,se)}k(ae),d("done")},B=re=>{v(ae=>{const oe=new Set(ae);return oe.has(re)?oe.delete(re):oe.add(re),oe})},$=()=>{g.size===m.length?v(new Set):v(new Set(m.map((re,ae)=>ae)))},q=re=>{re||(d("choose"),p([]),v(new Set),k(0),S(0),i==="done"&&s()),t(re)},W=m.filter(re=>re.isDuplicate).length,K=g.size;return r.jsx(Ir,{open:e,onOpenChange:q,children:r.jsxs(Er,{className:"sm:max-w-lg max-h-[90vh]",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(qy,{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"&&r.jsx(Zs,{children:"Add contacts from your phone directly into Agent OS."})]}),i==="choose"&&r.jsxs("div",{className:"space-y-4 pt-2",children:[T&&r.jsxs(X,{onClick:I,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[r.jsx(qy,{className:"h-6 w-6"}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"font-semibold",children:"Select from Phone"}),r.jsx("div",{className:"text-xs opacity-80",children:"Pick contacts directly from your device"})]})]}),r.jsxs("div",{className:"relative",children:[T&&r.jsx("div",{className:"absolute inset-0 flex items-center",children:r.jsx("span",{className:"w-full border-t"})}),T&&r.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:r.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"or"})})]}),r.jsxs(X,{variant:T?"outline":"default",onClick:()=>{var re;return(re=l.current)==null?void 0:re.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[r.jsx(Xi,{className:"h-6 w-6"}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"font-semibold",children:"Upload Contact File"}),r.jsx("div",{className:"text-xs opacity-80",children:T?"Import a .vcf file exported from your Contacts app":"Export contacts from your phone as a .vcf file, then upload here"})]})]}),r.jsx("input",{ref:l,type:"file",accept:".vcf,.vcard",onChange:R,className:"hidden"}),!T&&r.jsxs("div",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground space-y-2",children:[r.jsx("p",{className:"font-medium",children:"How to export contacts:"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-xs",children:"iPhone:"}),r.jsx("p",{className:"text-xs",children:'Open Contacts → select contacts → Share → choose "Export vCard"'})]}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-xs",children:"Android:"}),r.jsx("p",{className:"text-xs",children:"Open Contacts → Menu → Export → save as .vcf file"})]})]})]}),i==="preview"&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("span",{children:[m.length," contact",m.length!==1?"s":""," found",W>0&&r.jsxs("span",{className:"text-amber-600 ml-1",children:["(",W," already exist)"]})]}),r.jsx(X,{variant:"ghost",size:"sm",onClick:$,children:g.size===m.length?"Deselect All":"Select All"})]}),r.jsx(To,{className:"h-[350px] rounded-md border",children:r.jsx("div",{className:"divide-y",children:m.map((re,ae)=>r.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${re.isDuplicate?"opacity-60":""}`,onClick:()=>B(ae),children:[r.jsx(Qo,{checked:g.has(ae),onCheckedChange:()=>B(ae),className:"mt-0.5"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"font-medium text-sm truncate",children:[re.first_name," ",re.last_name]}),re.isDuplicate&&r.jsxs(_t,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",re.duplicateField,")"]})]}),r.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[re.phone&&r.jsx("div",{children:re.phone}),re.email&&r.jsx("div",{className:"truncate",children:re.email})]})]})]},ae))})}),r.jsxs("div",{className:"flex items-center justify-between pt-2",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>d("choose"),children:"Back"}),r.jsxs(X,{onClick:D,disabled:K===0,children:["Import ",K," Contact",K!==1?"s":""]})]})]}),i==="importing"&&r.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[r.jsx($r,{className:"h-8 w-8 animate-spin text-primary"}),r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"font-medium",children:"Importing contacts..."}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:[w,"% complete"]})]}),r.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:r.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${w}%`}})})]}),i==="done"&&r.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[r.jsx("div",{className:"h-12 w-12 rounded-full bg-emerald-500/10 flex items-center justify-center",children:r.jsx(mi,{className:"h-6 w-6 text-emerald-600"})}),r.jsxs("div",{className:"text-center",children:[r.jsxs("p",{className:"font-semibold text-lg",children:[_," contact",_!==1?"s":""," imported!"]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Your contacts are now in Agent OS and ready for touchpoint plans."})]}),r.jsx(X,{onClick:()=>q(!1),className:"mt-2",children:"Done"})]})]})})}function zPt({selectedIds:e,contacts:t,onClearSelection:s,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const{data:i}=gg(),d=u1e(),m=Rr(),{isGmailConnected:p}=kN(),[g,v]=A.useState(!1),[_,k]=A.useState(!1),w=e.size;if(w===0)return null;const S=async I=>{v(!0);try{const D=Array.from(e).map($=>({contact_id:$,relationship_type_id:I})),{error:B}=await Y.from("innercircle_contact_tags").upsert(D,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(B)throw B;m.invalidateQueries({queryKey:["innercircle-contacts"]}),m.invalidateQueries({queryKey:["innercircle-contact-counts"]}),ta({title:`Assigned type to ${w} contacts`}),s()}catch(R){ta({title:"Error assigning type",description:R.message,variant:"destructive"})}finally{v(!1)}},T=()=>{const I=t.filter(K=>e.has(K.id)),R=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],D=I.map(K=>{var re;return[K.first_name,K.last_name||"",K.email||"",K.phone||"",K.address||"",K.birthday||"",K.home_anniversary||"",K.notes||"",((re=K.tags)==null?void 0:re.map(ae=>{var oe;return(oe=ae.relationship_type)==null?void 0:oe.name}).join("; "))||""]}),B=[R.join(","),...D.map(K=>K.map(re=>`"${(re||"").replace(/"/g,'""')}"`).join(","))].join(` `),$=new Blob([B],{type:"text/csv"}),q=URL.createObjectURL($),W=document.createElement("a");W.href=q,W.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,W.click(),URL.revokeObjectURL(q),ta({title:`Exported ${w} contacts`})},C=async()=>{if(confirm(`Are you sure you want to delete ${w} contacts? This cannot be undone.`)){v(!0);try{const I=Array.from(e);for(const R of I)await d.mutateAsync(R);s()}catch(I){ta({title:"Error deleting contacts",description:I.message,variant:"destructive"})}finally{v(!1)}}};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-3 p-3 bg-primary/5 border border-primary/20 rounded-lg",children:[r.jsxs(_t,{variant:"secondary",className:"font-semibold",children:[w," selected"]}),r.jsxs(ds,{onValueChange:S,disabled:g,children:[r.jsx(ls,{className:"w-[180px] h-8",children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(px,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),r.jsx(cs,{children:i==null?void 0:i.filter(I=>I.active).map(I=>r.jsx(Ut,{value:I.id,children:I.name},I.id))})]}),p&&r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>k(!0),disabled:g,children:[r.jsx(Vs,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),a&&n&&r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>n(Array.from(e)),disabled:g,children:[r.jsx(dx,{className:"h-3.5 w-3.5 mr-1"}),"Send to Lead Pond"]}),l&&o&&r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>o(Array.from(e)),disabled:g,children:[r.jsx(Dy,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:T,disabled:g,children:[r.jsx(Fi,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:C,disabled:g,className:"text-destructive hover:text-destructive",children:[r.jsx(Os,{className:"h-3.5 w-3.5 mr-1"}),"Delete"]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:s,className:"ml-auto",children:[r.jsx(Xs,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),r.jsx(yoe,{open:_,onOpenChange:k,bulkContacts:Array.from(e).map(I=>{const R=t.find(D=>D.id===I);return R?{id:R.id,first_name:R.first_name,last_name:R.last_name,email:R.email||""}:null}).filter(I=>I!==null&&I.email!==""),onSendComplete:()=>{k(!1),s()}})]})}function SMe({contact:e,onEdit:t,onDelete:s,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const d=Ks(),m=`${e.first_name} ${e.last_name||""}`.trim();return r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:p=>p.stopPropagation(),children:r.jsx(Nf,{className:"h-4 w-4"})})}),r.jsxs(vu,{align:"end",onClick:p=>p.stopPropagation(),children:[r.jsxs(Ba,{onClick:()=>d(`/mission-control/contacts/${e.id}?tab=activity&action=log`),children:[r.jsx(fi,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),r.jsxs(Ba,{onClick:()=>d(`/mission-control/video?contactId=${e.id}`),children:[r.jsx(ma,{className:"h-4 w-4 mr-2"}),"Send Video"]}),r.jsxs(Ba,{onClick:()=>d(`/mission-control/popbys?contactId=${e.id}`),children:[r.jsx(Yi,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),r.jsxs(Ba,{onClick:()=>n(e.id,m),children:[r.jsx(Bm,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&r.jsxs(Ba,{onClick:()=>a(e.id),children:[r.jsx(dx,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&r.jsxs(Ba,{onClick:()=>l(e.id),children:[r.jsx(Dy,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),r.jsxs(Ba,{onClick:()=>t(e),children:[r.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Edit"]}),r.jsxs(Ba,{onClick:()=>s(e.id),className:"text-destructive focus:text-destructive",children:[r.jsx(Os,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function BPt(){const{user:e}=Gr();return Ht({queryKey:["contact-smart-lists",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("contact_smart_lists").select("*").order("created_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function $Pt(){const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async({name:s,filters:n,sort_by:a})=>{const{data:o,error:l}=await Y.from("contact_smart_lists").insert({owner_user_id:t.id,name:s,filters:n,sort_by:a}).select().single();if(l)throw l;return o},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-smart-lists"]}),ta({title:"Smart filter saved"})},onError:s=>{ta({title:"Error saving smart filter",description:s.message,variant:"destructive"})}})}function UPt(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("contact_smart_lists").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["contact-smart-lists"]}),ta({title:"Smart filter deleted"})}})}function VPt({currentFilters:e,currentSortBy:t,onApplySmartList:s}){const{data:n}=BPt(),a=$Pt(),o=UPt(),[l,i]=A.useState(!1),[d,m]=A.useState(""),p=e.search||e.type&&e.type!=="all"||e.status&&e.status!=="all",g=async()=>{d.trim()&&(await a.mutateAsync({name:d.trim(),filters:e,sort_by:t}),m(""),i(!1))};return r.jsxs(r.Fragment,{children:[r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"sm",className:"gap-1.5",children:[r.jsx(b1,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&r.jsx(_t,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),r.jsx(ad,{className:"h-3.5 w-3.5"})]})}),r.jsxs(vu,{align:"start",className:"w-56",children:[n&&n.length>0?r.jsxs(r.Fragment,{children:[n.map(v=>r.jsxs(Ba,{className:"flex items-center justify-between group",children:[r.jsx("span",{className:"flex-1 cursor-pointer",onClick:()=>s(v.filters,v.sort_by),children:v.name}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 opacity-0 group-hover:opacity-100",onClick:_=>{_.stopPropagation(),o.mutate(v.id)},children:r.jsx(Os,{className:"h-3 w-3 text-destructive"})})]},v.id)),r.jsx(Yk,{})]}):r.jsx(Ba,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&r.jsxs(Ba,{onClick:()=>i(!0),children:[r.jsx(uE,{className:"h-4 w-4 mr-2"}),"Save Current Filter"]})]})]}),r.jsx(Ir,{open:l,onOpenChange:i,children:r.jsxs(Er,{className:"max-w-sm",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Save Smart Filter"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx(Ye,{placeholder:"e.g. Buyers in 40205",value:d,onChange:v=>m(v.target.value),onKeyDown:v=>v.key==="Enter"&&g(),autoFocus:!0}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),r.jsx(X,{onClick:g,disabled:!d.trim()||a.isPending,children:"Save"})]})]})]})})]})}function YA(e){if(!e)return null;try{const t=e.split(/[-/T]/);if(t.length<3)return null;const s=parseInt(t[1],10)-1,n=parseInt(t[2],10);if(isNaN(s)||isNaN(n))return null;const a=new Date;a.setHours(0,0,0,0);let o=new Date(a.getFullYear(),s,n);return o.setHours(0,0,0,0),os)return null;const a=t==="birthday"?"🎂":"🏡",o=n===0?t==="birthday"?"Birthday today!":"Anniversary today!":n===1?t==="birthday"?"Birthday tomorrow":"Anniversary tomorrow":`${a} in ${n}d`;return{emoji:a,label:o,daysUntil:n}}function MMe({birthday:e,homeAnniversary:t,className:s,contactId:n,contactName:a,contactAddress:o}){const l=Ks(),i=CMe(e,"birthday",7),d=CMe(t,"anniversary",7);if(!i&&!d)return null;const m=(p,g)=>{g.stopPropagation();const v=new URLSearchParams;n&&v.set("contactId",n),a&&v.set("name",a),o&&v.set("address",o),p==="home_anniversary"&&t&&v.set("date",t),v.set("cardType",p),l(`/mission-control/card-studio?${v.toString()}`)};return r.jsxs("div",{className:Vt("flex flex-wrap gap-1",s),children:[i&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx(_t,{variant:"secondary",className:Vt("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&&r.jsxs("button",{onClick:p=>m("birthday",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-pink-500/15 text-pink-600 dark:text-pink-400 hover:bg-pink-500/25 transition-colors",title:"Send a birthday card",children:[r.jsx(Vs,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),d&&r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx(_t,{variant:"secondary",className:Vt("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&&r.jsxs("button",{onClick:p=>m("home_anniversary",p),className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[9px] font-semibold bg-blue-500/15 text-blue-600 dark:text-blue-400 hover:bg-blue-500/25 transition-colors",title:"Send an anniversary card",children:[r.jsx(Vs,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function TMe({deal:e}){if(!e||!e.stage)return null;const{stage:t}=e;return r.jsxs(_t,{variant:"outline",className:"text-[10px] gap-1 font-medium whitespace-nowrap",style:{borderColor:t.color,color:t.color,backgroundColor:`${t.color}10`},children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:t.color}}),t.name]})}function qPt(){const e=fl();return Ht({queryKey:["contact-deals-map",e],queryFn:async()=>{const{data:t,error:s}=await Y.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(s)throw s;const n={};return(t||[]).forEach(a=>{a.contact_id&&!n[a.contact_id]&&(n[a.contact_id]=a)}),n},enabled:!!e})}function HPt(){var Et;const e=Ks(),[t]=Cc(),{user:s}=Gr(),n=V3(),a=Rr(),o=t.get("type"),l=t.get("filter")??t.get("status"),i=t.get("new")==="true",{contactsWithScores:d,isLoading:m}=p1e(),{data:p}=gg(),{data:g}=qPt(),v=d1e(),_=s9e(),k=u1e(),[w,S]=A.useState(""),[T,C]=A.useState(o||"all"),[I,R]=A.useState(l||"all"),[D,B]=A.useState("date-added"),[$,q]=A.useState(i),[W,K]=A.useState(null),[re,ae]=A.useState(!1),[oe,se]=A.useState(!1),[pe,ie]=A.useState(null),[de,ce]=A.useState(""),[ge,Te]=A.useState(new Set),[_e,ve]=A.useState(!1),[Me,Ze]=A.useState(1),[Ae,Le]=A.useState(50),[Ue,Ve]=A.useState("my"),{data:Ie}=o_(),{addToLeadPond:We}=Sqe(Ie==null?void 0:Ie.teamId),wt=!!((Et=Ie==null?void 0:Ie.team)!=null&&Et.lead_pond_enabled&&(Ie!=null&&Ie.teamId)),Pe=!!(Ie!=null&&Ie.teamId),[st,ue]=A.useState([]),[$e,tt]=A.useState(!1),rt=Pt=>{ue([Pt]),tt(!0)},je=Pt=>{ue(Pt),tt(!0)},it=Pt=>{Ie!=null&&Ie.teamId&&We.mutate({contact_id:Pt,team_id:Ie.teamId})},Se=Pt=>{Ie!=null&&Ie.teamId&&Pt.forEach(Sr=>{We.mutate({contact_id:Sr,team_id:Ie.teamId})})},et=A.useCallback(Pt=>{ve(!1),Te(Sr=>{const fs=new Set(Sr);return fs.has(Pt)?fs.delete(Pt):fs.add(Pt),fs})},[]);A.useEffect(()=>{if(!(s!=null&&s.id))return;const Pt=Y.channel(`innercircle_contacts_inserts_${s.id}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"innercircle_contacts",filter:`owner_user_id=eq.${s.id}`},()=>{a.invalidateQueries({queryKey:["innercircle-contacts"]}),a.invalidateQueries({queryKey:["innercircle-contact-counts"]})}).subscribe();return()=>{Y.removeChannel(Pt)}},[a,s==null?void 0:s.id]),A.useEffect(()=>{l&&R(l)},[l]);const[Qe,He]=A.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",notes:"",tagIds:[]});A.useEffect(()=>{i&&q(!0)},[i]),A.useEffect(()=>{var Pt;W&&He({first_name:W.first_name||"",last_name:W.last_name||"",email:W.email||"",phone:W.phone||"",address:W.address||"",city:W.city||"",state:W.state||"",zip_code:W.zip_code||"",birthday:W.birthday||"",home_anniversary:W.home_anniversary||"",spouse_name:W.spouse_name||"",spouse_email:W.spouse_email||"",notes:W.notes||"",tagIds:((Pt=W.tags)==null?void 0:Pt.map(Sr=>Sr.relationship_type_id))||[]})},[W]);const ot=A.useMemo(()=>{if(!d)return[];let Pt=d.filter(Sr=>{var tn,xi,La;const fs=w===""||`${Sr.first_name} ${Sr.last_name}`.toLowerCase().includes(w.toLowerCase())||((tn=Sr.email)==null?void 0:tn.toLowerCase().includes(w.toLowerCase()))||((xi=Sr.phone)==null?void 0:xi.includes(w)),Ws=T==="all"||((La=Sr.tags)==null?void 0:La.some(un=>un.relationship_type_id===T));return fs&&Ws});return I==="not-touched-90"?Pt=Pt.filter(Sr=>{const fs=Sr.relationshipScore.daysSinceTouch;return fs===null||fs>90}):I==="at-risk"?Pt=Pt.filter(Sr=>Sr.relationshipScore.status==="at-risk"):I==="cooling"?Pt=Pt.filter(Sr=>Sr.relationshipScore.status==="cooling"):I==="warm"?Pt=Pt.filter(Sr=>Sr.relationshipScore.status==="warm"):I==="has-deal"?Pt=Pt.filter(Sr=>g&&g[Sr.id]):I==="no-deal"?Pt=Pt.filter(Sr=>!g||!g[Sr.id]):I==="open-house"&&(Pt=Pt.filter(Sr=>Sr.lead_source==="Open House")),Pt=[...Pt].sort((Sr,fs)=>{switch(D){case"important-dates":{const Ws=YA(Sr.birthday),tn=YA(fs.birthday),xi=YA(Sr.home_anniversary),La=YA(fs.home_anniversary),un=[Ws,xi].filter(rn=>rn!==null).sort((rn,Wn)=>(rn??1/0)-(Wn??1/0))[0]??1/0,ia=[tn,La].filter(rn=>rn!==null).sort((rn,Wn)=>(rn??1/0)-(Wn??1/0))[0]??1/0;return un-ia}case"last-touched":{const Ws=Sr.relationshipScore.lastTouchDate,tn=fs.relationshipScore.lastTouchDate;return!Ws&&!tn?0:Ws?tn?new Date(Ws).getTime()-new Date(tn).getTime():1:-1}case"next-touch":{const Ws=Sr.relationshipScore.daysSinceTouch,tn=fs.relationshipScore.daysSinceTouch;return Ws===null&&tn===null?0:Ws===null?-1:tn===null?1:tn-Ws}case"score":return Sr.relationshipScore.score-fs.relationshipScore.score;case"date-added":{const Ws=Sr.created_at,tn=fs.created_at;return!Ws&&!tn?0:Ws?tn?new Date(tn).getTime()-new Date(Ws).getTime():-1:1}case"name":default:{const Ws=`${Sr.first_name||""} ${Sr.last_name||""}`.toLowerCase(),tn=`${fs.first_name||""} ${fs.last_name||""}`.toLowerCase();return Ws.localeCompare(tn)}}}),Pt},[d,w,T,I,D,g]),ut=ot.length,ft=Math.max(1,Math.ceil(ut/Ae)),ct=Math.min(Me,ft),Tt=A.useMemo(()=>{const Pt=(ct-1)*Ae;return ot.slice(Pt,Pt+Ae)},[ot,ct,Ae]);A.useEffect(()=>{Ze(1)},[w,T,I,D]);const Ot=A.useCallback(()=>{ve(!1),Te(Pt=>Pt.size>0?new Set:new Set(Tt.map(Sr=>Sr.id)))},[Tt]),rr=A.useCallback(()=>{ve(!0),Te(new Set(ot.map(Pt=>Pt.id)))},[ot]),Lr=A.useCallback((Pt,Sr)=>{S(Pt.search||""),C(Pt.type||"all"),R(Pt.status||"all"),B(Sr||"name")},[]),cr=()=>{He({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",notes:"",tagIds:[]})},Mr=async Pt=>{Pt.preventDefault(),W?(await _.mutateAsync({id:W.id,...Qe}),K(null)):(await v.mutateAsync(Qe),q(!1)),cr()},As=async Pt=>{confirm("Are you sure you want to delete this contact?")&&await k.mutateAsync(Pt)};return r.jsx(Ur,{title:"Contacts",description:"Manage your InnerCircle contacts",children:r.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Contacts"}),r.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"})]}),Ie&&r.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[r.jsx("button",{onClick:()=>Ve("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${Ue==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(Ie.team.contact_visibility==="full_team"||Ie.team.contact_visibility==="leader_only"&&Ie.role==="team_leader")&&r.jsxs("button",{onClick:()=>Ve("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${Ue==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[r.jsx(ws,{className:"h-3.5 w-3.5"}),"Team"]}),Ie.team.lead_pond_enabled&&r.jsxs("button",{onClick:()=>Ve("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${Ue==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[r.jsx(dx,{className:"h-3.5 w-3.5"}),"Lead Pond"]})]})]}),r.jsx("div",{className:"flex items-center gap-4",children:r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>e("/mission-control"),children:[r.jsx(jc,{className:"h-4 w-4 mr-1"}),"Back"]})}),Ue==="team"?r.jsx(x_e,{}):Ue==="lead-pond"&&Ie?r.jsx(y_e,{teamId:Ie.teamId}):r.jsxs(r.Fragment,{children:[r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name, email, or phone...",value:w,onChange:Pt=>S(Pt.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:T,onValueChange:C,children:[r.jsx(ls,{className:"w-[160px]",children:r.jsx(us,{placeholder:"Filter by type"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Types"}),p==null?void 0:p.filter(Pt=>Pt.active).map(Pt=>r.jsx(Ut,{value:Pt.id,children:Pt.name},Pt.id))]})]}),r.jsxs(ds,{value:I,onValueChange:R,children:[r.jsx(ls,{className:"w-[160px]",children:r.jsx(us,{placeholder:"Filter by status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Status"}),r.jsx(Ut,{value:"warm",children:"🟢 Warm"}),r.jsx(Ut,{value:"cooling",children:"🟡 Cooling Off"}),r.jsx(Ut,{value:"at-risk",children:"🔴 At Risk"}),r.jsx(Ut,{value:"has-deal",children:"📋 Has Deal"}),r.jsx(Ut,{value:"no-deal",children:"📭 No Deal"}),r.jsx(Ut,{value:"open-house",children:"🏠 Open House"})]})]}),r.jsxs(ds,{value:D,onValueChange:B,children:[r.jsx(ls,{className:"w-[180px]",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(eg,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(us,{placeholder:"Sort by"})]})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"name",children:"Name (A-Z)"}),r.jsx(Ut,{value:"important-dates",children:"Important Dates"}),r.jsx(Ut,{value:"last-touched",children:"Last Touched"}),r.jsx(Ut,{value:"next-touch",children:"Next Touch Due"}),r.jsx(Ut,{value:"score",children:"Relationship Score"}),r.jsx(Ut,{value:"date-added",children:"Date Added"})]})]}),r.jsx(VPt,{currentFilters:{search:w,type:T,status:I},currentSortBy:D,onApplySmartList:Lr}),r.jsxs(X,{onClick:()=>q(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Add Contact"]}),r.jsxs(X,{variant:"outline",onClick:()=>ae(!0),children:[r.jsx(Xi,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),r.jsxs(X,{variant:"outline",onClick:()=>se(!0),children:[r.jsx(qy,{className:"h-4 w-4 mr-1"}),"Import from Phone"]})]})})}),r.jsx(zPt,{selectedIds:ge,contacts:ot,onClearSelection:()=>{Te(new Set),ve(!1)},showLeadPondAction:wt,onSendToLeadPond:Se,showTransferAction:Pe,onTransfer:je}),ge.size>0&&ge.size===Tt.length&&!_e&&ut>Ae&&r.jsxs("div",{className:"flex items-center justify-center gap-2 p-2 bg-primary/5 border border-primary/20 rounded-lg text-sm",children:[r.jsxs("span",{children:["All ",Tt.length," contacts on this page are selected."]}),r.jsxs(X,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:rr,children:["Select all ",ut.toLocaleString()," matching contacts"]})]}),_e&&r.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 ",ut.toLocaleString()," matching contacts are selected.",r.jsx(X,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Te(new Set),ve(!1)},children:"Clear selection"})]}),n?r.jsx("div",{className:"space-y-3",children:m?r.jsx(ze,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):ot.length===0?r.jsx(ze,{className:"p-6 text-center text-muted-foreground",children:w||T!=="all"||I!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Tt.map(Pt=>{var fs;const{relationshipScore:Sr}=Pt;return r.jsx(ze,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Ws=new URLSearchParams;w&&Ws.set("search",w),T!=="all"&&Ws.set("type",T),I!=="all"&&Ws.set("filter",I);const tn=Ws.toString();e(`/mission-control/contacts/${Pt.id}${tn?`?${tn}`:""}`)},children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsxs("h3",{className:"font-semibold text-base truncate",children:[Pt.first_name," ",Pt.last_name]}),r.jsx(Zi,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),r.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[Pt.email&&r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[r.jsx(Vs,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{className:"truncate",children:Pt.email})]}),Pt.phone&&r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[r.jsx(fi,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{children:Pt.phone})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[r.jsx(khe,{score:Sr,size:"sm"}),r.jsx(Nge,{contact:Pt}),Pt.lead_source&&r.jsx(_t,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:Pt.lead_source}),(fs=Pt.tags)==null?void 0:fs.map(Ws=>{var tn;return r.jsx(_t,{variant:"secondary",className:"text-xs",children:(tn=Ws.relationship_type)==null?void 0:tn.name},Ws.id)}),r.jsx(TMe,{deal:g==null?void 0:g[Pt.id]})]}),r.jsx(MMe,{birthday:Pt.birthday,homeAnniversary:Pt.home_anniversary,className:"mb-2",contactId:Pt.id,contactName:`${Pt.first_name}${Pt.last_name?" "+Pt.last_name:""}`,contactAddress:[Pt.address,Pt.city,Pt.state].filter(Boolean).join(", ")}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[Sr.lastTouchDate?r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),Xr(new Date(Sr.lastTouchDate),"MMM d")]}):r.jsx("span",{className:"italic",children:"Never contacted"}),Pt.birthday&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(Pt.birthday),"MMM d")]}),Pt.home_anniversary&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Vn,{className:"h-3 w-3"}),Xr(new Date(Pt.home_anniversary),"MMM d")]})]})]}),r.jsx("div",{className:"ml-2",onClick:Ws=>Ws.stopPropagation(),children:r.jsx(SMe,{contact:Pt,onEdit:K,onDelete:As,onSnooze:(Ws,tn)=>{ie(Ws),ce(tn)},showLeadPondAction:wt,onSendToLeadPond:it,showTransferAction:Pe,onTransfer:rt})})]})})},Pt.id)})}):r.jsx(ze,{children:r.jsx(qe,{className:"p-0 overflow-x-auto",children:r.jsxs(Fn,{className:"min-w-[800px]",children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-[40px]",children:r.jsx(Qo,{checked:Tt.length>0&&Tt.every(Pt=>ge.has(Pt.id)),onCheckedChange:()=>Ot()})}),r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Score"}),r.jsx(Mt,{children:"Contact Info"}),r.jsx(Mt,{children:"Types / Pipeline"}),r.jsx(Mt,{children:"Last Contact"}),r.jsx(Mt,{children:"Important Dates"}),r.jsx(Mt,{className:"w-[50px]",children:"Actions"})]})}),r.jsx(Bn,{children:m?r.jsx(Nr,{children:r.jsx(dt,{colSpan:9,className:"text-center py-8",children:"Loading contacts..."})}):ot.length===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:w||T!=="all"||I!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Tt.map(Pt=>{var Ws;const{relationshipScore:Sr}=Pt,fs=g==null?void 0:g[Pt.id];return r.jsxs(Nr,{className:`cursor-pointer hover:bg-accent/50 ${ge.has(Pt.id)?"bg-accent/30":""}`,onClick:()=>{const tn=new URLSearchParams;w&&tn.set("search",w),T!=="all"&&tn.set("type",T),I!=="all"&&tn.set("status",I);const xi=tn.toString();e(`/mission-control/contacts/${Pt.id}${xi?`?${xi}`:""}`)},children:[r.jsx(dt,{onClick:tn=>tn.stopPropagation(),children:r.jsx(Qo,{checked:ge.has(Pt.id),onCheckedChange:()=>et(Pt.id)})}),r.jsxs(dt,{className:"font-medium",children:[Pt.first_name," ",Pt.last_name]}),r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.jsx(khe,{score:Sr,size:"sm"}),r.jsx(Nge,{contact:Pt})]})}),r.jsx(dt,{children:r.jsx(khe,{score:Sr,size:"sm",showScore:!0})}),r.jsx(dt,{children:r.jsxs("div",{className:"space-y-1 text-sm",children:[Pt.email&&r.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Vs,{className:"h-3 w-3"}),Pt.email]}),Pt.phone&&r.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(fi,{className:"h-3 w-3"}),Pt.phone]})]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex flex-wrap gap-1",children:[Pt.lead_source&&r.jsx(_t,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:Pt.lead_source}),(Ws=Pt.tags)==null?void 0:Ws.map(tn=>{var xi;return r.jsx(_t,{variant:"secondary",className:"text-xs",children:(xi=tn.relationship_type)==null?void 0:xi.name},tn.id)}),r.jsx(TMe,{deal:fs})]})}),r.jsx(dt,{children:r.jsx("div",{className:"text-sm",children:Sr.lastTouchDate?r.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[r.jsx(Pa,{className:"h-3 w-3"}),Xr(new Date(Sr.lastTouchDate),"MMM d, yyyy")]}):r.jsx("span",{className:"text-muted-foreground text-xs italic",children:"Never contacted"})})}),r.jsx(dt,{children:r.jsxs("div",{className:"space-y-1",children:[r.jsx(MMe,{birthday:Pt.birthday,homeAnniversary:Pt.home_anniversary,contactId:Pt.id,contactName:`${Pt.first_name}${Pt.last_name?" "+Pt.last_name:""}`,contactAddress:[Pt.address,Pt.city,Pt.state].filter(Boolean).join(", ")}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[Pt.birthday&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(Pt.birthday),"MMM d")]}),Pt.home_anniversary&&r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Vn,{className:"h-3 w-3"}),Xr(new Date(Pt.home_anniversary),"MMM d")]})]})]})}),r.jsx(dt,{children:r.jsx(SMe,{contact:Pt,onEdit:K,onDelete:As,onSnooze:(tn,xi)=>{ie(tn),ce(xi)},showLeadPondAction:wt,onSendToLeadPond:it,showTransferAction:Pe,onTransfer:rt})})]},Pt.id)})})]})})}),ut>0&&r.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 py-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsxs("span",{children:["Showing ",(ct-1)*Ae+1,"–",Math.min(ct*Ae,ut)," of ",ut.toLocaleString()," contacts"]}),r.jsxs(ds,{value:String(Ae),onValueChange:Pt=>{Le(Number(Pt)),Ze(1)},children:[r.jsx(ls,{className:"w-[80px] h-8",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"50",children:"50"}),r.jsx(Ut,{value:"100",children:"100"}),r.jsx(Ut,{value:"250",children:"250"})]})]}),r.jsx("span",{className:"text-xs",children:"per page"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"outline",size:"sm",disabled:ct<=1,onClick:()=>Ze(1),children:"First"}),r.jsx(X,{variant:"outline",size:"sm",disabled:ct<=1,onClick:()=>Ze(Pt=>Pt-1),children:r.jsx(jc,{className:"h-4 w-4"})}),r.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",ct," of ",ft]}),r.jsx(X,{variant:"outline",size:"sm",disabled:ct>=ft,onClick:()=>Ze(Pt=>Pt+1),children:r.jsx(Zi,{className:"h-4 w-4"})}),r.jsx(X,{variant:"outline",size:"sm",disabled:ct>=ft,onClick:()=>Ze(ft),children:"Last"})]})]}),r.jsx(Ir,{open:$||!!W,onOpenChange:Pt=>{Pt||(q(!1),K(null),cr())},children:r.jsxs(Er,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:W?"Edit Contact":"Add Contact"})}),r.jsxs("form",{onSubmit:Mr,className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"first_name",children:"First Name *"}),r.jsx(Ye,{id:"first_name",value:Qe.first_name,onChange:Pt=>He({...Qe,first_name:Pt.target.value}),required:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"last_name",children:"Last Name"}),r.jsx(Ye,{id:"last_name",value:Qe.last_name,onChange:Pt=>He({...Qe,last_name:Pt.target.value})})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"email",children:"Email"}),r.jsx(Ye,{id:"email",type:"email",value:Qe.email,onChange:Pt=>He({...Qe,email:Pt.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"phone",children:"Phone"}),r.jsx(Ye,{id:"phone",value:Qe.phone,onChange:Pt=>He({...Qe,phone:Pt.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"address",children:"Address"}),r.jsx(Ye,{id:"address",value:Qe.address,onChange:Pt=>He({...Qe,address:Pt.target.value}),placeholder:"Street address"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"city",children:"City"}),r.jsx(Ye,{id:"city",value:Qe.city,onChange:Pt=>He({...Qe,city:Pt.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"state",children:"State"}),r.jsx(Ye,{id:"state",value:Qe.state,onChange:Pt=>He({...Qe,state:Pt.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"zip_code",children:"Zip"}),r.jsx(Ye,{id:"zip_code",value:Qe.zip_code,onChange:Pt=>He({...Qe,zip_code:Pt.target.value})})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"birthday",children:"Birthday"}),r.jsx(Ye,{id:"birthday",type:"date",value:Qe.birthday,onChange:Pt=>He({...Qe,birthday:Pt.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"home_anniversary",children:"Home Anniversary"}),r.jsx(Ye,{id:"home_anniversary",type:"date",value:Qe.home_anniversary,onChange:Pt=>He({...Qe,home_anniversary:Pt.target.value})})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"spouse_name",children:"Spouse/Partner Name"}),r.jsx(Ye,{id:"spouse_name",value:Qe.spouse_name,onChange:Pt=>He({...Qe,spouse_name:Pt.target.value}),placeholder:"Spouse/partner name"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"spouse_email",children:"Spouse/Partner Email"}),r.jsx(Ye,{id:"spouse_email",type:"email",value:Qe.spouse_email,onChange:Pt=>He({...Qe,spouse_email:Pt.target.value}),placeholder:"Spouse/partner email"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Relationship Types"}),r.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:p==null?void 0:p.filter(Pt=>Pt.active).map(Pt=>r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx(Qo,{checked:Qe.tagIds.includes(Pt.id),onCheckedChange:Sr=>{He(Sr?{...Qe,tagIds:[...Qe.tagIds,Pt.id]}:{...Qe,tagIds:Qe.tagIds.filter(fs=>fs!==Pt.id)})}}),r.jsx("span",{className:"text-sm",children:Pt.name})]},Pt.id))})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"notes",children:"Notes"}),r.jsx(qs,{id:"notes",value:Qe.notes,onChange:Pt=>He({...Qe,notes:Pt.target.value}),rows:3})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>{q(!1),K(null),cr()},children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:v.isPending||_.isPending,children:[W?"Update":"Create"," Contact"]})]})]})]})}),r.jsx(DPt,{open:re,onOpenChange:ae,relationshipTypes:(p==null?void 0:p.filter(Pt=>Pt.active))||[],onSuccess:()=>{ae(!1)}}),r.jsx(FPt,{open:oe,onOpenChange:se,onComplete:()=>se(!1)}),r.jsx(xoe,{open:!!pe,onOpenChange:Pt=>{Pt||ie(null)},contactId:pe||"",contactName:de}),r.jsx(Cqe,{open:$e,onOpenChange:tt,contactIds:st,contactNames:st.map(Pt=>{const Sr=ot.find(fs=>fs.id===Pt);return Sr?`${Sr.first_name} ${Sr.last_name||""}`.trim():""}),onComplete:()=>{ue([]),Te(new Set),ve(!1)}})]})]})})}function WPt(){return Ht({queryKey:["video-script-categories"],queryFn:async()=>{const{data:e,error:t}=await Y.from("video_script_categories").select("*").order("sort_order");if(t)throw t;return e}})}function GPt(e){return Ht({queryKey:["video-scripts",e],queryFn:async()=>{let t=Y.from("video_scripts").select("*, category:video_script_categories(*)").eq("is_active",!0).order("title");const{data:s,error:n}=await t;if(n)throw n;return s}})}function KPt(){const{user:e}=Gr();return Ht({queryKey:["user-video-scripts",e==null?void 0:e.id],queryFn:async()=>{if(!(e!=null&&e.id))return[];const{data:t,error:s}=await Y.from("user_video_scripts").select("*, category:video_script_categories(*)").eq("owner_user_id",e.id).order("title");if(s)throw s;return t},enabled:!!(e!=null&&e.id)})}function ZPt(){const{user:e}=Gr(),t=Rr();return Qt({mutationFn:async s=>{if(!(e!=null&&e.id))throw new Error("Not authenticated");const{data:n,error:a}=await Y.from("user_video_scripts").insert([{owner_user_id:e.id,source_script_id:s.id,category_id:s.category_id,title:s.title,script_text:s.script_text,tags:s.tags,is_custom:!1}]).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["user-video-scripts"]})}})}function YPt(e){const{user:t}=Gr();return Ht({queryKey:["agent-videos",t==null?void 0:t.id,e],queryFn:async()=>{if(!(t!=null&&t.id))return[];let s=Y.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("owner_user_id",t.id).order("created_at",{ascending:!1});s=s.eq("is_deleted",!1);const{data:n,error:a}=await s;if(a)throw a;return n},enabled:!!(t!=null&&t.id)})}function XPt(e){return Ht({queryKey:["agent-video",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("agent_videos").select("*, contact:innercircle_contacts(id, first_name, last_name)").eq("id",e).single();if(s)throw s;return t},enabled:!!e})}function q3(){const{user:e}=Gr(),t=Rr();return Qt({mutationFn:async s=>{if(!(e!=null&&e.id))throw new Error("Not authenticated");const{data:n,error:a}=await Y.from("agent_videos").insert([{owner_user_id:e.id,contact_id:s.contact_id,bunny_video_id:s.bunny_video_id,playback_url:s.playback_url,thumbnail_url:s.thumbnail_url,preview_url:s.preview_url,duration_seconds:s.duration_seconds,file_size_mb:s.file_size_mb||0,title:s.title,notes:s.notes,task_id:s.task_id,status:s.status||"processing",touch_type:s.touch_type||"video",page_template:"default"}]).select("*, share_token").single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-videos"]}),t.invalidateQueries({queryKey:["storage-usage"]})}})}function QPt(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("agent_videos").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:t=>{e.invalidateQueries({queryKey:["agent-videos"]}),e.invalidateQueries({queryKey:["agent-video",t.id]})}})}function JPt(){const e=Rr();return Qt({mutationFn:async({id:t,bunnyVideoId:s,hardDelete:n=!1})=>{if(console.log("Deleting video:",{id:t,bunnyVideoId:s,hardDelete:n}),s){console.log("Calling bunny-upload delete for videoId:",s);const{data:a,error:o}=await Y.functions.invoke("bunny-upload",{body:{action:"delete",videoId:s,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:",t);const{error:a}=await Y.from("agent_videos").delete().eq("id",t);if(a)throw a}else{console.log("Soft deleting from database:",t);const{error:a}=await Y.from("agent_videos").update({is_deleted:!0}).eq("id",t);if(a)throw a}console.log("Video deletion complete")},onSuccess:()=>{e.invalidateQueries({queryKey:["agent-videos"]}),e.invalidateQueries({queryKey:["storage-usage"]})}})}function _oe(){const{user:e}=Gr();return Ht({queryKey:["storage-usage",e==null?void 0:e.id],queryFn:async()=>{if(!(e!=null&&e.id))return null;const{data:t,error:s}=await Y.from("agent_storage_usage").select("*").eq("user_id",e.id).maybeSingle();if(s)throw s;return t||{user_id:e.id,total_storage_mb:0,storage_tier:"basic",max_storage_mb:1024}},enabled:!!(e!=null&&e.id)})}function lHe(){const{data:e,isLoading:t}=_oe(),s=e?e.total_storage_mb0?e.total_storage_mb/e.max_storage_mb*100:0,o=a>=80;return{canRecord:s,remainingMb:n,usagePercent:a,isNearLimit:o,storage:e,isLoading:t}}async function boe(e){const{data:t,error:s}=await Y.functions.invoke("bunny-upload",{body:{action:"create",title:e,isAgentVideo:!0}});if(s)throw s;return t}async function woe(e){const{data:t,error:s}=await Y.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:e,isAgentVideo:!0}});if(s)throw s;return t}async function jne(e){const{data:t,error:s}=await Y.functions.invoke("bunny-upload",{body:{action:"status",videoId:e,isAgentVideo:!0}});if(s)throw s;return t}function e6t(){const{user:e}=Gr(),t=Rr();return Qt({mutationFn:async({contactId:s,videoId:n,notes:a})=>{if(!(e!=null&&e.id))throw new Error("Not authenticated");const{data:o}=await Y.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 Y.from("contact_touch_logs").insert([{owner_user_id:e.id,contact_id:s,action_type_id:o.id,notes:a||`Quick Video Touch - Video ID: ${n}`}]).select().single();if(i)throw i;return l},onSuccess:()=>{t.invalidateQueries({queryKey:["contact-touch-logs"]}),t.invalidateQueries({queryKey:["contacts"]})}})}function t6t(e){return Ht({queryKey:["contact-video-replies",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("video_replies").select(` *, video:agent_videos(id, title, thumbnail_url, playback_url) `).eq("contact_id",e).order("created_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function r6t({videoId:e}){var l;const{data:t,isLoading:s,error:n}=XPt(e);if(s)return r.jsxs("div",{className:"space-y-4",children:[r.jsx(pr,{className:"w-full aspect-video rounded-lg"}),r.jsx(pr,{className:"h-4 w-1/3"})]});if(n||!t||t.is_deleted)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[r.jsx(ch,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"font-medium",children:"Video Unavailable"}),r.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=t.playback_url)==null?void 0:l.includes("iframe.mediadelivery.net");return r.jsxs("div",{className:"space-y-4",children:[t.playback_url?r.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:o?r.jsx("iframe",{src:a(t.playback_url),title:t.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}):r.jsx("video",{src:t.playback_url,controls:!0,autoPlay:!0,className:"absolute top-0 left-0 w-full h-full object-contain"})}):r.jsx("div",{className:"w-full aspect-video bg-muted rounded-lg flex items-center justify-center",children:r.jsx("p",{className:"text-muted-foreground",children:"Video is still processing..."})}),t.title&&r.jsxs("div",{children:[r.jsx("h4",{className:"font-medium",children:t.title}),t.notes&&r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.notes})]})]})}function s6t({contactId:e}){const t=Ks(),{data:s,isLoading:n}=Ht({queryKey:["contact-linked-deals",e],queryFn:async()=>{const{data:a,error:o}=await Y.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",e).order("updated_at",{ascending:!1});if(o)throw o;return a},enabled:!!e});return n||!s||s.length===0?null:r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx(Pu,{className:"h-4 w-4"}),"Linked Deals"]})}),r.jsx(qe,{className:"space-y-2",children:s.map(a=>{const o=a.stage;return r.jsx("button",{onClick:()=>t(`/mission-control/pipeline?deal=${a.id}`),className:"w-full text-left p-3 rounded-lg border hover:bg-accent transition-colors group",children:r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:a.deal_name}),a.property_address&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.property_address}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx(_t,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&r.jsxs(_t,{variant:"outline",className:"text-[10px] gap-1",style:{borderColor:o.color,color:o.color,backgroundColor:`${o.color}10`},children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:o.color}}),o.name]})]})]}),r.jsx(Ki,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function n6t(){var st,ue;const{contactId:e}=Bl(),t=Ks(),[s]=Cc(),n=s.get("search")||"",a=s.get("type")||"all",o=s.get("status")||"all",{data:l,isLoading:i}=_bt(e||""),{data:d}=gg(),{data:m}=h1e(),{data:p}=$ie(365),{data:g}=voe(365),{data:v}=t6t(e),{contactsWithScores:_}=p1e(),k=s9e(),w=u1e(),S=a9e(),[T,C]=A.useState(!1),[I,R]=A.useState({}),[D,B]=A.useState(!1),[$,q]=A.useState(null),[W,K]=A.useState(""),[re,ae]=A.useState(null),[oe,se]=A.useState(!1),[pe,ie]=A.useState(null),{isGmailConnected:de,gmailEmail:ce}=kN(),{data:ge}=Ht({queryKey:["gmail-sent-emails",e],queryFn:async()=>{const{data:$e,error:tt}=await Y.from("gmail_sent_emails").select("*").eq("contact_id",e).order("sent_at",{ascending:!1});if(tt)throw tt;return $e},enabled:!!e}),Te=$e=>{if(!$e)return null;const tt=$e.match(/Video ID:\s*([a-f0-9-]+)/i);return tt?tt[1]:null},_e=A.useMemo(()=>{if(!_)return[];let $e=_.filter(tt=>{var it,Se,et;const rt=n===""||`${tt.first_name} ${tt.last_name}`.toLowerCase().includes(n.toLowerCase())||((it=tt.email)==null?void 0:it.toLowerCase().includes(n.toLowerCase()))||((Se=tt.phone)==null?void 0:Se.includes(n)),je=a==="all"||((et=tt.tags)==null?void 0:et.some(Qe=>Qe.relationship_type_id===a));return rt&&je});return o==="not-touched-90"?$e=$e.filter(tt=>{const rt=tt.relationshipScore.daysSinceTouch;return rt===null||rt>90}):o==="at-risk"?$e=$e.filter(tt=>tt.relationshipScore.status==="at-risk"):o==="cooling"?$e=$e.filter(tt=>tt.relationshipScore.status==="cooling"):o==="warm"&&($e=$e.filter(tt=>tt.relationshipScore.status==="warm")),$e.map(tt=>tt.id)},[_,n,a,o]),ve=_e.indexOf(e||""),Me=ve>0?_e[ve-1]:null,Ze=ve<_e.length-1?_e[ve+1]:null,Ae=_e.length>1&&ve!==-1,Le=$e=>{const tt=new URLSearchParams;n&&tt.set("search",n),a!=="all"&&tt.set("type",a),o!=="all"&&tt.set("status",o);const rt=tt.toString();return`/mission-control/contacts/${$e}${rt?`?${rt}`:""}`},Ue=A.useMemo(()=>{const $e=((p==null?void 0:p.filter(rt=>rt.contact_id===e))||[]).map(rt=>{var it,Se;const je=Te(rt.notes);return{id:rt.id,type:"touch",completed_at:rt.completed_at,name:((it=rt.action_type)==null?void 0:it.name)||"Touch",color:((Se=rt.action_type)==null?void 0:Se.color)||"#3B82F6",notes:rt.notes,videoId:je}}),tt=((g==null?void 0:g.filter(rt=>rt.contact_id===e))||[]).map(rt=>({id:rt.id,type:"popby",completed_at:rt.completed_at,name:"Pop-by",color:"#F97316",notes:rt.notes,videoId:null}));return[...$e,...tt].sort((rt,je)=>new Date(je.completed_at).getTime()-new Date(rt.completed_at).getTime())},[p,g,e]),Ve=()=>{var $e;l&&(R({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:(($e=l.tags)==null?void 0:$e.map(tt=>tt.relationship_type_id))||[]}),C(!0))},Ie=async()=>{await k.mutateAsync({id:e,...I}),C(!1)},We=async()=>{confirm("Are you sure you want to delete this contact?")&&(await w.mutateAsync(e),t("/mission-control/contacts"))},wt=async()=>{$&&(await S.mutateAsync({contactId:e,actionTypeId:$,notes:W}),B(!1),q(null),K(""))},Pe=($e,tt)=>{de&&l?(ie({email:$e,name:tt||`${l.first_name} ${l.last_name||""}`.trim()}),se(!0)):window.location.href=`mailto:${$e}`};return i?r.jsx(Ur,{title:"Contact Details",children:r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):l?r.jsxs(r.Fragment,{children:[r.jsx(Ur,{title:`${l.first_name} ${l.last_name||""}`,description:"Contact details and activity",children:r.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>t("/mission-control/contacts"),children:[r.jsx(jc,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),Ae&&r.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>Me&&t(Le(Me)),disabled:!Me,className:"px-2",children:[r.jsx(jc,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only sm:not-sr-only sm:ml-1",children:"Prev"})]}),r.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[ve+1," of ",_e.length]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>Ze&&t(Le(Ze)),disabled:!Ze,className:"px-2",children:[r.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),r.jsx(Zi,{className:"h-4 w-4"})]})]})]}),r.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end flex-wrap",children:[l.email&&r.jsxs(X,{variant:"outline",onClick:()=>Pe(l.email,`${l.first_name} ${l.last_name||""}`.trim()),children:[r.jsx(Vs,{className:"h-4 w-4 mr-1"}),"Email"]}),r.jsxs(X,{variant:"default",onClick:()=>t(`/mission-control/video/record?contact_id=${e}`),className:"bg-gradient-to-r from-primary to-primary/80",children:[r.jsx(ma,{className:"h-4 w-4 mr-1"}),"Quick Video Touch"]}),r.jsxs(Ir,{open:D,onOpenChange:B,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",children:[r.jsx(gs,{className:"h-4 w-4 mr-1"}),"Log Action"]})}),r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Log an Action"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Action Type"}),r.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:m==null?void 0:m.filter($e=>$e.active).map($e=>r.jsxs("button",{onClick:()=>q($e.id),className:` p-3 rounded-lg border text-left transition-all ${$===$e.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[r.jsx("div",{className:"font-medium",children:$e.name}),r.jsx("div",{className:"text-xs text-muted-foreground",children:$e.description})]},$e.id))})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"action-notes",children:"Notes (optional)"}),r.jsx(qs,{id:"action-notes",value:W,onChange:$e=>K($e.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),r.jsxs(X,{onClick:wt,disabled:!$||S.isPending,className:"w-full",children:[r.jsx(mi,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),r.jsxs(X,{variant:"outline",onClick:Ve,children:[r.jsx(Lc,{className:"h-4 w-4 mr-1"}),"Edit"]}),r.jsx(X,{variant:"destructive",size:"icon",onClick:We,children:r.jsx(Os,{className:"h-4 w-4"})})]})]}),r.jsx("div",{className:"bg-card border rounded-lg p-4 sm:p-6",children:r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-4",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold",children:[l.first_name," ",l.last_name||""]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-2 text-muted-foreground",children:[l.email&&r.jsxs("button",{onClick:()=>Pe(l.email),className:"flex items-center gap-1 hover:text-primary transition-colors",children:[r.jsx(Vs,{className:"h-4 w-4"}),r.jsx("span",{className:"text-sm",children:l.email})]}),l.phone&&r.jsxs("a",{href:`tel:${l.phone}`,className:"flex items-center gap-1 hover:text-primary transition-colors",children:[r.jsx(fi,{className:"h-4 w-4"}),r.jsx("span",{className:"text-sm",children:l.phone})]})]})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx(Nge,{contact:l}),(st=l.tags)==null?void 0:st.map($e=>{const tt=d==null?void 0:d.find(rt=>rt.id===$e.relationship_type_id);return tt?r.jsx(_t,{variant:"secondary",className:"text-xs",children:tt.name},$e.id):null})]})]})}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[r.jsxs(ze,{className:"md:col-span-2",children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Contact Information"})}),r.jsx(qe,{children:T?r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"first_name",children:"First Name"}),r.jsx(Ye,{id:"first_name",value:I.first_name,onChange:$e=>R({...I,first_name:$e.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"last_name",children:"Last Name"}),r.jsx(Ye,{id:"last_name",value:I.last_name,onChange:$e=>R({...I,last_name:$e.target.value})})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"email",children:"Email"}),r.jsx(Ye,{id:"email",type:"email",value:I.email,onChange:$e=>R({...I,email:$e.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"phone",children:"Phone"}),r.jsx(Ye,{id:"phone",value:I.phone,onChange:$e=>R({...I,phone:$e.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"address",children:"Street Address"}),r.jsx(Ye,{id:"address",value:I.address,onChange:$e=>R({...I,address:$e.target.value}),placeholder:"123 Main St"})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"col-span-2",children:[r.jsx(Ee,{htmlFor:"city",children:"City"}),r.jsx(Ye,{id:"city",value:I.city,onChange:$e=>R({...I,city:$e.target.value}),placeholder:"City"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"state",children:"State"}),r.jsx(Ye,{id:"state",value:I.state,onChange:$e=>R({...I,state:$e.target.value}),placeholder:"TX",maxLength:2})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"zip_code",children:"Zip Code"}),r.jsx(Ye,{id:"zip_code",value:I.zip_code,onChange:$e=>R({...I,zip_code:$e.target.value}),placeholder:"12345"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"birthday",children:"Birthday"}),r.jsx(Ye,{id:"birthday",type:"date",value:I.birthday,onChange:$e=>R({...I,birthday:$e.target.value})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"home_anniversary",children:"Home Anniversary"}),r.jsx(Ye,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:$e=>R({...I,home_anniversary:$e.target.value})})]})]}),r.jsx(kd,{}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"spouse_name",children:"Spouse/Partner Name"}),r.jsx(Ye,{id:"spouse_name",value:I.spouse_name,onChange:$e=>R({...I,spouse_name:$e.target.value}),placeholder:"Enter spouse name"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"spouse_email",children:"Spouse/Partner Email"}),r.jsx(Ye,{id:"spouse_email",type:"email",value:I.spouse_email,onChange:$e=>R({...I,spouse_email:$e.target.value}),placeholder:"Enter spouse email"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"company_name",children:"Company"}),r.jsx(Ye,{id:"company_name",value:I.company_name,onChange:$e=>R({...I,company_name:$e.target.value}),placeholder:"Enter company name"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"job_title",children:"Job Title"}),r.jsx(Ye,{id:"job_title",value:I.job_title,onChange:$e=>R({...I,job_title:$e.target.value}),placeholder:"Enter job title"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Relationship Types"}),r.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:d==null?void 0:d.filter($e=>$e.active).map($e=>{var tt;return r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx(Qo,{checked:(tt=I.tagIds)==null?void 0:tt.includes($e.id),onCheckedChange:rt=>{var je;R(rt?{...I,tagIds:[...I.tagIds||[],$e.id]}:{...I,tagIds:(je=I.tagIds)==null?void 0:je.filter(it=>it!==$e.id)})}}),r.jsx("span",{className:"text-sm",children:$e.name})]},$e.id)})})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"notes",children:"Notes"}),r.jsx(qs,{id:"notes",value:I.notes,onChange:$e=>R({...I,notes:$e.target.value}),rows:4})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{onClick:Ie,disabled:k.isPending,children:"Save Changes"}),r.jsx(X,{variant:"outline",onClick:()=>C(!1),children:"Cancel"})]})]}):r.jsxs("div",{className:"space-y-4",children:[Ue.length>0&&r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4 text-primary"}),r.jsxs("span",{className:"text-sm",children:[r.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",Xr(new Date(Ue[0].completed_at),"MMM d, yyyy")," ","(",Ue[0].name,")"]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:gap-6 gap-2",children:[l.email&&r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(Vs,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),r.jsx("button",{onClick:()=>Pe(l.email),className:"text-primary hover:underline truncate text-left",children:l.email})]}),l.phone&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fi,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),r.jsx("a",{href:`tel:${l.phone}`,className:"text-primary hover:underline",children:l.phone})]})]}),(l.address||l.city||l.state||l.zip_code)&&r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Yi,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),r.jsxs("div",{className:"flex flex-col",children:[l.address&&r.jsx("span",{children:l.address}),(l.city||l.state||l.zip_code)&&r.jsxs("span",{className:"text-muted-foreground",children:[[l.city,l.state].filter(Boolean).join(", "),l.zip_code&&` ${l.zip_code}`]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[l.birthday&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{children:["Birthday: ",Xr(new Date(l.birthday),"MMMM d")]})]}),l.home_anniversary&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Vn,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{children:["Home Anniversary: ",Xr(new Date(l.home_anniversary),"MMMM d")]})]})]}),(l.spouse_name||l.spouse_email||l.company_name||l.job_title)&&r.jsxs(r.Fragment,{children:[r.jsx(kd,{}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(l.spouse_name||l.spouse_email)&&r.jsxs("div",{className:"space-y-1",children:[l.spouse_name&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{children:["Spouse: ",l.spouse_name]})]}),l.spouse_email&&r.jsxs("div",{className:"flex items-center gap-2 ml-6",children:[r.jsx(Vs,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("button",{onClick:()=>Pe(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)&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ni,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{children:l.job_title&&l.company_name?`${l.job_title} at ${l.company_name}`:l.job_title||l.company_name})]})]})]}),r.jsx(kd,{}),r.jsxs("div",{children:[r.jsx("h4",{className:"font-medium mb-2",children:"Relationship Types"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:(ue=l.tags)!=null&&ue.length?l.tags.map($e=>{var tt;return r.jsx(_t,{variant:"secondary",children:(tt=$e.relationship_type)==null?void 0:tt.name},$e.id)}):r.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&r.jsxs(r.Fragment,{children:[r.jsx(kd,{}),r.jsxs("div",{children:[r.jsx("h4",{className:"font-medium mb-2",children:"Notes"}),r.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:l.notes})]})]})]})})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsx(EPt,{contact:l,onLogTouch:()=>B(!0)}),r.jsx(s6t,{contactId:e}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Activity Log"})}),r.jsx(qe,{children:Ue.length>0?r.jsx("div",{className:"space-y-4",children:Ue.map($e=>{var tt;return r.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[r.jsx("div",{className:"h-8 w-8 rounded-full flex items-center justify-center text-white text-xs",style:{backgroundColor:$e.color},children:$e.type==="popby"?r.jsx(po,{className:"h-4 w-4"}):(tt=$e.name)==null?void 0:tt.charAt(0)}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-medium text-sm",children:$e.name}),$e.videoId&&r.jsxs(X,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ae($e.videoId),children:[r.jsx(tc,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),r.jsx("div",{className:"text-xs text-muted-foreground",children:Xr(new Date($e.completed_at),"MMM d, yyyy h:mm a")}),$e.notes&&!$e.videoId&&r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:$e.notes})]})]},$e.id)})}):r.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"})})]}),v&&v.length>0&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Vo,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),r.jsx(qe,{children:r.jsx("div",{className:"space-y-4",children:v.map($e=>{var tt,rt;return r.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(tt=$e.video)!=null&&tt.thumbnail_url?r.jsx("img",{src:$e.video.thumbnail_url,alt:$e.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>ae($e.video_id)}):r.jsx("div",{className:"h-12 w-16 bg-muted rounded flex items-center justify-center cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>ae($e.video_id),children:r.jsx(ma,{className:"h-5 w-5 text-muted-foreground"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"font-medium text-sm truncate",children:["Replied to: ",((rt=$e.video)==null?void 0:rt.title)||"Untitled Video"]}),r.jsxs(X,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>ae($e.video_id),children:[r.jsx(tc,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),r.jsx("div",{className:"text-xs text-muted-foreground",children:Xr(new Date($e.created_at),"MMM d, yyyy h:mm a")}),$e.message&&r.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',$e.message,'"']})]})]},$e.id)})})})]}),ge&&ge.length>0&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ai,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),r.jsx(qe,{children:r.jsx("div",{className:"space-y-4",children:ge.map($e=>r.jsxs("details",{className:"group pb-3 border-b last:border-0",children:[r.jsxs("summary",{className:"flex items-start gap-3 cursor-pointer list-none",children:[r.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:r.jsx(Vs,{className:"h-4 w-4"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:$e.subject}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",$e.to_email," · ",Xr(new Date($e.sent_at),"MMM d, yyyy h:mm a")]})]})]}),r.jsx("div",{className:"mt-2 ml-11 p-3 bg-muted/30 rounded-lg text-sm whitespace-pre-wrap",children:$e.body})]},$e.id))})})]})]}),r.jsx(Ir,{open:!!re,onOpenChange:$e=>!$e&&ae(null),children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Video Preview"})}),re&&r.jsx(r6t,{videoId:re})]})})]})]})}),de&&l&&pe&&r.jsx(yoe,{open:oe,onOpenChange:se,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:pe.email},gmailEmail:ce})]}):r.jsx(Ur,{title:"Contact Not Found",children:r.jsxs("div",{className:"text-center py-12",children:[r.jsx("p",{className:"text-muted-foreground mb-4",children:"This contact was not found."}),r.jsx(X,{onClick:()=>t("/mission-control/contacts"),children:"Back to Contacts"})]})})}const AMe={Crown:_h,FileText:ya,Users:ws,Globe:ux,Star:Dn,Phone:fi,MessageSquare:Vo,PenTool:Nk,Video:ma,Gift:po},Nhe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function a6t(){var ot,ut;const e=Ks(),{user:t}=Gr(),{data:s}=gg(),{data:n}=wbt(),{data:a}=Tbt(),{data:o}=r9e(),{data:l}=h1e(),{data:i}=bbt(),d=Abt(),m=jbt(),p=Nbt(),g=Sbt(),v=Cbt(),_=Mbt(),k=kbt(),[w,S]=A.useState(null),[T,C]=A.useState(!1),[I,R]=A.useState(null),[D,B]=A.useState(""),[$,q]=A.useState(""),[W,K]=A.useState([]),[re,ae]=A.useState(null),[oe,se]=A.useState(null),[pe,ie]=A.useState(!1),[de,ce]=A.useState(""),[ge,Te]=A.useState(""),[_e,ve]=A.useState(""),[Me,Ze]=A.useState(""),Ae=(ft,ct)=>a==null?void 0:a.some(Tt=>Tt.plan_id===ft&&Tt.relationship_type_id===ct&&Tt.active),Le=ft=>a==null?void 0:a.find(ct=>ct.relationship_type_id===ft&&ct.active),Ue=async(ft,ct)=>{const Tt=Ae(ft,ct);await d.mutateAsync({planId:ft,relationshipTypeId:ct,active:!Tt})},Ve=(n==null?void 0:n.filter(ft=>ft.active&&!ft.owner_user_id))||[],Ie=(n==null?void 0:n.filter(ft=>ft.owner_user_id===(t==null?void 0:t.id)))||[],We=s==null?void 0:s.find(ft=>ft.id===w),wt=w?Le(w):null,Pe=n==null?void 0:n.find(ft=>ft.id===(wt==null?void 0:wt.plan_id)),st=async()=>{if(!D.trim())return;const ft=await m.mutateAsync({name:D,description:$});ft&&W.length>0&&await v.mutateAsync({planId:ft.id,items:W}),tt()},ue=async()=>{!D.trim()||!I||(await p.mutateAsync({id:I,name:D,description:$}),await v.mutateAsync({planId:I,items:W}),tt())},$e=ft=>{var ct;R(ft.id),B(ft.name),q(ft.description||""),K(((ct=ft.items)==null?void 0:ct.map(Tt=>({month_number:Tt.month_number,action_type_id:Tt.action_type_id,default_script_id:Tt.default_script_id||void 0,notes:Tt.notes||void 0})))||[]),C(!0)},tt=()=>{C(!1),R(null),B(""),q(""),K([])},rt=(ft,ct)=>{se(ct)},je=(ft,ct,Tt)=>{K(Ot=>[...Ot.filter(Lr=>Lr.month_number!==ft),{month_number:ft,action_type_id:ct,default_script_id:Tt}]),ae(null),se(null)},it=ft=>{K(ct=>ct.filter(Tt=>Tt.month_number!==ft))},Se=async()=>{if(!de.trim()||!ge.trim()||!oe)return;const ft=await _.mutateAsync({actionTypeId:oe,title:de,scriptBody:ge,emailSubject:_e||void 0,tone:Me||void 0});ft&&re!==null&&je(re,oe,ft.id),ie(!1),ce(""),Te(""),ve(""),Ze("")},et=oe?i==null?void 0:i.filter(ft=>ft.action_type_id===oe&&ft.active):[],Qe=ft=>AMe[ft||"Phone"]||fi,He=ft=>AMe[ft||"Users"]||ws;return r.jsxs(Ur,{title:"Touchpoint Plans",description:"Assign plans to your contact groups",children:[r.jsxs("div",{className:"space-y-6 overflow-x-hidden",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Touchpoint Plans"}),r.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"})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>e("/mission-control"),children:[r.jsx(jc,{className:"h-4 w-4 mr-1"}),"Back"]}),r.jsxs(X,{onClick:()=>C(!0),className:"w-full sm:w-auto",children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create Custom Plan"]})]}),r.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx("h3",{className:"font-semibold text-lg",children:"Your Contact Groups"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Select a group to assign a touchpoint plan"}),s==null?void 0:s.filter(ft=>ft.active).map(ft=>{const ct=He(ft.icon),Tt=(o==null?void 0:o[ft.id])||0,Ot=Le(ft.id),rr=n==null?void 0:n.find(cr=>cr.id===(Ot==null?void 0:Ot.plan_id)),Lr=w===ft.id;return r.jsxs("button",{onClick:()=>S(ft.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Lr?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[r.jsx(ct,{className:"h-5 w-5 text-muted-foreground"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"font-medium",children:ft.name}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[Tt," contacts"]})]}),rr?r.jsxs(_t,{variant:"secondary",className:"text-xs",children:[r.jsx(ui,{className:"h-3 w-3 mr-1"}),rr.name.split(" ")[0]]}):r.jsx(_t,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},ft.id)})]}),r.jsx("div",{className:"lg:col-span-2",children:w&&We?r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[(()=>{const ft=He(We.icon);return r.jsx(ft,{className:"h-5 w-5"})})(),We.name," Touchpoint Plan"]}),r.jsxs(Cs,{children:["Choose a plan for your ",We.name," contacts"]})]}),r.jsxs(qe,{className:"space-y-6",children:[Pe&&r.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"font-medium flex items-center gap-2",children:[r.jsx(ui,{className:"h-4 w-4 text-green-500"}),"Currently using: ",Pe.name]}),Pe.description&&r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:Pe.description})]}),r.jsx(X,{variant:"outline",size:"sm",onClick:()=>Ue(Pe.id,w),children:"Disable"})]}),Pe.items&&Pe.items.length>0&&r.jsxs("div",{className:"mt-4",children:[r.jsxs("div",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4"}),"12-Month Schedule"]}),r.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:Nhe.map((ft,ct)=>{var Lr,cr;const Tt=((Lr=Pe.items)==null?void 0:Lr.filter(Mr=>Mr.month_number===ct+1))||[],Ot=(cr=Tt[0])==null?void 0:cr.action_type,rr=Ot?Qe(Ot.icon):null;return r.jsxs("div",{className:` p-2 rounded border text-center ${Tt.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[r.jsx("div",{className:"text-xs text-muted-foreground",children:ft}),rr&&r.jsx(rr,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Ot==null?void 0:Ot.color)||"#3B82F6"}})]},ct)})})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"font-medium mb-3",children:Pe?"Switch to a Different Plan":"Choose a Plan"}),Ve.length>0&&r.jsxs("div",{className:"space-y-2 mb-4",children:[r.jsx("div",{className:"text-sm text-muted-foreground",children:"Pre-built Templates"}),Ve.map(ft=>{var Tt;const ct=(Pe==null?void 0:Pe.id)===ft.id;return r.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${ct?"opacity-50":"hover:bg-accent"} `,children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:ft.name}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Tt=ft.items)==null?void 0:Tt.length)||0," touchpoints/year"]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{size:"sm",variant:"ghost",title:"Duplicate as my own plan",disabled:k.isPending,onClick:()=>{const Ot=`${ft.name} (Copy)`;k.mutate({sourcePlanId:ft.id,newName:Ot})},children:r.jsx(uo,{className:"h-4 w-4"})}),r.jsx(X,{size:"sm",variant:ct?"outline":"default",disabled:ct||d.isPending,onClick:()=>Ue(ft.id,w),children:ct?"Active":"Use This"})]})]},ft.id)})]}),Ie.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Ie.map(ft=>{var Tt;const ct=(Pe==null?void 0:Pe.id)===ft.id;return r.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${ct?"opacity-50":"hover:bg-accent"} `,children:[r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:ft.name}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[((Tt=ft.items)==null?void 0:Tt.length)||0," touchpoints/year"]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>$e(ft),children:r.jsx(kv,{className:"h-4 w-4"})}),r.jsx(X,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>g.mutate(ft.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})}),r.jsx(X,{size:"sm",variant:ct?"outline":"default",disabled:ct||d.isPending,onClick:()=>Ue(ft.id,w),children:ct?"Active":"Use This"})]})]},ft.id)})]}),Ve.length===0&&Ie.length===0&&r.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No plans available. Create a custom plan to get started."})]})]})]}):r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center text-muted-foreground",children:[r.jsx(An,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"Select a contact group to view and assign plans"})]})})})]}),r.jsx(ze,{className:"bg-muted/50",children:r.jsx(qe,{className:"py-4",children:r.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.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."]})})})]}),r.jsx(Ir,{open:T,onOpenChange:ft=>{ft?C(!0):tt()},children:r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:I?"Edit Touchpoint Plan":"Create Custom Touchpoint Plan"})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"plan-name",children:"Plan Name"}),r.jsx(Ye,{id:"plan-name",value:D,onChange:ft=>B(ft.target.value),placeholder:"e.g., My VIP Plan"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"plan-description",children:"Description (optional)"}),r.jsx(qs,{id:"plan-description",value:$,onChange:ft=>q(ft.target.value),placeholder:"Describe your plan...",rows:2})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"12-Month Schedule"}),r.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Click on a month to add a touchpoint"}),r.jsx("div",{className:"grid grid-cols-6 gap-2",children:Nhe.map((ft,ct)=>{const Tt=ct+1,Ot=W.find(cr=>cr.month_number===Tt),rr=Ot?l==null?void 0:l.find(cr=>cr.id===Ot.action_type_id):null,Lr=rr?Qe(rr.icon):null;return r.jsxs("div",{className:"relative",children:[r.jsxs("button",{type:"button",onClick:()=>ae(re===Tt?null:Tt),className:` w-full p-3 rounded-lg border text-center transition-all ${Ot?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${re===Tt?"ring-2 ring-primary":""} `,children:[r.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:ft}),Lr?r.jsx(Lr,{className:"h-5 w-5 mx-auto mt-1",style:{color:(rr==null?void 0:rr.color)||"#3B82F6"}}):r.jsx(gs,{className:"h-5 w-5 mx-auto mt-1 text-muted-foreground/50"})]}),Ot&&r.jsx("button",{type:"button",onClick:cr=>{cr.stopPropagation(),it(Tt)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:r.jsx(Xs,{className:"h-3 w-3"})})]},ct)})}),re!==null&&!oe&&r.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[r.jsxs("div",{className:"text-sm font-medium mb-2",children:["Step 1: Select action for ",Nhe[re-1],":"]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(ft=>ft.active).map(ft=>{const ct=Qe(ft.icon);return r.jsxs("button",{type:"button",onClick:()=>rt(re,ft.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[r.jsx(ct,{className:"h-4 w-4",style:{color:ft.color||"#3B82F6"}}),r.jsx("span",{className:"text-sm",children:ft.name})]},ft.id)})})]}),re!==null&&oe&&r.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"text-sm font-medium",children:"Step 2: Select a script (optional)"}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>se(null),children:[r.jsx(jc,{className:"h-4 w-4 mr-1"})," Back"]})]}),r.jsxs("div",{className:"space-y-2 max-h-[300px] overflow-y-auto pr-1",children:[r.jsx("button",{type:"button",onClick:()=>je(re,oe),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"font-medium text-sm",children:"No Script"}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Use without a predefined script"})]})}),et==null?void 0:et.map(ft=>r.jsx("button",{type:"button",onClick:()=>je(re,oe,ft.id),className:"w-full flex items-center gap-3 p-3 rounded-lg border bg-background hover:bg-accent transition-colors text-left",children:r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"font-medium text-sm",children:ft.title}),ft.tone&&r.jsx(_t,{variant:"secondary",className:"text-xs mt-1",children:ft.tone}),r.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[ft.script_body.substring(0,100),"..."]})]})},ft.id)),r.jsxs("button",{type:"button",onClick:()=>ie(!0),className:"w-full flex items-center gap-3 p-3 rounded-lg border border-dashed bg-background hover:bg-accent transition-colors text-left",children:[r.jsx(gs,{className:"h-5 w-5 text-muted-foreground"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"font-medium text-sm",children:"Create Custom Script"}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Write your own script for this action"})]})]})]})]})]}),W.length>0&&r.jsxs("div",{className:"text-sm text-muted-foreground",children:[W.length," touchpoint",W.length!==1?"s":""," per year"]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:tt,children:"Cancel"}),r.jsxs(X,{onClick:I?ue:st,disabled:!D.trim()||m.isPending||p.isPending,children:[r.jsx(zf,{className:"h-4 w-4 mr-2"}),I?"Save Changes":"Create Plan"]})]})]})}),r.jsx(Ir,{open:pe,onOpenChange:ie,children:r.jsxs(Er,{className:"max-w-lg",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Create Custom Script"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script-title",children:"Script Title"}),r.jsx(Ye,{id:"script-title",value:de,onChange:ft=>ce(ft.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script-tone",children:"Tone (optional)"}),r.jsxs(ds,{value:Me,onValueChange:Ze,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select tone..."})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"friendly",children:"Friendly"}),r.jsx(Ut,{value:"professional",children:"Professional"}),r.jsx(Ut,{value:"casual",children:"Casual"}),r.jsx(Ut,{value:"formal",children:"Formal"})]})]})]}),((ut=(ot=l==null?void 0:l.find(ft=>ft.id===oe))==null?void 0:ot.name)==null?void 0:ut.toLowerCase().includes("email"))&&r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script-email-subject",children:"Email Subject"}),r.jsx(Ye,{id:"script-email-subject",value:_e,onChange:ft=>ve(ft.target.value),placeholder:"e.g., Quick Hello!"})]}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"script-body",children:"Script Content"}),r.jsx(qs,{id:"script-body",value:ge,onChange:ft=>Te(ft.target.value),placeholder:"Write your script here... You can use {{FirstName}} and {{LastName}} as placeholders.",rows:6}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Tip: Use ","{{FirstName}}"," and ","{{LastName}}"," as placeholders"]})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>ie(!1),children:"Cancel"}),r.jsxs(X,{onClick:Se,disabled:!de.trim()||!ge.trim()||_.isPending,children:[r.jsx(zf,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const i6t="0dde5abb-0005-4c8c-a471-30d0cbc9e280",o6t=[{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 l6t(){const e=Ks(),t=aHe(),{data:s}=rHe(),{data:n}=gg(),{data:a}=T_e(),{data:o}=voe(90),{data:l}=Xf(),i=TPt(),d=iHe(),m=CPt(),p=MPt(),{data:g=[],isLoading:v}=Ht({queryKey:["popby-templates"],queryFn:async()=>{const{data:pe,error:ie}=await Y.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("category_id",i6t).order("publish_date",{ascending:!1});if(ie)throw ie;const{data:de}=await Y.from("template_likes").select("template_id"),{data:ce}=await Y.from("template_comments").select("template_id"),ge=new Map;de==null||de.forEach(_e=>{ge.set(_e.template_id,(ge.get(_e.template_id)||0)+1)});const Te=new Map;return ce==null||ce.forEach(_e=>{Te.set(_e.template_id,(Te.get(_e.template_id)||0)+1)}),(pe||[]).map(_e=>({..._e,likesCount:ge.get(_e.id)||0,commentsCount:Te.get(_e.id)||0}))}}),_=pe=>{const ie=l==null?void 0:l.find(de=>de.id===pe);return ie?`${ie.first_name} ${ie.last_name||""}`.trim():"Unknown"},k=pe=>{if(!pe)return null;const ie=s==null?void 0:s.find(de=>de.id===pe);return(ie==null?void 0:ie.name)||null},[w,S]=A.useState(null),[T,C]=A.useState(!1),[I,R]=A.useState(!1),[D,B]=A.useState(!1),[$,q]=A.useState({popby_item_id:"",notes:""}),[W,K]=A.useState({name:"",description:""}),re=async()=>{w&&(await d.mutateAsync({contact_id:w.id,popby_item_id:$.popby_item_id||void 0,notes:$.notes||void 0}),C(!1),S(null),q({popby_item_id:"",notes:""}))},ae=async()=>{W.name.trim()&&(await m.mutateAsync({name:W.name.trim(),description:W.description.trim()||void 0}),B(!1),K({name:"",description:""}))},oe=async(pe,ie)=>{await p.mutateAsync({relationship_type_id:pe,frequency_days:parseInt(ie)})},se=pe=>{var de;const ie=a==null?void 0:a.find(ce=>ce.relationship_type_id===pe);return((de=ie==null?void 0:ie.frequency_days)==null?void 0:de.toString())||"90"};return r.jsx(Ur,{title:"Popbys",description:"Drop off gifts to stay top of mind",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Popbys"}),r.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"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-primary",children:i.thisWeekCount}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"This Week"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-emerald-500",children:i.thisMonthCount}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"This Month"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-3xl font-bold text-amber-500",children:i.dueCount}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"Due Now"})]})})]}),r.jsxs("div",{className:"flex gap-2 flex-wrap",children:[r.jsxs(X,{onClick:()=>e("/mission-control/popbys/map"),children:[r.jsx(Yi,{className:"h-4 w-4 mr-2"}),"View Map"]}),r.jsxs(X,{variant:"outline",onClick:()=>R(!0),children:[r.jsx(ld,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),r.jsxs(X,{variant:"outline",onClick:()=>B(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),r.jsxs(ii,{defaultValue:"due",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"due",children:"Due for Popby"}),r.jsx(Kr,{value:"activity",children:"Recent Activity"}),r.jsx(Kr,{value:"library",children:"Popby Library"}),r.jsx(Kr,{value:"templates",children:"Popby Templates"})]}),r.jsx(hs,{value:"due",className:"space-y-4 mt-4",children:!t||t.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"p-8 text-center text-muted-foreground",children:[r.jsx(po,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No contacts due for a popby right now!"}),r.jsx("p",{className:"text-sm mt-1",children:"Great job staying connected."})]})}):r.jsx("div",{className:"space-y-3",children:t.map(pe=>r.jsx(ze,{className:"hover:shadow-md transition-shadow",children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"font-medium",children:[pe.first_name," ",pe.last_name]}),pe.daysOverdue>0&&r.jsxs(_t,{variant:"destructive",className:"text-xs",children:[pe.daysOverdue,"+ days overdue"]}),pe.daysSinceLastPopby===null&&r.jsx(_t,{variant:"outline",className:"text-xs",children:"Never visited"})]}),r.jsxs("div",{className:"flex items-center gap-4 mt-1 text-sm text-muted-foreground",children:[pe.address&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Yi,{className:"h-3 w-3"}),pe.city||pe.address]}),pe.tags&&pe.tags.length>0&&r.jsx("span",{children:pe.tags.map(ie=>{var de;return(de=ie.relationship_type)==null?void 0:de.name}).join(", ")})]}),pe.lastPopby&&r.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Last popby: ",Xr(new Date(pe.lastPopby),"MMM d, yyyy")]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[pe.phone&&r.jsx(X,{size:"sm",variant:"ghost",asChild:!0,children:r.jsx("a",{href:`tel:${pe.phone}`,children:r.jsx(fi,{className:"h-4 w-4"})})}),r.jsxs(X,{size:"sm",onClick:()=>{S(pe),C(!0)},children:[r.jsx(ui,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},pe.id))})}),r.jsx(hs,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"p-8 text-center text-muted-foreground",children:[r.jsx(Pa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No popby activity yet!"}),r.jsx("p",{className:"text-sm mt-1",children:"Start logging popbys to see your history here."})]})}):r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Recent Popby Log"})}),r.jsx(qe,{className:"space-y-3",children:o.map(pe=>r.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0 last:pb-0",children:[r.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/10 flex items-center justify-center",children:r.jsx(po,{className:"h-5 w-5 text-orange-500"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"font-medium",children:_(pe.contact_id)}),k(pe.popby_item_id)&&r.jsx(_t,{variant:"secondary",className:"text-xs",children:k(pe.popby_item_id)})]}),r.jsx("div",{className:"text-sm text-muted-foreground",children:Xr(new Date(pe.completed_at),"MMM d, yyyy h:mm a")}),pe.notes&&r.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:pe.notes})]})]},pe.id))})]})}),r.jsx(hs,{value:"library",className:"space-y-4 mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[s==null?void 0:s.map(pe=>r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(po,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"font-medium",children:pe.name}),pe.description&&r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:pe.description}),!pe.owner_user_id&&r.jsx(_t,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},pe.id)),r.jsx(ze,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>B(!0),children:r.jsx(qe,{className:"p-4 flex items-center justify-center h-full min-h-[100px]",children:r.jsxs("div",{className:"text-center text-muted-foreground",children:[r.jsx(gs,{className:"h-8 w-8 mx-auto mb-2"}),r.jsx("p",{children:"Add New Popby Idea"})]})})})]})}),r.jsxs(hs,{value:"templates",className:"space-y-4 mt-4",children:[r.jsxs("div",{className:"text-sm text-muted-foreground",children:[g.length," template",g.length!==1?"s":""," found"]}),v&&r.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((pe,ie)=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx(pr,{className:"aspect-[3/2] w-full rounded-lg mb-4"}),r.jsx(pr,{className:"h-5 w-3/4 mb-2"}),r.jsx(pr,{className:"h-4 w-full mb-4"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(pr,{className:"h-5 w-16"}),r.jsx(pr,{className:"h-5 w-20"})]})]})},ie))}),!v&&g.length===0&&r.jsx(ze,{children:r.jsxs(qe,{className:"p-8 text-center text-muted-foreground",children:[r.jsx(ec,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No popby templates available yet!"}),r.jsx("p",{className:"text-sm mt-1",children:"Check back soon for new templates."})]})}),!v&&g.length>0&&r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:g.map(pe=>r.jsxs(ze,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer",onClick:()=>e(`/templates/${pe.id}`),children:[r.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:pe.preview_image_url?r.jsx("img",{src:pe.preview_image_url,alt:pe.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No Preview"})}),r.jsxs(qe,{className:"p-4 flex flex-col",children:[r.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:pe.name}),pe.description&&r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:Zae(pe.description)}),r.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:r.jsx(_t,{variant:"secondary",className:"text-xs",children:"PopBys"})}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground mb-3",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Cd,{className:"h-3.5 w-3.5"}),pe.likesCount]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Rl,{className:"h-3.5 w-3.5"}),pe.commentsCount]})]}),r.jsxs(X,{size:"sm",className:"w-full gap-2",onClick:ie=>{ie.stopPropagation(),e(`/templates/${pe.id}`)},children:[r.jsx(jn,{className:"h-4 w-4"}),"View Template"]})]})]},pe.id))})]})]}),r.jsx(Ir,{open:T,onOpenChange:C,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Log Popby for ",w==null?void 0:w.first_name," ",w==null?void 0:w.last_name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Popby Item (optional)"}),r.jsxs(ds,{value:$.popby_item_id,onValueChange:pe=>q(ie=>({...ie,popby_item_id:pe})),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a popby item..."})}),r.jsx(cs,{children:s==null?void 0:s.map(pe=>r.jsx(Ut,{value:pe.id,children:pe.name},pe.id))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Notes (optional)"}),r.jsx(qs,{placeholder:"Any notes about this popby...",value:$.notes,onChange:pe=>q(ie=>({...ie,notes:pe.target.value}))})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),r.jsx(X,{onClick:re,disabled:d.isPending,children:"Log Popby"})]})]})}),r.jsx(Ir,{open:I,onOpenChange:R,children:r.jsxs(Er,{className:"max-w-md",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Popby Frequency Settings"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.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(pe=>r.jsxs("div",{className:"flex items-center justify-between gap-4",children:[r.jsx(Ee,{className:"font-medium",children:pe.name}),r.jsxs(ds,{value:se(pe.id),onValueChange:ie=>oe(pe.id,ie),children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{})}),r.jsx(cs,{children:o6t.map(ie=>r.jsx(Ut,{value:ie.value,children:ie.label},ie.value))})]})]},pe.id))]}),r.jsx(Rn,{children:r.jsx(X,{onClick:()=>R(!1),children:"Done"})})]})}),r.jsx(Ir,{open:D,onOpenChange:B,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Add Popby Idea"})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Name *"}),r.jsx(Ye,{placeholder:"e.g., Homemade cookies",value:W.name,onChange:pe=>K(ie=>({...ie,name:pe.target.value}))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(qs,{placeholder:"Optional description...",value:W.description,onChange:pe=>K(ie=>({...ie,description:pe.target.value}))})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),r.jsx(X,{onClick:ae,disabled:!W.name.trim()||m.isPending,children:"Add Item"})]})]})})]})})}function c6t(){const e=Ks(),{isAdmin:t}=Gr(),s=A.useRef(null),n=A.useRef(null),a=A.useRef([]),o=nHe(),{data:l}=rHe(),i=iHe(),[d,m]=A.useState(""),[p,g]=A.useState(""),[v,_]=A.useState(!0),[k,w]=A.useState(null),[S,T]=A.useState(null),[C,I]=A.useState(!1),[R,D]=A.useState({popby_item_id:"",notes:""}),B=o.filter(K=>K.address||K.city&&K.state);A.useEffect(()=>{(async()=>{_(!0);try{const{data:re}=await Y.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();re!=null&&re.value&&m(re.value)}catch(re){console.error("Error fetching mapbox token:",re)}_(!1)})()},[]),A.useEffect(()=>{"geolocation"in navigator&&navigator.geolocation.getCurrentPosition(K=>{w([K.coords.longitude,K.coords.latitude])},K=>{console.log("Could not get location:",K)})},[]),A.useEffect(()=>{if(!(!s.current||!d||n.current))return fc.accessToken=d,n.current=new fc.Map({container:s.current,style:"mapbox://styles/mapbox/streets-v12",zoom:k?12:4,center:k||[-98.5795,39.8283]}),n.current.addControl(new fc.NavigationControl,"top-right"),()=>{var K;(K=n.current)==null||K.remove(),n.current=null}},[d,k]),A.useEffect(()=>{!n.current||!d||(a.current.forEach(K=>K.remove()),a.current=[],B.forEach(async K=>{var ae;const re=[K.address,K.city,K.state,K.zip].filter(Boolean).join(", ");if(re)try{const se=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(re)}.json?access_token=${d}`)).json();if(se.features&&se.features.length>0){const[pe,ie]=se.features[0].center,de=document.createElement("div");de.className="cursor-pointer",de.innerHTML=`
${K.first_name[0]}${((ae=K.last_name)==null?void 0:ae[0])||""}
${K.isDue?'
':""}
`;const ce=new fc.Marker(de).setLngLat([pe,ie]).addTo(n.current);de.addEventListener("click",()=>{T(K)}),a.current.push(ce)}}catch(oe){console.error("Geocoding error for",K.first_name,oe)}}))},[B,d]);const $=()=>{k&&n.current?n.current.flyTo({center:k,zoom:13}):ta({title:"Location not available",description:"Please enable location services",variant:"destructive"})},q=async()=>{S&&(await i.mutateAsync({contact_id:S.id,popby_item_id:R.popby_item_id||void 0,notes:R.notes||void 0,latitude:k==null?void 0:k[1],longitude:k==null?void 0:k[0]}),I(!1),T(null),D({popby_item_id:"",notes:""}))},W=async()=>{if(p.trim())try{await Y.from("settings").upsert({key:"mapbox_public_token",value:p.trim()}),m(p.trim()),ta({title:"Mapbox token saved!"})}catch{ta({title:"Error saving token",variant:"destructive"})}};return v?r.jsx(Ur,{title:"Popby Map",children:r.jsx("div",{className:"flex items-center justify-center h-[60vh]",children:r.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):d?r.jsx(Ur,{title:"Popby Map",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(X,{variant:"ghost",onClick:()=>e("/mission-control/popbys"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]}),r.jsxs(X,{onClick:$,children:[r.jsx(vE,{className:"h-4 w-4 mr-2"}),"My Location"]})]}),r.jsxs("div",{className:"flex gap-4 text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-4 h-4 rounded-full bg-primary"}),r.jsx("span",{children:"Up to date"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-4 h-4 rounded-full bg-amber-500"}),r.jsx("span",{children:"Due for popby"})]})]}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{ref:s,className:"w-full h-[60vh] rounded-lg shadow-lg"}),B.length===0&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 rounded-lg",children:r.jsxs("div",{className:"text-center p-6",children:[r.jsx(kl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),r.jsx("p",{className:"font-medium",children:"No contacts with addresses"}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Add addresses to your contacts to see them on the map."})]})})]}),S&&r.jsx(ze,{className:"fixed bottom-4 left-4 right-4 md:left-auto md:right-4 md:w-96 z-50 shadow-xl",children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-start justify-between mb-3",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"font-semibold",children:[S.first_name," ",S.last_name]}),S.address&&r.jsxs("p",{className:"text-sm text-muted-foreground",children:[S.city,", ",S.state]})]}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>T(null),children:"×"})]}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[S.isDue?r.jsxs(_t,{variant:"destructive",children:[S.daysOverdue,"+ days overdue"]}):r.jsx(_t,{variant:"secondary",children:"Up to date"}),S.lastPopby&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last: ",Xr(new Date(S.lastPopby),"MMM d")]})]}),r.jsxs("div",{className:"flex gap-2",children:[S.phone&&r.jsx(X,{size:"sm",variant:"outline",asChild:!0,className:"flex-1",children:r.jsxs("a",{href:`tel:${S.phone}`,children:[r.jsx(fi,{className:"h-4 w-4 mr-1"}),"Call"]})}),S.address&&r.jsxs(X,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const K=[S.address,S.city,S.state,S.zip].filter(Boolean).join(", ");window.open(`https://maps.google.com/maps?daddr=${encodeURIComponent(K)}`,"_blank")},children:[r.jsx(SE,{className:"h-4 w-4 mr-1"}),"Navigate"]}),r.jsxs(X,{size:"sm",className:"flex-1",onClick:()=>I(!0),children:[r.jsx(po,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})}),r.jsx(Ir,{open:C,onOpenChange:I,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Log Popby for ",S==null?void 0:S.first_name," ",S==null?void 0:S.last_name]})}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Popby Item (optional)"}),r.jsxs(ds,{value:R.popby_item_id,onValueChange:K=>D(re=>({...re,popby_item_id:K})),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a popby item..."})}),r.jsx(cs,{children:l==null?void 0:l.map(K=>r.jsx(Ut,{value:K.id,children:K.name},K.id))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Notes (optional)"}),r.jsx(qs,{placeholder:"Any notes about this popby...",value:R.notes,onChange:K=>D(re=>({...re,notes:K.target.value}))})]}),k&&r.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[r.jsx(Yi,{className:"h-3 w-3"}),"Your current location will be recorded"]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>I(!1),children:"Cancel"}),r.jsxs(X,{onClick:q,disabled:i.isPending,children:[r.jsx(ui,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})]})}):t?r.jsx(Ur,{title:"Popby Map",children:r.jsx("div",{className:"max-w-md mx-auto mt-8",children:r.jsx(ze,{children:r.jsxs(qe,{className:"p-6 space-y-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsx(Yi,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),r.jsx("h2",{className:"text-lg font-semibold",children:"Setup Map"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter your Mapbox public token to enable the map feature."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Mapbox Public Token"}),r.jsx(Ye,{placeholder:"pk.eyJ1I...",value:p,onChange:K=>g(K.target.value)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token at"," ",r.jsx("a",{href:"https://mapbox.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"mapbox.com"})]})]}),r.jsx(X,{onClick:W,className:"w-full",children:"Save Token"}),r.jsxs(X,{variant:"outline",className:"w-full",onClick:()=>e("/mission-control/popbys"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})}):r.jsx(Ur,{title:"Popby Map",children:r.jsx("div",{className:"max-w-md mx-auto mt-8",children:r.jsx(ze,{children:r.jsxs(qe,{className:"p-6 space-y-4",children:[r.jsxs("div",{className:"text-center",children:[r.jsx(kl,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),r.jsx("h2",{className:"text-lg font-semibold",children:"Map Not Available"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"The map feature has not been configured yet. Please contact your administrator."})]}),r.jsxs(X,{variant:"outline",className:"w-full",onClick:()=>e("/mission-control/popbys"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Popbys"]})]})})})})}const d6t=i_({property_address:zo().min(1,"Property address is required"),city:zo().optional(),state:zo().optional(),zip:zo().optional(),transaction_type:I7e(["buyer","seller"]),close_date:zo().min(1,"Close date is required"),sale_price:KE().min(0,"Sale price must be positive"),commission_amount:KE().optional(),lead_source_id:zo().optional(),client_type_id:zo().optional(),contact_id:zo().optional(),notes:zo().optional(),is_win:k0t()});function cHe({open:e,onOpenChange:t,transaction:s}){const[n,a]=A.useState(!1),[o,l]=A.useState(""),[i,d]=A.useState(!1),[m,p]=A.useState(""),g=Vie(),v=ewt(),{data:_}=Uie(),{data:k}=gg(),{data:w}=Xf(),S=d1e(),T=Jbt(),{data:C}=qie(),I=(C==null?void 0:C.show_commission)??!0,R=Pie({resolver:Lie(d6t),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}});A.useEffect(()=>{s?R.reset({property_address:s.property_address,city:s.city||"",state:s.state||"",zip:s.zip||"",transaction_type:s.transaction_type,close_date:s.close_date,sale_price:Number(s.sale_price),commission_amount:s.commission_amount?Number(s.commission_amount):void 0,lead_source_id:s.lead_source_id||void 0,client_type_id:s.client_type_id||void 0,contact_id:s.contact_id||void 0,notes:s.notes||"",is_win:s.is_win}):R.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})},[s,R]);const D=async W=>{const K={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};s?await v.mutateAsync({id:s.id,...K}):await g.mutateAsync(K),t(!1)},B=async()=>{if(!o.trim())return;const[W,...K]=o.trim().split(" "),re=K.join(" ")||null,ae=await S.mutateAsync({first_name:W,last_name:re,tagIds:[]});ae&&(R.setValue("contact_id",ae.id),l(""),d(!1),a(!1))},$=async()=>{if(!m.trim())return;const W=await T.mutateAsync(m.trim());W&&(R.setValue("lead_source_id",W.id),p(""))},q=w==null?void 0:w.find(W=>W.id===R.watch("contact_id"));return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-lg max-h-[90vh]",children:[r.jsx(zr,{children:r.jsx(Fr,{children:s?"Edit Transaction":"Add Transaction"})}),r.jsx(To,{className:"max-h-[70vh] pr-4",children:r.jsx(Die,{...R,children:r.jsxs("form",{onSubmit:R.handleSubmit(D),className:"space-y-4",children:[r.jsx(Hl,{control:R.control,name:"property_address",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Property Address *"}),r.jsx(Ll,{children:r.jsx(Ye,{placeholder:"123 Main St",...W})}),r.jsx(uh,{})]})}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(Hl,{control:R.control,name:"city",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"City"}),r.jsx(Ll,{children:r.jsx(Ye,{placeholder:"City",...W})})]})}),r.jsx(Hl,{control:R.control,name:"state",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"State"}),r.jsx(Ll,{children:r.jsx(Ye,{placeholder:"TX",...W})})]})}),r.jsx(Hl,{control:R.control,name:"zip",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Zip"}),r.jsx(Ll,{children:r.jsx(Ye,{placeholder:"75001",...W})})]})})]}),r.jsx(Hl,{control:R.control,name:"transaction_type",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Transaction Type *"}),r.jsxs(ds,{onValueChange:W.onChange,value:W.value,children:[r.jsx(Ll,{children:r.jsx(ls,{children:r.jsx(us,{placeholder:"Select type"})})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"buyer",children:"Buyer"}),r.jsx(Ut,{value:"seller",children:"Seller"})]})]}),r.jsx(uh,{})]})}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Hl,{control:R.control,name:"close_date",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Close Date *"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"date",...W})}),r.jsx(uh,{})]})}),r.jsx(Hl,{control:R.control,name:"sale_price",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Sale Price *"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"number",placeholder:"0",...W,onChange:K=>W.onChange(Number(K.target.value))})}),r.jsx(uh,{})]})})]}),I&&r.jsx(Hl,{control:R.control,name:"commission_amount",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Commission"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"number",placeholder:"0",...W,value:W.value??"",onChange:K=>W.onChange(K.target.value?Number(K.target.value):void 0)})})]})}),r.jsx(Hl,{control:R.control,name:"lead_source_id",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Lead Source"}),r.jsxs(ds,{onValueChange:W.onChange,value:W.value||"",children:[r.jsx(Ll,{children:r.jsx(ls,{children:r.jsx(us,{placeholder:"Select source"})})}),r.jsx(cs,{children:_==null?void 0:_.map(K=>r.jsx(Ut,{value:K.id,children:K.name},K.id))})]})]})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{placeholder:"Add custom source...",value:m,onChange:W=>p(W.target.value),className:"flex-1"}),r.jsx(X,{type:"button",variant:"outline",size:"icon",onClick:$,disabled:!m.trim(),children:r.jsx(gs,{className:"h-4 w-4"})})]}),r.jsx(Hl,{control:R.control,name:"client_type_id",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Client Type"}),r.jsxs(ds,{onValueChange:W.onChange,value:W.value||"",children:[r.jsx(Ll,{children:r.jsx(ls,{children:r.jsx(us,{placeholder:"Select client type"})})}),r.jsx(cs,{children:k==null?void 0:k.map(K=>r.jsx(Ut,{value:K.id,children:K.name},K.id))})]})]})}),r.jsx(Hl,{control:R.control,name:"contact_id",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Client Contact"}),r.jsxs(cd,{open:n,onOpenChange:a,children:[r.jsx(dd,{asChild:!0,children:r.jsx(Ll,{children:r.jsxs(X,{variant:"outline",role:"combobox",className:Vt("w-full justify-between",!W.value&&"text-muted-foreground"),children:[q?`${q.first_name} ${q.last_name||""}`.trim():"Select contact",r.jsx(Ry,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),r.jsxs(Hc,{className:"w-full p-0",align:"start",children:[r.jsxs(a0,{children:[r.jsx(i0,{placeholder:"Search contacts..."}),r.jsxs(o0,{children:[r.jsx(l0,{children:r.jsxs("div",{className:"p-2 space-y-2",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"No contact found."}),!i&&r.jsxs(X,{variant:"outline",size:"sm",className:"w-full",onClick:()=>d(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add New Contact"]})]})}),r.jsx(c0,{children:w==null?void 0:w.map(K=>r.jsxs(d0,{value:`${K.first_name} ${K.last_name||""}`,onSelect:()=>{W.onChange(K.id),a(!1)},children:[r.jsx(mi,{className:Vt("mr-2 h-4 w-4",K.id===W.value?"opacity-100":"opacity-0")}),K.first_name," ",K.last_name||""]},K.id))})]})]}),i&&r.jsxs("div",{className:"p-2 border-t space-y-2",children:[r.jsx(Ye,{placeholder:"Enter contact name...",value:o,onChange:K=>l(K.target.value)}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{size:"sm",onClick:B,disabled:!o.trim()||S.isPending,children:"Add Contact"}),r.jsx(X,{size:"sm",variant:"outline",onClick:()=>{d(!1),l("")},children:"Cancel"})]})]})]})]})]})}),r.jsx(Hl,{control:R.control,name:"notes",render:({field:W})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Notes"}),r.jsx(Ll,{children:r.jsx(qs,{placeholder:"Any notes about this transaction...",...W})})]})}),r.jsx(Hl,{control:R.control,name:"is_win",render:({field:W})=>r.jsxs(Il,{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Pl,{children:"Mark as Win 🏆"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),r.jsx(Ll,{children:r.jsx(fn,{checked:W.value,onCheckedChange:W.onChange})})]})}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:g.isPending||v.isPending,children:[s?"Update":"Add"," Transaction"]})]})]})})})]})})}function dHe({transactions:e,showCommission:t,isLoading:s}){const[n,a]=A.useState(null),[o,l]=A.useState(null),[i,d]=A.useState(""),[m,p]=A.useState("all"),[g,v]=A.useState("all"),[_,k]=A.useState("all"),[w,S]=A.useState(!1),T=twt(),C=Vie(),{data:I}=Uie(),{data:R}=gg(),D=V3(),B=W=>{const{id:K,created_at:re,updated_at:ae,lead_source:oe,client_type:se,contact:pe,...ie}=W;C.mutate(ie)},$=()=>{o&&(T.mutate(o),l(null))},q=e.filter(W=>{var pe,ie,de,ce;const K=i===""||W.property_address.toLowerCase().includes(i.toLowerCase())||((ie=(pe=W.contact)==null?void 0:pe.first_name)==null?void 0:ie.toLowerCase().includes(i.toLowerCase()))||((ce=(de=W.contact)==null?void 0:de.last_name)==null?void 0:ce.toLowerCase().includes(i.toLowerCase())),re=m==="all"||W.transaction_type===m,ae=g==="all"||W.lead_source_id===g,oe=_==="all"||W.client_type_id===_,se=!w||W.is_win;return K&&re&&ae&&oe&&se});return s?r.jsx(ze,{children:r.jsx(qe,{className:"p-6 space-y-4",children:[1,2,3].map(W=>r.jsx(pr,{className:"h-16 w-full"},W))})}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[r.jsxs(Zt,{children:["Transactions (",q.length,")"]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search...",value:i,onChange:W=>d(W.target.value),className:"pl-8 w-[150px]"})]}),r.jsxs(ds,{value:m,onValueChange:p,children:[r.jsx(ls,{className:"w-[100px]",children:r.jsx(us,{placeholder:"Type"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Types"}),r.jsx(Ut,{value:"buyer",children:"Buyer"}),r.jsx(Ut,{value:"seller",children:"Seller"})]})]}),r.jsxs(ds,{value:g,onValueChange:v,children:[r.jsx(ls,{className:"w-[130px]",children:r.jsx(us,{placeholder:"Lead Source"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Sources"}),I==null?void 0:I.map(W=>r.jsx(Ut,{value:W.id,children:W.name},W.id))]})]}),r.jsxs(X,{variant:w?"default":"outline",size:"sm",onClick:()=>S(!w),children:[r.jsx(Yl,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),r.jsx(qe,{children:q.length===0?r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):D?r.jsx("div",{className:"space-y-3",children:q.map(W=>r.jsxs(ze,{className:"p-4",children:[r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"font-medium truncate",children:W.property_address}),W.is_win&&r.jsx(Yl,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[W.city,W.state?`, ${W.state}`:""]})]}),r.jsx(_t,{variant:W.transaction_type==="buyer"?"default":"secondary",children:W.transaction_type})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-sm",children:[r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Close Date: "}),LSe(W.close_date)]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Price: "}),du(W.sale_price)]}),t&&W.commission_amount&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),du(W.commission_amount)]}),W.lead_source&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Source: "}),W.lead_source.name]}),W.contact&&r.jsxs("div",{className:"col-span-2",children:[r.jsx("span",{className:"text-muted-foreground",children:"Client: "}),W.contact.first_name," ",W.contact.last_name]})]}),r.jsxs("div",{className:"flex justify-end gap-2 mt-3 pt-3 border-t",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>a(W),children:r.jsx(Lc,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>B(W),children:r.jsx(uo,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>l(W.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})]},W.id))}):r.jsx("div",{className:"overflow-x-auto",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Property"}),r.jsx(Mt,{children:"Type"}),r.jsx(Mt,{children:"Close Date"}),r.jsx(Mt,{children:"Sale Price"}),t&&r.jsx(Mt,{children:"Commission"}),r.jsx(Mt,{children:"Lead Source"}),r.jsx(Mt,{children:"Client"}),r.jsx(Mt,{className:"w-[50px]"})]})}),r.jsx(Bn,{children:q.map(W=>{var K;return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-2",children:[W.is_win&&r.jsx(Yl,{className:"h-4 w-4 text-yellow-500"}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:W.property_address}),r.jsxs("div",{className:"text-sm text-muted-foreground",children:[W.city,W.state?`, ${W.state}`:""]})]})]})}),r.jsx(dt,{children:r.jsx(_t,{variant:W.transaction_type==="buyer"?"default":"secondary",children:W.transaction_type})}),r.jsx(dt,{children:LSe(W.close_date)}),r.jsx(dt,{children:du(W.sale_price)}),t&&r.jsx(dt,{children:W.commission_amount?du(W.commission_amount):"-"}),r.jsx(dt,{children:((K=W.lead_source)==null?void 0:K.name)||"-"}),r.jsx(dt,{children:W.contact?`${W.contact.first_name} ${W.contact.last_name||""}`.trim():"-"}),r.jsx(dt,{children:r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",children:r.jsx(Qg,{className:"h-4 w-4"})})}),r.jsxs(vu,{align:"end",children:[r.jsxs(Ba,{onClick:()=>a(W),children:[r.jsx(Lc,{className:"h-4 w-4 mr-2"}),"Edit"]}),r.jsxs(Ba,{onClick:()=>B(W),children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),r.jsxs(Ba,{onClick:()=>l(W.id),className:"text-destructive",children:[r.jsx(Os,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},W.id)})})]})})})]}),r.jsx(cHe,{open:!!n,onOpenChange:W=>!W&&a(null),transaction:n||void 0}),r.jsx($c,{open:!!o,onOpenChange:W=>!W&&l(null),children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Delete Transaction?"}),r.jsx(bc,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:$,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function uHe({goals:e,stats:t,year:s,showCommission:n}){const a=new Date().getMonth()+1,o=new Date().getFullYear()===s?a:12,l=12-o,i=(v,_)=>{if(!_||_===0)return null;const k=Math.min(v/_*100,100),w=Math.max(_-v,0),S=l>0?w/l:0,T=o/12*100,C=k>=T?"ahead":k>=T*.8?"on-track":"behind";return{percent:k,remaining:w,pace:S,status:C}},d=i(t.totalTransactions,e.transactions_goal),m=i(t.totalVolume,e.volume_goal),p=n?i(t.totalCommission,e.gci_goal):null,g=v=>{switch(v){case"ahead":return r.jsxs(_t,{className:"bg-green-500 text-white",children:[r.jsx(pu,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return r.jsxs(_t,{variant:"secondary",children:[r.jsx(k1,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return r.jsxs(_t,{variant:"destructive",children:[r.jsx(Tk,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!e.transactions_goal&&!e.volume_goal&&!e.gci_goal?null:r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Bf,{className:"h-5 w-5 text-primary"}),r.jsxs(Zt,{children:[s," Goals Progress"]})]})}),r.jsx(qe,{children:r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.transactions_goal&&d&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-medium",children:"Transactions"}),g(d.status)]}),r.jsx(zl,{value:d.percent,className:"h-2"}),r.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[r.jsxs("span",{children:[t.totalTransactions," of ",e.transactions_goal]}),r.jsxs("span",{children:[Math.round(d.percent),"%"]})]}),d.remaining>0&&l>0&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",Math.ceil(d.pace),"/month to hit goal"]})]}),e.volume_goal&&m&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-medium",children:"Volume"}),g(m.status)]}),r.jsx(zl,{value:m.percent,className:"h-2"}),r.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[r.jsxs("span",{children:[du(t.totalVolume,!0)," of ",du(e.volume_goal,!0)]}),r.jsxs("span",{children:[Math.round(m.percent),"%"]})]}),m.remaining>0&&l>0&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",du(m.pace,!0),"/month"]})]}),n&&e.gci_goal&&p&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm font-medium",children:"GCI"}),g(p.status)]}),r.jsx(zl,{value:p.percent,className:"h-2"}),r.jsxs("div",{className:"flex justify-between text-sm text-muted-foreground",children:[r.jsxs("span",{children:[du(t.totalCommission,!0)," of ",du(e.gci_goal,!0)]}),r.jsxs("span",{children:[Math.round(p.percent),"%"]})]}),p.remaining>0&&l>0&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Need ",du(p.pace,!0),"/month"]})]})]})})]})}var u6t=Array.isArray,om=u6t,h6t=typeof Ny=="object"&&Ny&&Ny.Object===Object&&Ny,hHe=h6t,m6t=hHe,f6t=typeof self=="object"&&self&&self.Object===Object&&self,p6t=m6t||f6t||Function("return this")(),Ox=p6t,g6t=Ox,x6t=g6t.Symbol,V6=x6t,EMe=V6,mHe=Object.prototype,y6t=mHe.hasOwnProperty,v6t=mHe.toString,jA=EMe?EMe.toStringTag:void 0;function _6t(e){var t=y6t.call(e,jA),s=e[jA];try{e[jA]=void 0;var n=!0}catch{}var a=v6t.call(e);return n&&(t?e[jA]=s:delete e[jA]),a}var b6t=_6t,w6t=Object.prototype,j6t=w6t.toString;function k6t(e){return j6t.call(e)}var N6t=k6t,IMe=V6,S6t=b6t,C6t=N6t,M6t="[object Null]",T6t="[object Undefined]",PMe=IMe?IMe.toStringTag:void 0;function A6t(e){return e==null?e===void 0?T6t:M6t:PMe&&PMe in Object(e)?S6t(e):C6t(e)}var y0=A6t;function E6t(e){return e!=null&&typeof e=="object"}var v0=E6t,I6t=y0,P6t=v0,L6t="[object Symbol]";function D6t(e){return typeof e=="symbol"||P6t(e)&&I6t(e)==L6t}var H3=D6t,O6t=om,R6t=H3,F6t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,z6t=/^\w*$/;function B6t(e,t){if(O6t(e))return!1;var s=typeof e;return s=="number"||s=="symbol"||s=="boolean"||e==null||R6t(e)?!0:z6t.test(e)||!F6t.test(e)||t!=null&&e in Object(t)}var A_e=B6t;function $6t(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var h_=$6t;const W3=ho(h_);var U6t=y0,V6t=h_,q6t="[object AsyncFunction]",H6t="[object Function]",W6t="[object GeneratorFunction]",G6t="[object Proxy]";function K6t(e){if(!V6t(e))return!1;var t=U6t(e);return t==H6t||t==W6t||t==q6t||t==G6t}var E_e=K6t;const ri=ho(E_e);var Z6t=Ox,Y6t=Z6t["__core-js_shared__"],X6t=Y6t,She=X6t,LMe=function(){var e=/[^.]+$/.exec(She&&She.keys&&She.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Q6t(e){return!!LMe&&LMe in e}var J6t=Q6t,eLt=Function.prototype,tLt=eLt.toString;function rLt(e){if(e!=null){try{return tLt.call(e)}catch{}try{return e+""}catch{}}return""}var fHe=rLt,sLt=E_e,nLt=J6t,aLt=h_,iLt=fHe,oLt=/[\\^$.*+?()[\]{}|]/g,lLt=/^\[object .+?Constructor\]$/,cLt=Function.prototype,dLt=Object.prototype,uLt=cLt.toString,hLt=dLt.hasOwnProperty,mLt=RegExp("^"+uLt.call(hLt).replace(oLt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function fLt(e){if(!aLt(e)||nLt(e))return!1;var t=sLt(e)?mLt:lLt;return t.test(iLt(e))}var pLt=fLt;function gLt(e,t){return e==null?void 0:e[t]}var xLt=gLt,yLt=pLt,vLt=xLt;function _Lt(e,t){var s=vLt(e,t);return yLt(s)?s:void 0}var NN=_Lt,bLt=NN,wLt=bLt(Object,"create"),joe=wLt,DMe=joe;function jLt(){this.__data__=DMe?DMe(null):{},this.size=0}var kLt=jLt;function NLt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var SLt=NLt,CLt=joe,MLt="__lodash_hash_undefined__",TLt=Object.prototype,ALt=TLt.hasOwnProperty;function ELt(e){var t=this.__data__;if(CLt){var s=t[e];return s===MLt?void 0:s}return ALt.call(t,e)?t[e]:void 0}var ILt=ELt,PLt=joe,LLt=Object.prototype,DLt=LLt.hasOwnProperty;function OLt(e){var t=this.__data__;return PLt?t[e]!==void 0:DLt.call(t,e)}var RLt=OLt,FLt=joe,zLt="__lodash_hash_undefined__";function BLt(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=FLt&&t===void 0?zLt:t,this}var $Lt=BLt,ULt=kLt,VLt=SLt,qLt=ILt,HLt=RLt,WLt=$Lt;function G3(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t-1}var cDt=lDt,dDt=koe;function uDt(e,t){var s=this.__data__,n=dDt(s,e);return n<0?(++this.size,s.push([e,t])):s[n][1]=t,this}var hDt=uDt,mDt=ZLt,fDt=sDt,pDt=iDt,gDt=cDt,xDt=hDt;function K3(e){var t=-1,s=e==null?0:e.length;for(this.clear();++t0?1:-1},Zj=function(t){return lN(t)&&t.indexOf("%")===t.length-1},Us=function(t){return ROt(t)&&!q6(t)},$Ot=function(t){return Bi(t)},Nd=function(t){return Us(t)||lN(t)},UOt=0,H6=function(t){var s=++UOt;return"".concat(t||"").concat(s)},fh=function(t,s){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Us(t)&&!lN(t))return n;var o;if(Zj(t)){var l=t.indexOf("%");o=s*parseFloat(t.slice(0,l))/100}else o=+t;return q6(o)&&(o=n),a&&o>s&&(o=s),o},$v=function(t){if(!t)return null;var s=Object.keys(t);return s&&s.length?t[s[0]]:null},VOt=function(t){if(!Array.isArray(t))return!1;for(var s=t.length,n={},a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function YOt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}var UMe={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"},Ky=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},VMe=null,Mhe=null,$_e=function e(t){if(t===VMe&&Array.isArray(Mhe))return Mhe;var s=[];return A.Children.forEach(t,function(n){Bi(n)||(IOt.isFragment(n)?s=s.concat(e(n.props.children)):s.push(n))}),Mhe=s,VMe=t,s};function qf(e,t){var s=[],n=[];return Array.isArray(t)?n=t.map(function(a){return Ky(a)}):n=[Ky(t)],$_e(e).forEach(function(a){var o=Vm(a,"type.displayName")||Vm(a,"type.name");n.indexOf(o)!==-1&&s.push(a)}),s}function jm(e,t){var s=qf(e,t);return s&&s[0]}var qMe=function(t){if(!t||!t.props)return!1;var s=t.props,n=s.width,a=s.height;return!(!Us(n)||n<=0||!Us(a)||a<=0)},XOt=["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"],QOt=function(t){return t&&t.type&&lN(t.type)&&XOt.indexOf(t.type)>=0},JOt=function(t,s,n,a){var o,l=(o=Che==null?void 0:Che[a])!==null&&o!==void 0?o:[];return s.startsWith("data-")||!ri(t)&&(a&&l.includes(s)||WOt.includes(s))||n&&B_e.includes(s)},Za=function(t,s,n){if(!t||typeof t=="function"||typeof t=="boolean")return null;var a=t;if(A.isValidElement(t)&&(a=t.props),!W3(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;JOt((i=a)===null||i===void 0?void 0:i[l],l,s,n)&&(o[l]=a[l])}),o},Mge=function e(t,s){if(t===s)return!0;var n=A.Children.count(t);if(n!==A.Children.count(s))return!1;if(n===0)return!0;if(n===1)return HMe(Array.isArray(t)?t[0]:t,Array.isArray(s)?s[0]:s);for(var a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function n8t(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function Age(e){var t=e.children,s=e.width,n=e.height,a=e.viewBox,o=e.className,l=e.style,i=e.title,d=e.desc,m=s8t(e,r8t),p=a||{width:s,height:n,x:0,y:0},g=ki("recharts-surface",o);return lt.createElement("svg",Tge({},Za(m,!0,"svg"),{className:g,width:s,height:n,style:l,viewBox:"".concat(p.x," ").concat(p.y," ").concat(p.width," ").concat(p.height)}),lt.createElement("title",null,i),lt.createElement("desc",null,d),t)}var a8t=["children","className"];function Ege(){return Ege=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function o8t(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}var $o=lt.forwardRef(function(e,t){var s=e.children,n=e.className,a=i8t(e,a8t),o=ki("recharts-layer",n);return lt.createElement("g",Ege({className:o},Za(a,!0),{ref:t}),s)}),og=function(t,s){for(var n=arguments.length,a=new Array(n>2?n-2:0),o=2;oa?0:a+t),s=s>a?a:s,s<0&&(s+=a),a=t>s?0:s-t>>>0,t>>>=0;for(var o=Array(a);++n=n?e:d8t(e,t,s)}var h8t=u8t,m8t="\\ud800-\\udfff",f8t="\\u0300-\\u036f",p8t="\\ufe20-\\ufe2f",g8t="\\u20d0-\\u20ff",x8t=f8t+p8t+g8t,y8t="\\ufe0e\\ufe0f",v8t="\\u200d",_8t=RegExp("["+v8t+m8t+x8t+y8t+"]");function b8t(e){return _8t.test(e)}var kHe=b8t;function w8t(e){return e.split("")}var j8t=w8t,NHe="\\ud800-\\udfff",k8t="\\u0300-\\u036f",N8t="\\ufe20-\\ufe2f",S8t="\\u20d0-\\u20ff",C8t=k8t+N8t+S8t,M8t="\\ufe0e\\ufe0f",T8t="["+NHe+"]",Ige="["+C8t+"]",Pge="\\ud83c[\\udffb-\\udfff]",A8t="(?:"+Ige+"|"+Pge+")",SHe="[^"+NHe+"]",CHe="(?:\\ud83c[\\udde6-\\uddff]){2}",MHe="[\\ud800-\\udbff][\\udc00-\\udfff]",E8t="\\u200d",THe=A8t+"?",AHe="["+M8t+"]?",I8t="(?:"+E8t+"(?:"+[SHe,CHe,MHe].join("|")+")"+AHe+THe+")*",P8t=AHe+THe+I8t,L8t="(?:"+[SHe+Ige+"?",Ige,CHe,MHe,T8t].join("|")+")",D8t=RegExp(Pge+"(?="+Pge+")|"+L8t+P8t,"g");function O8t(e){return e.match(D8t)||[]}var R8t=O8t,F8t=j8t,z8t=kHe,B8t=R8t;function $8t(e){return z8t(e)?B8t(e):F8t(e)}var U8t=$8t,V8t=h8t,q8t=kHe,H8t=U8t,W8t=yHe;function G8t(e){return function(t){t=W8t(t);var s=q8t(t)?H8t(t):void 0,n=s?s[0]:t.charAt(0),a=s?V8t(s,1).join(""):t.slice(1);return n[e]()+a}}var K8t=G8t,Z8t=K8t,Y8t=Z8t("toUpperCase"),X8t=Y8t;const Foe=ho(X8t);function cl(e){return function(){return e}}const EHe=Math.cos,Nne=Math.sin,vg=Math.sqrt,Sne=Math.PI,zoe=2*Sne,Lge=Math.PI,Dge=2*Lge,Tj=1e-6,Q8t=Dge-Tj;function IHe(e){this._+=e[0];for(let t=1,s=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return IHe;const s=10**t;return function(n){this._+=n[0];for(let a=1,o=n.length;aTj)if(!(Math.abs(g*d-m*p)>Tj)||!o)this._append`L${this._x1=t},${this._y1=s}`;else{let _=n-l,k=a-i,w=d*d+m*m,S=_*_+k*k,T=Math.sqrt(w),C=Math.sqrt(v),I=o*Math.tan((Lge-Math.acos((w+v-S)/(2*T*C)))/2),R=I/C,D=I/T;Math.abs(R-1)>Tj&&this._append`L${t+R*p},${s+R*g}`,this._append`A${o},${o},0,0,${+(g*_>p*k)},${this._x1=t+D*d},${this._y1=s+D*m}`}}arc(t,s,n,a,o,l){if(t=+t,s=+s,n=+n,l=!!l,n<0)throw new Error(`negative radius: ${n}`);let i=n*Math.cos(a),d=n*Math.sin(a),m=t+i,p=s+d,g=1^l,v=l?a-o:o-a;this._x1===null?this._append`M${m},${p}`:(Math.abs(this._x1-m)>Tj||Math.abs(this._y1-p)>Tj)&&this._append`L${m},${p}`,n&&(v<0&&(v=v%Dge+Dge),v>Q8t?this._append`A${n},${n},0,1,${g},${t-i},${s-d}A${n},${n},0,1,${g},${this._x1=m},${this._y1=p}`:v>Tj&&this._append`A${n},${n},0,${+(v>=Lge)},${g},${this._x1=t+n*Math.cos(o)},${this._y1=s+n*Math.sin(o)}`)}rect(t,s,n,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+s}h${n=+n}v${+a}h${-n}Z`}toString(){return this._}}function U_e(e){let t=3;return e.digits=function(s){if(!arguments.length)return t;if(s==null)t=null;else{const n=Math.floor(s);if(!(n>=0))throw new RangeError(`invalid digits: ${s}`);t=n}return e},()=>new eRt(t)}function V_e(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function PHe(e){this._context=e}PHe.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(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Boe(e){return new PHe(e)}function LHe(e){return e[0]}function DHe(e){return e[1]}function OHe(e,t){var s=cl(!0),n=null,a=Boe,o=null,l=U_e(i);e=typeof e=="function"?e:e===void 0?LHe:cl(e),t=typeof t=="function"?t:t===void 0?DHe:cl(t);function i(d){var m,p=(d=V_e(d)).length,g,v=!1,_;for(n==null&&(o=a(_=l())),m=0;m<=p;++m)!(m=_;--k)i.point(I[k],R[k]);i.lineEnd(),i.areaEnd()}T&&(I[v]=+e(S,v,g),R[v]=+t(S,v,g),i.point(n?+n(S,v,g):I[v],s?+s(S,v,g):R[v]))}if(C)return i=null,C+""||null}function p(){return OHe().defined(a).curve(l).context(o)}return m.x=function(g){return arguments.length?(e=typeof g=="function"?g:cl(+g),n=null,m):e},m.x0=function(g){return arguments.length?(e=typeof g=="function"?g:cl(+g),m):e},m.x1=function(g){return arguments.length?(n=g==null?null:typeof g=="function"?g:cl(+g),m):n},m.y=function(g){return arguments.length?(t=typeof g=="function"?g:cl(+g),s=null,m):t},m.y0=function(g){return arguments.length?(t=typeof g=="function"?g:cl(+g),m):t},m.y1=function(g){return arguments.length?(s=g==null?null:typeof g=="function"?g:cl(+g),m):s},m.lineX0=m.lineY0=function(){return p().x(e).y(t)},m.lineY1=function(){return p().x(e).y(s)},m.lineX1=function(){return p().x(n).y(t)},m.defined=function(g){return arguments.length?(a=typeof g=="function"?g:cl(!!g),m):a},m.curve=function(g){return arguments.length?(l=g,o!=null&&(i=l(o)),m):l},m.context=function(g){return arguments.length?(g==null?o=i=null:i=l(o=g),m):o},m}class RHe{constructor(t,s){this._context=t,this._x=s}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(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._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,s,t,s):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+s)/2,t,this._y0,t,s);break}}this._x0=t,this._y0=s}}function tRt(e){return new RHe(e,!0)}function rRt(e){return new RHe(e,!1)}const q_e={draw(e,t){const s=vg(t/Sne);e.moveTo(s,0),e.arc(0,0,s,0,zoe)}},sRt={draw(e,t){const s=vg(t/5)/2;e.moveTo(-3*s,-s),e.lineTo(-s,-s),e.lineTo(-s,-3*s),e.lineTo(s,-3*s),e.lineTo(s,-s),e.lineTo(3*s,-s),e.lineTo(3*s,s),e.lineTo(s,s),e.lineTo(s,3*s),e.lineTo(-s,3*s),e.lineTo(-s,s),e.lineTo(-3*s,s),e.closePath()}},FHe=vg(1/3),nRt=FHe*2,aRt={draw(e,t){const s=vg(t/nRt),n=s*FHe;e.moveTo(0,-s),e.lineTo(n,0),e.lineTo(0,s),e.lineTo(-n,0),e.closePath()}},iRt={draw(e,t){const s=vg(t),n=-s/2;e.rect(n,n,s,s)}},oRt=.8908130915292852,zHe=Nne(Sne/10)/Nne(7*Sne/10),lRt=Nne(zoe/10)*zHe,cRt=-EHe(zoe/10)*zHe,dRt={draw(e,t){const s=vg(t*oRt),n=lRt*s,a=cRt*s;e.moveTo(0,-s),e.lineTo(n,a);for(let o=1;o<5;++o){const l=zoe*o/5,i=EHe(l),d=Nne(l);e.lineTo(d*s,-i*s),e.lineTo(i*n-d*a,d*n+i*a)}e.closePath()}},The=vg(3),uRt={draw(e,t){const s=-vg(t/(The*3));e.moveTo(0,s*2),e.lineTo(-The*s,-s),e.lineTo(The*s,-s),e.closePath()}},mf=-.5,ff=vg(3)/2,Oge=1/vg(12),hRt=(Oge/2+1)*3,mRt={draw(e,t){const s=vg(t/hRt),n=s/2,a=s*Oge,o=n,l=s*Oge+s,i=-o,d=l;e.moveTo(n,a),e.lineTo(o,l),e.lineTo(i,d),e.lineTo(mf*n-ff*a,ff*n+mf*a),e.lineTo(mf*o-ff*l,ff*o+mf*l),e.lineTo(mf*i-ff*d,ff*i+mf*d),e.lineTo(mf*n+ff*a,mf*a-ff*n),e.lineTo(mf*o+ff*l,mf*l-ff*o),e.lineTo(mf*i+ff*d,mf*d-ff*i),e.closePath()}};function fRt(e,t){let s=null,n=U_e(a);e=typeof e=="function"?e:cl(e||q_e),t=typeof t=="function"?t:cl(t===void 0?64:+t);function a(){let o;if(s||(s=o=n()),e.apply(this,arguments).draw(s,+t.apply(this,arguments)),o)return s=null,o+""||null}return a.type=function(o){return arguments.length?(e=typeof o=="function"?o:cl(o),a):e},a.size=function(o){return arguments.length?(t=typeof o=="function"?o:cl(+o),a):t},a.context=function(o){return arguments.length?(s=o??null,a):s},a}function Cne(){}function Mne(e,t,s){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+s)/6)}function BHe(e){this._context=e}BHe.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:Mne(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(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);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:Mne(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function pRt(e){return new BHe(e)}function $He(e){this._context=e}$He.prototype={areaStart:Cne,areaEnd:Cne,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(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Mne(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function gRt(e){return new $He(e)}function UHe(e){this._context=e}UHe.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(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var s=(this._x0+4*this._x1+e)/6,n=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(s,n):this._context.moveTo(s,n);break;case 3:this._point=4;default:Mne(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function xRt(e){return new UHe(e)}function VHe(e){this._context=e}VHe.prototype={areaStart:Cne,areaEnd:Cne,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function yRt(e){return new VHe(e)}function GMe(e){return e<0?-1:1}function KMe(e,t,s){var n=e._x1-e._x0,a=t-e._x1,o=(e._y1-e._y0)/(n||a<0&&-0),l=(s-e._y1)/(a||n<0&&-0),i=(o*a+l*n)/(n+a);return(GMe(o)+GMe(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function ZMe(e,t){var s=e._x1-e._x0;return s?(3*(e._y1-e._y0)/s-t)/2:t}function Ahe(e,t,s){var n=e._x0,a=e._y0,o=e._x1,l=e._y1,i=(o-n)/3;e._context.bezierCurveTo(n+i,a+i*t,o-i,l-i*s,o,l)}function Tne(e){this._context=e}Tne.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:Ahe(this,this._t0,ZMe(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var s=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,Ahe(this,ZMe(this,s=KMe(this,e,t)),s);break;default:Ahe(this,this._t0,s=KMe(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=s}}};function qHe(e){this._context=new HHe(e)}(qHe.prototype=Object.create(Tne.prototype)).point=function(e,t){Tne.prototype.point.call(this,t,e)};function HHe(e){this._context=e}HHe.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,s,n,a,o){this._context.bezierCurveTo(t,e,n,s,o,a)}};function vRt(e){return new Tne(e)}function _Rt(e){return new qHe(e)}function WHe(e){this._context=e}WHe.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,s=e.length;if(s)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),s===2)this._context.lineTo(e[1],t[1]);else for(var n=YMe(e),a=YMe(t),o=0,l=1;l=0;--t)a[t]=(l[t]-a[t+1])/o[t];for(o[s-1]=(e[s]+a[s-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var s=this._x*(1-this._t)+e*this._t;this._context.lineTo(s,this._y),this._context.lineTo(s,t)}break}}this._x=e,this._y=t}};function wRt(e){return new $oe(e,.5)}function jRt(e){return new $oe(e,0)}function kRt(e){return new $oe(e,1)}function H5(e,t){if((l=e.length)>1)for(var s=1,n,a,o=e[t[0]],l,i=o.length;s=0;)s[t]=t;return s}function NRt(e,t){return e[t]}function SRt(e){const t=[];return t.key=e,t}function CRt(){var e=cl([]),t=Rge,s=H5,n=NRt;function a(o){var l=Array.from(e.apply(this,arguments),SRt),i,d=l.length,m=-1,p;for(const g of o)for(i=0,++m;i0){for(var s,n,a=0,o=e[0].length,l;a0){for(var s=0,n=e[t[0]],a,o=n.length;s0)||!((o=(a=e[t[0]]).length)>0))){for(var s=0,n=1,a,o,l;n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function ORt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}var GHe={symbolCircle:q_e,symbolCross:sRt,symbolDiamond:aRt,symbolSquare:iRt,symbolStar:dRt,symbolTriangle:uRt,symbolWye:mRt},RRt=Math.PI/180,FRt=function(t){var s="symbol".concat(Foe(t));return GHe[s]||q_e},zRt=function(t,s,n){if(s==="area")return t;switch(n){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var a=18*RRt;return 1.25*t*t*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},BRt=function(t,s){GHe["symbol".concat(Foe(t))]=s},H_e=function(t){var s=t.type,n=s===void 0?"circle":s,a=t.size,o=a===void 0?64:a,l=t.sizeType,i=l===void 0?"area":l,d=DRt(t,ERt),m=QMe(QMe({},d),{},{type:n,size:o,sizeType:i}),p=function(){var S=FRt(n),T=fRt().type(S).size(zRt(o,i,n));return T()},g=m.className,v=m.cx,_=m.cy,k=Za(m,!0);return v===+v&&_===+_&&o===+o?lt.createElement("path",Fge({},k,{className:ki("recharts-symbols",g),transform:"translate(".concat(v,", ").concat(_,")"),d:p()})):null};H_e.registerSymbol=BRt;function W5(e){"@babel/helpers - typeof";return W5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},W5(e)}function zge(){return zge=Object.assign?Object.assign.bind():function(e){for(var t=1;t`);var C=_.inactive?m:_.color;return lt.createElement("li",zge({className:S,style:g,key:"legend-item-".concat(k)},cN(n.props,_,k)),lt.createElement(Age,{width:l,height:l,viewBox:p,style:v},n.renderIcon(_)),lt.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},w?w(T,_,k):T))})}},{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())}}])}(A.PureComponent);yP(W_e,"displayName","Legend");yP(W_e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var YRt=Noe;function XRt(){this.__data__=new YRt,this.size=0}var QRt=XRt;function JRt(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s}var eFt=JRt;function tFt(e){return this.__data__.get(e)}var rFt=tFt;function sFt(e){return this.__data__.has(e)}var nFt=sFt,aFt=Noe,iFt=P_e,oFt=L_e,lFt=200;function cFt(e,t){var s=this.__data__;if(s instanceof aFt){var n=s.__data__;if(!iFt||n.lengthi))return!1;var m=o.get(e),p=o.get(t);if(m&&p)return m==t&&p==e;var g=-1,v=!0,_=s&EFt?new CFt:void 0;for(o.set(e,t),o.set(t,e);++g-1&&e%1==0&&e-1&&e%1==0&&e<=Dzt}var Y_e=Ozt,Rzt=y0,Fzt=Y_e,zzt=v0,Bzt="[object Arguments]",$zt="[object Array]",Uzt="[object Boolean]",Vzt="[object Date]",qzt="[object Error]",Hzt="[object Function]",Wzt="[object Map]",Gzt="[object Number]",Kzt="[object Object]",Zzt="[object RegExp]",Yzt="[object Set]",Xzt="[object String]",Qzt="[object WeakMap]",Jzt="[object ArrayBuffer]",e7t="[object DataView]",t7t="[object Float32Array]",r7t="[object Float64Array]",s7t="[object Int8Array]",n7t="[object Int16Array]",a7t="[object Int32Array]",i7t="[object Uint8Array]",o7t="[object Uint8ClampedArray]",l7t="[object Uint16Array]",c7t="[object Uint32Array]",bl={};bl[t7t]=bl[r7t]=bl[s7t]=bl[n7t]=bl[a7t]=bl[i7t]=bl[o7t]=bl[l7t]=bl[c7t]=!0;bl[Bzt]=bl[$zt]=bl[Jzt]=bl[Uzt]=bl[e7t]=bl[Vzt]=bl[qzt]=bl[Hzt]=bl[Wzt]=bl[Gzt]=bl[Kzt]=bl[Zzt]=bl[Yzt]=bl[Xzt]=bl[Qzt]=!1;function d7t(e){return zzt(e)&&Fzt(e.length)&&!!bl[Rzt(e)]}var u7t=d7t;function h7t(e){return function(t){return e(t)}}var nWe=h7t,Pne={exports:{}};Pne.exports;(function(e,t){var s=hHe,n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===n,l=o&&s.process,i=function(){try{var d=a&&a.require&&a.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}}();e.exports=i})(Pne,Pne.exports);var m7t=Pne.exports,f7t=u7t,p7t=nWe,aTe=m7t,iTe=aTe&&aTe.isTypedArray,g7t=iTe?p7t(iTe):f7t,aWe=g7t,x7t=_zt,y7t=K_e,v7t=om,_7t=sWe,b7t=Z_e,w7t=aWe,j7t=Object.prototype,k7t=j7t.hasOwnProperty;function N7t(e,t){var s=v7t(e),n=!s&&y7t(e),a=!s&&!n&&_7t(e),o=!s&&!n&&!a&&w7t(e),l=s||n||a||o,i=l?x7t(e.length,String):[],d=i.length;for(var m in e)(t||k7t.call(e,m))&&!(l&&(m=="length"||a&&(m=="offset"||m=="parent")||o&&(m=="buffer"||m=="byteLength"||m=="byteOffset")||b7t(m,d)))&&i.push(m);return i}var S7t=N7t,C7t=Object.prototype;function M7t(e){var t=e&&e.constructor,s=typeof t=="function"&&t.prototype||C7t;return e===s}var T7t=M7t;function A7t(e,t){return function(s){return e(t(s))}}var iWe=A7t,E7t=iWe,I7t=E7t(Object.keys,Object),P7t=I7t,L7t=T7t,D7t=P7t,O7t=Object.prototype,R7t=O7t.hasOwnProperty;function F7t(e){if(!L7t(e))return D7t(e);var t=[];for(var s in Object(e))R7t.call(e,s)&&s!="constructor"&&t.push(s);return t}var z7t=F7t,B7t=E_e,$7t=Y_e;function U7t(e){return e!=null&&$7t(e.length)&&!B7t(e)}var W6=U7t,V7t=S7t,q7t=z7t,H7t=W6;function W7t(e){return H7t(e)?V7t(e):q7t(e)}var Uoe=W7t,G7t=lzt,K7t=yzt,Z7t=Uoe;function Y7t(e){return G7t(e,Z7t,K7t)}var X7t=Y7t,oTe=X7t,Q7t=1,J7t=Object.prototype,eBt=J7t.hasOwnProperty;function tBt(e,t,s,n,a,o){var l=s&Q7t,i=oTe(e),d=i.length,m=oTe(t),p=m.length;if(d!=p&&!l)return!1;for(var g=d;g--;){var v=i[g];if(!(l?v in t:eBt.call(t,v)))return!1}var _=o.get(e),k=o.get(t);if(_&&k)return _==t&&k==e;var w=!0;o.set(e,t),o.set(t,e);for(var S=l;++g-1}var J9t=Q9t;function e$t(e,t,s){for(var n=-1,a=e==null?0:e.length;++n=p$t){var m=t?null:m$t(e);if(m)return f$t(m);l=!1,a=h$t,d=new c$t}else d=t?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function E$t(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function I$t(e){return e.value}function P$t(e,t){if(lt.isValidElement(e))return lt.cloneElement(e,t);if(typeof e=="function")return lt.createElement(e,t);t.ref;var s=A$t(t,w$t);return lt.createElement(W_e,s)}var jTe=1,t5=function(e){function t(){var s;j$t(this,t);for(var n=arguments.length,a=new Array(n),o=0;ojTe||Math.abs(a.height-this.lastBoundingBox.height)>jTe)&&(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?hy({},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,m=a.chartWidth,p=a.chartHeight,g,v;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(l==="center"&&o==="vertical"){var _=this.getBBoxSnapshot();g={left:((m||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 k=this.getBBoxSnapshot();v={top:((p||0)-k.height)/2}}else v=i==="bottom"?{bottom:d&&d.bottom||0}:{top:d&&d.top||0};return hy(hy({},g),v)}},{key:"render",value:function(){var n=this,a=this.props,o=a.content,l=a.width,i=a.height,d=a.wrapperStyle,m=a.payloadUniqBy,p=a.payload,g=hy(hy({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=_}},P$t(o,hy(hy({},this.props),{},{payload:mWe(p,m,I$t)})))}}],[{key:"getWithHeight",value:function(n,a){var o=hy(hy({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&Us(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(A.PureComponent);Voe(t5,"displayName","Legend");Voe(t5,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var kTe=V6,L$t=K_e,D$t=om,NTe=kTe?kTe.isConcatSpreadable:void 0;function O$t(e){return D$t(e)||L$t(e)||!!(NTe&&e&&e[NTe])}var R$t=O$t,F$t=tWe,z$t=R$t;function gWe(e,t,s,n,a){var o=-1,l=e.length;for(s||(s=z$t),a||(a=[]);++o0&&s(i)?t>1?gWe(i,t-1,s,n,a):F$t(a,i):n||(a[a.length]=i)}return a}var xWe=gWe;function B$t(e){return function(t,s,n){for(var a=-1,o=Object(t),l=n(t),i=l.length;i--;){var d=l[e?i:++a];if(s(o[d],d,o)===!1)break}return t}}var $$t=B$t,U$t=$$t,V$t=U$t(),q$t=V$t,H$t=q$t,W$t=Uoe;function G$t(e,t){return e&&H$t(e,t,W$t)}var yWe=G$t,K$t=W6;function Z$t(e,t){return function(s,n){if(s==null)return s;if(!K$t(s))return e(s,n);for(var a=s.length,o=t?a:-1,l=Object(s);(t?o--:++ot||o&&l&&d&&!i&&!m||n&&l&&d||!s&&d||!a)return 1;if(!n&&!o&&!m&&e=i)return d;var m=s[n];return d*(m=="desc"?-1:1)}}return e.index-t.index}var cUt=lUt,Lhe=O_e,dUt=R_e,uUt=Rx,hUt=vWe,mUt=nUt,fUt=nWe,pUt=cUt,gUt=Q3,xUt=om;function yUt(e,t,s){t.length?t=Lhe(t,function(o){return xUt(o)?function(l){return dUt(l,o.length===1?o[0]:o)}:o}):t=[gUt];var n=-1;t=Lhe(t,fUt(uUt));var a=hUt(e,function(o,l,i){var d=Lhe(t,function(m){return m(o)});return{criteria:d,index:++n,value:o}});return mUt(a,function(o,l){return pUt(o,l,s)})}var vUt=yUt;function _Ut(e,t,s){switch(s.length){case 0:return e.call(t);case 1:return e.call(t,s[0]);case 2:return e.call(t,s[0],s[1]);case 3:return e.call(t,s[0],s[1],s[2])}return e.apply(t,s)}var bUt=_Ut,wUt=bUt,CTe=Math.max;function jUt(e,t,s){return t=CTe(t===void 0?e.length-1:t,0),function(){for(var n=arguments,a=-1,o=CTe(n.length-t,0),l=Array(o);++a0){if(++t>=PUt)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var RUt=OUt,FUt=IUt,zUt=RUt,BUt=zUt(FUt),$Ut=BUt,UUt=Q3,VUt=kUt,qUt=$Ut;function HUt(e,t){return qUt(VUt(e,t,UUt),e+"")}var WUt=HUt,GUt=I_e,KUt=W6,ZUt=Z_e,YUt=h_;function XUt(e,t,s){if(!YUt(s))return!1;var n=typeof t;return(n=="number"?KUt(s)&&ZUt(t,s.length):n=="string"&&t in s)?GUt(s[t],e):!1}var qoe=XUt,QUt=xWe,JUt=vUt,eVt=WUt,TTe=qoe,tVt=eVt(function(e,t){if(e==null)return[];var s=t.length;return s>1&&TTe(e,t[0],t[1])?t=[]:s>2&&TTe(t[0],t[1],t[2])&&(t=[t[0]]),JUt(e,QUt(t,1),[])}),rVt=tVt;const J_e=ho(rVt);function vP(e){"@babel/helpers - typeof";return vP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vP(e)}function Gge(){return Gge=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var s=0,n=new Array(t);s=t.x),"".concat(kA,"-left"),Us(s)&&t&&Us(t.x)&&s=t.y),"".concat(kA,"-top"),Us(n)&&t&&Us(t.y)&&nw?Math.max(p,d[n]):Math.max(g,d[n])}function xVt(e){var t=e.translateX,s=e.translateY,n=e.useTranslate3d;return{transform:n?"translate3d(".concat(t,"px, ").concat(s,"px, 0)"):"translate(".concat(t,"px, ").concat(s,"px)")}}function yVt(e){var t=e.allowEscapeViewBox,s=e.coordinate,n=e.offsetTopLeft,a=e.position,o=e.reverseDirection,l=e.tooltipBox,i=e.useTranslate3d,d=e.viewBox,m,p,g;return l.height>0&&l.width>0&&s?(p=ITe({allowEscapeViewBox:t,coordinate:s,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:d,viewBoxDimension:d.width}),g=ITe({allowEscapeViewBox:t,coordinate:s,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:d,viewBoxDimension:d.height}),m=xVt({translateX:p,translateY:g,useTranslate3d:i})):m=pVt,{cssProperties:m,cssClasses:gVt({translateX:p,translateY:g,coordinate:s})}}function K5(e){"@babel/helpers - typeof";return K5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},K5(e)}function PTe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function LTe(e){for(var t=1;tDTe||Math.abs(n.height-this.state.lastBoundingBox.height)>DTe)&&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,m=a.children,p=a.coordinate,g=a.hasPayload,v=a.isAnimationActive,_=a.offset,k=a.position,w=a.reverseDirection,S=a.useTranslate3d,T=a.viewBox,C=a.wrapperStyle,I=yVt({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:_,position:k,reverseDirection:w,tooltipBox:this.state.lastBoundingBox,useTranslate3d:S,viewBox:T}),R=I.cssClasses,D=I.cssProperties,B=LTe(LTe({transition:v&&o?"transform ".concat(i,"ms ").concat(d):void 0},D),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&g?"visible":"hidden",position:"absolute",top:0,left:0},C);return lt.createElement("div",{tabIndex:-1,className:R,style:B,ref:function(q){n.wrapperNode=q}},m)}}])}(A.PureComponent),MVt=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},J3={isSsr:MVt()};function Z5(e){"@babel/helpers - typeof";return Z5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z5(e)}function OTe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function RTe(e){for(var t=1;t0;return lt.createElement(CVt,{allowEscapeViewBox:l,animationDuration:i,animationEasing:d,isAnimationActive:v,active:o,coordinate:p,hasPayload:B,offset:_,position:S,reverseDirection:T,useTranslate3d:C,viewBox:I,wrapperStyle:R},FVt(m,RTe(RTe({},this.props),{},{payload:D})))}}])}(A.PureComponent);ebe($p,"displayName","Tooltip");ebe($p,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!J3.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 zVt=Ox,BVt=function(){return zVt.Date.now()},$Vt=BVt,UVt=/\s/;function VVt(e){for(var t=e.length;t--&&UVt.test(e.charAt(t)););return t}var qVt=VVt,HVt=qVt,WVt=/^\s+/;function GVt(e){return e&&e.slice(0,HVt(e)+1).replace(WVt,"")}var KVt=GVt,ZVt=KVt,FTe=h_,YVt=H3,zTe=NaN,XVt=/^[-+]0x[0-9a-f]+$/i,QVt=/^0b[01]+$/i,JVt=/^0o[0-7]+$/i,eqt=parseInt;function tqt(e){if(typeof e=="number")return e;if(YVt(e))return zTe;if(FTe(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=FTe(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=ZVt(e);var s=QVt.test(e);return s||JVt.test(e)?eqt(e.slice(2),s?2:8):XVt.test(e)?zTe:+e}var NWe=tqt,rqt=h_,Ohe=$Vt,BTe=NWe,sqt="Expected a function",nqt=Math.max,aqt=Math.min;function iqt(e,t,s){var n,a,o,l,i,d,m=0,p=!1,g=!1,v=!0;if(typeof e!="function")throw new TypeError(sqt);t=BTe(t)||0,rqt(s)&&(p=!!s.leading,g="maxWait"in s,o=g?nqt(BTe(s.maxWait)||0,t):o,v="trailing"in s?!!s.trailing:v);function _(B){var $=n,q=a;return n=a=void 0,m=B,l=e.apply(q,$),l}function k(B){return m=B,i=setTimeout(T,t),p?_(B):l}function w(B){var $=B-d,q=B-m,W=t-$;return g?aqt(W,o-q):W}function S(B){var $=B-d,q=B-m;return d===void 0||$>=t||$<0||g&&q>=o}function T(){var B=Ohe();if(S(B))return C(B);i=setTimeout(T,w(B))}function C(B){return i=void 0,v&&n?_(B):(n=a=void 0,l)}function I(){i!==void 0&&clearTimeout(i),m=0,n=d=a=i=void 0}function R(){return i===void 0?l:C(Ohe())}function D(){var B=Ohe(),$=S(B);if(n=arguments,a=this,d=B,$){if(i===void 0)return k(d);if(g)return clearTimeout(i),i=setTimeout(T,t),_(d)}return i===void 0&&(i=setTimeout(T,t)),l}return D.cancel=I,D.flush=R,D}var oqt=iqt,lqt=oqt,cqt=h_,dqt="Expected a function";function uqt(e,t,s){var n=!0,a=!0;if(typeof e!="function")throw new TypeError(dqt);return cqt(s)&&(n="leading"in s?!!s.leading:n,a="trailing"in s?!!s.trailing:a),lqt(e,t,{leading:n,maxWait:t,trailing:a})}var hqt=uqt;const SWe=ho(hqt);function bP(e){"@babel/helpers - typeof";return bP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bP(e)}function $Te(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function r8(e){for(var t=1;te.length)&&(t=e.length);for(var s=0,n=new Array(t);s0&&(oe=SWe(oe,w,{trailing:!0,leading:!1}));var se=new ResizeObserver(oe),pe=D.current.getBoundingClientRect(),ie=pe.width,de=pe.height;return re(ie,de),se.observe(D.current),function(){se.disconnect()}},[re,w]);var ae=A.useMemo(function(){var oe=W.containerWidth,se=W.containerHeight;if(oe<0||se<0)return null;og(Zj(l)||Zj(d),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,d),og(!s||s>0,"The aspect(%s) must be greater than zero.",s);var pe=Zj(l)?oe:l,ie=Zj(d)?se:d;s&&s>0&&(pe?ie=pe/s:ie&&(pe=ie*s),v&&ie>v&&(ie=v)),og(pe>0||ie>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the height and width.`,pe,ie,l,d,p,g,s);var de=!Array.isArray(_)&&Ky(_.type).endsWith("Chart");return lt.Children.map(_,function(ce){return lt.isValidElement(ce)?A.cloneElement(ce,r8({width:pe,height:ie},de?{style:r8({height:"100%",width:"100%",maxHeight:ie,maxWidth:pe},ce.props.style)}:{})):ce})},[s,_,d,v,g,p,W,l]);return lt.createElement("div",{id:S?"".concat(S):void 0,className:ki("recharts-responsive-container",T),style:r8(r8({},R),{},{width:l,height:d,minWidth:p,minHeight:g,maxHeight:v}),ref:D},ae)}),Hoe=function(t){return null};Hoe.displayName="Cell";function wP(e){"@babel/helpers - typeof";return wP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wP(e)}function VTe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function Qge(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||J3.isSsr)return{width:0,height:0};var n=Sqt(s),a=JSON.stringify({text:t,copyStyle:n});if(MC.widthCache[a])return MC.widthCache[a];try{var o=document.getElementById(qTe);o||(o=document.createElement("span"),o.setAttribute("id",qTe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Qge(Qge({},Nqt),n);Object.assign(o.style,l),o.textContent="".concat(t);var i=o.getBoundingClientRect(),d={width:i.width,height:i.height};return MC.widthCache[a]=d,++MC.cacheCount>kqt&&(MC.cacheCount=0,MC.widthCache={}),d}catch{return{width:0,height:0}}},Cqt=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function jP(e){"@babel/helpers - typeof";return jP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jP(e)}function Rne(e,t){return Eqt(e)||Aqt(e,t)||Tqt(e,t)||Mqt()}function Mqt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tqt(e,t){if(e){if(typeof e=="string")return HTe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return HTe(e,t)}}function HTe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function Hqt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function XTe(e,t){return Zqt(e)||Kqt(e,t)||Gqt(e,t)||Wqt()}function Wqt(){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 Gqt(e,t){if(e){if(typeof e=="string")return QTe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return QTe(e,t)}}function QTe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s0&&arguments[0]!==void 0?arguments[0]:[];return pe.reduce(function(ie,de){var ce=de.word,ge=de.width,Te=ie[ie.length-1];if(Te&&(a==null||o||Te.width+ge+nde.width?ie:de})};if(!p)return _;for(var w="…",S=function(pe){var ie=g.slice(0,pe),de=AWe({breakAll:m,style:d,children:ie+w}).wordsWithComputedWidth,ce=v(de),ge=ce.length>l||k(ce).width>Number(a);return[ge,ce]},T=0,C=g.length-1,I=0,R;T<=C&&I<=g.length-1;){var D=Math.floor((T+C)/2),B=D-1,$=S(B),q=XTe($,2),W=q[0],K=q[1],re=S(D),ae=XTe(re,1),oe=ae[0];if(!W&&!oe&&(T=D+1),W&&oe&&(C=D-1),!W&&oe){R=K;break}I++}return R||_},JTe=function(t){var s=Bi(t)?[]:t.toString().split(TWe);return[{words:s}]},Xqt=function(t){var s=t.width,n=t.scaleToFit,a=t.children,o=t.style,l=t.breakAll,i=t.maxLines;if((s||n)&&!J3.isSsr){var d,m,p=AWe({breakAll:l,children:a,style:o});if(p){var g=p.wordsWithComputedWidth,v=p.spaceWidth;d=g,m=v}else return JTe(a);return Yqt({breakAll:l,children:a,maxLines:i,style:o},d,m,s,n)}return JTe(a)},eAe="#808080",dN=function(t){var s=t.x,n=s===void 0?0:s,a=t.y,o=a===void 0?0:a,l=t.lineHeight,i=l===void 0?"1em":l,d=t.capHeight,m=d===void 0?"0.71em":d,p=t.scaleToFit,g=p===void 0?!1:p,v=t.textAnchor,_=v===void 0?"start":v,k=t.verticalAnchor,w=k===void 0?"end":k,S=t.fill,T=S===void 0?eAe:S,C=YTe(t,Vqt),I=A.useMemo(function(){return Xqt({breakAll:C.breakAll,children:C.children,maxLines:C.maxLines,scaleToFit:g,style:C.style,width:C.width})},[C.breakAll,C.children,C.maxLines,g,C.style,C.width]),R=C.dx,D=C.dy,B=C.angle,$=C.className,q=C.breakAll,W=YTe(C,qqt);if(!Nd(n)||!Nd(o))return null;var K=n+(Us(R)?R:0),re=o+(Us(D)?D:0),ae;switch(w){case"start":ae=Rhe("calc(".concat(m,")"));break;case"middle":ae=Rhe("calc(".concat((I.length-1)/2," * -").concat(i," + (").concat(m," / 2))"));break;default:ae=Rhe("calc(".concat(I.length-1," * -").concat(i,")"));break}var oe=[];if(g){var se=I[0].width,pe=C.width;oe.push("scale(".concat((Us(pe)?pe/se:1)/se,")"))}return B&&oe.push("rotate(".concat(B,", ").concat(K,", ").concat(re,")")),oe.length&&(W.transform=oe.join(" ")),lt.createElement("text",Jge({},Za(W,!0),{x:K,y:re,className:ki("recharts-text",$),textAnchor:_,fill:T.includes("url")?eAe:T}),I.map(function(ie,de){var ce=ie.words.join(q?"":" ");return lt.createElement("tspan",{x:K,dy:de===0?ae:i,key:"".concat(ce,"-").concat(de)},ce)}))};function R1(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function Qqt(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function tbe(e){let t,s,n;e.length!==2?(t=R1,s=(i,d)=>R1(e(i),d),n=(i,d)=>e(i)-d):(t=e===R1||e===Qqt?e:Jqt,s=e,n=e);function a(i,d,m=0,p=i.length){if(m>>1;s(i[g],d)<0?m=g+1:p=g}while(m>>1;s(i[g],d)<=0?m=g+1:p=g}while(mm&&n(i[g-1],d)>-n(i[g],d)?g-1:g}return{left:a,center:l,right:o}}function Jqt(){return 0}function EWe(e){return e===null?NaN:+e}function*eHt(e,t){for(let s of e)s!=null&&(s=+s)>=s&&(yield s)}const tHt=tbe(R1),G6=tHt.right;tbe(EWe).center;class tAe extends Map{constructor(t,s=nHt){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:s}}),t!=null)for(const[n,a]of t)this.set(n,a)}get(t){return super.get(rAe(this,t))}has(t){return super.has(rAe(this,t))}set(t,s){return super.set(rHt(this,t),s)}delete(t){return super.delete(sHt(this,t))}}function rAe({_intern:e,_key:t},s){const n=t(s);return e.has(n)?e.get(n):s}function rHt({_intern:e,_key:t},s){const n=t(s);return e.has(n)?e.get(n):(e.set(n,s),s)}function sHt({_intern:e,_key:t},s){const n=t(s);return e.has(n)&&(s=e.get(n),e.delete(n)),s}function nHt(e){return e!==null&&typeof e=="object"?e.valueOf():e}function aHt(e=R1){if(e===R1)return IWe;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,s)=>{const n=e(t,s);return n||n===0?n:(e(s,s)===0)-(e(t,t)===0)}}function IWe(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const iHt=Math.sqrt(50),oHt=Math.sqrt(10),lHt=Math.sqrt(2);function Fne(e,t,s){const n=(t-e)/Math.max(0,s),a=Math.floor(Math.log10(n)),o=n/Math.pow(10,a),l=o>=iHt?10:o>=oHt?5:o>=lHt?2:1;let i,d,m;return a<0?(m=Math.pow(10,-a)/l,i=Math.round(e*m),d=Math.round(t*m),i/mt&&--d,m=-m):(m=Math.pow(10,a)*l,i=Math.round(e/m),d=Math.round(t/m),i*mt&&--d),d0))return[];if(e===t)return[e];const n=t=a))return[];const i=o-a+1,d=new Array(i);if(n)if(l<0)for(let m=0;m=n)&&(s=n);return s}function nAe(e,t){let s;for(const n of e)n!=null&&(s>n||s===void 0&&n>=n)&&(s=n);return s}function PWe(e,t,s=0,n=1/0,a){if(t=Math.floor(t),s=Math.floor(Math.max(0,s)),n=Math.floor(Math.min(e.length-1,n)),!(s<=t&&t<=n))return e;for(a=a===void 0?IWe:aHt(a);n>s;){if(n-s>600){const d=n-s+1,m=t-s+1,p=Math.log(d),g=.5*Math.exp(2*p/3),v=.5*Math.sqrt(p*g*(d-g)/d)*(m-d/2<0?-1:1),_=Math.max(s,Math.floor(t-m*g/d+v)),k=Math.min(n,Math.floor(t+(d-m)*g/d+v));PWe(e,t,_,k,a)}const o=e[t];let l=s,i=n;for(NA(e,s,t),a(e[n],o)>0&&NA(e,s,n);l0;)--i}a(e[s],o)===0?NA(e,s,i):(++i,NA(e,i,n)),i<=t&&(s=i+1),t<=i&&(n=i-1)}return e}function NA(e,t,s){const n=e[t];e[t]=e[s],e[s]=n}function cHt(e,t,s){if(e=Float64Array.from(eHt(e)),!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return nAe(e);if(t>=1)return sAe(e);var n,a=(n-1)*t,o=Math.floor(a),l=sAe(PWe(e,o).subarray(0,o+1)),i=nAe(e.subarray(o+1));return l+(i-l)*(a-o)}}function dHt(e,t,s=EWe){if(!(!(n=e.length)||isNaN(t=+t))){if(t<=0||n<2)return+s(e[0],0,e);if(t>=1)return+s(e[n-1],n-1,e);var n,a=(n-1)*t,o=Math.floor(a),l=+s(e[o],o,e),i=+s(e[o+1],o+1,e);return l+(i-l)*(a-o)}}function uHt(e,t,s){e=+e,t=+t,s=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+s;for(var n=-1,a=Math.max(0,Math.ceil((t-e)/s))|0,o=new Array(a);++n>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):s===8?n8(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):s===4?n8(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=mHt.exec(e))?new Zh(t[1],t[2],t[3],1):(t=fHt.exec(e))?new Zh(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=pHt.exec(e))?n8(t[1],t[2],t[3],t[4]):(t=gHt.exec(e))?n8(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=xHt.exec(e))?uAe(t[1],t[2]/100,t[3]/100,1):(t=yHt.exec(e))?uAe(t[1],t[2]/100,t[3]/100,t[4]):aAe.hasOwnProperty(e)?lAe(aAe[e]):e==="transparent"?new Zh(NaN,NaN,NaN,0):null}function lAe(e){return new Zh(e>>16&255,e>>8&255,e&255,1)}function n8(e,t,s,n){return n<=0&&(e=t=s=NaN),new Zh(e,t,s,n)}function bHt(e){return e instanceof K6||(e=CP(e)),e?(e=e.rgb(),new Zh(e.r,e.g,e.b,e.opacity)):new Zh}function nxe(e,t,s,n){return arguments.length===1?bHt(e):new Zh(e,t,s,n??1)}function Zh(e,t,s,n){this.r=+e,this.g=+t,this.b=+s,this.opacity=+n}sbe(Zh,nxe,DWe(K6,{brighter(e){return e=e==null?zne:Math.pow(zne,e),new Zh(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?NP:Math.pow(NP,e),new Zh(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Zh(zk(this.r),zk(this.g),zk(this.b),Bne(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:cAe,formatHex:cAe,formatHex8:wHt,formatRgb:dAe,toString:dAe}));function cAe(){return`#${Yj(this.r)}${Yj(this.g)}${Yj(this.b)}`}function wHt(){return`#${Yj(this.r)}${Yj(this.g)}${Yj(this.b)}${Yj((isNaN(this.opacity)?1:this.opacity)*255)}`}function dAe(){const e=Bne(this.opacity);return`${e===1?"rgb(":"rgba("}${zk(this.r)}, ${zk(this.g)}, ${zk(this.b)}${e===1?")":`, ${e})`}`}function Bne(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function zk(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Yj(e){return e=zk(e),(e<16?"0":"")+e.toString(16)}function uAe(e,t,s,n){return n<=0?e=t=s=NaN:s<=0||s>=1?e=t=NaN:t<=0&&(e=NaN),new Gp(e,t,s,n)}function OWe(e){if(e instanceof Gp)return new Gp(e.h,e.s,e.l,e.opacity);if(e instanceof K6||(e=CP(e)),!e)return new Gp;if(e instanceof Gp)return e;e=e.rgb();var t=e.r/255,s=e.g/255,n=e.b/255,a=Math.min(t,s,n),o=Math.max(t,s,n),l=NaN,i=o-a,d=(o+a)/2;return i?(t===o?l=(s-n)/i+(s0&&d<1?0:l,new Gp(l,i,d,e.opacity)}function jHt(e,t,s,n){return arguments.length===1?OWe(e):new Gp(e,t,s,n??1)}function Gp(e,t,s,n){this.h=+e,this.s=+t,this.l=+s,this.opacity=+n}sbe(Gp,jHt,DWe(K6,{brighter(e){return e=e==null?zne:Math.pow(zne,e),new Gp(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?NP:Math.pow(NP,e),new Gp(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,s=this.l,n=s+(s<.5?s:1-s)*t,a=2*s-n;return new Zh(Fhe(e>=240?e-240:e+120,a,n),Fhe(e,a,n),Fhe(e<120?e+240:e-120,a,n),this.opacity)},clamp(){return new Gp(hAe(this.h),a8(this.s),a8(this.l),Bne(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 e=Bne(this.opacity);return`${e===1?"hsl(":"hsla("}${hAe(this.h)}, ${a8(this.s)*100}%, ${a8(this.l)*100}%${e===1?")":`, ${e})`}`}}));function hAe(e){return e=(e||0)%360,e<0?e+360:e}function a8(e){return Math.max(0,Math.min(1,e||0))}function Fhe(e,t,s){return(e<60?t+(s-t)*e/60:e<180?s:e<240?t+(s-t)*(240-e)/60:t)*255}const nbe=e=>()=>e;function kHt(e,t){return function(s){return e+s*t}}function NHt(e,t,s){return e=Math.pow(e,s),t=Math.pow(t,s)-e,s=1/s,function(n){return Math.pow(e+n*t,s)}}function SHt(e){return(e=+e)==1?RWe:function(t,s){return s-t?NHt(t,s,e):nbe(isNaN(t)?s:t)}}function RWe(e,t){var s=t-e;return s?kHt(e,s):nbe(isNaN(e)?t:e)}const mAe=function e(t){var s=SHt(t);function n(a,o){var l=s((a=nxe(a)).r,(o=nxe(o)).r),i=s(a.g,o.g),d=s(a.b,o.b),m=RWe(a.opacity,o.opacity);return function(p){return a.r=l(p),a.g=i(p),a.b=d(p),a.opacity=m(p),a+""}}return n.gamma=e,n}(1);function CHt(e,t){t||(t=[]);var s=e?Math.min(t.length,e.length):0,n=t.slice(),a;return function(o){for(a=0;as&&(o=t.slice(s,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:$ne(n,a)})),s=zhe.lastIndex;return st&&(s=e,e=t,t=s),function(n){return Math.max(e,Math.min(t,n))}}function FHt(e,t,s){var n=e[0],a=e[1],o=t[0],l=t[1];return a2?zHt:FHt,d=m=null,g}function g(v){return v==null||isNaN(v=+v)?o:(d||(d=i(e.map(n),t,s)))(n(l(v)))}return g.invert=function(v){return l(a((m||(m=i(t,e.map(n),$ne)))(v)))},g.domain=function(v){return arguments.length?(e=Array.from(v,Une),p()):e.slice()},g.range=function(v){return arguments.length?(t=Array.from(v),p()):t.slice()},g.rangeRound=function(v){return t=Array.from(v),s=abe,p()},g.clamp=function(v){return arguments.length?(l=v?!0:ph,p()):l!==ph},g.interpolate=function(v){return arguments.length?(s=v,p()):s},g.unknown=function(v){return arguments.length?(o=v,g):o},function(v,_){return n=v,a=_,p()}}function ibe(){return Woe()(ph,ph)}function BHt(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Vne(e,t){if((s=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var s,n=e.slice(0,s);return[n.length>1?n[0]+n.slice(2):n,+e.slice(s+1)]}function Y5(e){return e=Vne(Math.abs(e)),e?e[1]:NaN}function $Ht(e,t){return function(s,n){for(var a=s.length,o=[],l=0,i=e[0],d=0;a>0&&i>0&&(d+i+1>n&&(i=Math.max(1,n-d)),o.push(s.substring(a-=i,a+i)),!((d+=i+1)>n));)i=e[l=(l+1)%e.length];return o.reverse().join(t)}}function UHt(e){return function(t){return t.replace(/[0-9]/g,function(s){return e[+s]})}}var VHt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function MP(e){if(!(t=VHt.exec(e)))throw new Error("invalid format: "+e);var t;return new obe({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}MP.prototype=obe.prototype;function obe(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}obe.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 qHt(e){e:for(var t=e.length,s=1,n=-1,a;s0&&(n=0);break}return n>0?e.slice(0,n)+e.slice(a+1):e}var FWe;function HHt(e,t){var s=Vne(e,t);if(!s)return e+"";var n=s[0],a=s[1],o=a-(FWe=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")+Vne(e,Math.max(0,t+o-1))[0]}function pAe(e,t){var s=Vne(e,t);if(!s)return e+"";var n=s[0],a=s[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 gAe={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:BHt,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>pAe(e*100,t),r:pAe,s:HHt,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function xAe(e){return e}var yAe=Array.prototype.map,vAe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function WHt(e){var t=e.grouping===void 0||e.thousands===void 0?xAe:$Ht(yAe.call(e.grouping,Number),e.thousands+""),s=e.currency===void 0?"":e.currency[0]+"",n=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",o=e.numerals===void 0?xAe:UHt(yAe.call(e.numerals,String)),l=e.percent===void 0?"%":e.percent+"",i=e.minus===void 0?"−":e.minus+"",d=e.nan===void 0?"NaN":e.nan+"";function m(g){g=MP(g);var v=g.fill,_=g.align,k=g.sign,w=g.symbol,S=g.zero,T=g.width,C=g.comma,I=g.precision,R=g.trim,D=g.type;D==="n"?(C=!0,D="g"):gAe[D]||(I===void 0&&(I=12),R=!0,D="g"),(S||v==="0"&&_==="=")&&(S=!0,v="0",_="=");var B=w==="$"?s:w==="#"&&/[boxX]/.test(D)?"0"+D.toLowerCase():"",$=w==="$"?n:/[%p]/.test(D)?l:"",q=gAe[D],W=/[defgprs%]/.test(D);I=I===void 0?6:/[gprs]/.test(D)?Math.max(1,Math.min(21,I)):Math.max(0,Math.min(20,I));function K(re){var ae=B,oe=$,se,pe,ie;if(D==="c")oe=q(re)+oe,re="";else{re=+re;var de=re<0||1/re<0;if(re=isNaN(re)?d:q(Math.abs(re),I),R&&(re=qHt(re)),de&&+re==0&&k!=="+"&&(de=!1),ae=(de?k==="("?k:i:k==="-"||k==="("?"":k)+ae,oe=(D==="s"?vAe[8+FWe/3]:"")+oe+(de&&k==="("?")":""),W){for(se=-1,pe=re.length;++seie||ie>57){oe=(ie===46?a+re.slice(se+1):re.slice(se))+oe,re=re.slice(0,se);break}}}C&&!S&&(re=t(re,1/0));var ce=ae.length+re.length+oe.length,ge=ce>1)+ae+re+oe+ge.slice(ce);break;default:re=ge+ae+re+oe;break}return o(re)}return K.toString=function(){return g+""},K}function p(g,v){var _=m((g=MP(g),g.type="f",g)),k=Math.max(-8,Math.min(8,Math.floor(Y5(v)/3)))*3,w=Math.pow(10,-k),S=vAe[8+k/3];return function(T){return _(w*T)+S}}return{format:m,formatPrefix:p}}var i8,lbe,zWe;GHt({thousands:",",grouping:[3],currency:["$",""]});function GHt(e){return i8=WHt(e),lbe=i8.format,zWe=i8.formatPrefix,i8}function KHt(e){return Math.max(0,-Y5(Math.abs(e)))}function ZHt(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Y5(t)/3)))*3-Y5(Math.abs(e)))}function YHt(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Y5(t)-Y5(e))+1}function BWe(e,t,s,n){var a=rxe(e,t,s),o;switch(n=MP(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(e),Math.abs(t));return n.precision==null&&!isNaN(o=ZHt(a,l))&&(n.precision=o),zWe(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=YHt(a,Math.max(Math.abs(e),Math.abs(t))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=KHt(a))&&(n.precision=o-(n.type==="%")*2);break}}return lbe(n)}function m_(e){var t=e.domain;return e.ticks=function(s){var n=t();return exe(n[0],n[n.length-1],s??10)},e.tickFormat=function(s,n){var a=t();return BWe(a[0],a[a.length-1],s??10,n)},e.nice=function(s){s==null&&(s=10);var n=t(),a=0,o=n.length-1,l=n[a],i=n[o],d,m,p=10;for(i0;){if(m=txe(l,i,s),m===d)return n[a]=l,n[o]=i,t(n);if(m>0)l=Math.floor(l/m)*m,i=Math.ceil(i/m)*m;else if(m<0)l=Math.ceil(l*m)/m,i=Math.floor(i*m)/m;else break;d=m}return e},e}function qne(){var e=ibe();return e.copy=function(){return Z6(e,qne())},Jf.apply(e,arguments),m_(e)}function $We(e){var t;function s(n){return n==null||isNaN(n=+n)?t:n}return s.invert=s,s.domain=s.range=function(n){return arguments.length?(e=Array.from(n,Une),s):e.slice()},s.unknown=function(n){return arguments.length?(t=n,s):t},s.copy=function(){return $We(e).unknown(t)},e=arguments.length?Array.from(e,Une):[0,1],m_(s)}function UWe(e,t){e=e.slice();var s=0,n=e.length-1,a=e[s],o=e[n],l;return oMath.pow(e,t)}function tWt(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function wAe(e){return(t,s)=>-e(-t,s)}function cbe(e){const t=e(_Ae,bAe),s=t.domain;let n=10,a,o;function l(){return a=tWt(n),o=eWt(n),s()[0]<0?(a=wAe(a),o=wAe(o),e(XHt,QHt)):e(_Ae,bAe),t}return t.base=function(i){return arguments.length?(n=+i,l()):n},t.domain=function(i){return arguments.length?(s(i),l()):s()},t.ticks=i=>{const d=s();let m=d[0],p=d[d.length-1];const g=p0){for(;v<=_;++v)for(k=1;kp)break;T.push(w)}}else for(;v<=_;++v)for(k=n-1;k>=1;--k)if(w=v>0?k/o(-v):k*o(v),!(wp)break;T.push(w)}T.length*2{if(i==null&&(i=10),d==null&&(d=n===10?"s":","),typeof d!="function"&&(!(n%1)&&(d=MP(d)).precision==null&&(d.trim=!0),d=lbe(d)),i===1/0)return d;const m=Math.max(1,n*i/t.ticks().length);return p=>{let g=p/o(Math.round(a(p)));return g*ns(UWe(s(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),t}function VWe(){const e=cbe(Woe()).domain([1,10]);return e.copy=()=>Z6(e,VWe()).base(e.base()),Jf.apply(e,arguments),e}function jAe(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function kAe(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function dbe(e){var t=1,s=e(jAe(t),kAe(t));return s.constant=function(n){return arguments.length?e(jAe(t=+n),kAe(t)):t},m_(s)}function qWe(){var e=dbe(Woe());return e.copy=function(){return Z6(e,qWe()).constant(e.constant())},Jf.apply(e,arguments)}function NAe(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function rWt(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function sWt(e){return e<0?-e*e:e*e}function ube(e){var t=e(ph,ph),s=1;function n(){return s===1?e(ph,ph):s===.5?e(rWt,sWt):e(NAe(s),NAe(1/s))}return t.exponent=function(a){return arguments.length?(s=+a,n()):s},m_(t)}function hbe(){var e=ube(Woe());return e.copy=function(){return Z6(e,hbe()).exponent(e.exponent())},Jf.apply(e,arguments),e}function nWt(){return hbe.apply(null,arguments).exponent(.5)}function SAe(e){return Math.sign(e)*e*e}function aWt(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function HWe(){var e=ibe(),t=[0,1],s=!1,n;function a(o){var l=aWt(e(o));return isNaN(l)?n:s?Math.round(l):l}return a.invert=function(o){return e.invert(SAe(o))},a.domain=function(o){return arguments.length?(e.domain(o),a):e.domain()},a.range=function(o){return arguments.length?(e.range((t=Array.from(o,Une)).map(SAe)),a):t.slice()},a.rangeRound=function(o){return a.range(o).round(!0)},a.round=function(o){return arguments.length?(s=!!o,a):s},a.clamp=function(o){return arguments.length?(e.clamp(o),a):e.clamp()},a.unknown=function(o){return arguments.length?(n=o,a):n},a.copy=function(){return HWe(e.domain(),t).round(s).clamp(e.clamp()).unknown(n)},Jf.apply(a,arguments),m_(a)}function WWe(){var e=[],t=[],s=[],n;function a(){var l=0,i=Math.max(1,t.length);for(s=new Array(i-1);++l0?s[i-1]:e[0],i=s?[n[s-1],t]:[n[m-1],n[m]]},l.unknown=function(d){return arguments.length&&(o=d),l},l.thresholds=function(){return n.slice()},l.copy=function(){return GWe().domain([e,t]).range(a).unknown(o)},Jf.apply(m_(l),arguments)}function KWe(){var e=[.5],t=[0,1],s,n=1;function a(o){return o!=null&&o<=o?t[G6(e,o,0,n)]:s}return a.domain=function(o){return arguments.length?(e=Array.from(o),n=Math.min(e.length,t.length-1),a):e.slice()},a.range=function(o){return arguments.length?(t=Array.from(o),n=Math.min(e.length,t.length-1),a):t.slice()},a.invertExtent=function(o){var l=t.indexOf(o);return[e[l-1],e[l]]},a.unknown=function(o){return arguments.length?(s=o,a):s},a.copy=function(){return KWe().domain(e).range(t).unknown(s)},Jf.apply(a,arguments)}const Bhe=new Date,$he=new Date;function Ad(e,t,s,n){function a(o){return e(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(e(o=new Date(+o)),o),a.ceil=o=>(e(o=new Date(o-1)),t(o,1),e(o),o),a.round=o=>{const l=a(o),i=a.ceil(o);return o-l(t(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 m;do d.push(m=new Date(+o)),t(o,i),e(o);while(mAd(l=>{if(l>=l)for(;e(l),!o(l);)l.setTime(l-1)},(l,i)=>{if(l>=l)if(i<0)for(;++i<=0;)for(;t(l,-1),!o(l););else for(;--i>=0;)for(;t(l,1),!o(l););}),s&&(a.count=(o,l)=>(Bhe.setTime(+o),$he.setTime(+l),e(Bhe),e($he),Math.floor(s(Bhe,$he))),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 Hne=Ad(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Hne.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?Ad(t=>{t.setTime(Math.floor(t/e)*e)},(t,s)=>{t.setTime(+t+s*e)},(t,s)=>(s-t)/e):Hne);Hne.range;const Ay=1e3,Af=Ay*60,Ey=Af*60,u0=Ey*24,mbe=u0*7,CAe=u0*30,Uhe=u0*365,Xj=Ad(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Ay)},(e,t)=>(t-e)/Ay,e=>e.getUTCSeconds());Xj.range;const fbe=Ad(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Ay)},(e,t)=>{e.setTime(+e+t*Af)},(e,t)=>(t-e)/Af,e=>e.getMinutes());fbe.range;const pbe=Ad(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Af)},(e,t)=>(t-e)/Af,e=>e.getUTCMinutes());pbe.range;const gbe=Ad(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Ay-e.getMinutes()*Af)},(e,t)=>{e.setTime(+e+t*Ey)},(e,t)=>(t-e)/Ey,e=>e.getHours());gbe.range;const xbe=Ad(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Ey)},(e,t)=>(t-e)/Ey,e=>e.getUTCHours());xbe.range;const Y6=Ad(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Af)/u0,e=>e.getDate()-1);Y6.range;const Goe=Ad(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/u0,e=>e.getUTCDate()-1);Goe.range;const ZWe=Ad(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/u0,e=>Math.floor(e/u0));ZWe.range;function SN(e){return Ad(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,s)=>{t.setDate(t.getDate()+s*7)},(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*Af)/mbe)}const Koe=SN(0),Wne=SN(1),iWt=SN(2),oWt=SN(3),X5=SN(4),lWt=SN(5),cWt=SN(6);Koe.range;Wne.range;iWt.range;oWt.range;X5.range;lWt.range;cWt.range;function CN(e){return Ad(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s*7)},(t,s)=>(s-t)/mbe)}const Zoe=CN(0),Gne=CN(1),dWt=CN(2),uWt=CN(3),Q5=CN(4),hWt=CN(5),mWt=CN(6);Zoe.range;Gne.range;dWt.range;uWt.range;Q5.range;hWt.range;mWt.range;const ybe=Ad(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());ybe.range;const vbe=Ad(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());vbe.range;const h0=Ad(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());h0.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ad(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,s)=>{t.setFullYear(t.getFullYear()+s*e)});h0.range;const m0=Ad(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());m0.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:Ad(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCFullYear(t.getUTCFullYear()+s*e)});m0.range;function YWe(e,t,s,n,a,o){const l=[[Xj,1,Ay],[Xj,5,5*Ay],[Xj,15,15*Ay],[Xj,30,30*Ay],[o,1,Af],[o,5,5*Af],[o,15,15*Af],[o,30,30*Af],[a,1,Ey],[a,3,3*Ey],[a,6,6*Ey],[a,12,12*Ey],[n,1,u0],[n,2,2*u0],[s,1,mbe],[t,1,CAe],[t,3,3*CAe],[e,1,Uhe]];function i(m,p,g){const v=pS).right(l,v);if(_===l.length)return e.every(rxe(m/Uhe,p/Uhe,g));if(_===0)return Hne.every(Math.max(rxe(m,p,g),1));const[k,w]=l[v/l[_-1][2]53)return null;"w"in Pe||(Pe.w=1),"Z"in Pe?(ue=qhe(SA(Pe.y,0,1)),$e=ue.getUTCDay(),ue=$e>4||$e===0?Gne.ceil(ue):Gne(ue),ue=Goe.offset(ue,(Pe.V-1)*7),Pe.y=ue.getUTCFullYear(),Pe.m=ue.getUTCMonth(),Pe.d=ue.getUTCDate()+(Pe.w+6)%7):(ue=Vhe(SA(Pe.y,0,1)),$e=ue.getDay(),ue=$e>4||$e===0?Wne.ceil(ue):Wne(ue),ue=Y6.offset(ue,(Pe.V-1)*7),Pe.y=ue.getFullYear(),Pe.m=ue.getMonth(),Pe.d=ue.getDate()+(Pe.w+6)%7)}else("W"in Pe||"U"in Pe)&&("w"in Pe||(Pe.w="u"in Pe?Pe.u%7:"W"in Pe?1:0),$e="Z"in Pe?qhe(SA(Pe.y,0,1)).getUTCDay():Vhe(SA(Pe.y,0,1)).getDay(),Pe.m=0,Pe.d="W"in Pe?(Pe.w+6)%7+Pe.W*7-($e+5)%7:Pe.w+Pe.U*7-($e+6)%7);return"Z"in Pe?(Pe.H+=Pe.Z/100|0,Pe.M+=Pe.Z%100,qhe(Pe)):Vhe(Pe)}}function q(Ie,We,wt,Pe){for(var st=0,ue=We.length,$e=wt.length,tt,rt;st=$e)return-1;if(tt=We.charCodeAt(st++),tt===37){if(tt=We.charAt(st++),rt=D[tt in MAe?We.charAt(st++):tt],!rt||(Pe=rt(Ie,wt,Pe))<0)return-1}else if(tt!=wt.charCodeAt(Pe++))return-1}return Pe}function W(Ie,We,wt){var Pe=m.exec(We.slice(wt));return Pe?(Ie.p=p.get(Pe[0].toLowerCase()),wt+Pe[0].length):-1}function K(Ie,We,wt){var Pe=_.exec(We.slice(wt));return Pe?(Ie.w=k.get(Pe[0].toLowerCase()),wt+Pe[0].length):-1}function re(Ie,We,wt){var Pe=g.exec(We.slice(wt));return Pe?(Ie.w=v.get(Pe[0].toLowerCase()),wt+Pe[0].length):-1}function ae(Ie,We,wt){var Pe=T.exec(We.slice(wt));return Pe?(Ie.m=C.get(Pe[0].toLowerCase()),wt+Pe[0].length):-1}function oe(Ie,We,wt){var Pe=w.exec(We.slice(wt));return Pe?(Ie.m=S.get(Pe[0].toLowerCase()),wt+Pe[0].length):-1}function se(Ie,We,wt){return q(Ie,t,We,wt)}function pe(Ie,We,wt){return q(Ie,s,We,wt)}function ie(Ie,We,wt){return q(Ie,n,We,wt)}function de(Ie){return l[Ie.getDay()]}function ce(Ie){return o[Ie.getDay()]}function ge(Ie){return d[Ie.getMonth()]}function Te(Ie){return i[Ie.getMonth()]}function _e(Ie){return a[+(Ie.getHours()>=12)]}function ve(Ie){return 1+~~(Ie.getMonth()/3)}function Me(Ie){return l[Ie.getUTCDay()]}function Ze(Ie){return o[Ie.getUTCDay()]}function Ae(Ie){return d[Ie.getUTCMonth()]}function Le(Ie){return i[Ie.getUTCMonth()]}function Ue(Ie){return a[+(Ie.getUTCHours()>=12)]}function Ve(Ie){return 1+~~(Ie.getUTCMonth()/3)}return{format:function(Ie){var We=B(Ie+="",I);return We.toString=function(){return Ie},We},parse:function(Ie){var We=$(Ie+="",!1);return We.toString=function(){return Ie},We},utcFormat:function(Ie){var We=B(Ie+="",R);return We.toString=function(){return Ie},We},utcParse:function(Ie){var We=$(Ie+="",!0);return We.toString=function(){return Ie},We}}}var MAe={"-":"",_:" ",0:"0"},Qd=/^\s*\d+/,vWt=/^%/,_Wt=/[\\^$*+?|[\]().{}]/g;function ko(e,t,s){var n=e<0?"-":"",a=(n?-e:e)+"",o=a.length;return n+(o[t.toLowerCase(),s]))}function wWt(e,t,s){var n=Qd.exec(t.slice(s,s+1));return n?(e.w=+n[0],s+n[0].length):-1}function jWt(e,t,s){var n=Qd.exec(t.slice(s,s+1));return n?(e.u=+n[0],s+n[0].length):-1}function kWt(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.U=+n[0],s+n[0].length):-1}function NWt(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.V=+n[0],s+n[0].length):-1}function SWt(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.W=+n[0],s+n[0].length):-1}function TAe(e,t,s){var n=Qd.exec(t.slice(s,s+4));return n?(e.y=+n[0],s+n[0].length):-1}function AAe(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.y=+n[0]+(+n[0]>68?1900:2e3),s+n[0].length):-1}function CWt(e,t,s){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(s,s+6));return n?(e.Z=n[1]?0:-(n[2]+(n[3]||"00")),s+n[0].length):-1}function MWt(e,t,s){var n=Qd.exec(t.slice(s,s+1));return n?(e.q=n[0]*3-3,s+n[0].length):-1}function TWt(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.m=n[0]-1,s+n[0].length):-1}function EAe(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.d=+n[0],s+n[0].length):-1}function AWt(e,t,s){var n=Qd.exec(t.slice(s,s+3));return n?(e.m=0,e.d=+n[0],s+n[0].length):-1}function IAe(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.H=+n[0],s+n[0].length):-1}function EWt(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.M=+n[0],s+n[0].length):-1}function IWt(e,t,s){var n=Qd.exec(t.slice(s,s+2));return n?(e.S=+n[0],s+n[0].length):-1}function PWt(e,t,s){var n=Qd.exec(t.slice(s,s+3));return n?(e.L=+n[0],s+n[0].length):-1}function LWt(e,t,s){var n=Qd.exec(t.slice(s,s+6));return n?(e.L=Math.floor(n[0]/1e3),s+n[0].length):-1}function DWt(e,t,s){var n=vWt.exec(t.slice(s,s+1));return n?s+n[0].length:-1}function OWt(e,t,s){var n=Qd.exec(t.slice(s));return n?(e.Q=+n[0],s+n[0].length):-1}function RWt(e,t,s){var n=Qd.exec(t.slice(s));return n?(e.s=+n[0],s+n[0].length):-1}function PAe(e,t){return ko(e.getDate(),t,2)}function FWt(e,t){return ko(e.getHours(),t,2)}function zWt(e,t){return ko(e.getHours()%12||12,t,2)}function BWt(e,t){return ko(1+Y6.count(h0(e),e),t,3)}function XWe(e,t){return ko(e.getMilliseconds(),t,3)}function $Wt(e,t){return XWe(e,t)+"000"}function UWt(e,t){return ko(e.getMonth()+1,t,2)}function VWt(e,t){return ko(e.getMinutes(),t,2)}function qWt(e,t){return ko(e.getSeconds(),t,2)}function HWt(e){var t=e.getDay();return t===0?7:t}function WWt(e,t){return ko(Koe.count(h0(e)-1,e),t,2)}function QWe(e){var t=e.getDay();return t>=4||t===0?X5(e):X5.ceil(e)}function GWt(e,t){return e=QWe(e),ko(X5.count(h0(e),e)+(h0(e).getDay()===4),t,2)}function KWt(e){return e.getDay()}function ZWt(e,t){return ko(Wne.count(h0(e)-1,e),t,2)}function YWt(e,t){return ko(e.getFullYear()%100,t,2)}function XWt(e,t){return e=QWe(e),ko(e.getFullYear()%100,t,2)}function QWt(e,t){return ko(e.getFullYear()%1e4,t,4)}function JWt(e,t){var s=e.getDay();return e=s>=4||s===0?X5(e):X5.ceil(e),ko(e.getFullYear()%1e4,t,4)}function eGt(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+ko(t/60|0,"0",2)+ko(t%60,"0",2)}function LAe(e,t){return ko(e.getUTCDate(),t,2)}function tGt(e,t){return ko(e.getUTCHours(),t,2)}function rGt(e,t){return ko(e.getUTCHours()%12||12,t,2)}function sGt(e,t){return ko(1+Goe.count(m0(e),e),t,3)}function JWe(e,t){return ko(e.getUTCMilliseconds(),t,3)}function nGt(e,t){return JWe(e,t)+"000"}function aGt(e,t){return ko(e.getUTCMonth()+1,t,2)}function iGt(e,t){return ko(e.getUTCMinutes(),t,2)}function oGt(e,t){return ko(e.getUTCSeconds(),t,2)}function lGt(e){var t=e.getUTCDay();return t===0?7:t}function cGt(e,t){return ko(Zoe.count(m0(e)-1,e),t,2)}function eGe(e){var t=e.getUTCDay();return t>=4||t===0?Q5(e):Q5.ceil(e)}function dGt(e,t){return e=eGe(e),ko(Q5.count(m0(e),e)+(m0(e).getUTCDay()===4),t,2)}function uGt(e){return e.getUTCDay()}function hGt(e,t){return ko(Gne.count(m0(e)-1,e),t,2)}function mGt(e,t){return ko(e.getUTCFullYear()%100,t,2)}function fGt(e,t){return e=eGe(e),ko(e.getUTCFullYear()%100,t,2)}function pGt(e,t){return ko(e.getUTCFullYear()%1e4,t,4)}function gGt(e,t){var s=e.getUTCDay();return e=s>=4||s===0?Q5(e):Q5.ceil(e),ko(e.getUTCFullYear()%1e4,t,4)}function xGt(){return"+0000"}function DAe(){return"%"}function OAe(e){return+e}function RAe(e){return Math.floor(+e/1e3)}var TC,tGe,rGe;yGt({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 yGt(e){return TC=yWt(e),tGe=TC.format,TC.parse,rGe=TC.utcFormat,TC.utcParse,TC}function vGt(e){return new Date(e)}function _Gt(e){return e instanceof Date?+e:+new Date(+e)}function _be(e,t,s,n,a,o,l,i,d,m){var p=ibe(),g=p.invert,v=p.domain,_=m(".%L"),k=m(":%S"),w=m("%I:%M"),S=m("%I %p"),T=m("%a %d"),C=m("%b %d"),I=m("%B"),R=m("%Y");function D(B){return(d(B)t(a/(e.length-1)))},s.quantiles=function(n){return Array.from({length:n+1},(a,o)=>cHt(e,o/n))},s.copy=function(){return iGe(t).domain(e)},_0.apply(s,arguments)}function Xoe(){var e=0,t=.5,s=1,n=1,a,o,l,i,d,m=ph,p,g=!1,v;function _(w){return isNaN(w=+w)?v:(w=.5+((w=+p(w))-o)*(n*wt}var dGe=CGt,MGt=Qoe,TGt=dGe,AGt=Q3;function EGt(e){return e&&e.length?MGt(e,AGt,TGt):void 0}var IGt=EGt;const Joe=ho(IGt);function PGt(e,t){return ee.e^o.s<0?1:-1;for(n=o.d.length,a=e.d.length,t=0,s=ne.d[t]^o.s<0?1:-1;return n===a?0:n>a^o.s<0?1:-1};On.decimalPlaces=On.dp=function(){var e=this,t=e.d.length-1,s=(t-e.e)*jl;if(t=e.d[t],t)for(;t%10==0;t/=10)s--;return s<0?0:s};On.dividedBy=On.div=function(e){return Zy(this,new this.constructor(e))};On.dividedToIntegerBy=On.idiv=function(e){var t=this,s=t.constructor;return Jo(Zy(t,new s(e),0,1),s.precision)};On.equals=On.eq=function(e){return!this.cmp(e)};On.exponent=function(){return ud(this)};On.greaterThan=On.gt=function(e){return this.cmp(e)>0};On.greaterThanOrEqualTo=On.gte=function(e){return this.cmp(e)>=0};On.isInteger=On.isint=function(){return this.e>this.d.length-2};On.isNegative=On.isneg=function(){return this.s<0};On.isPositive=On.ispos=function(){return this.s>0};On.isZero=function(){return this.s===0};On.lessThan=On.lt=function(e){return this.cmp(e)<0};On.lessThanOrEqualTo=On.lte=function(e){return this.cmp(e)<1};On.logarithm=On.log=function(e){var t,s=this,n=s.constructor,a=n.precision,o=a+5;if(e===void 0)e=new n(10);else if(e=new n(e),e.s<1||e.eq(Am))throw Error(Kf+"NaN");if(s.s<1)throw Error(Kf+(s.s?"NaN":"-Infinity"));return s.eq(Am)?new n(0):(Ol=!1,t=Zy(TP(s,o),TP(e,o),o),Ol=!0,Jo(t,a))};On.minus=On.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?pGe(t,e):mGe(t,(e.s=-e.s,e))};On.modulo=On.mod=function(e){var t,s=this,n=s.constructor,a=n.precision;if(e=new n(e),!e.s)throw Error(Kf+"NaN");return s.s?(Ol=!1,t=Zy(s,e,0,1).times(e),Ol=!0,s.minus(t)):Jo(new n(s),a)};On.naturalExponential=On.exp=function(){return fGe(this)};On.naturalLogarithm=On.ln=function(){return TP(this)};On.negated=On.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};On.plus=On.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?mGe(t,e):pGe(t,(e.s=-e.s,e))};On.precision=On.sd=function(e){var t,s,n,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Bk+e);if(t=ud(a)+1,n=a.d.length-1,s=n*jl+1,n=a.d[n],n){for(;n%10==0;n/=10)s--;for(n=a.d[0];n>=10;n/=10)s++}return e&&t>s?t:s};On.squareRoot=On.sqrt=function(){var e,t,s,n,a,o,l,i=this,d=i.constructor;if(i.s<1){if(!i.s)return new d(0);throw Error(Kf+"NaN")}for(e=ud(i),Ol=!1,a=Math.sqrt(+i),a==0||a==1/0?(t=ax(i.d),(t.length+e)%2==0&&(t+="0"),a=Math.sqrt(t),e=rM((e+1)/2)-(e<0||e%2),a==1/0?t="5e"+e:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),n=new d(t)):n=new d(a.toString()),s=d.precision,a=l=s+3;;)if(o=n,n=o.plus(Zy(i,o,l+2)).times(.5),ax(o.d).slice(0,l)===(t=ax(n.d)).slice(0,l)){if(t=t.slice(l-3,l+1),a==l&&t=="4999"){if(Jo(o,s+1,0),o.times(o).eq(i)){n=o;break}}else if(t!="9999")break;l+=4}return Ol=!0,Jo(n,s)};On.times=On.mul=function(e){var t,s,n,a,o,l,i,d,m,p=this,g=p.constructor,v=p.d,_=(e=new g(e)).d;if(!p.s||!e.s)return new g(0);for(e.s*=p.s,s=p.e+e.e,d=v.length,m=_.length,d=0;){for(t=0,a=d+n;a>n;)i=o[a]+_[n]*v[a-n-1]+t,o[a--]=i%Bd|0,t=i/Bd|0;o[a]=(o[a]+t)%Bd|0}for(;!o[--l];)o.pop();return t?++s:o.shift(),e.d=o,e.e=s,Ol?Jo(e,g.precision):e};On.toDecimalPlaces=On.todp=function(e,t){var s=this,n=s.constructor;return s=new n(s),e===void 0?s:(Tx(e,0,tM),t===void 0?t=n.rounding:Tx(t,0,8),Jo(s,e+ud(s)+1,t))};On.toExponential=function(e,t){var s,n=this,a=n.constructor;return e===void 0?s=uN(n,!0):(Tx(e,0,tM),t===void 0?t=a.rounding:Tx(t,0,8),n=Jo(new a(n),e+1,t),s=uN(n,!0,e+1)),s};On.toFixed=function(e,t){var s,n,a=this,o=a.constructor;return e===void 0?uN(a):(Tx(e,0,tM),t===void 0?t=o.rounding:Tx(t,0,8),n=Jo(new o(a),e+ud(a)+1,t),s=uN(n.abs(),!1,e+ud(n)+1),a.isneg()&&!a.isZero()?"-"+s:s)};On.toInteger=On.toint=function(){var e=this,t=e.constructor;return Jo(new t(e),ud(e)+1,t.rounding)};On.toNumber=function(){return+this};On.toPower=On.pow=function(e){var t,s,n,a,o,l,i=this,d=i.constructor,m=12,p=+(e=new d(e));if(!e.s)return new d(Am);if(i=new d(i),!i.s){if(e.s<1)throw Error(Kf+"Infinity");return i}if(i.eq(Am))return i;if(n=d.precision,e.eq(Am))return Jo(i,n);if(t=e.e,s=e.d.length-1,l=t>=s,o=i.s,l){if((s=p<0?-p:p)<=hGe){for(a=new d(Am),t=Math.ceil(n/jl+4),Ol=!1;s%2&&(a=a.times(i),BAe(a.d,t)),s=rM(s/2),s!==0;)i=i.times(i),BAe(i.d,t);return Ol=!0,e.s<0?new d(Am).div(a):Jo(a,n)}}else if(o<0)throw Error(Kf+"NaN");return o=o<0&&e.d[Math.max(t,s)]&1?-1:1,i.s=1,Ol=!1,a=e.times(TP(i,n+m)),Ol=!0,a=fGe(a),a.s=o,a};On.toPrecision=function(e,t){var s,n,a=this,o=a.constructor;return e===void 0?(s=ud(a),n=uN(a,s<=o.toExpNeg||s>=o.toExpPos)):(Tx(e,1,tM),t===void 0?t=o.rounding:Tx(t,0,8),a=Jo(new o(a),e,t),s=ud(a),n=uN(a,e<=s||s<=o.toExpNeg,e)),n};On.toSignificantDigits=On.tosd=function(e,t){var s=this,n=s.constructor;return e===void 0?(e=n.precision,t=n.rounding):(Tx(e,1,tM),t===void 0?t=n.rounding:Tx(t,0,8)),Jo(new n(s),e,t)};On.toString=On.valueOf=On.val=On.toJSON=On[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=ud(e),s=e.constructor;return uN(e,t<=s.toExpNeg||t>=s.toExpPos)};function mGe(e,t){var s,n,a,o,l,i,d,m,p=e.constructor,g=p.precision;if(!e.s||!t.s)return t.s||(t=new p(e)),Ol?Jo(t,g):t;if(d=e.d,m=t.d,l=e.e,a=t.e,d=d.slice(),o=l-a,o){for(o<0?(n=d,o=-o,i=m.length):(n=m,a=l,i=d.length),l=Math.ceil(g/jl),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=m.length,i-o<0&&(o=i,n=m,m=d,d=n),s=0;o;)s=(d[--o]=d[o]+m[o]+s)/Bd|0,d[o]%=Bd;for(s&&(d.unshift(s),++a),i=d.length;d[--i]==0;)d.pop();return t.d=d,t.e=a,Ol?Jo(t,g):t}function Tx(e,t,s){if(e!==~~e||es)throw Error(Bk+e)}function ax(e){var t,s,n,a=e.length-1,o="",l=e[0];if(a>0){for(o+=l,t=1;tl?1:-1;else for(i=d=0;ia[i]?1:-1;break}return d}function s(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,m,p,g,v,_,k,w,S,T,C,I,R,D,B,$,q,W=n.constructor,K=n.s==a.s?1:-1,re=n.d,ae=a.d;if(!n.s)return new W(n);if(!a.s)throw Error(Kf+"Division by zero");for(d=n.e-a.e,$=ae.length,D=re.length,_=new W(K),k=_.d=[],m=0;ae[m]==(re[m]||0);)++m;if(ae[m]>(re[m]||0)&&--d,o==null?C=o=W.precision:l?C=o+(ud(n)-ud(a))+1:C=o,C<0)return new W(0);if(C=C/jl+2|0,m=0,$==1)for(p=0,ae=ae[0],C++;(m1&&(ae=e(ae,p),re=e(re,p),$=ae.length,D=re.length),R=$,w=re.slice(0,$),S=w.length;S<$;)w[S++]=0;q=ae.slice(),q.unshift(0),B=ae[0],ae[1]>=Bd/2&&++B;do p=0,i=t(ae,w,$,S),i<0?(T=w[0],$!=S&&(T=T*Bd+(w[1]||0)),p=T/B|0,p>1?(p>=Bd&&(p=Bd-1),g=e(ae,p),v=g.length,S=w.length,i=t(g,w,v,S),i==1&&(p--,s(g,$16)throw Error(jbe+ud(e));if(!e.s)return new p(Am);for(Ol=!1,i=g,l=new p(.03125);e.abs().gte(.1);)e=e.times(l),m+=5;for(n=Math.log(Ej(2,m))/Math.LN10*2+5|0,i+=n,s=a=o=new p(Am),p.precision=i;;){if(a=Jo(a.times(e),i),s=s.times(++d),l=o.plus(Zy(a,s,i)),ax(l.d).slice(0,i)===ax(o.d).slice(0,i)){for(;m--;)o=Jo(o.times(o),i);return p.precision=g,t==null?(Ol=!0,Jo(o,g)):o}o=l}}function ud(e){for(var t=e.e*jl,s=e.d[0];s>=10;s/=10)t++;return t}function Hhe(e,t,s){if(t>e.LN10.sd())throw Ol=!0,s&&(e.precision=s),Error(Kf+"LN10 precision limit exceeded");return Jo(new e(e.LN10),t)}function Lv(e){for(var t="";e--;)t+="0";return t}function TP(e,t){var s,n,a,o,l,i,d,m,p,g=1,v=10,_=e,k=_.d,w=_.constructor,S=w.precision;if(_.s<1)throw Error(Kf+(_.s?"NaN":"-Infinity"));if(_.eq(Am))return new w(0);if(t==null?(Ol=!1,m=S):m=t,_.eq(10))return t==null&&(Ol=!0),Hhe(w,m);if(m+=v,w.precision=m,s=ax(k),n=s.charAt(0),o=ud(_),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&s.charAt(1)>3;)_=_.times(e),s=ax(_.d),n=s.charAt(0),g++;o=ud(_),n>1?(_=new w("0."+s),o++):_=new w(n+"."+s.slice(1))}else return d=Hhe(w,m+2,S).times(o+""),_=TP(new w(n+"."+s.slice(1)),m-v).plus(d),w.precision=S,t==null?(Ol=!0,Jo(_,S)):_;for(i=l=_=Zy(_.minus(Am),_.plus(Am),m),p=Jo(_.times(_),m),a=3;;){if(l=Jo(l.times(p),m),d=i.plus(Zy(l,new w(a),m)),ax(d.d).slice(0,m)===ax(i.d).slice(0,m))return i=i.times(2),o!==0&&(i=i.plus(Hhe(w,m+2,S).times(o+""))),i=Zy(i,new w(g),m),w.precision=S,t==null?(Ol=!0,Jo(i,S)):i;i=d,a+=2}}function zAe(e,t){var s,n,a;for((s=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(s<0&&(s=n),s+=+t.slice(n+1),t=t.substring(0,n)):s<0&&(s=t.length),n=0;t.charCodeAt(n)===48;)++n;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(n,a),t){if(a-=n,s=s-n-1,e.e=rM(s/jl),e.d=[],n=(s+1)%jl,s<0&&(n+=jl),nKne||e.e<-Kne))throw Error(jbe+s)}else e.s=0,e.e=0,e.d=[0];return e}function Jo(e,t,s){var n,a,o,l,i,d,m,p,g=e.d;for(l=1,o=g[0];o>=10;o/=10)l++;if(n=t-l,n<0)n+=jl,a=t,m=g[p=0];else{if(p=Math.ceil((n+1)/jl),o=g.length,p>=o)return e;for(m=o=g[p],l=1;o>=10;o/=10)l++;n%=jl,a=n-jl+l}if(s!==void 0&&(o=Ej(10,l-a-1),i=m/o%10|0,d=t<0||g[p+1]!==void 0||m%o,d=s<4?(i||d)&&(s==0||s==(e.s<0?3:2)):i>5||i==5&&(s==4||d||s==6&&(n>0?a>0?m/Ej(10,l-a):0:g[p-1])%10&1||s==(e.s<0?8:7))),t<1||!g[0])return d?(o=ud(e),g.length=1,t=t-o-1,g[0]=Ej(10,(jl-t%jl)%jl),e.e=rM(-t/jl)||0):(g.length=1,g[0]=e.e=e.s=0),e;if(n==0?(g.length=p,o=1,p--):(g.length=p+1,o=Ej(10,jl-n),g[p]=a>0?(m/Ej(10,l-a)%Ej(10,a)|0)*o:0),d)for(;;)if(p==0){(g[0]+=o)==Bd&&(g[0]=1,++e.e);break}else{if(g[p]+=o,g[p]!=Bd)break;g[p--]=0,o=1}for(n=g.length;g[--n]===0;)g.pop();if(Ol&&(e.e>Kne||e.e<-Kne))throw Error(jbe+ud(e));return e}function pGe(e,t){var s,n,a,o,l,i,d,m,p,g,v=e.constructor,_=v.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new v(e),Ol?Jo(t,_):t;if(d=e.d,g=t.d,n=t.e,m=e.e,d=d.slice(),l=m-n,l){for(p=l<0,p?(s=d,l=-l,i=g.length):(s=g,n=m,i=d.length),a=Math.max(Math.ceil(_/jl),i)+2,l>a&&(l=a,s.length=1),s.reverse(),a=l;a--;)s.push(0);s.reverse()}else{for(a=d.length,i=g.length,p=a0;--a)d[i++]=0;for(a=g.length;a>l;){if(d[--a]0?o=o.charAt(0)+"."+o.slice(1)+Lv(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+Lv(-a-1)+o,s&&(n=s-l)>0&&(o+=Lv(n))):a>=l?(o+=Lv(a+1-l),s&&(n=s-a-1)>0&&(o=o+"."+Lv(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=Lv(n))),e.s<0?"-"+o:o}function BAe(e,t){if(e.length>t)return e.length=t,!0}function gGe(e){var t,s,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(Bk+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 zAe(l,o.toString())}else if(typeof o!="string")throw Error(Bk+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,eKt.test(o))zAe(l,o);else throw Error(Bk+o)}if(a.prototype=On,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=gGe,a.config=a.set=tKt,e===void 0&&(e={}),e)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t=a[t+1]&&n<=a[t+2])this[s]=n;else throw Error(Bk+s+": "+n);if((n=e[s="LN10"])!==void 0)if(n==Math.LN10)this[s]=new this(n);else throw Error(Bk+s+": "+n);return this}var kbe=gGe(JGt);Am=new kbe(1);const Ko=kbe;function rKt(e){return iKt(e)||aKt(e)||nKt(e)||sKt()}function sKt(){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 nKt(e,t){if(e){if(typeof e=="string")return oxe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return oxe(e,t)}}function aKt(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function iKt(e){if(Array.isArray(e))return oxe(e)}function oxe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s=t?s.apply(void 0,a):e(t-l,$Ae(function(){for(var i=arguments.length,d=new Array(i),m=0;me.length)&&(t=e.length);for(var s=0,n=new Array(t);s"u"||!(Symbol.iterator in Object(e)))){var s=[],n=!0,a=!1,o=void 0;try{for(var l=e[Symbol.iterator](),i;!(n=(i=l.next()).done)&&(s.push(i.value),!(t&&s.length===t));n=!0);}catch(d){a=!0,o=d}finally{try{!n&&l.return!=null&&l.return()}finally{if(a)throw o}}return s}}function bKt(e){if(Array.isArray(e))return e}function bGe(e){var t=AP(e,2),s=t[0],n=t[1],a=s,o=n;return s>n&&(a=n,o=s),[a,o]}function wGe(e,t,s){if(e.lte(0))return new Ko(0);var n=sle.getDigitCount(e.toNumber()),a=new Ko(10).pow(n),o=e.div(a),l=n!==1?.05:.1,i=new Ko(Math.ceil(o.div(l).toNumber())).add(s).mul(l),d=i.mul(a);return t?d:new Ko(Math.ceil(d))}function wKt(e,t,s){var n=1,a=new Ko(e);if(!a.isint()&&s){var o=Math.abs(e);o<1?(n=new Ko(10).pow(sle.getDigitCount(e)-1),a=new Ko(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new Ko(Math.floor(e)))}else e===0?a=new Ko(Math.floor((t-1)/2)):s||(a=new Ko(Math.floor(e)));var l=Math.floor((t-1)/2),i=dKt(cKt(function(d){return a.add(new Ko(d-l).mul(n)).toNumber()}),lxe);return i(0,t)}function jGe(e,t,s,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(s-1)))return{step:new Ko(0),tickMin:new Ko(0),tickMax:new Ko(0)};var o=wGe(new Ko(t).sub(e).div(s-1),n,a),l;e<=0&&t>=0?l=new Ko(0):(l=new Ko(e).add(t).div(2),l=l.sub(new Ko(l).mod(o)));var i=Math.ceil(l.sub(e).div(o).toNumber()),d=Math.ceil(new Ko(t).sub(l).div(o).toNumber()),m=i+d+1;return m>s?jGe(e,t,s,n,a+1):(m0?d+(s-m):d,i=t>0?i:i+(s-m)),{step:o,tickMin:l.sub(new Ko(i).mul(o)),tickMax:l.add(new Ko(d).mul(o))})}function jKt(e){var t=AP(e,2),s=t[0],n=t[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=bGe([s,n]),d=AP(i,2),m=d[0],p=d[1];if(m===-1/0||p===1/0){var g=p===1/0?[m].concat(dxe(lxe(0,a-1).map(function(){return 1/0}))):[].concat(dxe(lxe(0,a-1).map(function(){return-1/0})),[p]);return s>n?cxe(g):g}if(m===p)return wKt(m,a,o);var v=jGe(m,p,l,o),_=v.step,k=v.tickMin,w=v.tickMax,S=sle.rangeStep(k,w.add(new Ko(.1).mul(_)),_);return s>n?cxe(S):S}function kKt(e,t){var s=AP(e,2),n=s[0],a=s[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=bGe([n,a]),i=AP(l,2),d=i[0],m=i[1];if(d===-1/0||m===1/0)return[n,a];if(d===m)return[d];var p=Math.max(t,2),g=wGe(new Ko(m).sub(d).div(p-1),o,0),v=[].concat(dxe(sle.rangeStep(new Ko(d),new Ko(m).sub(new Ko(.99).mul(g)),g)),[m]);return n>a?cxe(v):v}var NKt=vGe(jKt),SKt=vGe(kKt),CKt="Invariant failed";function hN(e,t){throw new Error(CKt)}var MKt=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function J5(e){"@babel/helpers - typeof";return J5=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},J5(e)}function Zne(){return Zne=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var s=0,n=new Array(t);s=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function DKt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function OKt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function RKt(e,t){for(var s=0;se.length)&&(t=e.length);for(var s=0,n=new Array(t);s1&&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=(s=n==null?void 0:n.length)!==null&&s!==void 0?s: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,m=0;m0?a[m-1].coordinate:a[i-1].coordinate,g=a[m].coordinate,v=m>=i-1?a[0].coordinate:a[m+1].coordinate,_=void 0;if(mh(g-p)!==mh(v-g)){var k=[];if(mh(v-g)===mh(d[1]-d[0])){_=v;var w=g+d[1]-d[0];k[0]=Math.min(w,(w+p)/2),k[1]=Math.max(w,(w+p)/2)}else{_=p;var S=v+d[1]-d[0];k[0]=Math.min(g,(S+g)/2),k[1]=Math.max(g,(S+g)/2)}var T=[Math.min(g,(_+g)/2),Math.max(g,(_+g)/2)];if(t>T[0]&&t<=T[1]||t>=k[0]&&t<=k[1]){l=a[m].index;break}}else{var C=Math.min(p,v),I=Math.max(p,v);if(t>(C+g)/2&&t<=(I+g)/2){l=a[m].index;break}}}else for(var R=0;R0&&R(n[R].coordinate+n[R-1].coordinate)/2&&t<=(n[R].coordinate+n[R+1].coordinate)/2||R===i-1&&t>(n[R].coordinate+n[R-1].coordinate)/2){l=n[R].index;break}return l},Nbe=function(t){var s,n=t,a=n.type.displayName,o=(s=t.type)!==null&&s!==void 0&&s.defaultProps?uc(uc({},t.type.defaultProps),t.props):t.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},eZt=function(t){var s=t.barSize,n=t.totalSize,a=t.stackGroups,o=a===void 0?{}:a;if(!o)return{};for(var l={},i=Object.keys(o),d=0,m=i.length;d=0});if(T&&T.length){var C=T[0].type.defaultProps,I=C!==void 0?uc(uc({},C),T[0].props):T[0].props,R=I.barSize,D=I[S];l[D]||(l[D]=[]);var B=Bi(R)?s:R;l[D].push({item:T[0],stackList:T.slice(1),barSize:Bi(B)?void 0:fh(B,n,0)})}}return l},tZt=function(t){var s=t.barGap,n=t.barCategoryGap,a=t.bandSize,o=t.sizeList,l=o===void 0?[]:o,i=t.maxBarSize,d=l.length;if(d<1)return null;var m=fh(s,a,0,!0),p,g=[];if(l[0].barSize===+l[0].barSize){var v=!1,_=a/d,k=l.reduce(function(R,D){return R+D.barSize||0},0);k+=(d-1)*m,k>=a&&(k-=(d-1)*m,m=0),k>=a&&_>0&&(v=!0,_*=.9,k=d*_);var w=(a-k)/2>>0,S={offset:w-m,size:0};p=l.reduce(function(R,D){var B={item:D.item,position:{offset:S.offset+S.size+m,size:v?_:D.barSize}},$=[].concat(qAe(R),[B]);return S=$[$.length-1].position,D.stackList&&D.stackList.length&&D.stackList.forEach(function(q){$.push({item:q,position:S})}),$},g)}else{var T=fh(n,a,0,!0);a-2*T-(d-1)*m<=0&&(m=0);var C=(a-2*T-(d-1)*m)/d;C>1&&(C>>=0);var I=i===+i?Math.min(C,i):C;p=l.reduce(function(R,D,B){var $=[].concat(qAe(R),[{item:D.item,position:{offset:T+(C+m)*B+(C-I)/2,size:I}}]);return D.stackList&&D.stackList.length&&D.stackList.forEach(function(q){$.push({item:q,position:$[$.length-1].position})}),$},g)}return p},rZt=function(t,s,n,a){var o=n.children,l=n.width,i=n.margin,d=l-(i.left||0)-(i.right||0),m=CGe({children:o,legendWidth:d});if(m){var p=a||{},g=p.width,v=p.height,_=m.align,k=m.verticalAlign,w=m.layout;if((w==="vertical"||w==="horizontal"&&k==="middle")&&_!=="center"&&Us(t[_]))return uc(uc({},t),{},s5({},_,t[_]+(g||0)));if((w==="horizontal"||w==="vertical"&&_==="center")&&k!=="middle"&&Us(t[k]))return uc(uc({},t),{},s5({},k,t[k]+(v||0)))}return t},sZt=function(t,s,n){return Bi(s)?!0:t==="horizontal"?s==="yAxis":t==="vertical"||n==="x"?s==="xAxis":n==="y"?s==="yAxis":!0},MGe=function(t,s,n,a,o){var l=s.props.children,i=qf(l,nle).filter(function(m){return sZt(a,o,m.props.direction)});if(i&&i.length){var d=i.map(function(m){return m.props.dataKey});return t.reduce(function(m,p){var g=Eu(p,n);if(Bi(g))return m;var v=Array.isArray(g)?[ele(g),Joe(g)]:[g,g],_=d.reduce(function(k,w){var S=Eu(p,w,0),T=v[0]-Math.abs(Array.isArray(S)?S[0]:S),C=v[1]+Math.abs(Array.isArray(S)?S[1]:S);return[Math.min(T,k[0]),Math.max(C,k[1])]},[1/0,-1/0]);return[Math.min(_[0],m[0]),Math.max(_[1],m[1])]},[1/0,-1/0])}return null},nZt=function(t,s,n,a,o){var l=s.map(function(i){return MGe(t,i,n,o,a)}).filter(function(i){return!Bi(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},TGe=function(t,s,n,a,o){var l=s.map(function(d){var m=d.props.dataKey;return n==="number"&&m&&MGe(t,d,m,a)||mI(t,m,n,o)});if(n==="number")return l.reduce(function(d,m){return[Math.min(d[0],m[0]),Math.max(d[1],m[1])]},[1/0,-1/0]);var i={};return l.reduce(function(d,m){for(var p=0,g=m.length;p=2?mh(i[0]-i[1])*2*m:m,s&&(t.ticks||t.niceTicks)){var p=(t.ticks||t.niceTicks).map(function(g){var v=o?o.indexOf(g):g;return{coordinate:a(v)+m,value:g,offset:m}});return p.filter(function(g){return!q6(g.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(g,v){return{coordinate:a(g)+m,value:g,index:v,offset:m}}):a.ticks&&!n?a.ticks(t.tickCount).map(function(g){return{coordinate:a(g)+m,value:g,offset:m}}):a.domain().map(function(g,v){return{coordinate:a(g)+m,value:o?o[g]:g,index:v,offset:m}})},Whe=new WeakMap,o8=function(t,s){if(typeof s!="function")return t;Whe.has(t)||Whe.set(t,new WeakMap);var n=Whe.get(t);if(n.has(s))return n.get(s);var a=function(){t.apply(void 0,arguments),s.apply(void 0,arguments)};return n.set(s,a),a},IGe=function(t,s,n){var a=t.scale,o=t.type,l=t.layout,i=t.axisType;if(a==="auto")return l==="radial"&&i==="radiusAxis"?{scale:kP(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:qne(),realScaleType:"linear"}:o==="category"&&s&&(s.indexOf("LineChart")>=0||s.indexOf("AreaChart")>=0||s.indexOf("ComposedChart")>=0&&!n)?{scale:hI(),realScaleType:"point"}:o==="category"?{scale:kP(),realScaleType:"band"}:{scale:qne(),realScaleType:"linear"};if(lN(a)){var d="scale".concat(Foe(a));return{scale:(FAe[d]||hI)(),realScaleType:FAe[d]?d:"point"}}return ri(a)?{scale:a}:{scale:hI(),realScaleType:"point"}},WAe=1e-4,PGe=function(t){var s=t.domain();if(!(!s||s.length<=2)){var n=s.length,a=t.range(),o=Math.min(a[0],a[1])-WAe,l=Math.max(a[0],a[1])+WAe,i=t(s[0]),d=t(s[n-1]);(il||dl)&&t.domain([s[0],s[n-1]])}},aZt=function(t,s){if(!t)return null;for(var n=0,a=t.length;na)&&(o[1]=a),o[0]>a&&(o[0]=a),o[1]=0?(t[i][n][0]=o,t[i][n][1]=o+d,o=t[i][n][1]):(t[i][n][0]=l,t[i][n][1]=l+d,l=t[i][n][1])}},lZt=function(t){var s=t.length;if(!(s<=0))for(var n=0,a=t[0].length;n=0?(t[l][n][0]=o,t[l][n][1]=o+i,o=t[l][n][1]):(t[l][n][0]=0,t[l][n][1]=0)}},cZt={sign:oZt,expand:MRt,none:H5,silhouette:TRt,wiggle:ARt,positive:lZt},dZt=function(t,s,n){var a=s.map(function(i){return i.props.dataKey}),o=cZt[n],l=CRt().keys(a).value(function(i,d){return+Eu(i,d,0)}).order(Rge).offset(o);return l(t)},uZt=function(t,s,n,a,o,l){if(!t)return null;var i=l?s.reverse():s,d={},m=i.reduce(function(g,v){var _,k=(_=v.type)!==null&&_!==void 0&&_.defaultProps?uc(uc({},v.type.defaultProps),v.props):v.props,w=k.stackId,S=k.hide;if(S)return g;var T=k[n],C=g[T]||{hasStack:!1,stackGroups:{}};if(Nd(w)){var I=C.stackGroups[w]||{numericAxisId:n,cateAxisId:a,items:[]};I.items.push(v),C.hasStack=!0,C.stackGroups[w]=I}else C.stackGroups[H6("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[v]};return uc(uc({},g),{},s5({},T,C))},d),p={};return Object.keys(m).reduce(function(g,v){var _=m[v];if(_.hasStack){var k={};_.stackGroups=Object.keys(_.stackGroups).reduce(function(w,S){var T=_.stackGroups[S];return uc(uc({},w),{},s5({},S,{numericAxisId:n,cateAxisId:a,items:T.items,stackedData:dZt(t,T.items,o)}))},k)}return uc(uc({},g),{},s5({},v,_))},p)},LGe=function(t,s){var n=s.realScaleType,a=s.type,o=s.tickCount,l=s.originalDomain,i=s.allowDecimals,d=n||s.scale;if(d!=="auto"&&d!=="linear")return null;if(o&&a==="number"&&l&&(l[0]==="auto"||l[1]==="auto")){var m=t.domain();if(!m.length)return null;var p=NKt(m,o,i);return t.domain([ele(p),Joe(p)]),{niceTicks:p}}if(o&&a==="number"){var g=t.domain(),v=SKt(g,o,i);return{niceTicks:v}}return null},GAe=function(t){var s=t.axis,n=t.ticks,a=t.offset,o=t.bandSize,l=t.entry,i=t.index;if(s.type==="category")return n[i]?n[i].coordinate+a:null;var d=Eu(l,s.dataKey,s.domain[i]);return Bi(d)?null:s.scale(d)-o/2+a},hZt=function(t){var s=t.numericAxis,n=s.scale.domain();if(s.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]},mZt=function(t,s){var n,a=(n=t.type)!==null&&n!==void 0&&n.defaultProps?uc(uc({},t.type.defaultProps),t.props):t.props,o=a.stackId;if(Nd(o)){var l=s[o];if(l){var i=l.items.indexOf(t);return i>=0?l.stackedData[i]:null}}return null},fZt=function(t){return t.reduce(function(s,n){return[ele(n.concat([s[0]]).filter(Us)),Joe(n.concat([s[1]]).filter(Us))]},[1/0,-1/0])},DGe=function(t,s,n){return Object.keys(t).reduce(function(a,o){var l=t[o],i=l.stackedData,d=i.reduce(function(m,p){var g=fZt(p.slice(s,n+1));return[Math.min(m[0],g[0]),Math.max(m[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})},KAe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,ZAe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,fxe=function(t,s,n){if(ri(t))return t(s,n);if(!Array.isArray(t))return s;var a=[];if(Us(t[0]))a[0]=n?t[0]:Math.min(t[0],s[0]);else if(KAe.test(t[0])){var o=+KAe.exec(t[0])[1];a[0]=s[0]-o}else ri(t[0])?a[0]=t[0](s[0]):a[0]=s[0];if(Us(t[1]))a[1]=n?t[1]:Math.max(t[1],s[1]);else if(ZAe.test(t[1])){var l=+ZAe.exec(t[1])[1];a[1]=s[1]+l}else ri(t[1])?a[1]=t[1](s[1]):a[1]=s[1];return a},Xne=function(t,s,n){if(t&&t.scale&&t.scale.bandwidth){var a=t.scale.bandwidth();if(!n||a>0)return a}if(t&&s&&s.length>=2){for(var o=J_e(s,function(g){return g.coordinate}),l=1/0,i=1,d=o.length;ie.length)&&(t=e.length);for(var s=0,n=new Array(t);s2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(t-(n.left||0)-(n.right||0)),Math.abs(s-(n.top||0)-(n.bottom||0)))/2},jZt=function(t,s,n,a,o){var l=t.width,i=t.height,d=t.startAngle,m=t.endAngle,p=fh(t.cx,l,l/2),g=fh(t.cy,i,i/2),v=FGe(l,i,n),_=fh(t.innerRadius,v,0),k=fh(t.outerRadius,v,v*.8),w=Object.keys(s);return w.reduce(function(S,T){var C=s[T],I=C.domain,R=C.reversed,D;if(Bi(C.range))a==="angleAxis"?D=[d,m]:a==="radiusAxis"&&(D=[_,k]),R&&(D=[D[1],D[0]]);else{D=C.range;var B=D,$=xZt(B,2);d=$[0],m=$[1]}var q=IGe(C,o),W=q.realScaleType,K=q.scale;K.domain(I).range(D),PGe(K);var re=LGe(K,vy(vy({},C),{},{realScaleType:W})),ae=vy(vy(vy({},C),re),{},{range:D,radius:k,realScaleType:W,scale:K,cx:p,cy:g,innerRadius:_,outerRadius:k,startAngle:d,endAngle:m});return vy(vy({},S),{},RGe({},T,ae))},{})},kZt=function(t,s){var n=t.x,a=t.y,o=s.x,l=s.y;return Math.sqrt(Math.pow(n-o,2)+Math.pow(a-l,2))},NZt=function(t,s){var n=t.x,a=t.y,o=s.cx,l=s.cy,i=kZt({x:n,y:a},{x:o,y:l});if(i<=0)return{radius:i};var d=(n-o)/i,m=Math.acos(d);return a>l&&(m=2*Math.PI-m),{radius:i,angle:wZt(m),angleInRadian:m}},SZt=function(t){var s=t.startAngle,n=t.endAngle,a=Math.floor(s/360),o=Math.floor(n/360),l=Math.min(a,o);return{startAngle:s-l*360,endAngle:n-l*360}},CZt=function(t,s){var n=s.startAngle,a=s.endAngle,o=Math.floor(n/360),l=Math.floor(a/360),i=Math.min(o,l);return t+i*360},JAe=function(t,s){var n=t.x,a=t.y,o=NZt({x:n,y:a},s),l=o.radius,i=o.angle,d=s.innerRadius,m=s.outerRadius;if(lm)return!1;if(l===0)return!0;var p=SZt(s),g=p.startAngle,v=p.endAngle,_=i,k;if(g<=v){for(;_>v;)_-=360;for(;_=g&&_<=v}else{for(;_>g;)_-=360;for(;_=v&&_<=g}return k?vy(vy({},s),{},{radius:l,angle:CZt(_,s)}):null},zGe=function(t){return!A.isValidElement(t)&&!ri(t)&&typeof t!="boolean"?t.className:""};function LP(e){"@babel/helpers - typeof";return LP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},LP(e)}var MZt=["offset"];function TZt(e){return PZt(e)||IZt(e)||EZt(e)||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 EZt(e,t){if(e){if(typeof e=="string")return pxe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return pxe(e,t)}}function IZt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function PZt(e){if(Array.isArray(e))return pxe(e)}function pxe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function DZt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function eEe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function gd(e){for(var t=1;t=0?1:-1,I,R;a==="insideStart"?(I=_+C*l,R=w):a==="insideEnd"?(I=k-C*l,R=!w):a==="end"&&(I=k+C*l,R=w),R=T<=0?R:!R;var D=ul(m,p,S,I),B=ul(m,p,S,I+(R?1:-1)*359),$="M".concat(D.x,",").concat(D.y,` A`).concat(S,",").concat(S,",0,1,").concat(R?0:1,`, `).concat(B.x,",").concat(B.y),q=Bi(t.id)?H6("recharts-radial-line-"):t.id;return lt.createElement("text",DP({},n,{dominantBaseline:"central",className:ki("recharts-radial-bar-label",i)}),lt.createElement("defs",null,lt.createElement("path",{id:q,d:$})),lt.createElement("textPath",{xlinkHref:"#".concat(q)},s))},UZt=function(t){var s=t.viewBox,n=t.offset,a=t.position,o=s,l=o.cx,i=o.cy,d=o.innerRadius,m=o.outerRadius,p=o.startAngle,g=o.endAngle,v=(p+g)/2;if(a==="outside"){var _=ul(l,i,m+n,v),k=_.x,w=_.y;return{x:k,y:w,textAnchor:k>=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 S=(d+m)/2,T=ul(l,i,S,v),C=T.x,I=T.y;return{x:C,y:I,textAnchor:"middle",verticalAnchor:"middle"}},VZt=function(t){var s=t.viewBox,n=t.parentViewBox,a=t.offset,o=t.position,l=s,i=l.x,d=l.y,m=l.width,p=l.height,g=p>=0?1:-1,v=g*a,_=g>0?"end":"start",k=g>0?"start":"end",w=m>=0?1:-1,S=w*a,T=w>0?"end":"start",C=w>0?"start":"end";if(o==="top"){var I={x:i+m/2,y:d-g*a,textAnchor:"middle",verticalAnchor:_};return gd(gd({},I),n?{height:Math.max(d-n.y,0),width:m}:{})}if(o==="bottom"){var R={x:i+m/2,y:d+p+v,textAnchor:"middle",verticalAnchor:k};return gd(gd({},R),n?{height:Math.max(n.y+n.height-(d+p),0),width:m}:{})}if(o==="left"){var D={x:i-S,y:d+p/2,textAnchor:T,verticalAnchor:"middle"};return gd(gd({},D),n?{width:Math.max(D.x-n.x,0),height:p}:{})}if(o==="right"){var B={x:i+m+S,y:d+p/2,textAnchor:C,verticalAnchor:"middle"};return gd(gd({},B),n?{width:Math.max(n.x+n.width-B.x,0),height:p}:{})}var $=n?{width:m,height:p}:{};return o==="insideLeft"?gd({x:i+S,y:d+p/2,textAnchor:C,verticalAnchor:"middle"},$):o==="insideRight"?gd({x:i+m-S,y:d+p/2,textAnchor:T,verticalAnchor:"middle"},$):o==="insideTop"?gd({x:i+m/2,y:d+v,textAnchor:"middle",verticalAnchor:k},$):o==="insideBottom"?gd({x:i+m/2,y:d+p-v,textAnchor:"middle",verticalAnchor:_},$):o==="insideTopLeft"?gd({x:i+S,y:d+v,textAnchor:C,verticalAnchor:k},$):o==="insideTopRight"?gd({x:i+m-S,y:d+v,textAnchor:T,verticalAnchor:k},$):o==="insideBottomLeft"?gd({x:i+S,y:d+p-v,textAnchor:C,verticalAnchor:_},$):o==="insideBottomRight"?gd({x:i+m-S,y:d+p-v,textAnchor:T,verticalAnchor:_},$):W3(o)&&(Us(o.x)||Zj(o.x))&&(Us(o.y)||Zj(o.y))?gd({x:i+fh(o.x,m),y:d+fh(o.y,p),textAnchor:"end",verticalAnchor:"end"},$):gd({x:i+m/2,y:d+p/2,textAnchor:"middle",verticalAnchor:"middle"},$)},qZt=function(t){return"cx"in t&&Us(t.cx)};function Hd(e){var t=e.offset,s=t===void 0?5:t,n=LZt(e,MZt),a=gd({offset:s},n),o=a.viewBox,l=a.position,i=a.value,d=a.children,m=a.content,p=a.className,g=p===void 0?"":p,v=a.textBreakAll;if(!o||Bi(i)&&Bi(d)&&!A.isValidElement(m)&&!ri(m))return null;if(A.isValidElement(m))return A.cloneElement(m,a);var _;if(ri(m)){if(_=A.createElement(m,a),A.isValidElement(_))return _}else _=zZt(a);var k=qZt(o),w=Za(a,!0);if(k&&(l==="insideStart"||l==="insideEnd"||l==="end"))return $Zt(a,_,w);var S=k?UZt(a):VZt(a);return lt.createElement(dN,DP({className:ki("recharts-label",g)},w,S,{breakAll:v}),_)}Hd.displayName="Label";var BGe=function(t){var s=t.cx,n=t.cy,a=t.angle,o=t.startAngle,l=t.endAngle,i=t.r,d=t.radius,m=t.innerRadius,p=t.outerRadius,g=t.x,v=t.y,_=t.top,k=t.left,w=t.width,S=t.height,T=t.clockWise,C=t.labelViewBox;if(C)return C;if(Us(w)&&Us(S)){if(Us(g)&&Us(v))return{x:g,y:v,width:w,height:S};if(Us(_)&&Us(k))return{x:_,y:k,width:w,height:S}}return Us(g)&&Us(v)?{x:g,y:v,width:0,height:0}:Us(s)&&Us(n)?{cx:s,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:m||0,outerRadius:p||d||i||0,clockWise:T}:t.viewBox?t.viewBox:{}},HZt=function(t,s){return t?t===!0?lt.createElement(Hd,{key:"label-implicit",viewBox:s}):Nd(t)?lt.createElement(Hd,{key:"label-implicit",viewBox:s,value:t}):A.isValidElement(t)?t.type===Hd?A.cloneElement(t,{key:"label-implicit",viewBox:s}):lt.createElement(Hd,{key:"label-implicit",content:t,viewBox:s}):ri(t)?lt.createElement(Hd,{key:"label-implicit",content:t,viewBox:s}):W3(t)?lt.createElement(Hd,DP({viewBox:s},t,{key:"label-implicit"})):null:null},WZt=function(t,s){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&n&&!t.label)return null;var a=t.children,o=BGe(t),l=qf(a,Hd).map(function(d,m){return A.cloneElement(d,{viewBox:s||o,key:"label-".concat(m)})});if(!n)return l;var i=HZt(t.label,s||o);return[i].concat(TZt(l))};Hd.parseViewBox=BGe;Hd.renderCallByParent=WZt;function GZt(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var KZt=GZt;const ZZt=ho(KZt);function OP(e){"@babel/helpers - typeof";return OP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},OP(e)}var YZt=["valueAccessor"],XZt=["data","dataKey","clockWise","id","textBreakAll"];function QZt(e){return rYt(e)||tYt(e)||eYt(e)||JZt()}function JZt(){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 eYt(e,t){if(e){if(typeof e=="string")return gxe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return gxe(e,t)}}function tYt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function rYt(e){if(Array.isArray(e))return gxe(e)}function gxe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function iYt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}var oYt=function(t){return Array.isArray(t.value)?ZZt(t.value):t.value};function F1(e){var t=e.valueAccessor,s=t===void 0?oYt:t,n=sEe(e,YZt),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,d=n.textBreakAll,m=sEe(n,XZt);return!a||!a.length?null:lt.createElement($o,{className:"recharts-label-list"},a.map(function(p,g){var v=Bi(o)?s(p,g):Eu(p&&p.payload,o),_=Bi(i)?{}:{id:"".concat(i,"-").concat(g)};return lt.createElement(Hd,Jne({},Za(p,!0),m,_,{parentViewBox:p.parentViewBox,value:v,textBreakAll:d,viewBox:Hd.parseViewBox(Bi(l)?p:rEe(rEe({},p),{},{clockWise:l})),key:"label-".concat(g),index:g}))}))}F1.displayName="LabelList";function lYt(e,t){return e?e===!0?lt.createElement(F1,{key:"labelList-implicit",data:t}):lt.isValidElement(e)||ri(e)?lt.createElement(F1,{key:"labelList-implicit",data:t,content:e}):W3(e)?lt.createElement(F1,Jne({data:t},e,{key:"labelList-implicit"})):null:null}function cYt(e,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&s&&!e.label)return null;var n=e.children,a=qf(n,F1).map(function(l,i){return A.cloneElement(l,{data:t,key:"labelList-".concat(i)})});if(!s)return a;var o=lYt(e.label,t);return[o].concat(QZt(a))}F1.renderCallByParent=cYt;function RP(e){"@babel/helpers - typeof";return RP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},RP(e)}function xxe(){return xxe=Object.assign?Object.assign.bind():function(e){for(var t=1;t180),",").concat(+(l>m),`, `).concat(g.x,",").concat(g.y,` `);if(a>0){var _=ul(s,n,a,l),k=ul(s,n,a,m);v+="L ".concat(k.x,",").concat(k.y,` A `).concat(a,",").concat(a,`,0, `).concat(+(Math.abs(d)>180),",").concat(+(l<=m),`, `).concat(_.x,",").concat(_.y," Z")}else v+="L ".concat(s,",").concat(n," Z");return v},fYt=function(t){var s=t.cx,n=t.cy,a=t.innerRadius,o=t.outerRadius,l=t.cornerRadius,i=t.forceCornerRadius,d=t.cornerIsExternal,m=t.startAngle,p=t.endAngle,g=mh(p-m),v=l8({cx:s,cy:n,radius:o,angle:m,sign:g,cornerRadius:l,cornerIsExternal:d}),_=v.circleTangency,k=v.lineTangency,w=v.theta,S=l8({cx:s,cy:n,radius:o,angle:p,sign:-g,cornerRadius:l,cornerIsExternal:d}),T=S.circleTangency,C=S.lineTangency,I=S.theta,R=d?Math.abs(m-p):Math.abs(m-p)-w-I;if(R<0)return i?"M ".concat(k.x,",").concat(k.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 `):$Ge({cx:s,cy:n,innerRadius:a,outerRadius:o,startAngle:m,endAngle:p});var D="M ".concat(k.x,",").concat(k.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(_.x,",").concat(_.y,` A`).concat(o,",").concat(o,",0,").concat(+(R>180),",").concat(+(g<0),",").concat(T.x,",").concat(T.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var B=l8({cx:s,cy:n,radius:a,angle:m,sign:g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),$=B.circleTangency,q=B.lineTangency,W=B.theta,K=l8({cx:s,cy:n,radius:a,angle:p,sign:-g,isExternal:!0,cornerRadius:l,cornerIsExternal:d}),re=K.circleTangency,ae=K.lineTangency,oe=K.theta,se=d?Math.abs(m-p):Math.abs(m-p)-W-oe;if(se<0&&l===0)return"".concat(D,"L").concat(s,",").concat(n,"Z");D+="L".concat(ae.x,",").concat(ae.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(re.x,",").concat(re.y,` A`).concat(a,",").concat(a,",0,").concat(+(se>180),",").concat(+(g>0),",").concat($.x,",").concat($.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(g<0),",").concat(q.x,",").concat(q.y,"Z")}else D+="L".concat(s,",").concat(n,"Z");return D},pYt={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},UGe=function(t){var s=aEe(aEe({},pYt),t),n=s.cx,a=s.cy,o=s.innerRadius,l=s.outerRadius,i=s.cornerRadius,d=s.forceCornerRadius,m=s.cornerIsExternal,p=s.startAngle,g=s.endAngle,v=s.className;if(l0&&Math.abs(p-g)<360?S=fYt({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(w,k/2),forceCornerRadius:d,cornerIsExternal:m,startAngle:p,endAngle:g}):S=$Ge({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:g}),lt.createElement("path",xxe({},Za(s,!0),{className:_,d:S,role:"img"}))};function FP(e){"@babel/helpers - typeof";return FP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},FP(e)}function yxe(){return yxe=Object.assign?Object.assign.bind():function(e){for(var t=1;t0;)if(!s.equals(e[n],t[n],n,n,e,t,s))return!1;return!0}function LYt(e,t){return MN(e.getTime(),t.getTime())}function DYt(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function OYt(e,t){return e===t}function mEe(e,t,s){var n=e.size;if(n!==t.size)return!1;if(!n)return!0;for(var a=new Array(n),o=e.entries(),l,i,d=0;(l=o.next())&&!l.done;){for(var m=t.entries(),p=!1,g=0;(i=m.next())&&!i.done;){if(a[g]){g++;continue}var v=l.value,_=i.value;if(s.equals(v[0],_[0],d,g,e,t,s)&&s.equals(v[1],_[1],v[0],_[0],e,t,s)){p=a[g]=!0;break}g++}if(!p)return!1;d++}return!0}var RYt=MN;function FYt(e,t,s){var n=hEe(e),a=n.length;if(hEe(t).length!==a)return!1;for(;a-- >0;)if(!WGe(e,t,s,n[a]))return!1;return!0}function EA(e,t,s){var n=dEe(e),a=n.length;if(dEe(t).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!WGe(e,t,s,o)||(l=uEe(e,o),i=uEe(t,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function zYt(e,t){return MN(e.valueOf(),t.valueOf())}function BYt(e,t){return e.source===t.source&&e.flags===t.flags}function fEe(e,t,s){var n=e.size;if(n!==t.size)return!1;if(!n)return!0;for(var a=new Array(n),o=e.values(),l,i;(l=o.next())&&!l.done;){for(var d=t.values(),m=!1,p=0;(i=d.next())&&!i.done;){if(!a[p]&&s.equals(l.value,i.value,l.value,i.value,e,t,s)){m=a[p]=!0;break}p++}if(!m)return!1}return!0}function $Yt(e,t){var s=e.length;if(t.length!==s)return!1;for(;s-- >0;)if(e[s]!==t[s])return!1;return!0}function UYt(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function WGe(e,t,s,n){return(n===IYt||n===EYt||n===AYt)&&(e.$$typeof||t.$$typeof)?!0:TYt(t,n)&&s.equals(e[n],t[n],n,n,e,t,s)}var VYt="[object Arguments]",qYt="[object Boolean]",HYt="[object Date]",WYt="[object Error]",GYt="[object Map]",KYt="[object Number]",ZYt="[object Object]",YYt="[object RegExp]",XYt="[object Set]",QYt="[object String]",JYt="[object URL]",eXt=Array.isArray,pEe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,gEe=Object.assign,tXt=Object.prototype.toString.call.bind(Object.prototype.toString);function rXt(e){var t=e.areArraysEqual,s=e.areDatesEqual,n=e.areErrorsEqual,a=e.areFunctionsEqual,o=e.areMapsEqual,l=e.areNumbersEqual,i=e.areObjectsEqual,d=e.arePrimitiveWrappersEqual,m=e.areRegExpsEqual,p=e.areSetsEqual,g=e.areTypedArraysEqual,v=e.areUrlsEqual;return function(k,w,S){if(k===w)return!0;if(k==null||w==null)return!1;var T=typeof k;if(T!==typeof w)return!1;if(T!=="object")return T==="number"?l(k,w,S):T==="function"?a(k,w,S):!1;var C=k.constructor;if(C!==w.constructor)return!1;if(C===Object)return i(k,w,S);if(eXt(k))return t(k,w,S);if(pEe!=null&&pEe(k))return g(k,w,S);if(C===Date)return s(k,w,S);if(C===RegExp)return m(k,w,S);if(C===Map)return o(k,w,S);if(C===Set)return p(k,w,S);var I=tXt(k);return I===HYt?s(k,w,S):I===YYt?m(k,w,S):I===GYt?o(k,w,S):I===XYt?p(k,w,S):I===ZYt?typeof k.then!="function"&&typeof w.then!="function"&&i(k,w,S):I===JYt?v(k,w,S):I===WYt?n(k,w,S):I===VYt?i(k,w,S):I===qYt||I===KYt||I===QYt?d(k,w,S):!1}}function sXt(e){var t=e.circular,s=e.createCustomConfig,n=e.strict,a={areArraysEqual:n?EA:PYt,areDatesEqual:LYt,areErrorsEqual:DYt,areFunctionsEqual:OYt,areMapsEqual:n?cEe(mEe,EA):mEe,areNumbersEqual:RYt,areObjectsEqual:n?EA:FYt,arePrimitiveWrappersEqual:zYt,areRegExpsEqual:BYt,areSetsEqual:n?cEe(fEe,EA):fEe,areTypedArraysEqual:n?EA:$Yt,areUrlsEqual:UYt};if(s&&(a=gEe({},a,s(a))),t){var o=d8(a.areArraysEqual),l=d8(a.areMapsEqual),i=d8(a.areObjectsEqual),d=d8(a.areSetsEqual);a=gEe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:d})}return a}function nXt(e){return function(t,s,n,a,o,l,i){return e(t,s,i)}}function aXt(e){var t=e.circular,s=e.comparator,n=e.createState,a=e.equals,o=e.strict;if(n)return function(d,m){var p=n(),g=p.cache,v=g===void 0?t?new WeakMap:void 0:g,_=p.meta;return s(d,m,{cache:v,equals:a,meta:_,strict:o})};if(t)return function(d,m){return s(d,m,{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,m){return s(d,m,l)}}var iXt=p_();p_({strict:!0});p_({circular:!0});p_({circular:!0,strict:!0});p_({createInternalComparator:function(){return MN}});p_({strict:!0,createInternalComparator:function(){return MN}});p_({circular:!0,createInternalComparator:function(){return MN}});p_({circular:!0,createInternalComparator:function(){return MN},strict:!0});function p_(e){e===void 0&&(e={});var t=e.circular,s=t===void 0?!1:t,n=e.createInternalComparator,a=e.createState,o=e.strict,l=o===void 0?!1:o,i=sXt(e),d=rXt(i),m=n?n(d):nXt(d);return aXt({circular:s,comparator:d,createState:a,equals:m,strict:l})}function oXt(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function xEe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=-1,n=function a(o){s<0&&(s=o),o-s>t?(e(o),s=-1):oXt(a)};requestAnimationFrame(n)}function _xe(e){"@babel/helpers - typeof";return _xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_xe(e)}function lXt(e){return hXt(e)||uXt(e)||dXt(e)||cXt()}function cXt(){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 dXt(e,t){if(e){if(typeof e=="string")return yEe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return yEe(e,t)}}function yEe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);se.length)&&(t=e.length);for(var s=0,n=new Array(t);s1?1:T<0?0:T},w=function(T){for(var C=T>1?1:T,I=C,R=0;R<8;++R){var D=g(I)-C,B=_(I);if(Math.abs(D-C)0&&arguments[0]!==void 0?arguments[0]:{},s=t.stiff,n=s===void 0?100:s,a=t.damping,o=a===void 0?8:a,l=t.dt,i=l===void 0?17:l,d=function(p,g,v){var _=-(p-g)*n,k=v*o,w=v+(_-k)*i/1e3,S=v*i/1e3+p;return Math.abs(S-g)e.length)&&(t=e.length);for(var s=0,n=new Array(t);s=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function VXt(e,t){if(e==null)return{};var s={},n=Object.keys(e),a,o;for(o=0;o=0)&&(s[a]=e[a]);return s}function Ghe(e){return GXt(e)||WXt(e)||HXt(e)||qXt()}function qXt(){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 HXt(e,t){if(e){if(typeof e=="string")return Nxe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return Nxe(e,t)}}function WXt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function GXt(e){if(Array.isArray(e))return Nxe(e)}function Nxe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s"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 rae(e){return rae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},rae(e)}var f0=function(e){QXt(s,e);var t=JXt(s);function s(n,a){var o;KXt(this,s),o=t.call(this,n,a);var l=o.props,i=l.isActive,d=l.attributeName,m=l.from,p=l.to,g=l.steps,v=l.children,_=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(Mxe(o)),o.changeStyle=o.changeStyle.bind(Mxe(o)),!i||_<=0)return o.state={style:{}},typeof v=="function"&&(o.state={style:p}),Cxe(o);if(g&&g.length)o.state={style:g[0].style};else if(m){if(typeof v=="function")return o.state={style:m},Cxe(o);o.state={style:d?XA({},d,m):m}}else o.state={style:{}};return o}return YXt(s,[{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,m=o.shouldReAnimate,p=o.to,g=o.from,v=this.state.style;if(i){if(!l){var _={style:d?XA({},d,p):p};this.state&&v&&(d&&v[d]!==p||!d&&v!==p)&&this.setState(_);return}if(!(iXt(a.to,p)&&a.canBegin&&a.isActive)){var k=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var w=k||m?g:a.to;if(this.state&&v){var S={style:d?XA({},d,w):w};(d&&v[d]!==w||!d&&v!==w)&&this.setState(S)}this.runAnimation(Mp(Mp({},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,m=a.easing,p=a.begin,g=a.onAnimationEnd,v=a.onAnimationStart,_=BXt(l,i,TXt(m),d,this.changeStyle),k=function(){o.stopJSAnimation=_()};this.manager.start([v,p,k,d,g])}},{key:"runStepAnimation",value:function(a){var o=this,l=a.steps,i=a.begin,d=a.onAnimationStart,m=l[0],p=m.style,g=m.duration,v=g===void 0?0:g,_=function(w,S,T){if(T===0)return w;var C=S.duration,I=S.easing,R=I===void 0?"ease":I,D=S.style,B=S.properties,$=S.onAnimationEnd,q=T>0?l[T-1]:S,W=B||Object.keys(D);if(typeof R=="function"||R==="spring")return[].concat(Ghe(w),[o.runJSAnimation.bind(o,{from:q.style,to:D,duration:C,easing:R}),C]);var K=bEe(W,C,R),re=Mp(Mp(Mp({},q.style),D),{},{transition:K});return[].concat(Ghe(w),[re,C,$]).filter(xXt)};return this.manager.start([d].concat(Ghe(l.reduce(_,[p,Math.max(v,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=mXt());var o=a.begin,l=a.duration,i=a.attributeName,d=a.to,m=a.easing,p=a.onAnimationStart,g=a.onAnimationEnd,v=a.steps,_=a.children,k=this.manager;if(this.unSubscribe=k.subscribe(this.handleStyleChange),typeof m=="function"||typeof _=="function"||m==="spring"){this.runJSAnimation(a);return}if(v.length>1){this.runStepAnimation(a);return}var w=i?XA({},i,d):d,S=bEe(Object.keys(w),l,m);k.start([p,o,Mp(Mp({},w),{},{transition:S}),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=UXt(a,$Xt),m=A.Children.count(o),p=this.state.style;if(typeof o=="function")return o(p);if(!i||m===0||l<=0)return o;var g=function(_){var k=_.props,w=k.style,S=w===void 0?{}:w,T=k.className,C=A.cloneElement(_,Mp(Mp({},d),{},{style:Mp(Mp({},S),p),className:T}));return C};return m===1?g(A.Children.only(o)):lt.createElement("div",null,A.Children.map(o,function(v){return g(v)}))}}]),s}(A.PureComponent);f0.displayName="Animate";f0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};f0.propTypes={from:Io.oneOfType([Io.object,Io.string]),to:Io.oneOfType([Io.object,Io.string]),attributeName:Io.string,duration:Io.number,begin:Io.number,easing:Io.oneOfType([Io.string,Io.func]),steps:Io.arrayOf(Io.shape({duration:Io.number.isRequired,style:Io.object.isRequired,easing:Io.oneOfType([Io.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Io.func]),properties:Io.arrayOf("string"),onAnimationEnd:Io.func})),children:Io.oneOfType([Io.node,Io.func]),isActive:Io.bool,canBegin:Io.bool,onAnimationEnd:Io.func,shouldReAnimate:Io.bool,onAnimationStart:Io.func,onAnimationReStart:Io.func};function $P(e){"@babel/helpers - typeof";return $P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$P(e)}function sae(){return sae=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var s=0,n=new Array(t);s=0?1:-1,d=n>=0?1:-1,m=a>=0&&n>=0||a<0&&n<0?1:0,p;if(l>0&&o instanceof Array){for(var g=[0,0,0,0],v=0,_=4;v<_;v++)g[v]=o[v]>l?l:o[v];p="M".concat(t,",").concat(s+i*g[0]),g[0]>0&&(p+="A ".concat(g[0],",").concat(g[0],",0,0,").concat(m,",").concat(t+d*g[0],",").concat(s)),p+="L ".concat(t+n-d*g[1],",").concat(s),g[1]>0&&(p+="A ".concat(g[1],",").concat(g[1],",0,0,").concat(m,`, `).concat(t+n,",").concat(s+i*g[1])),p+="L ".concat(t+n,",").concat(s+a-i*g[2]),g[2]>0&&(p+="A ".concat(g[2],",").concat(g[2],",0,0,").concat(m,`, `).concat(t+n-d*g[2],",").concat(s+a)),p+="L ".concat(t+d*g[3],",").concat(s+a),g[3]>0&&(p+="A ".concat(g[3],",").concat(g[3],",0,0,").concat(m,`, `).concat(t,",").concat(s+a-i*g[3])),p+="Z"}else if(l>0&&o===+o&&o>0){var k=Math.min(l,o);p="M ".concat(t,",").concat(s+i*k,` A `).concat(k,",").concat(k,",0,0,").concat(m,",").concat(t+d*k,",").concat(s,` L `).concat(t+n-d*k,",").concat(s,` A `).concat(k,",").concat(k,",0,0,").concat(m,",").concat(t+n,",").concat(s+i*k,` L `).concat(t+n,",").concat(s+a-i*k,` A `).concat(k,",").concat(k,",0,0,").concat(m,",").concat(t+n-d*k,",").concat(s+a,` L `).concat(t+d*k,",").concat(s+a,` A `).concat(k,",").concat(k,",0,0,").concat(m,",").concat(t,",").concat(s+a-i*k," Z")}else p="M ".concat(t,",").concat(s," h ").concat(n," v ").concat(a," h ").concat(-n," Z");return p},cQt=function(t,s){if(!t||!s)return!1;var n=t.x,a=t.y,o=s.x,l=s.y,i=s.width,d=s.height;if(Math.abs(i)>0&&Math.abs(d)>0){var m=Math.min(o,o+i),p=Math.max(o,o+i),g=Math.min(l,l+d),v=Math.max(l,l+d);return n>=m&&n<=p&&a>=g&&a<=v}return!1},dQt={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Sbe=function(t){var s=TEe(TEe({},dQt),t),n=A.useRef(),a=A.useState(-1),o=tQt(a,2),l=o[0],i=o[1];A.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var R=n.current.getTotalLength();R&&i(R)}catch{}},[]);var d=s.x,m=s.y,p=s.width,g=s.height,v=s.radius,_=s.className,k=s.animationEasing,w=s.animationDuration,S=s.animationBegin,T=s.isAnimationActive,C=s.isUpdateAnimationActive;if(d!==+d||m!==+m||p!==+p||g!==+g||p===0||g===0)return null;var I=ki("recharts-rectangle",_);return C?lt.createElement(f0,{canBegin:l>0,from:{width:p,height:g,x:d,y:m},to:{width:p,height:g,x:d,y:m},duration:w,animationEasing:k,isActive:C},function(R){var D=R.width,B=R.height,$=R.x,q=R.y;return lt.createElement(f0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:S,duration:w,isActive:T,easing:k},lt.createElement("path",sae({},Za(s,!0),{className:I,d:AEe($,q,D,B,v),ref:n})))}):lt.createElement("path",sae({},Za(s,!0),{className:I,d:AEe(d,m,p,g,v)}))},uQt=["points","className","baseLinePoints","connectNulls"];function t4(){return t4=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function mQt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function EEe(e){return xQt(e)||gQt(e)||pQt(e)||fQt()}function fQt(){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 pQt(e,t){if(e){if(typeof e=="string")return Txe(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);if(s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set")return Array.from(e);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return Txe(e,t)}}function gQt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function xQt(e){if(Array.isArray(e))return Txe(e)}function Txe(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s0&&arguments[0]!==void 0?arguments[0]:[],s=[[]];return t.forEach(function(n){IEe(n)?s[s.length-1].push(n):s[s.length-1].length>0&&s.push([])}),IEe(t[0])&&s[s.length-1].push(t[0]),s[s.length-1].length<=0&&(s=s.slice(0,-1)),s},pI=function(t,s){var n=yQt(t);s&&(n=[n.reduce(function(o,l){return[].concat(EEe(o),EEe(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},vQt=function(t,s,n){var a=pI(t,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(pI(s.reverse(),n).slice(1))},_Qt=function(t){var s=t.points,n=t.className,a=t.baseLinePoints,o=t.connectNulls,l=hQt(t,uQt);if(!s||!s.length)return null;var i=ki("recharts-polygon",n);if(a&&a.length){var d=l.stroke&&l.stroke!=="none",m=vQt(s,a,o);return lt.createElement("g",{className:i},lt.createElement("path",t4({},Za(l,!0),{fill:m.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:m})),d?lt.createElement("path",t4({},Za(l,!0),{fill:"none",d:pI(s,o)})):null,d?lt.createElement("path",t4({},Za(l,!0),{fill:"none",d:pI(a,o)})):null)}var p=pI(s,o);return lt.createElement("path",t4({},Za(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function Axe(){return Axe=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function CQt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}var MQt=function(t,s,n,a,o,l){return"M".concat(t,",").concat(o,"v").concat(a,"M").concat(l,",").concat(s,"h").concat(n)},TQt=function(t){var s=t.x,n=s===void 0?0:s,a=t.y,o=a===void 0?0:a,l=t.top,i=l===void 0?0:l,d=t.left,m=d===void 0?0:d,p=t.width,g=p===void 0?0:p,v=t.height,_=v===void 0?0:v,k=t.className,w=SQt(t,bQt),S=wQt({x:n,y:o,top:i,left:m,width:g,height:_},w);return!Us(n)||!Us(o)||!Us(g)||!Us(_)||!Us(i)||!Us(m)?null:lt.createElement("path",Exe({},Za(S,!0),{className:ki("recharts-cross",k),d:MQt(n,o,g,_,i,m)}))},AQt=Qoe,EQt=dGe,IQt=Rx;function PQt(e,t){return e&&e.length?AQt(e,IQt(t),EQt):void 0}var LQt=PQt;const DQt=ho(LQt);var OQt=Qoe,RQt=Rx,FQt=uGe;function zQt(e,t){return e&&e.length?OQt(e,RQt(t),FQt):void 0}var BQt=zQt;const $Qt=ho(BQt);var UQt=["cx","cy","angle","ticks","axisLine"],VQt=["ticks","tick","angle","tickFormatter","stroke"];function t3(e){"@babel/helpers - typeof";return t3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t3(e)}function gI(){return gI=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function qQt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function HQt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function OEe(e,t){for(var s=0;szEe?l=a==="outer"?"start":"end":o<-zEe?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,m=ub(ub({},Za(this.props,!1)),{},{fill:"none"},Za(i,!1));if(d==="circle")return lt.createElement(Cbe,Fj({className:"recharts-polar-angle-axis-line"},m,{cx:a,cy:o,r:l}));var p=this.props.ticks,g=p.map(function(v){return ul(a,o,l,v.coordinate)});return lt.createElement(_Qt,Fj({className:"recharts-polar-angle-axis-line"},m,{points:g}))}},{key:"renderTicks",value:function(){var n=this,a=this.props,o=a.ticks,l=a.tick,i=a.tickLine,d=a.tickFormatter,m=a.stroke,p=Za(this.props,!1),g=Za(l,!1),v=ub(ub({},p),{},{fill:"none"},Za(i,!1)),_=o.map(function(k,w){var S=n.getTickLineCoord(k),T=n.getTickTextAnchor(k),C=ub(ub(ub({textAnchor:T},p),{},{stroke:"none",fill:m},g),{},{index:w,payload:k,x:S.x2,y:S.y2});return lt.createElement($o,Fj({className:ki("recharts-polar-angle-axis-tick",zGe(l)),key:"tick-".concat(k.coordinate)},cN(n.props,k,w)),i&<.createElement("line",Fj({className:"recharts-polar-angle-axis-tick-line"},v,S)),l&&t.renderTickItem(l,C,d?d(k.value,w):k.value))});return lt.createElement($o,{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($o,{className:ki("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):ri(n)?l=n(a):l=lt.createElement(dN,Fj({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(A.PureComponent);ole(lle,"displayName","PolarAngleAxis");ole(lle,"axisType","angleAxis");ole(lle,"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 iJt=iWe,oJt=iJt(Object.getPrototypeOf,Object),lJt=oJt,cJt=y0,dJt=lJt,uJt=v0,hJt="[object Object]",mJt=Function.prototype,fJt=Object.prototype,sKe=mJt.toString,pJt=fJt.hasOwnProperty,gJt=sKe.call(Object);function xJt(e){if(!uJt(e)||cJt(e)!=hJt)return!1;var t=dJt(e);if(t===null)return!0;var s=pJt.call(t,"constructor")&&t.constructor;return typeof s=="function"&&s instanceof s&&sKe.call(s)==gJt}var yJt=xJt;const vJt=ho(yJt);var _Jt=y0,bJt=v0,wJt="[object Boolean]";function jJt(e){return e===!0||e===!1||bJt(e)&&_Jt(e)==wJt}var kJt=jJt;const NJt=ho(kJt);function VP(e){"@babel/helpers - typeof";return VP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},VP(e)}function iae(){return iae=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var s=0,n=new Array(t);s0,from:{upperWidth:0,lowerWidth:0,height:v,x:d,y:m},to:{upperWidth:p,lowerWidth:g,height:v,x:d,y:m},duration:w,animationEasing:k,isActive:T},function(I){var R=I.upperWidth,D=I.lowerWidth,B=I.height,$=I.x,q=I.y;return lt.createElement(f0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:S,duration:w,easing:k},lt.createElement("path",iae({},Za(s,!0),{className:C,d:VEe($,q,R,D,B),ref:n})))}):lt.createElement("g",null,lt.createElement("path",iae({},Za(s,!0),{className:C,d:VEe(d,m,p,g,v)})))},OJt=["option","shapeType","propTransformer","activeClassName","isActive"];function qP(e){"@babel/helpers - typeof";return qP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},qP(e)}function RJt(e,t){if(e==null)return{};var s=FJt(e,t),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function FJt(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function qEe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function oae(e){for(var t=1;t0?Vm(I,"paddingAngle",0):0;if(D){var $=Pv(D.endAngle-D.startAngle,I.endAngle-I.startAngle),q=ll(ll({},I),{},{startAngle:C+B,endAngle:C+$(w)+B});S.push(q),C=q.endAngle}else{var W=I.endAngle,K=I.startAngle,re=Pv(0,W-K),ae=re(w),oe=ll(ll({},I),{},{startAngle:C+B,endAngle:C+ae+B});S.push(oe),C=oe.endAngle}}),lt.createElement($o,null,n.renderSectorsStatically(S))})}},{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||!tle(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,m=a.cx,p=a.cy,g=a.innerRadius,v=a.outerRadius,_=a.isAnimationActive,k=this.state.isAnimationFinished;if(o||!l||!l.length||!Us(m)||!Us(p)||!Us(g)||!Us(v))return null;var w=ki("recharts-pie",i);return lt.createElement($o,{tabIndex:this.props.rootTabIndex,className:w,ref:function(T){n.pieRef=T}},this.renderSectors(),d&&this.renderLabels(l),Hd.renderCallByParent(this.props,null,!1),(!_||k)&&F1.renderCallByParent(this.props,l,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return a.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:a.curSectors,isAnimationFinished:!0}:n.sectors!==a.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,a){return n>a?"start":n=360?C:C-1)*d,R=S-C*_-I,D=a.reduce(function(q,W){var K=Eu(W,T,0);return q+(Us(K)?K:0)},0),B;if(D>0){var $;B=a.map(function(q,W){var K=Eu(q,T,0),re=Eu(q,p,W),ae=(Us(K)?K:0)/D,oe;W?oe=$.endAngle+mh(w)*d*(K!==0?1:0):oe=l;var se=oe+mh(w)*((K!==0?_:0)+ae*R),pe=(oe+se)/2,ie=(k.innerRadius+k.outerRadius)/2,de=[{name:re,value:K,payload:q,dataKey:T,type:v}],ce=ul(k.cx,k.cy,ie,pe);return $=ll(ll(ll({percent:ae,cornerRadius:o,name:re,tooltipPayload:de,midAngle:pe,middleRadius:ie,tooltipPosition:ce},q),k),{},{value:Eu(q,T),startAngle:oe,endAngle:se,payload:q,paddingAngle:mh(w)*d}),$})}return ll(ll({},k),{},{sectors:B,data:a})});var aer=Math.ceil,ier=Math.max;function oer(e,t,s,n){for(var a=-1,o=ier(aer((t-e)/(s||1)),0),l=Array(o);o--;)l[n?o:++a]=e,e+=s;return l}var ler=oer,cer=NWe,KEe=1/0,der=17976931348623157e292;function uer(e){if(!e)return e===0?e:0;if(e=cer(e),e===KEe||e===-KEe){var t=e<0?-1:1;return t*der}return e===e?e:0}var oKe=uer,her=ler,mer=qoe,Khe=oKe;function fer(e){return function(t,s,n){return n&&typeof n!="number"&&mer(t,s,n)&&(s=n=void 0),t=Khe(t),s===void 0?(s=t,t=0):s=Khe(s),n=n===void 0?t0&&n.handleDrag(a.changedTouches[0])}),_m(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()}),_m(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),_m(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),_m(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),_m(n,"handleSlideDragStart",function(a){var o=JEe(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 Mer(t,e),ker(t,[{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,m=i.data,p=m.length-1,g=Math.min(a,o),v=Math.max(a,o),_=t.getIndexInRange(l,g),k=t.getIndexInRange(l,v);return{startIndex:_-_%d,endIndex:k===p?p:k-k%d}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,d=Eu(o[n],i,n);return ri(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,m=d.x,p=d.width,g=d.travellerWidth,v=d.startIndex,_=d.endIndex,k=d.onChange,w=n.pageX-o;w>0?w=Math.min(w,m+p-g-i,m+p-g-l):w<0&&(w=Math.max(w,m-l,m-i));var S=this.getIndex({startX:l+w,endX:i+w});(S.startIndex!==v||S.endIndex!==_)&&k&&k(S),this.setState({startX:l+w,endX:i+w,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=JEe(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,m=this.state[l],p=this.props,g=p.x,v=p.width,_=p.travellerWidth,k=p.onChange,w=p.gap,S=p.data,T={startX:this.state.startX,endX:this.state.endX},C=n.pageX-o;C>0?C=Math.min(C,g+v-_-m):C<0&&(C=Math.max(C,g-m)),T[l]=m+C;var I=this.getIndex(T),R=I.startIndex,D=I.endIndex,B=function(){var q=S.length-1;return l==="startX"&&(i>d?R%w===0:D%w===0)||id?D%w===0:R%w===0)||i>d&&D===q};this.setState(_m(_m({},l,m+C),"brushMoveStartX",n.pageX),function(){k&&B()&&k(I)})}},{key:"handleTravellerMoveKeyboard",value:function(n,a){var o=this,l=this.state,i=l.scaleValues,d=l.startX,m=l.endX,p=this.state[a],g=i.indexOf(p);if(g!==-1){var v=g+n;if(!(v===-1||v>=i.length)){var _=i[v];a==="startX"&&_>=m||a==="endX"&&_<=d||this.setState(_m({},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,m=n.stroke;return lt.createElement("rect",{stroke:m,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,m=n.children,p=n.padding,g=A.Children.only(m);return g?lt.cloneElement(g,{x:a,y:o,width:l,height:i,margin:p,compact:!0,data:d}):null}},{key:"renderTravellerLayer",value:function(n,a){var o,l,i=this,d=this.props,m=d.y,p=d.travellerWidth,g=d.height,v=d.traveller,_=d.ariaLabel,k=d.data,w=d.startIndex,S=d.endIndex,T=Math.max(n,this.props.x),C=Zhe(Zhe({},Za(this.props,!1)),{},{x:T,y:m,width:p,height:g}),I=_||"Min value: ".concat((o=k[w])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=k[S])===null||l===void 0?void 0:l.name);return lt.createElement($o,{tabIndex:0,role:"slider","aria-label":I,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(D){["ArrowLeft","ArrowRight"].includes(D.key)&&(D.preventDefault(),D.stopPropagation(),i.handleTravellerMoveKeyboard(D.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(v,C))}},{key:"renderSlide",value:function(n,a){var o=this.props,l=o.y,i=o.height,d=o.stroke,m=o.travellerWidth,p=Math.min(n,a)+m,g=Math.max(Math.abs(a-n)-m,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:p,y:l,width:g,height:i})}},{key:"renderText",value:function(){var n=this.props,a=n.startIndex,o=n.endIndex,l=n.y,i=n.height,d=n.travellerWidth,m=n.stroke,p=this.state,g=p.startX,v=p.endX,_=5,k={pointerEvents:"none",fill:m};return lt.createElement($o,{className:"recharts-brush-texts"},lt.createElement(dN,dae({textAnchor:"end",verticalAnchor:"middle",x:Math.min(g,v)-_,y:l+i/2},k),this.getTextOfTick(a)),lt.createElement(dN,dae({textAnchor:"start",verticalAnchor:"middle",x:Math.max(g,v)+d+_,y:l+i/2},k),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,m=n.width,p=n.height,g=n.alwaysShowText,v=this.state,_=v.startX,k=v.endX,w=v.isTextActive,S=v.isSlideMoving,T=v.isTravellerMoving,C=v.isTravellerFocused;if(!a||!a.length||!Us(i)||!Us(d)||!Us(m)||!Us(p)||m<=0||p<=0)return null;var I=ki("recharts-brush",o),R=lt.Children.count(l)===1,D=wer("userSelect","none");return lt.createElement($o,{className:I,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:D},this.renderBackground(),R&&this.renderPanorama(),this.renderSlide(_,k),this.renderTravellerLayer(_,"startX"),this.renderTravellerLayer(k,"endX"),(w||S||T||C||g)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var a=n.x,o=n.y,l=n.width,i=n.height,d=n.stroke,m=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:m,x2:a+l-1,y2:m,fill:"none",stroke:"#fff"}),lt.createElement("line",{x1:a+1,y1:m+2,x2:a+l-1,y2:m+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,a){var o;return lt.isValidElement(n)?o=lt.cloneElement(n,a):ri(n)?o=n(a):o=t.renderDefaultTraveller(a),o}},{key:"getDerivedStateFromProps",value:function(n,a){var o=n.data,l=n.width,i=n.x,d=n.travellerWidth,m=n.updateId,p=n.startIndex,g=n.endIndex;if(o!==a.prevData||m!==a.prevUpdateId)return Zhe({prevData:o,prevTravellerWidth:d,prevUpdateId:m,prevX:i,prevWidth:l},o&&o.length?Aer({data:o,width:l,x:i,travellerWidth:d,startIndex:p,endIndex:g}):{scale:null,scaleValues:null});if(a.scale&&(l!==a.prevWidth||i!==a.prevX||d!==a.prevTravellerWidth)){a.scale.range([i,i+l-d]);var v=a.scale.domain().map(function(_){return a.scale(_)});return{prevData:o,prevTravellerWidth:d,prevUpdateId:m,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}}])}(A.PureComponent);_m(a3,"displayName","Brush");_m(a3,"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 Eer=Q_e;function Ier(e,t){var s;return Eer(e,function(n,a,o){return s=t(n,a,o),!s}),!!s}var Per=Ier,Ler=QHe,Der=Rx,Oer=Per,Rer=om,Fer=qoe;function zer(e,t,s){var n=Rer(e)?Ler:Oer;return s&&Fer(e,t,s)&&(t=void 0),n(e,Der(t))}var Ber=zer;const $er=ho(Ber);var _x=function(t,s){var n=t.alwaysShow,a=t.ifOverflow;return n&&(a="extendDomain"),a===s},eIe=_We;function Uer(e,t,s){t=="__proto__"&&eIe?eIe(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}var Ver=Uer,qer=Ver,Her=yWe,Wer=Rx;function Ger(e,t){var s={};return t=Wer(t),Her(e,function(n,a,o){qer(s,a,t(n,a,o))}),s}var Ker=Ger;const Zer=ho(Ker);function Yer(e,t){for(var s=-1,n=e==null?0:e.length;++s=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function mtr(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function ftr(e,t){var s=e.x,n=e.y,a=htr(e,ltr),o="".concat(s),l=parseInt(o,10),i="".concat(n),d=parseInt(i,10),m="".concat(t.height||a.height),p=parseInt(m,10),g="".concat(t.width||a.width),v=parseInt(g,10);return IA(IA(IA(IA(IA({},t),a),l?{x:l}:{}),d?{y:d}:{}),{},{height:p,width:v,name:t.name,radius:t.radius})}function rIe(e){return lt.createElement(nKe,Oxe({shapeType:"rectangle",propTransformer:ftr,activeClassName:"recharts-active-bar"},e))}var ptr=function(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(n,a){if(typeof t=="number")return t;var o=Us(n)||$Ot(n);return o?t(n,a):(o||hN(),s)}},gtr=["value","background"],hKe;function i3(e){"@babel/helpers - typeof";return i3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i3(e)}function xtr(e,t){if(e==null)return{};var s=ytr(e,t),n,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function ytr(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function hae(){return hae=Object.assign?Object.assign.bind():function(e){for(var t=1;t0&&Math.abs(pe)0&&Math.abs(se)0&&(oe=Math.min((Ze||0)-(se[Ae-1]||0),oe))}),Number.isFinite(oe)){var pe=oe/ae,ie=w.layout==="vertical"?n.height:n.width;if(w.padding==="gap"&&($=pe*ie/2),w.padding==="no-gap"){var de=fh(t.barCategoryGap,pe*ie),ce=pe*ie/2;$=ce-de-(ce-de)/ie*de}}}a==="xAxis"?q=[n.left+(I.left||0)+($||0),n.left+n.width-(I.right||0)-($||0)]:a==="yAxis"?q=d==="horizontal"?[n.top+n.height-(I.bottom||0),n.top+(I.top||0)]:[n.top+(I.top||0)+($||0),n.top+n.height-(I.bottom||0)-($||0)]:q=w.range,D&&(q=[q[1],q[0]]);var ge=IGe(w,o,v),Te=ge.scale,_e=ge.realScaleType;Te.domain(T).range(q),PGe(Te);var ve=LGe(Te,Up(Up({},w),{},{realScaleType:_e}));a==="xAxis"?(re=S==="top"&&!R||S==="bottom"&&R,W=n.left,K=g[B]-re*w.height):a==="yAxis"&&(re=S==="left"&&!R||S==="right"&&R,W=g[B]-re*w.width,K=n.top);var Me=Up(Up(Up({},w),ve),{},{realScaleType:_e,x:W,y:K,scale:Te,width:a==="xAxis"?n.width:w.width,height:a==="yAxis"?n.height:w.height});return Me.bandSize=Xne(Me,ve),!w.hide&&a==="xAxis"?g[B]+=(re?-1:1)*Me.height:w.hide||(g[B]+=(re?-1:1)*Me.width),Up(Up({},_),{},ule({},k,Me))},{})},gKe=function(t,s){var n=t.x,a=t.y,o=s.x,l=s.y;return{x:Math.min(n,o),y:Math.min(a,l),width:Math.abs(o-n),height:Math.abs(l-a)}},Atr=function(t){var s=t.x1,n=t.y1,a=t.x2,o=t.y2;return gKe({x:s,y:n},{x:a,y:o})},xKe=function(){function e(t){Str(this,e),this.scale=t}return Ctr(e,[{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(s){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.bandAware,o=n.position;if(s!==void 0){if(o)switch(o){case"start":return this.scale(s);case"middle":{var l=this.bandwidth?this.bandwidth()/2:0;return this.scale(s)+l}case"end":{var i=this.bandwidth?this.bandwidth():0;return this.scale(s)+i}default:return this.scale(s)}if(a){var d=this.bandwidth?this.bandwidth()/2:0;return this.scale(s)+d}return this.scale(s)}}},{key:"isInRange",value:function(s){var n=this.range(),a=n[0],o=n[n.length-1];return a<=o?s>=a&&s<=o:s>=o&&s<=a}}],[{key:"create",value:function(s){return new e(s)}}])}();ule(xKe,"EPS",1e-4);var Mbe=function(t){var s=Object.keys(t).reduce(function(n,a){return Up(Up({},n),{},ule({},a,xKe.create(t[a])))},{});return Up(Up({},s),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return Zer(a,function(d,m){return s[m].apply(d,{bandAware:l,position:i})})},isInRange:function(a){return uKe(a,function(o,l){return s[l].isInRange(o)})}})};function Etr(e){return(e%180+180)%180}var Itr=function(t){var s=t.width,n=t.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=Etr(a),l=o*Math.PI/180,i=Math.atan(n/s),d=l>i&&l-1?a[o?t[l]:l]:void 0}}var Rtr=Otr,Ftr=oKe;function ztr(e){var t=Ftr(e),s=t%1;return t===t?s?t-s:t:0}var Btr=ztr,$tr=hWe,Utr=Rx,Vtr=Btr,qtr=Math.max;function Htr(e,t,s){var n=e==null?0:e.length;if(!n)return-1;var a=s==null?0:Vtr(s);return a<0&&(a=qtr(n+a,0)),$tr(e,Utr(t),a)}var Wtr=Htr,Gtr=Rtr,Ktr=Wtr,Ztr=Gtr(Ktr),Ytr=Ztr;const Xtr=ho(Ytr);var Qtr=GDt(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),Tbe=A.createContext(void 0),Abe=A.createContext(void 0),yKe=A.createContext(void 0),vKe=A.createContext({}),_Ke=A.createContext(void 0),bKe=A.createContext(0),wKe=A.createContext(0),oIe=function(t){var s=t.state,n=s.xAxisMap,a=s.yAxisMap,o=s.offset,l=t.clipPathId,i=t.children,d=t.width,m=t.height,p=Qtr(o);return lt.createElement(Tbe.Provider,{value:n},lt.createElement(Abe.Provider,{value:a},lt.createElement(vKe.Provider,{value:o},lt.createElement(yKe.Provider,{value:p},lt.createElement(_Ke.Provider,{value:l},lt.createElement(bKe.Provider,{value:m},lt.createElement(wKe.Provider,{value:d},i)))))))},Jtr=function(){return A.useContext(_Ke)},jKe=function(t){var s=A.useContext(Tbe);s==null&&hN();var n=s[t];return n==null&&hN(),n},err=function(){var t=A.useContext(Tbe);return $v(t)},trr=function(){var t=A.useContext(Abe),s=Xtr(t,function(n){return uKe(n.domain,Number.isFinite)});return s||$v(t)},kKe=function(t){var s=A.useContext(Abe);s==null&&hN();var n=s[t];return n==null&&hN(),n},rrr=function(){var t=A.useContext(yKe);return t},srr=function(){return A.useContext(vKe)},Ebe=function(){return A.useContext(wKe)},Ibe=function(){return A.useContext(bKe)};function o3(e){"@babel/helpers - typeof";return o3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o3(e)}function nrr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function arr(e,t){for(var s=0;se.length)&&(t=e.length);for(var s=0,n=new Array(t);se*a)return!1;var o=s();return e*(t-e*o/2-n)>=0&&e*(t+e*o/2-a)<=0}function Brr(e,t){return EKe(e,t+1)}function $rr(e,t,s,n,a){for(var o=(n||[]).slice(),l=t.start,i=t.end,d=0,m=1,p=l,g=function(){var k=n==null?void 0:n[d];if(k===void 0)return{v:EKe(n,m)};var w=d,S,T=function(){return S===void 0&&(S=s(k,w)),S},C=k.coordinate,I=d===0||xae(e,C,T,p,i);I||(d=0,p=l,m+=1),I&&(p=C+e*(T()/2+a),d+=m)},v;m<=o.length;)if(v=g(),v)return v.v;return[]}function ZP(e){"@babel/helpers - typeof";return ZP=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ZP(e)}function pIe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function Mu(e){for(var t=1;t0?_.coordinate-S*e:_.coordinate})}else o[v]=_=Mu(Mu({},_),{},{tickCoord:_.coordinate});var T=xae(e,_.tickCoord,w,i,d);T&&(d=_.tickCoord-e*(w()/2+a),o[v]=Mu(Mu({},_),{},{isShow:!0}))},p=l-1;p>=0;p--)m(p);return o}function Wrr(e,t,s,n,a,o){var l=(n||[]).slice(),i=l.length,d=t.start,m=t.end;if(o){var p=n[i-1],g=s(p,i-1),v=e*(p.coordinate+e*g/2-m);l[i-1]=p=Mu(Mu({},p),{},{tickCoord:v>0?p.coordinate-v*e:p.coordinate});var _=xae(e,p.tickCoord,function(){return g},d,m);_&&(m=p.tickCoord-e*(g/2+a),l[i-1]=Mu(Mu({},p),{},{isShow:!0}))}for(var k=o?i-1:i,w=function(C){var I=l[C],R,D=function(){return R===void 0&&(R=s(I,C)),R};if(C===0){var B=e*(I.coordinate-e*D()/2-d);l[C]=I=Mu(Mu({},I),{},{tickCoord:B<0?I.coordinate-B*e:I.coordinate})}else l[C]=I=Mu(Mu({},I),{},{tickCoord:I.coordinate});var $=xae(e,I.tickCoord,D,d,m);$&&(d=I.tickCoord+e*(D()/2+a),l[C]=Mu(Mu({},I),{},{isShow:!0}))},S=0;S=2?mh(a[1].coordinate-a[0].coordinate):1,T=zrr(o,S,_);return d==="equidistantPreserveStart"?$rr(S,T,w,a,l):(d==="preserveStart"||d==="preserveStartEnd"?v=Wrr(S,T,w,a,l,d==="preserveStartEnd"):v=Hrr(S,T,w,a,l),v.filter(function(C){return C.isShow}))}var Grr=["viewBox"],Krr=["viewBox"],Zrr=["ticks"];function d3(e){"@babel/helpers - typeof";return d3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d3(e)}function s4(){return s4=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function Yrr(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function Xrr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function xIe(e,t){for(var s=0;s0?d(this.props):d(_)),l<=0||i<=0||!k||!k.length?null:lt.createElement($o,{className:ki("recharts-cartesian-axis",m),ref:function(S){n.layerReference=S}},o&&this.renderAxisLine(),this.renderTicks(k,this.state.fontSize,this.state.letterSpacing),Hd.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,a,o){var l,i=ki(a.className,"recharts-cartesian-axis-tick-value");return lt.isValidElement(n)?l=lt.cloneElement(n,pd(pd({},a),{},{className:i})):ri(n)?l=n(pd(pd({},a),{},{className:i})):l=lt.createElement(dN,s4({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(A.Component);Obe(sM,"displayName","CartesianAxis");Obe(sM,"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 nsr=["x1","y1","x2","y2","key"],asr=["offset"];function mN(e){"@babel/helpers - typeof";return mN=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mN(e)}function yIe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),s.push.apply(s,n)}return s}function Au(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function csr(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}var dsr=function(t){var s=t.fill;if(!s||s==="none")return null;var n=t.fillOpacity,a=t.x,o=t.y,l=t.width,i=t.height,d=t.ry;return lt.createElement("rect",{x:a,y:o,ry:d,width:l,height:i,stroke:"none",fill:s,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function LKe(e,t){var s;if(lt.isValidElement(e))s=lt.cloneElement(e,t);else if(ri(e))s=e(t);else{var n=t.x1,a=t.y1,o=t.x2,l=t.y2,i=t.key,d=vIe(t,nsr),m=Za(d,!1);m.offset;var p=vIe(m,asr);s=lt.createElement("line",Qj({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return s}function usr(e){var t=e.x,s=e.width,n=e.horizontal,a=n===void 0?!0:n,o=e.horizontalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,d){var m=Au(Au({},e),{},{x1:t,y1:i,x2:t+s,y2:i,key:"line-".concat(d),index:d});return LKe(a,m)});return lt.createElement("g",{className:"recharts-cartesian-grid-horizontal"},l)}function hsr(e){var t=e.y,s=e.height,n=e.vertical,a=n===void 0?!0:n,o=e.verticalPoints;if(!a||!o||!o.length)return null;var l=o.map(function(i,d){var m=Au(Au({},e),{},{x1:i,y1:t,x2:i,y2:t+s,key:"line-".concat(d),index:d});return LKe(a,m)});return lt.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function msr(e){var t=e.horizontalFill,s=e.fillOpacity,n=e.x,a=e.y,o=e.width,l=e.height,i=e.horizontalPoints,d=e.horizontal,m=d===void 0?!0:d;if(!m||!t||!t.length)return null;var p=i.map(function(v){return Math.round(v+a-a)}).sort(function(v,_){return v-_});a!==p[0]&&p.unshift(0);var g=p.map(function(v,_){var k=!p[_+1],w=k?a+l-v:p[_+1]-v;if(w<=0)return null;var S=_%t.length;return lt.createElement("rect",{key:"react-".concat(_),y:v,x:n,height:w,width:o,stroke:"none",fill:t[S],fillOpacity:s,className:"recharts-cartesian-grid-bg"})});return lt.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},g)}function fsr(e){var t=e.vertical,s=t===void 0?!0:t,n=e.verticalFill,a=e.fillOpacity,o=e.x,l=e.y,i=e.width,d=e.height,m=e.verticalPoints;if(!s||!n||!n.length)return null;var p=m.map(function(v){return Math.round(v+o-o)}).sort(function(v,_){return v-_});o!==p[0]&&p.unshift(0);var g=p.map(function(v,_){var k=!p[_+1],w=k?o+i-v:p[_+1]-v;if(w<=0)return null;var S=_%n.length;return lt.createElement("rect",{key:"react-".concat(_),x:v,y:l,width:w,height:d,stroke:"none",fill:n[S],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return lt.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},g)}var psr=function(t,s){var n=t.xAxis,a=t.width,o=t.height,l=t.offset;return EGe(Dbe(Au(Au(Au({},sM.defaultProps),n),{},{ticks:Iy(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,s)},gsr=function(t,s){var n=t.yAxis,a=t.width,o=t.height,l=t.offset;return EGe(Dbe(Au(Au(Au({},sM.defaultProps),n),{},{ticks:Iy(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,s)},AC={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function DKe(e){var t,s,n,a,o,l,i=Ebe(),d=Ibe(),m=srr(),p=Au(Au({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:AC.stroke,fill:(s=e.fill)!==null&&s!==void 0?s:AC.fill,horizontal:(n=e.horizontal)!==null&&n!==void 0?n:AC.horizontal,horizontalFill:(a=e.horizontalFill)!==null&&a!==void 0?a:AC.horizontalFill,vertical:(o=e.vertical)!==null&&o!==void 0?o:AC.vertical,verticalFill:(l=e.verticalFill)!==null&&l!==void 0?l:AC.verticalFill,x:Us(e.x)?e.x:m.left,y:Us(e.y)?e.y:m.top,width:Us(e.width)?e.width:m.width,height:Us(e.height)?e.height:m.height}),g=p.x,v=p.y,_=p.width,k=p.height,w=p.syncWithTicks,S=p.horizontalValues,T=p.verticalValues,C=err(),I=trr();if(!Us(_)||_<=0||!Us(k)||k<=0||!Us(g)||g!==+g||!Us(v)||v!==+v)return null;var R=p.verticalCoordinatesGenerator||psr,D=p.horizontalCoordinatesGenerator||gsr,B=p.horizontalPoints,$=p.verticalPoints;if((!B||!B.length)&&ri(D)){var q=S&&S.length,W=D({yAxis:I?Au(Au({},I),{},{ticks:q?S:I.ticks}):void 0,width:i,height:d,offset:m},q?!0:w);og(Array.isArray(W),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(mN(W),"]")),Array.isArray(W)&&(B=W)}if((!$||!$.length)&&ri(R)){var K=T&&T.length,re=R({xAxis:C?Au(Au({},C),{},{ticks:K?T:C.ticks}):void 0,width:i,height:d,offset:m},K?!0:w);og(Array.isArray(re),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(mN(re),"]")),Array.isArray(re)&&($=re)}return lt.createElement("g",{className:"recharts-cartesian-grid"},lt.createElement(dsr,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),lt.createElement(usr,Qj({},p,{offset:m,horizontalPoints:B,xAxis:C,yAxis:I})),lt.createElement(hsr,Qj({},p,{offset:m,verticalPoints:$,xAxis:C,yAxis:I})),lt.createElement(msr,Qj({},p,{horizontalPoints:B})),lt.createElement(fsr,Qj({},p,{verticalPoints:$})))}DKe.displayName="CartesianGrid";function u3(e){"@babel/helpers - typeof";return u3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u3(e)}function xsr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ysr(e,t){for(var s=0;se.length)&&(t=e.length);for(var s=0,n=new Array(t);s=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function nnr(e,t){if(e==null)return{};var s={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;s[n]=e[n]}return s}function anr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function inr(e,t){for(var s=0;se.length)&&(t=e.length);for(var s=0,n=new Array(t);s0?l:t&&t.length&&Us(a)&&Us(o)?t.slice(a,o+1):[]};function ZKe(e){return e==="number"?[0,"auto"]:void 0}var Jxe=function(t,s,n,a){var o=t.graphicalItems,l=t.tooltipAxis,i=yle(s,t);return n<0||!o||!o.length||n>=i.length?null:o.reduce(function(d,m){var p,g=(p=m.props.data)!==null&&p!==void 0?p:s;g&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=n&&(g=g.slice(t.dataStartIndex,t.dataEndIndex+1));var v;if(l.dataKey&&!l.allowDuplicatedCategory){var _=g===void 0?i:g;v=Sge(_,l.dataKey,a)}else v=g&&g[n]||i[n];return v?[].concat(f3(d),[OGe(m,v)]):d},[])},NIe=function(t,s,n,a){var o=a||{x:t.chartX,y:t.chartY},l=ynr(o,n),i=t.orderedTooltipTicks,d=t.tooltipAxis,m=t.tooltipTicks,p=JKt(l,i,m,d);if(p>=0&&m){var g=m[p]&&m[p].value,v=Jxe(t,s,p,g),_=vnr(n,i,p,o);return{activeTooltipIndex:p,activeLabel:g,activePayload:v,activeCoordinate:_}}return null},_nr=function(t,s){var n=s.axes,a=s.graphicalItems,o=s.axisType,l=s.axisIdKey,i=s.stackGroups,d=s.dataStartIndex,m=s.dataEndIndex,p=t.layout,g=t.children,v=t.stackOffset,_=AGe(p,o);return n.reduce(function(k,w){var S,T=w.type.defaultProps!==void 0?is(is({},w.type.defaultProps),w.props):w.props,C=T.type,I=T.dataKey,R=T.allowDataOverflow,D=T.allowDuplicatedCategory,B=T.scale,$=T.ticks,q=T.includeHidden,W=T[l];if(k[W])return k;var K=yle(t.data,{graphicalItems:a.filter(function(ve){var Me,Ze=l in ve.props?ve.props[l]:(Me=ve.type.defaultProps)===null||Me===void 0?void 0:Me[l];return Ze===W}),dataStartIndex:d,dataEndIndex:m}),re=K.length,ae,oe,se;Wsr(T.domain,R,C)&&(ae=fxe(T.domain,null,R),_&&(C==="number"||B!=="auto")&&(se=mI(K,I,"category")));var pe=ZKe(C);if(!ae||ae.length===0){var ie,de=(ie=T.domain)!==null&&ie!==void 0?ie:pe;if(I){if(ae=mI(K,I,C),C==="category"&&_){var ce=VOt(ae);D&&ce?(oe=ae,ae=cae(0,re)):D||(ae=YAe(de,ae,w).reduce(function(ve,Me){return ve.indexOf(Me)>=0?ve:[].concat(f3(ve),[Me])},[]))}else if(C==="category")D?ae=ae.filter(function(ve){return ve!==""&&!Bi(ve)}):ae=YAe(de,ae,w).reduce(function(ve,Me){return ve.indexOf(Me)>=0||Me===""||Bi(Me)?ve:[].concat(f3(ve),[Me])},[]);else if(C==="number"){var ge=nZt(K,a.filter(function(ve){var Me,Ze,Ae=l in ve.props?ve.props[l]:(Me=ve.type.defaultProps)===null||Me===void 0?void 0:Me[l],Le="hide"in ve.props?ve.props.hide:(Ze=ve.type.defaultProps)===null||Ze===void 0?void 0:Ze.hide;return Ae===W&&(q||!Le)}),I,o,p);ge&&(ae=ge)}_&&(C==="number"||B!=="auto")&&(se=mI(K,I,"category"))}else _?ae=cae(0,re):i&&i[W]&&i[W].hasStack&&C==="number"?ae=v==="expand"?[0,1]:DGe(i[W].stackGroups,d,m):ae=TGe(K,a.filter(function(ve){var Me=l in ve.props?ve.props[l]:ve.type.defaultProps[l],Ze="hide"in ve.props?ve.props.hide:ve.type.defaultProps.hide;return Me===W&&(q||!Ze)}),C,p,!0);if(C==="number")ae=Yxe(g,ae,W,o,$),de&&(ae=fxe(de,ae,R));else if(C==="category"&&de){var Te=de,_e=ae.every(function(ve){return Te.indexOf(ve)>=0});_e&&(ae=Te)}}return is(is({},k),{},za({},W,is(is({},T),{},{axisType:o,domain:ae,categoricalDomain:se,duplicateDomain:oe,originalDomain:(S=T.domain)!==null&&S!==void 0?S:pe,isCategorical:_,layout:p})))},{})},bnr=function(t,s){var n=s.graphicalItems,a=s.Axis,o=s.axisType,l=s.axisIdKey,i=s.stackGroups,d=s.dataStartIndex,m=s.dataEndIndex,p=t.layout,g=t.children,v=yle(t.data,{graphicalItems:n,dataStartIndex:d,dataEndIndex:m}),_=v.length,k=AGe(p,o),w=-1;return n.reduce(function(S,T){var C=T.type.defaultProps!==void 0?is(is({},T.type.defaultProps),T.props):T.props,I=C[l],R=ZKe("number");if(!S[I]){w++;var D;return k?D=cae(0,_):i&&i[I]&&i[I].hasStack?(D=DGe(i[I].stackGroups,d,m),D=Yxe(g,D,I,o)):(D=fxe(R,TGe(v,n.filter(function(B){var $,q,W=l in B.props?B.props[l]:($=B.type.defaultProps)===null||$===void 0?void 0:$[l],K="hide"in B.props?B.props.hide:(q=B.type.defaultProps)===null||q===void 0?void 0:q.hide;return W===I&&!K}),"number",p),a.defaultProps.allowDataOverflow),D=Yxe(g,D,I,o)),is(is({},S),{},za({},I,is(is({axisType:o},a.defaultProps),{},{hide:!0,orientation:Vm(gnr,"".concat(o,".").concat(w%2),null),domain:D,originalDomain:R,isCategorical:k,layout:p})))}return S},{})},wnr=function(t,s){var n=s.axisType,a=n===void 0?"xAxis":n,o=s.AxisComp,l=s.graphicalItems,i=s.stackGroups,d=s.dataStartIndex,m=s.dataEndIndex,p=t.children,g="".concat(a,"Id"),v=qf(p,o),_={};return v&&v.length?_=_nr(t,{axes:v,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:m}):l&&l.length&&(_=bnr(t,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:g,stackGroups:i,dataStartIndex:d,dataEndIndex:m})),_},jnr=function(t){var s=$v(t),n=Iy(s,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:J_e(n,function(a){return a.coordinate}),tooltipAxis:s,tooltipAxisBandSize:Xne(s,n)}},SIe=function(t){var s=t.children,n=t.defaultShowTooltip,a=jm(s,a3),o=0,l=0;return t.data&&t.data.length!==0&&(l=t.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}},knr=function(t){return!t||!t.length?!1:t.some(function(s){var n=Ky(s&&s.type);return n&&n.indexOf("Bar")>=0})},CIe=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Nnr=function(t,s){var n=t.props,a=t.graphicalItems,o=t.xAxisMap,l=o===void 0?{}:o,i=t.yAxisMap,d=i===void 0?{}:i,m=n.width,p=n.height,g=n.children,v=n.margin||{},_=jm(g,a3),k=jm(g,t5),w=Object.keys(d).reduce(function(D,B){var $=d[B],q=$.orientation;return!$.mirror&&!$.hide?is(is({},D),{},za({},q,D[q]+$.width)):D},{left:v.left||0,right:v.right||0}),S=Object.keys(l).reduce(function(D,B){var $=l[B],q=$.orientation;return!$.mirror&&!$.hide?is(is({},D),{},za({},q,Vm(D,"".concat(q))+$.height)):D},{top:v.top||0,bottom:v.bottom||0}),T=is(is({},S),w),C=T.bottom;_&&(T.bottom+=_.props.height||a3.defaultProps.height),k&&s&&(T=rZt(T,a,n,s));var I=m-T.left-T.right,R=p-T.top-T.bottom;return is(is({brushBottom:C},T),{},{width:Math.max(I,0),height:Math.max(R,0)})},Snr=function(t,s){if(s==="xAxis")return t[s].width;if(s==="yAxis")return t[s].height},YKe=function(t){var s=t.chartName,n=t.GraphicalChild,a=t.defaultTooltipEventType,o=a===void 0?"axis":a,l=t.validateTooltipEventTypes,i=l===void 0?["axis"]:l,d=t.axisComponents,m=t.legendContent,p=t.formatAxisMap,g=t.defaultProps,v=function(T,C){var I=C.graphicalItems,R=C.stackGroups,D=C.offset,B=C.updateId,$=C.dataStartIndex,q=C.dataEndIndex,W=T.barSize,K=T.layout,re=T.barGap,ae=T.barCategoryGap,oe=T.maxBarSize,se=CIe(K),pe=se.numericAxisName,ie=se.cateAxisName,de=knr(I),ce=[];return I.forEach(function(ge,Te){var _e=yle(T.data,{graphicalItems:[ge],dataStartIndex:$,dataEndIndex:q}),ve=ge.type.defaultProps!==void 0?is(is({},ge.type.defaultProps),ge.props):ge.props,Me=ve.dataKey,Ze=ve.maxBarSize,Ae=ve["".concat(pe,"Id")],Le=ve["".concat(ie,"Id")],Ue={},Ve=d.reduce(function(et,Qe){var He=C["".concat(Qe.axisType,"Map")],ot=ve["".concat(Qe.axisType,"Id")];He&&He[ot]||Qe.axisType==="zAxis"||hN();var ut=He[ot];return is(is({},et),{},za(za({},Qe.axisType,ut),"".concat(Qe.axisType,"Ticks"),Iy(ut)))},Ue),Ie=Ve[ie],We=Ve["".concat(ie,"Ticks")],wt=R&&R[Ae]&&R[Ae].hasStack&&mZt(ge,R[Ae].stackGroups),Pe=Ky(ge.type).indexOf("Bar")>=0,st=Xne(Ie,We),ue=[],$e=de&&eZt({barSize:W,stackGroups:R,totalSize:Snr(Ve,ie)});if(Pe){var tt,rt,je=Bi(Ze)?oe:Ze,it=(tt=(rt=Xne(Ie,We,!0))!==null&&rt!==void 0?rt:je)!==null&&tt!==void 0?tt:0;ue=tZt({barGap:re,barCategoryGap:ae,bandSize:it!==st?it:st,sizeList:$e[Le],maxBarSize:je}),it!==st&&(ue=ue.map(function(et){return is(is({},et),{},{position:is(is({},et.position),{},{offset:et.position.offset-it/2})})}))}var Se=ge&&ge.type&&ge.type.getComposedData;Se&&ce.push({props:is(is({},Se(is(is({},Ve),{},{displayedData:_e,props:T,dataKey:Me,item:ge,bandSize:st,barPosition:ue,offset:D,stackedData:wt,layout:K,dataStartIndex:$,dataEndIndex:q}))),{},za(za(za({key:ge.key||"item-".concat(Te)},pe,Ve[pe]),ie,Ve[ie]),"animationId",B)),childIndex:t8t(ge,T.children),item:ge})}),ce},_=function(T,C){var I=T.props,R=T.dataStartIndex,D=T.dataEndIndex,B=T.updateId;if(!qMe({props:I}))return null;var $=I.children,q=I.layout,W=I.stackOffset,K=I.data,re=I.reverseStackOrder,ae=CIe(q),oe=ae.numericAxisName,se=ae.cateAxisName,pe=qf($,n),ie=uZt(K,pe,"".concat(oe,"Id"),"".concat(se,"Id"),W,re),de=d.reduce(function(ve,Me){var Ze="".concat(Me.axisType,"Map");return is(is({},ve),{},za({},Ze,wnr(I,is(is({},Me),{},{graphicalItems:pe,stackGroups:Me.axisType===oe&&ie,dataStartIndex:R,dataEndIndex:D}))))},{}),ce=Nnr(is(is({},de),{},{props:I,graphicalItems:pe}),C==null?void 0:C.legendBBox);Object.keys(de).forEach(function(ve){de[ve]=p(I,de[ve],ce,ve.replace("Map",""),s)});var ge=de["".concat(se,"Map")],Te=jnr(ge),_e=v(I,is(is({},de),{},{dataStartIndex:R,dataEndIndex:D,updateId:B,graphicalItems:pe,stackGroups:ie,offset:ce}));return is(is({formattedGraphicalItems:_e,graphicalItems:pe,offset:ce,stackGroups:ie},Te),de)},k=function(S){function T(C){var I,R,D;return anr(this,T),D=lnr(this,T,[C]),za(D,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),za(D,"accessibilityManager",new Hsr),za(D,"handleLegendBBoxUpdate",function(B){if(B){var $=D.state,q=$.dataStartIndex,W=$.dataEndIndex,K=$.updateId;D.setState(is({legendBBox:B},_({props:D.props,dataStartIndex:q,dataEndIndex:W,updateId:K},is(is({},D.state),{},{legendBBox:B}))))}}),za(D,"handleReceiveSyncEvent",function(B,$,q){if(D.props.syncId===B){if(q===D.eventEmitterSymbol&&typeof D.props.syncMethod!="function")return;D.applySyncEvent($)}}),za(D,"handleBrushChange",function(B){var $=B.startIndex,q=B.endIndex;if($!==D.state.dataStartIndex||q!==D.state.dataEndIndex){var W=D.state.updateId;D.setState(function(){return is({dataStartIndex:$,dataEndIndex:q},_({props:D.props,dataStartIndex:$,dataEndIndex:q,updateId:W},D.state))}),D.triggerSyncEvent({dataStartIndex:$,dataEndIndex:q})}}),za(D,"handleMouseEnter",function(B){var $=D.getMouseInfo(B);if($){var q=is(is({},$),{},{isTooltipActive:!0});D.setState(q),D.triggerSyncEvent(q);var W=D.props.onMouseEnter;ri(W)&&W(q,B)}}),za(D,"triggeredAfterMouseMove",function(B){var $=D.getMouseInfo(B),q=$?is(is({},$),{},{isTooltipActive:!0}):{isTooltipActive:!1};D.setState(q),D.triggerSyncEvent(q);var W=D.props.onMouseMove;ri(W)&&W(q,B)}),za(D,"handleItemMouseEnter",function(B){D.setState(function(){return{isTooltipActive:!0,activeItem:B,activePayload:B.tooltipPayload,activeCoordinate:B.tooltipPosition||{x:B.cx,y:B.cy}}})}),za(D,"handleItemMouseLeave",function(){D.setState(function(){return{isTooltipActive:!1}})}),za(D,"handleMouseMove",function(B){B.persist(),D.throttleTriggeredAfterMouseMove(B)}),za(D,"handleMouseLeave",function(B){D.throttleTriggeredAfterMouseMove.cancel();var $={isTooltipActive:!1};D.setState($),D.triggerSyncEvent($);var q=D.props.onMouseLeave;ri(q)&&q($,B)}),za(D,"handleOuterEvent",function(B){var $=e8t(B),q=Vm(D.props,"".concat($));if($&&ri(q)){var W,K;/.*touch.*/i.test($)?K=D.getMouseInfo(B.changedTouches[0]):K=D.getMouseInfo(B),q((W=K)!==null&&W!==void 0?W:{},B)}}),za(D,"handleClick",function(B){var $=D.getMouseInfo(B);if($){var q=is(is({},$),{},{isTooltipActive:!0});D.setState(q),D.triggerSyncEvent(q);var W=D.props.onClick;ri(W)&&W(q,B)}}),za(D,"handleMouseDown",function(B){var $=D.props.onMouseDown;if(ri($)){var q=D.getMouseInfo(B);$(q,B)}}),za(D,"handleMouseUp",function(B){var $=D.props.onMouseUp;if(ri($)){var q=D.getMouseInfo(B);$(q,B)}}),za(D,"handleTouchMove",function(B){B.changedTouches!=null&&B.changedTouches.length>0&&D.throttleTriggeredAfterMouseMove(B.changedTouches[0])}),za(D,"handleTouchStart",function(B){B.changedTouches!=null&&B.changedTouches.length>0&&D.handleMouseDown(B.changedTouches[0])}),za(D,"handleTouchEnd",function(B){B.changedTouches!=null&&B.changedTouches.length>0&&D.handleMouseUp(B.changedTouches[0])}),za(D,"handleDoubleClick",function(B){var $=D.props.onDoubleClick;if(ri($)){var q=D.getMouseInfo(B);$(q,B)}}),za(D,"handleContextMenu",function(B){var $=D.props.onContextMenu;if(ri($)){var q=D.getMouseInfo(B);$(q,B)}}),za(D,"triggerSyncEvent",function(B){D.props.syncId!==void 0&&Xhe.emit(Qhe,D.props.syncId,B,D.eventEmitterSymbol)}),za(D,"applySyncEvent",function(B){var $=D.props,q=$.layout,W=$.syncMethod,K=D.state.updateId,re=B.dataStartIndex,ae=B.dataEndIndex;if(B.dataStartIndex!==void 0||B.dataEndIndex!==void 0)D.setState(is({dataStartIndex:re,dataEndIndex:ae},_({props:D.props,dataStartIndex:re,dataEndIndex:ae,updateId:K},D.state)));else if(B.activeTooltipIndex!==void 0){var oe=B.chartX,se=B.chartY,pe=B.activeTooltipIndex,ie=D.state,de=ie.offset,ce=ie.tooltipTicks;if(!de)return;if(typeof W=="function")pe=W(ce,B);else if(W==="value"){pe=-1;for(var ge=0;ge=0){var wt,Pe;if(oe.dataKey&&!oe.allowDuplicatedCategory){var st=typeof oe.dataKey=="function"?We:"payload.".concat(oe.dataKey.toString());wt=Sge(ge,st,pe),Pe=Te&&_e&&Sge(_e,st,pe)}else wt=ge==null?void 0:ge[se],Pe=Te&&_e&&_e[se];if(Le||Ae){var ue=B.props.activeIndex!==void 0?B.props.activeIndex:se;return[A.cloneElement(B,is(is(is({},W.props),Ve),{},{activeIndex:ue})),null,null]}if(!Bi(wt))return[Ie].concat(f3(D.renderActivePoints({item:W,activePoint:wt,basePoint:Pe,childIndex:se,isRange:Te})))}else{var $e,tt=($e=D.getItemByXY(D.state.activeCoordinate))!==null&&$e!==void 0?$e:{graphicalItem:Ie},rt=tt.graphicalItem,je=rt.item,it=je===void 0?B:je,Se=rt.childIndex,et=is(is(is({},W.props),Ve),{},{activeIndex:Se});return[A.cloneElement(it,et),null,null]}return Te?[Ie,null,null]:[Ie,null]}),za(D,"renderCustomized",function(B,$,q){return A.cloneElement(B,is(is({key:"recharts-customized-".concat(q)},D.props),D.state))}),za(D,"renderMap",{CartesianGrid:{handler:h8,once:!0},ReferenceArea:{handler:D.renderReferenceElement},ReferenceLine:{handler:h8},ReferenceDot:{handler:D.renderReferenceElement},XAxis:{handler:h8},YAxis:{handler:h8},Brush:{handler:D.renderBrush,once:!0},Bar:{handler:D.renderGraphicChild},Line:{handler:D.renderGraphicChild},Area:{handler:D.renderGraphicChild},Radar:{handler:D.renderGraphicChild},RadialBar:{handler:D.renderGraphicChild},Scatter:{handler:D.renderGraphicChild},Pie:{handler:D.renderGraphicChild},Funnel:{handler:D.renderGraphicChild},Tooltip:{handler:D.renderCursor,once:!0},PolarGrid:{handler:D.renderPolarGrid,once:!0},PolarAngleAxis:{handler:D.renderPolarAxis},PolarRadiusAxis:{handler:D.renderPolarAxis},Customized:{handler:D.renderCustomized}}),D.clipPathId="".concat((I=C.id)!==null&&I!==void 0?I:H6("recharts"),"-clip"),D.throttleTriggeredAfterMouseMove=SWe(D.triggeredAfterMouseMove,(R=C.throttleDelay)!==null&&R!==void 0?R:1e3/60),D.state={},D}return unr(T,S),onr(T,[{key:"componentDidMount",value:function(){var I,R;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(I=this.props.margin.left)!==null&&I!==void 0?I:0,top:(R=this.props.margin.top)!==null&&R!==void 0?R:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var I=this.props,R=I.children,D=I.data,B=I.height,$=I.layout,q=jm(R,$p);if(q){var W=q.props.defaultIndex;if(!(typeof W!="number"||W<0||W>this.state.tooltipTicks.length-1)){var K=this.state.tooltipTicks[W]&&this.state.tooltipTicks[W].value,re=Jxe(this.state,D,W,K),ae=this.state.tooltipTicks[W].coordinate,oe=(this.state.offset.top+B)/2,se=$==="horizontal",pe=se?{x:ae,y:oe}:{y:ae,x:oe},ie=this.state.formattedGraphicalItems.find(function(ce){var ge=ce.item;return ge.type.name==="Scatter"});ie&&(pe=is(is({},pe),ie.props.points[W].tooltipPosition),re=ie.props.points[W].tooltipPayload);var de={activeTooltipIndex:W,isTooltipActive:!0,activeLabel:K,activePayload:re,activeCoordinate:pe};this.setState(de),this.renderCursor(q),this.accessibilityManager.setIndex(W)}}}},{key:"getSnapshotBeforeUpdate",value:function(I,R){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==R.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==I.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==I.margin){var D,B;this.accessibilityManager.setDetails({offset:{left:(D=this.props.margin.left)!==null&&D!==void 0?D:0,top:(B=this.props.margin.top)!==null&&B!==void 0?B:0}})}return null}},{key:"componentDidUpdate",value:function(I){Mge([jm(I.children,$p)],[jm(this.props.children,$p)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var I=jm(this.props.children,$p);if(I&&typeof I.props.shared=="boolean"){var R=I.props.shared?"axis":"item";return i.indexOf(R)>=0?R:o}return o}},{key:"getMouseInfo",value:function(I){if(!this.container)return null;var R=this.container,D=R.getBoundingClientRect(),B=Cqt(D),$={chartX:Math.round(I.pageX-B.left),chartY:Math.round(I.pageY-B.top)},q=D.width/R.offsetWidth||1,W=this.inRange($.chartX,$.chartY,q);if(!W)return null;var K=this.state,re=K.xAxisMap,ae=K.yAxisMap,oe=this.getTooltipEventType(),se=NIe(this.state,this.props.data,this.props.layout,W);if(oe!=="axis"&&re&&ae){var pe=$v(re).scale,ie=$v(ae).scale,de=pe&&pe.invert?pe.invert($.chartX):null,ce=ie&&ie.invert?ie.invert($.chartY):null;return is(is({},$),{},{xValue:de,yValue:ce},se)}return se?is(is({},$),se):null}},{key:"inRange",value:function(I,R){var D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,B=this.props.layout,$=I/D,q=R/D;if(B==="horizontal"||B==="vertical"){var W=this.state.offset,K=$>=W.left&&$<=W.left+W.width&&q>=W.top&&q<=W.top+W.height;return K?{x:$,y:q}:null}var re=this.state,ae=re.angleAxisMap,oe=re.radiusAxisMap;if(ae&&oe){var se=$v(ae);return JAe({x:$,y:q},se)}return null}},{key:"parseEventsOfWrapper",value:function(){var I=this.props.children,R=this.getTooltipEventType(),D=jm(I,$p),B={};D&&R==="axis"&&(D.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 $=kne(this.props,this.handleOuterEvent);return is(is({},$),B)}},{key:"addListener",value:function(){Xhe.on(Qhe,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Xhe.removeListener(Qhe,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(I,R,D){for(var B=this.state.formattedGraphicalItems,$=0,q=B.length;$");return e}const JKe=A.forwardRef(({id:e,className:t,children:s,config:n,...a},o)=>{const l=A.useId(),i=`chart-${e||l.replace(/:/g,"")}`;return r.jsx(XKe.Provider,{value:{config:n},children:r.jsxs("div",{"data-chart":i,ref:o,className:Vt("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",t),...a,children:[r.jsx(Anr,{id:i,config:n}),r.jsx(Xge,{children:s})]})})});JKe.displayName="Chart";const Anr=({id:e,config:t})=>{const s=Object.entries(t).filter(([n,a])=>a.theme||a.color);return s.length?r.jsx("style",{dangerouslySetInnerHTML:{__html:Object.entries(Tnr).map(([n,a])=>` ${a} [data-chart=${e}] { ${s.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},eZe=A.forwardRef(({active:e,payload:t,className:s,indicator:n="dot",hideLabel:a=!1,hideIndicator:o=!1,label:l,labelFormatter:i,labelClassName:d,formatter:m,color:p,nameKey:g,labelKey:v},_)=>{const{config:k}=QKe(),w=A.useMemo(()=>{var D;if(a||!(t!=null&&t.length))return null;const[T]=t,C=`${v||T.dataKey||T.name||"value"}`,I=eye(k,T,C),R=!v&&typeof l=="string"?((D=k[l])==null?void 0:D.label)||l:I==null?void 0:I.label;return i?r.jsx("div",{className:Vt("font-medium",d),children:i(R,t)}):R?r.jsx("div",{className:Vt("font-medium",d),children:R}):null},[l,i,t,a,d,k,v]);if(!e||!(t!=null&&t.length))return null;const S=t.length===1&&n!=="dot";return r.jsxs("div",{ref:_,className:Vt("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",s),children:[S?null:w,r.jsx("div",{className:"grid gap-1.5",children:t.map((T,C)=>{const I=`${g||T.name||T.dataKey||"value"}`,R=eye(k,T,I),D=p||T.payload.fill||T.color;return r.jsx("div",{className:Vt("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:m&&(T==null?void 0:T.value)!==void 0&&T.name?m(T.value,T.name,T,C,T.payload):r.jsxs(r.Fragment,{children:[R!=null&&R.icon?r.jsx(R.icon,{}):!o&&r.jsx("div",{className:Vt("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":S&&n==="dashed"}),style:{"--color-bg":D,"--color-border":D}}),r.jsxs("div",{className:Vt("flex flex-1 justify-between leading-none",S?"items-end":"items-center"),children:[r.jsxs("div",{className:"grid gap-1.5",children:[S?w:null,r.jsx("span",{className:"text-muted-foreground",children:(R==null?void 0:R.label)||T.name})]}),T.value&&r.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:T.value.toLocaleString()})]})]})},T.dataKey)})})]})});eZe.displayName="ChartTooltip";const Enr=A.forwardRef(({className:e,hideIcon:t=!1,payload:s,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=QKe();return s!=null&&s.length?r.jsx("div",{ref:o,className:Vt("flex items-center justify-center gap-4",n==="top"?"pb-3":"pt-3",e),children:s.map(i=>{const d=`${a||i.dataKey||"value"}`,m=eye(l,i,d);return r.jsxs("div",{className:Vt("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),children:[m!=null&&m.icon&&!t?r.jsx(m.icon,{}):r.jsx("div",{className:"h-2 w-2 shrink-0 rounded-[2px]",style:{backgroundColor:i.color}}),m==null?void 0:m.label]},i.value)})}):null});Enr.displayName="ChartLegend";function eye(e,t,s){if(typeof t!="object"||t===null)return;const n="payload"in t&&typeof t.payload=="object"&&t.payload!==null?t.payload:void 0;let a=s;return s in t&&typeof t[s]=="string"?a=t[s]:n&&s in n&&typeof n[s]=="string"&&(a=n[s]),a in e?e[a]:e[s]}const m8=["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 tZe({stats:e,year:t}){const s=e.transactionsByMonth.some(a=>a.count>0),n=e.leadSourceBreakdown.length>0;return!s&&!n?r.jsx(ze,{children:r.jsx(qe,{className:"py-12 text-center text-muted-foreground",children:"Add transactions to see your performance charts"})}):r.jsxs("div",{className:"grid gap-6",children:[s&&r.jsxs(ze,{className:"overflow-hidden",children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-base",children:"Transactions by Month"})}),r.jsx(qe,{className:"overflow-hidden",children:r.jsx(JKe,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:r.jsx(Xge,{width:"100%",height:"100%",children:r.jsxs(Cnr,{data:e.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[r.jsx(DKe,{strokeDasharray:"3 3",className:"stroke-muted"}),r.jsx(gle,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),r.jsx(xle,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),r.jsx($p,{content:r.jsx(eZe,{})}),r.jsx(TN,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-base",children:"Lead Sources"})}),r.jsxs(qe,{children:[r.jsx("div",{className:"h-[250px]",children:r.jsx(Xge,{width:"100%",height:"100%",children:r.jsxs(Mnr,{children:[r.jsx(b0,{data:e.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:e.leadSourceBreakdown.map((a,o)=>r.jsx(Hoe,{fill:m8[o%m8.length]},`cell-${o}`))}),r.jsx($p,{formatter:(a,o)=>[`${a} deals`,o]})]})})}),r.jsx("div",{className:"flex flex-wrap gap-2 mt-2 justify-center",children:e.leadSourceBreakdown.slice(0,6).map((a,o)=>r.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[r.jsx("div",{className:"w-3 h-3 rounded-sm",style:{backgroundColor:m8[o%m8.length]}}),r.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function Inr(e){if(!e||!e.trim())return null;const t=e.trim(),s=["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 s)try{const a=Ove(t,n,new Date);if(gpe(a))return Xr(a,"yyyy-MM-dd")}catch{}try{const n=new Date(t);if(gpe(n))return Xr(n,"yyyy-MM-dd")}catch{}return null}const Pnr=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function Lnr({open:e,onOpenChange:t}){const[s,n]=A.useState([]),[a,o]=A.useState(!1),[l,i]=A.useState(0),{data:d}=Uie(),{data:m}=gg(),p=Vie(),g=()=>{const T=Pnr.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),I=`${T} ${C}`,R=new Blob([I],{type:"text/csv"}),D=URL.createObjectURL(R),B=document.createElement("a");B.href=D,B.download="transaction-import-template.csv",B.click(),URL.revokeObjectURL(D)},v=T=>{const C=T.split(` `).filter(R=>R.trim());if(C.length<2)return[];const I=C[0].split(",").map(R=>R.trim().toLowerCase().replace(/['"]/g,""));return C.slice(1).map((R,D)=>{var de,ce,ge,Te;const B=[];let $="",q=!1;for(const _e of R)_e==='"'?q=!q:_e===","&&!q?(B.push($.trim()),$=""):$+=_e;B.push($.trim());const W=_e=>{var Me;const ve=I.indexOf(_e);return ve>=0?(Me=B[ve])==null?void 0:Me.replace(/^["']|["']$/g,"").trim():""},K=(de=W("transaction_type"))==null?void 0:de.toLowerCase(),re=(ce=W("sale_price"))==null?void 0:ce.replace(/[$,]/g,""),ae=(ge=W("commission_amount"))==null?void 0:ge.replace(/[$,]/g,""),oe=(Te=W("is_win"))==null?void 0:Te.toLowerCase(),se=W("close_date"),pe=Inr(se);let ie;return W("property_address")?["buyer","seller"].includes(K)?pe?(!re||isNaN(Number(re)))&&(ie="Invalid sale price"):ie=`Invalid date format: "${se}" - use MM/DD/YYYY or YYYY-MM-DD`:ie='Transaction type must be "buyer" or "seller"':ie="Missing property address",{property_address:W("property_address"),city:W("city"),state:W("state"),zip:W("zip"),transaction_type:K==="seller"?"seller":"buyer",close_date:pe||"",sale_price:Number(re)||0,commission_amount:ae?Number(ae):null,lead_source_name:W("lead_source"),client_type_name:W("client_type"),is_win:["yes","true","1"].includes(oe),notes:W("notes"),error:ie}})},_=T=>{var R;const C=(R=T.target.files)==null?void 0:R[0];if(!C)return;const I=new FileReader;I.onload=D=>{var q;const B=(q=D.target)==null?void 0:q.result,$=v(B);n($)},I.readAsText(C)},k=async()=>{const T=s.filter(R=>!R.error);if(T.length===0){we.error("No valid transactions to import");return}o(!0),i(0);let C=0,I=0;for(let R=0;Rq.name.toLowerCase()===D.lead_source_name.toLowerCase()),$=m==null?void 0:m.find(q=>q.name.toLowerCase()===D.client_type_name.toLowerCase());await p.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,lead_source_id:(B==null?void 0:B.id)||null,client_type_id:($==null?void 0:$.id)||null,contact_id:null,notes:D.notes||null,is_win:D.is_win}),C++}catch(B){I++,console.error("Failed to import transaction:",B)}i(Math.round((R+1)/T.length*100))}o(!1),C>0&&we.success(`Imported ${C} transaction${C>1?"s":""}`),I>0&&we.error(`Failed to import ${I} transaction${I>1?"s":""}`),n([]),t(!1)},w=s.filter(T=>!T.error).length,S=s.filter(T=>T.error).length;return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-2xl max-h-[90vh]",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Import Transactions"}),r.jsx(Zs,{children:"Upload a CSV file with your past transactions"})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg bg-muted/50",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Download Template"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Get a CSV template with the correct format"})]}),r.jsxs(X,{variant:"outline",onClick:g,children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Template"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"csv-file",children:"Upload CSV File"}),r.jsx(Ye,{id:"csv-file",type:"file",accept:".csv",onChange:_})]}),s.length>0&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(_t,{variant:"outline",children:[s.length," rows found"]}),w>0&&r.jsxs(_t,{className:"bg-green-500 text-white",children:[r.jsx(mi,{className:"h-3 w-3 mr-1"}),w," valid"]}),S>0&&r.jsxs(_t,{variant:"destructive",children:[r.jsx(kl,{className:"h-3 w-3 mr-1"}),S," errors"]})]}),r.jsx(To,{className:"h-[200px] border rounded-lg",children:r.jsxs("div",{className:"p-2 space-y-2",children:[s.slice(0,10).map((T,C)=>r.jsxs("div",{className:`p-2 rounded text-sm ${T.error?"bg-destructive/10":"bg-muted/50"}`,children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-medium",children:T.property_address||"(no address)"}),r.jsx(_t,{variant:T.transaction_type==="buyer"?"default":"secondary",children:T.transaction_type})]}),r.jsxs("div",{className:"text-muted-foreground",children:[T.close_date," • $",T.sale_price.toLocaleString()]}),T.error&&r.jsx(m_e,{variant:"destructive",className:"mt-1 py-1",children:r.jsx(f_e,{className:"text-xs",children:T.error})})]},C)),s.length>10&&r.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["...and ",s.length-10," more"]})]})}),a&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"w-full bg-muted rounded-full h-2",children:r.jsx("div",{className:"bg-primary h-2 rounded-full transition-all",style:{width:`${l}%`}})}),r.jsxs("p",{className:"text-sm text-center text-muted-foreground",children:["Importing... ",l,"%"]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{onClick:k,disabled:w===0||a,children:[r.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Import ",w," Transaction",w!==1?"s":""]})]})]})]})})}const Dnr=i_({transactions_goal:KE().min(0).optional(),volume_goal:KE().min(0).optional(),gci_goal:KE().min(0).optional()});function Onr({open:e,onOpenChange:t,year:s,existingGoals:n}){const a=rwt(),{data:o}=qie(),l=(o==null?void 0:o.show_commission)??!0,i=Pie({resolver:Lie(Dnr),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});A.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,e]);const d=async m=>{await a.mutateAsync({year:s,transactions_goal:m.transactions_goal??null,volume_goal:m.volume_goal??null,gci_goal:l?m.gci_goal??null:null}),t(!1)};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-md",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{children:[s," Goals"]}),r.jsx(Zs,{children:"Set your annual targets to track your progress throughout the year."})]}),r.jsx(Die,{...i,children:r.jsxs("form",{onSubmit:i.handleSubmit(d),className:"space-y-4",children:[r.jsx(Hl,{control:i.control,name:"transactions_goal",render:({field:m})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Transactions Goal"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"number",placeholder:"e.g., 24",...m,value:m.value??"",onChange:p=>m.onChange(p.target.value?Number(p.target.value):void 0)})}),r.jsx(ire,{children:"Total number of deals you want to close"}),r.jsx(uh,{})]})}),r.jsx(Hl,{control:i.control,name:"volume_goal",render:({field:m})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"Volume Goal ($)"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"number",placeholder:"e.g., 5000000",...m,value:m.value??"",onChange:p=>m.onChange(p.target.value?Number(p.target.value):void 0)})}),r.jsx(ire,{children:"Total sales volume you want to achieve"}),r.jsx(uh,{})]})}),l&&r.jsx(Hl,{control:i.control,name:"gci_goal",render:({field:m})=>r.jsxs(Il,{children:[r.jsx(Pl,{children:"GCI Goal ($)"}),r.jsx(Ll,{children:r.jsx(Ye,{type:"number",placeholder:"e.g., 150000",...m,value:m.value??"",onChange:p=>m.onChange(p.target.value?Number(p.target.value):void 0)})}),r.jsx(ire,{children:"Gross commission income target"}),r.jsx(uh,{})]})}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsx(X,{type:"submit",disabled:a.isPending,children:"Save Goals"})]})]})})]})})}function rZe({transactions:e,isLoading:t}){const s=A.useRef(null),n=A.useRef(null),a=A.useRef([]),o=A.useRef(null),{isAdmin:l}=Gr(),[i,d]=A.useState(""),[m,p]=A.useState(!0),[g,v]=A.useState(0),[_,k]=A.useState(!1),w=e.filter(T=>T.latitude!=null&&T.longitude!=null),S=e.filter(T=>T.latitude==null||T.longitude==null);return A.useEffect(()=>{(async()=>{p(!0);try{const{data:C}=await Y.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&d(C.value)}catch(C){console.error("Error fetching mapbox token:",C)}p(!1)})()},[]),A.useEffect(()=>{if(!i||S.length===0||_)return;(async()=>{var I;k(!0);let C=0;for(const R of S){const D=[R.property_address,R.city,R.state,R.zip].filter(Boolean).join(", ");if(D)try{const $=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(D)}.json?access_token=${i}&limit=1`)).json();if((I=$.features)!=null&&I[0]){const[q,W]=$.features[0].center;await Y.from("scorecard_transactions").update({latitude:W,longitude:q}).eq("id",R.id),R.latitude=W,R.longitude=q,C++}}catch(B){console.error("Geocode error:",B)}}v(C),k(!1)})()},[i,e]),A.useEffect(()=>{if(!s.current||!i||n.current)return;fc.accessToken=i;const T=e.filter(R=>R.latitude!=null&&R.longitude!=null);let C=[-98.5795,39.8283],I=4;if(T.length>0){const R=T.reduce((B,$)=>B+$.longitude,0)/T.length,D=T.reduce((B,$)=>B+$.latitude,0)/T.length;C=[R,D],I=T.length===1?12:10}return n.current=new fc.Map({container:s.current,style:"mapbox://styles/mapbox/light-v11",zoom:I,center:C}),n.current.addControl(new fc.NavigationControl,"top-right"),()=>{var R;(R=n.current)==null||R.remove(),n.current=null}},[i]),A.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(I=>I.remove()),a.current=[],(C=o.current)==null||C.remove();const T=e.filter(I=>I.latitude!=null&&I.longitude!=null);if(T.forEach(I=>{var W;const R=I.transaction_type==="buyer",D=R?"#3B82F6":"#10B981",B=document.createElement("div");B.className="cursor-pointer",B.innerHTML=`
${R?'':''}
`;const $=new fc.Popup({offset:25,closeButton:!0}).setHTML(`
${I.property_address}
${I.city?`
${I.city}${I.state?", "+I.state:""} ${I.zip||""}
`:""}
${R?"Buyer":"Seller"} $${Number(I.sale_price).toLocaleString()}
Closed: ${new Date(I.close_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})} ${(W=I.lead_source)!=null&&W.name?" · "+I.lead_source.name:""}
${I.contact?`
Client: ${I.contact.first_name} ${I.contact.last_name||""}
`:""}
`),q=new fc.Marker(B).setLngLat([I.longitude,I.latitude]).setPopup($).addTo(n.current);a.current.push(q)}),T.length>1){const I=new fc.LngLatBounds;T.forEach(R=>I.extend([R.longitude,R.latitude])),n.current.fitBounds(I,{padding:60,maxZoom:13})}else T.length===1&&n.current.flyTo({center:[T[0].longitude,T[0].latitude],zoom:12})},[e,i,_]),m||t?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center h-[50vh]",children:r.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?e.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[r.jsx(Yi,{className:"h-12 w-12 text-muted-foreground"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:"No Transactions Yet"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Add transactions to see them plotted on the map."})]})]})}):r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#3B82F6"}}),r.jsx("span",{children:"Buyer"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow",style:{background:"#10B981"}}),r.jsx("span",{children:"Seller"})]}),r.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[w.length," of ",e.length," mapped",_&&" · Geocoding..."]})]}),r.jsx("div",{ref:s,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[r.jsx(kl,{className:"h-12 w-12 text-muted-foreground"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),r.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 sZe=new Date().getFullYear(),Rnr=Array.from({length:10},(e,t)=>sZe-t);function Fnr(){var D;const[e,t]=A.useState(sZe),[s,n]=A.useState(!1),[a,o]=A.useState(!1),[l,i]=A.useState(!1),[d,m]=A.useState(!1),{data:p,isLoading:g}=f1e(e),{yearStats:v,lifetimeStats:_,showCommission:k}=j9e(e),{data:w,isLoading:S}=w9e(e),{data:T}=qie(),C=swt(),I=()=>{if(!p||p.length===0)return;const B=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...k?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],$=p.map(ae=>{var oe,se;return[ae.property_address,ae.city||"",ae.state||"",ae.zip||"",ae.transaction_type,ae.close_date,ae.sale_price,...k?[ae.commission_amount||""]:[],((oe=ae.lead_source)==null?void 0:oe.name)||"",((se=ae.client_type)==null?void 0:se.name)||"",ae.contact?`${ae.contact.first_name} ${ae.contact.last_name||""}`.trim():"",ae.is_win?"Yes":"No",ae.notes||""]}),q=[B,...$].map(ae=>ae.map(oe=>`"${String(oe).replace(/"/g,'""')}"`).join(",")).join(` `),W=new Blob([q],{type:"text/csv"}),K=URL.createObjectURL(W),re=document.createElement("a");re.href=K,re.download=`transactions-${e}.csv`,re.click(),URL.revokeObjectURL(K)},R=!p||p.length===0;return r.jsxs(Ur,{title:"Scorecard",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Scorecard"}),r.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"})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Business Scorecard"}),r.jsx("p",{className:"text-muted-foreground",children:"Track your transactions, goals, and performance"})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(ds,{value:String(e),onValueChange:B=>t(Number(B)),children:[r.jsx(ls,{className:"w-[120px]",children:r.jsx(us,{})}),r.jsx(cs,{children:Rnr.map(B=>r.jsx(Ut,{value:String(B),children:B},B))})]}),r.jsx(X,{variant:"outline",size:"icon",onClick:()=>m(!d),children:r.jsx(ld,{className:"h-4 w-4"})})]})]}),d&&r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsx(Zt,{className:"text-lg",children:"Settings"})}),r.jsx(qe,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Ee,{children:"Show Commission"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),r.jsx(fn,{checked:(T==null?void 0:T.show_commission)??!0,onCheckedChange:B=>C.mutate({show_commission:B})})]})})]}),R&&!g?r.jsx(ze,{className:"py-12",children:r.jsxs(qe,{className:"text-center space-y-4",children:[r.jsx("div",{className:"w-16 h-16 mx-auto rounded-full bg-primary/10 flex items-center justify-center",children:r.jsx(Rc,{className:"h-8 w-8 text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-semibold",children:"Start Tracking Your Success"}),r.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."})]}),r.jsxs("div",{className:"flex flex-wrap justify-center gap-2 pt-2",children:[r.jsxs(X,{onClick:()=>n(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Your First Transaction"]}),r.jsxs(X,{variant:"outline",onClick:()=>o(!0),children:[r.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Import CSV"]})]}),r.jsxs("div",{className:"pt-4 border-t mt-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Need help formatting your data?"}),r.jsx(X,{variant:"link",className:"h-auto p-0",asChild:!0,children:r.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Download CSV Template"]})})]})]})}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(X,{onClick:()=>n(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Transaction"]}),r.jsxs(X,{variant:"outline",onClick:()=>i(!0),children:[r.jsx(Bf,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),r.jsxs(X,{variant:"outline",onClick:()=>o(!0),children:[r.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Import"]}),r.jsxs(X,{variant:"outline",onClick:I,disabled:R,children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Export"]}),r.jsx(X,{variant:"ghost",size:"sm",asChild:!0,children:r.jsxs("a",{href:"/templates/transaction-import-template.csv",download:!0,children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"CSV Template"]})})]}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Vn,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),r.jsx("p",{className:"text-2xl font-bold",children:v.totalTransactions}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.totalTransactions," lifetime"]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(ws,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),r.jsxs("p",{className:"text-2xl font-bold",children:[v.buyerCount,"/",v.sellerCount]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Sd,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),r.jsx("p",{className:"text-2xl font-bold",children:du(v.totalVolume,!0)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[du(_.totalVolume,!0)," lifetime"]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(pu,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),r.jsx("p",{className:"text-2xl font-bold",children:du(v.averagePrice,!0)})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Yl,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),r.jsx("p",{className:"text-lg font-bold truncate",children:((D=v.topLeadSource)==null?void 0:D.name)||"-"}),v.topLeadSource&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:[v.topLeadSource.count," deals"]})]})}),k&&r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Sd,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Commission"})]}),r.jsx("p",{className:"text-2xl font-bold",children:du(v.totalCommission,!0)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[du(_.totalCommission,!0)," lifetime"]})]})})]}),w&&r.jsx(uHe,{goals:w,stats:v,year:e,showCommission:k}),r.jsxs(ii,{defaultValue:"transactions",className:"space-y-4",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"transactions",children:"Transactions"}),r.jsx(Kr,{value:"charts",children:"Charts"}),r.jsxs(Kr,{value:"map",children:[r.jsx(Yi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),r.jsx(hs,{value:"transactions",children:r.jsx(dHe,{transactions:p||[],showCommission:k,isLoading:g})}),r.jsx(hs,{value:"charts",children:r.jsx(tZe,{stats:v,year:e})}),r.jsx(hs,{value:"map",children:r.jsx(rZe,{transactions:p||[],isLoading:g})})]})]})]}),r.jsx(cHe,{open:s,onOpenChange:n}),r.jsx(Lnr,{open:a,onOpenChange:o}),r.jsx(Onr,{open:l,onOpenChange:i,year:e,existingGoals:w})]})}function nZe({open:e,onOpenChange:t,listingId:s,listingSlug:n,listingTitle:a}){const{user:o}=Gr(),[l,i]=A.useState(null),[d,m]=A.useState(!1),[p,g]=A.useState(!1);A.useEffect(()=>{(async()=>{if(!(!e||!o)){m(!0);try{const{data:S,error:T}=await Y.from("listing_shares").select("id, share_token, click_count, lead_count").eq("listing_id",s).eq("sharing_agent_id",o.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(T)throw T;if(S&&S.share_token)i(S);else if(S&&!S.share_token){const{data:C,error:I}=await Y.from("listing_shares").update({share_type:"referral_link"}).eq("id",S.id).select("id, share_token, click_count, lead_count").single();if(I)throw I;i(C)}else{const{data:C,error:I}=await Y.from("listing_shares").insert({listing_id:s,sharing_agent_id:o.id,share_type:"referral_link"}).select("id, share_token, click_count, lead_count").single();if(I)throw I;i(C)}}catch(S){console.error("Error creating share link:",S),we.error("Failed to generate share link")}finally{m(!1)}}})()},[e,o,s]);const v=l!=null&&l.share_token?`https://listings.relevelup.com/${n||s}?ref=${l.share_token}`:"",_=async()=>{try{await navigator.clipboard.writeText(v),g(!0),we.success("Link copied to clipboard!"),setTimeout(()=>g(!1),2e3)}catch{we.error("Failed to copy link")}},k=w=>{const S=encodeURIComponent(v),T=encodeURIComponent(`Check out this listing: ${a}`);switch(w){case"email":window.open(`mailto:?subject=${T}&body=${S}`);break;case"text":window.open(`sms:?body=${T}%20${S}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${S}`,"_blank");break}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(bn,{className:"h-5 w-5 text-amber-500"}),"Share & Earn Leads"]}),r.jsx(Zs,{children:"Share this listing with your network. When someone submits a lead through your link, they'll become your contact!"})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-3",children:r.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[r.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!"]})}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Your Referral Link"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:d?"Generating...":v,readOnly:!0,className:"font-mono text-sm"}),r.jsx(X,{onClick:_,disabled:d||!v,variant:p?"default":"outline",children:p?r.jsx(mi,{className:"h-4 w-4"}):r.jsx(uo,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Share via"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{variant:"outline",className:"flex-1",onClick:()=>k("email"),disabled:d,children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Email"]}),r.jsxs(X,{variant:"outline",className:"flex-1",onClick:()=>k("text"),disabled:d,children:[r.jsx(Vo,{className:"h-4 w-4 mr-2"}),"Text"]}),r.jsxs(X,{variant:"outline",className:"flex-1",onClick:()=>k("facebook"),disabled:d,children:[r.jsx(fu,{className:"h-4 w-4 mr-2"}),"Facebook"]})]})]}),l&&(l.click_count>0||l.lead_count>0)&&r.jsxs("div",{className:"pt-4 border-t",children:[r.jsx(Ee,{className:"mb-2 block",children:"Your Share Performance"}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"bg-muted rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"flex items-center justify-center gap-1 text-muted-foreground mb-1",children:[r.jsx(Ii,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs",children:"Clicks"})]}),r.jsx("p",{className:"text-2xl font-bold",children:l.click_count})]}),r.jsxs("div",{className:"bg-primary/10 rounded-lg p-3 text-center",children:[r.jsxs("div",{className:"flex items-center justify-center gap-1 text-primary mb-1",children:[r.jsx(ws,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs",children:"Leads"})]}),r.jsx("p",{className:"text-2xl font-bold text-primary",children:l.lead_count})]})]})]})]})]})})}const znr={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},Bnr={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},$nr={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function f8({listing:e,onClick:t,onEdit:s,onDelete:n,showActions:a}){var w,S;const{user:o}=Gr(),{data:l}=g9e(e.id),i=p9e(),[d,m]=A.useState(!1),p=T=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(T),g=((w=e.photos)==null?void 0:w.find(T=>T.is_primary))||((S=e.photos)==null?void 0:S[0]),v=(o==null?void 0:o.id)===e.agent_id,_=async T=>{T.stopPropagation();try{const C=await i.mutateAsync(e.id);we.success(C.saved?"Listing saved!":"Listing removed from saved")}catch{we.error("Failed to save listing")}},k=T=>{if(T.stopPropagation(),o)m(!0);else{const C=`https://listings.relevelup.com/${e.slug||e.id}`;navigator.clipboard.writeText(C),we.success("Link copied to clipboard!")}};return r.jsxs(ze,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer group",onClick:t,children:[r.jsxs("div",{className:"relative aspect-[4/3] bg-muted",children:[g?r.jsx("img",{src:g.photo_url,alt:e.property_address||e.city,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:r.jsx(fx,{className:"h-12 w-12"})}),r.jsx(_t,{className:`absolute top-2 left-2 ${znr[e.status]} text-white border-0`,children:Bnr[e.status]}),e.is_featured&&r.jsx("div",{className:"absolute top-2 right-2 p-1.5 bg-amber-500 rounded-full",children:r.jsx(Dn,{className:"h-4 w-4 text-white fill-white"})}),r.jsxs("div",{className:"absolute bottom-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[r.jsx(X,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:_,children:r.jsx(Ai,{className:`h-4 w-4 ${l?"fill-pink-500 text-pink-500":""}`})}),r.jsx(X,{size:"icon",variant:"secondary",className:"h-8 w-8",onClick:k,title:v?"Copy link":"Share & earn leads",children:v?r.jsx(Uc,{className:"h-4 w-4"}):r.jsx(bn,{className:"h-4 w-4 text-amber-500"})})]})]}),r.jsx(nZe,{open:d,onOpenChange:m,listingId:e.id,listingSlug:e.slug||null,listingTitle:e.property_address||`${e.city}, ${e.state}`}),r.jsxs(qe,{className:"p-4 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-xl font-bold text-primary",children:p(e.price)}),e.open_to_referrals&&r.jsxs(_t,{variant:"outline",className:"text-xs",children:[r.jsx(ws,{className:"h-3 w-3 mr-1"}),"Referrals"]})]}),r.jsxs("div",{children:[e.property_address&&r.jsx("p",{className:"font-medium truncate",children:e.property_address}),r.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[r.jsx(Yi,{className:"h-3 w-3"}),e.city,", ",e.state,e.neighborhood&&` • ${e.neighborhood}`]})]}),r.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.bedrooms&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(x1,{className:"h-4 w-4"}),e.bedrooms," bd"]}),e.bathrooms&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(g1,{className:"h-4 w-4"}),e.bathrooms," ba"]}),e.square_footage&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(fx,{className:"h-4 w-4"}),e.square_footage.toLocaleString()," sqft"]})]}),r.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[r.jsx(_t,{variant:"secondary",className:"text-xs",children:$nr[e.property_type]}),e.agent&&r.jsx("p",{className:"text-xs text-muted-foreground truncate max-w-[120px]",children:e.agent.name})]}),r.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ii,{className:"h-3 w-3"}),e.view_count]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Uc,{className:"h-3 w-3"}),e.share_count]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ai,{className:"h-3 w-3"}),e.save_count]})]}),a&&(s||n)&&r.jsxs("div",{className:"flex gap-2",children:[s&&r.jsxs(X,{variant:"outline",size:"sm",className:"flex-1",onClick:T=>{T.stopPropagation(),s()},children:[r.jsx(Lc,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&r.jsx(X,{variant:"destructive",size:"sm",onClick:T=>{T.stopPropagation(),n()},children:r.jsx(Os,{className:"h-4 w-4"})})]})]})]})}const Unr=[{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"}],Vnr=[{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 qnr({filters:e,onFiltersChange:t,onClose:s}){const n=()=>{t({sortBy:"newest"})};return r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between pb-3",children:[r.jsx(Zt,{className:"text-lg",children:"Filters"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:n,children:"Clear All"}),r.jsx(X,{variant:"ghost",size:"icon",onClick:s,children:r.jsx(Xs,{className:"h-4 w-4"})})]})]}),r.jsxs(qe,{children:[r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Status"}),r.jsxs(ds,{value:e.status||"all",onValueChange:a=>t({...e,status:a==="all"?void 0:a}),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"All statuses"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Statuses"}),Unr.map(a=>r.jsx(Ut,{value:a.value,children:a.label},a.value))]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Property Type"}),r.jsxs(ds,{value:e.propertyType||"all",onValueChange:a=>t({...e,propertyType:a==="all"?void 0:a}),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"All types"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Types"}),Vnr.map(a=>r.jsx(Ut,{value:a.value,children:a.label},a.value))]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Min Price"}),r.jsx(Ye,{type:"number",placeholder:"No minimum",value:e.minPrice||"",onChange:a=>t({...e,minPrice:a.target.value?Number(a.target.value):void 0})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Max Price"}),r.jsx(Ye,{type:"number",placeholder:"No maximum",value:e.maxPrice||"",onChange:a=>t({...e,maxPrice:a.target.value?Number(a.target.value):void 0})})]})]}),r.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Open to Referrals Only"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),r.jsx(fn,{checked:e.openToReferrals||!1,onCheckedChange:a=>t({...e,openToReferrals:a||void 0})})]})]})]})}function Hnr({leaderboard:e}){const t=n=>{switch(n){case 0:return r.jsx(go,{className:"h-5 w-5 text-amber-500"});case 1:return r.jsx(Uy,{className:"h-5 w-5 text-gray-400"});case 2:return r.jsx(Yl,{className:"h-5 w-5 text-amber-700"});default:return r.jsx("span",{className:"text-sm font-medium text-muted-foreground w-5 text-center",children:n+1})}},s=(n,a)=>!n||n.length===0?r.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"No data yet. Start sharing to climb the leaderboard!"}):r.jsx("div",{className:"space-y-2",children:n.map((o,l)=>r.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:[r.jsx("div",{className:"flex items-center justify-center w-8",children:t(l)}),r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("p",{className:"font-medium truncate",children:o.name})}),r.jsxs(_t,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return r.jsxs("div",{className:"space-y-6",children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(go,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),r.jsx(qe,{children:r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.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:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-emerald-500/20 flex items-center justify-center",children:r.jsx(Uc,{className:"h-6 w-6 text-emerald-500"})}),r.jsx("p",{className:"font-medium text-sm",children:"Listing Amplifier"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Share 10+ listings"})]}),r.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:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-sky-500/20 flex items-center justify-center",children:r.jsx(Vn,{className:"h-6 w-6 text-sky-500"})}),r.jsx("p",{className:"font-medium text-sm",children:"Top Contributor"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Add 5+ listings"})]}),r.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:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-purple-500/20 flex items-center justify-center",children:r.jsx(Uy,{className:"h-6 w-6 text-purple-500"})}),r.jsx("p",{className:"font-medium text-sm",children:"Referral Connector"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Send 3+ referrals"})]}),r.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:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-2 rounded-full bg-amber-500/20 flex items-center justify-center",children:r.jsx(go,{className:"h-6 w-6 text-amber-500"})}),r.jsx("p",{className:"font-medium text-sm",children:"Community MVP"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Top performer"})]})]})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Community Leaderboard"})}),r.jsx(qe,{children:r.jsxs(ii,{defaultValue:"sharers",children:[r.jsxs(si,{className:"w-full",children:[r.jsxs(Kr,{value:"sharers",className:"flex-1",children:[r.jsx(Uc,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),r.jsxs(Kr,{value:"listers",className:"flex-1",children:[r.jsx(Vn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),r.jsx(hs,{value:"sharers",className:"mt-4",children:s(e==null?void 0:e.topSharers,"shares")}),r.jsx(hs,{value:"listers",className:"mt-4",children:s(e==null?void 0:e.topListers,"listings")})]})})]})]})}const MIe={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},TIe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function Wnr(e){return e>=1e6?`$${(e/1e6).toFixed(1)}M`:`$${(e/1e3).toFixed(0)}K`}function Gnr({listings:e,isLoading:t}){const s=Ks(),n=A.useRef(null),a=A.useRef(null),o=A.useRef([]),{isAdmin:l}=Gr(),[i,d]=A.useState(""),[m,p]=A.useState(!0),[g,v]=A.useState(!1),_=e.filter(w=>w.latitude!=null&&w.longitude!=null),k=e.filter(w=>(w.latitude==null||w.longitude==null)&&(w.property_address||w.city));return A.useEffect(()=>{(async()=>{p(!0);try{const{data:S}=await Y.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();S!=null&&S.value&&d(S.value)}catch(S){console.error("Error fetching mapbox token:",S)}p(!1)})()},[]),A.useEffect(()=>{if(!i||k.length===0||g)return;(async()=>{var S;v(!0);for(const T of k){const C=[T.property_address,T.city,T.state].filter(Boolean).join(", ");if(C)try{const R=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(C)}.json?access_token=${i}&limit=1`)).json();if((S=R.features)!=null&&S[0]){const[D,B]=R.features[0].center;await Y.from("listings").update({latitude:B,longitude:D}).eq("id",T.id),T.latitude=B,T.longitude=D}}catch(I){console.error("Geocode error:",I)}}v(!1)})()},[i,e]),A.useEffect(()=>{if(!n.current||!i||a.current)return;fc.accessToken=i;const w=e.filter(C=>C.latitude!=null&&C.longitude!=null);let S=[-98.5795,39.8283],T=4;if(w.length>0){const C=w.reduce((R,D)=>R+D.longitude,0)/w.length,I=w.reduce((R,D)=>R+D.latitude,0)/w.length;S=[C,I],T=w.length===1?12:10}return a.current=new fc.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:T,center:S}),a.current.addControl(new fc.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),A.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(S=>S.remove()),o.current=[];const w=e.filter(S=>S.latitude!=null&&S.longitude!=null);if(w.forEach(S=>{var B,$,q;const T=MIe[S.status]||"#10B981",C=((B=S.photos)==null?void 0:B.find(W=>W.is_primary))||(($=S.photos)==null?void 0:$[0]),I=document.createElement("div");I.className="cursor-pointer",I.innerHTML=`
`;const R=new fc.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${C!=null&&C.photo_url?``:""}
${Wnr(S.price)}
${S.property_address||""}
${S.city}, ${S.state}
${TIe[S.status]||S.status} ${S.bedrooms?`${S.bedrooms} bed`:""} ${S.bathrooms?`${S.bathrooms} bath`:""}
${(q=S.agent)!=null&&q.name?`
Listed by ${S.agent.name}
`:""}
Click to view details →
`),D=new fc.Marker(I).setLngLat([S.longitude,S.latitude]).setPopup(R).addTo(a.current);o.current.push(D)}),w.length>1){const S=new fc.LngLatBounds;w.forEach(T=>S.extend([T.longitude,T.latitude])),a.current.fitBounds(S,{padding:60,maxZoom:13})}else w.length===1&&a.current.flyTo({center:[w[0].longitude,w[0].latitude],zoom:12})},[e,i,g]),A.useEffect(()=>(window.__navigateToListing__=w=>{s(`/mission-control/listings/${w}`)},()=>{delete window.__navigateToListing__}),[s]),m||t?r.jsx(ze,{children:r.jsx(qe,{className:"flex items-center justify-center h-[60vh]",children:r.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})})}):i?e.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[r.jsx(Yi,{className:"h-12 w-12 text-muted-foreground"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:"No Listings Yet"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Add listings to see them on the map."})]})]})}):r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm",children:[Object.entries(MIe).map(([w,S])=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-3 h-3 rounded-full border-2 border-white shadow",style:{background:S}}),r.jsx("span",{className:"text-xs",children:TIe[w]})]},w)),r.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[_.length," of ",e.length," mapped",g&&" · Geocoding..."]})]}),r.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[r.jsx(kl,{className:"h-12 w-12 text-muted-foreground"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold",children:"Map Not Configured"}),r.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 Knr(){var W,K,re,ae,oe,se,pe,ie;const e=Ks(),{brokerageId:t}=Gr(),{data:s,isLoading:n}=d9e(),[a,o]=A.useState("feed"),[l,i]=A.useState(!1),[d,m]=A.useState(""),[p,g]=A.useState({sortBy:"newest"}),{data:v,isLoading:_}=u9e({...p,city:d||p.city}),{data:k,isLoading:w}=Bbt(),{data:S,isLoading:T}=h9e(),{data:C,isLoading:I}=qbt(),{data:R,isLoading:D}=Gbt(),{data:B}=Wbt(),$=f9e(),q=async de=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await $.mutateAsync(de),we.success("Listing deleted successfully")}catch{we.error("Failed to delete listing")}};return n?r.jsx(Ur,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})})}):s?r.jsx(Ur,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),r.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"})]}),r.jsxs(X,{onClick:()=>e("/mission-control/listings/new"),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:r.jsx(Vn,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:(v==null?void 0:v.length)||0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Listings"})]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:r.jsx(Ai,{className:"h-5 w-5 text-pink-500"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:(k==null?void 0:k.length)||0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved"})]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:r.jsx(fk,{className:"h-5 w-5 text-emerald-500"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:(S==null?void 0:S.length)||0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 flex items-center gap-3",children:[r.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:r.jsx(ws,{className:"h-5 w-5 text-sky-500"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:(((W=C==null?void 0:C.sent)==null?void 0:W.length)||0)+(((K=C==null?void 0:C.received)==null?void 0:K.length)||0)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),r.jsxs(ii,{value:a,onValueChange:o,children:[r.jsxs(si,{className:"w-full justify-start overflow-x-auto",children:[r.jsx(Kr,{value:"feed",children:"Community Feed"}),t&&r.jsx(Kr,{value:"brokerage",children:"Brokerage"}),r.jsx(Kr,{value:"my-listings",children:"My Listings"}),r.jsx(Kr,{value:"saved",children:"Saved"}),r.jsx(Kr,{value:"referrals",children:"Referrals"}),r.jsx(Kr,{value:"map",children:"Map"}),r.jsx(Kr,{value:"leaderboard",children:"Leaderboard"})]}),r.jsxs(hs,{value:"feed",className:"space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by city or neighborhood...",value:d,onChange:de=>m(de.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:p.sortBy,onValueChange:de=>g({...p,sortBy:de}),children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{placeholder:"Sort by"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"newest",children:"Newest First"}),r.jsx(Ut,{value:"updated",children:"Recently Updated"}),r.jsx(Ut,{value:"price_asc",children:"Price: Low to High"}),r.jsx(Ut,{value:"price_desc",children:"Price: High to Low"})]})]}),r.jsxs(X,{variant:"outline",onClick:()=>i(!l),children:[r.jsx(b1,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&r.jsx(qnr,{filters:p,onFiltersChange:g,onClose:()=>i(!1)}),_?r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((de,ce)=>r.jsxs(ze,{children:[r.jsx(pr,{className:"h-48 w-full"}),r.jsxs(qe,{className:"p-4 space-y-2",children:[r.jsx(pr,{className:"h-5 w-3/4"}),r.jsx(pr,{className:"h-4 w-1/2"}),r.jsx(pr,{className:"h-4 w-1/4"})]})]},ce))}):(v==null?void 0:v.length)===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(Vn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings found"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Be the first to share a listing with the community!"}),r.jsxs(X,{onClick:()=>e("/mission-control/listings/new"),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:v==null?void 0:v.map(de=>r.jsx(f8,{listing:de,onClick:()=>e(`/mission-control/listings/${de.id}`)},de.id))})]}),r.jsx(hs,{value:"my-listings",className:"space-y-4",children:T?r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((de,ce)=>r.jsxs(ze,{children:[r.jsx(pr,{className:"h-48 w-full"}),r.jsxs(qe,{className:"p-4 space-y-2",children:[r.jsx(pr,{className:"h-5 w-3/4"}),r.jsx(pr,{className:"h-4 w-1/2"})]})]},ce))}):(S==null?void 0:S.length)===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(fk,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No listings yet"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Share your listings with the LevelUp community!"}),r.jsxs(X,{onClick:()=>e("/mission-control/listings/new"),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Your First Listing"]})]})}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S==null?void 0:S.map(de=>r.jsx(f8,{listing:de,showActions:!0,onClick:()=>e(`/mission-control/listings/${de.id}`),onEdit:()=>e(`/mission-control/listings/${de.id}/edit`),onDelete:()=>q(de.id)},de.id))})}),r.jsx(hs,{value:"saved",className:"space-y-4",children:w?r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((de,ce)=>r.jsxs(ze,{children:[r.jsx(pr,{className:"h-48 w-full"}),r.jsxs(qe,{className:"p-4 space-y-2",children:[r.jsx(pr,{className:"h-5 w-3/4"}),r.jsx(pr,{className:"h-4 w-1/2"})]})]},ce))}):(k==null?void 0:k.length)===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(Ai,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No saved listings"}),r.jsx("p",{className:"text-muted-foreground",children:"Save listings to quickly access them later"})]})}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:k==null?void 0:k.map(de=>r.jsx(f8,{listing:de.listing,onClick:()=>e(`/mission-control/listings/${de.listing.id}`)},de.id))})}),r.jsx(hs,{value:"referrals",className:"space-y-6",children:r.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[r.jsx(Uc,{className:"h-4 w-4"}),"Referrals Sent (",((re=C==null?void 0:C.sent)==null?void 0:re.length)||0,")"]}),((ae=C==null?void 0:C.sent)==null?void 0:ae.length)===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):r.jsx("div",{className:"space-y-3",children:(oe=C==null?void 0:C.sent)==null?void 0:oe.map(de=>{var ce,ge;return r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex justify-between items-start mb-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:de.buyer_name}),r.jsx("p",{className:"text-sm text-muted-foreground",children:((ce=de.listing)==null?void 0:ce.property_address)||((ge=de.listing)==null?void 0:ge.city)})]}),r.jsx(_t,{variant:de.status==="closed"?"default":"secondary",children:de.status.replace("_"," ")})]})})},de.id)})})]}),r.jsxs("div",{children:[r.jsxs("h3",{className:"font-semibold mb-3 flex items-center gap-2",children:[r.jsx(ws,{className:"h-4 w-4"}),"Referrals Received (",((se=C==null?void 0:C.received)==null?void 0:se.length)||0,")"]}),((pe=C==null?void 0:C.received)==null?void 0:pe.length)===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):r.jsx("div",{className:"space-y-3",children:(ie=C==null?void 0:C.received)==null?void 0:ie.map(de=>{var ce;return r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex justify-between items-start mb-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:de.buyer_name}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:["From: ",(ce=de.sender)==null?void 0:ce.name]})]}),r.jsx(_t,{variant:de.status==="closed"?"default":"secondary",children:de.status.replace("_"," ")})]}),r.jsx(X,{size:"sm",variant:"outline",className:"w-full mt-2",onClick:()=>e(`/mission-control/listings/${de.listing_id}`),children:"View Listing"})]})},de.id)})})]})]})}),t&&r.jsx(hs,{value:"brokerage",className:"space-y-4",children:D?r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((de,ce)=>r.jsxs(ze,{children:[r.jsx(pr,{className:"h-48 w-full"}),r.jsxs(qe,{className:"p-4 space-y-2",children:[r.jsx(pr,{className:"h-5 w-3/4"}),r.jsx(pr,{className:"h-4 w-1/2"})]})]},ce))}):(R==null?void 0:R.length)===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(fk,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-medium mb-2",children:"No brokerage listings yet"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"No agents in your brokerage have added listings yet."}),r.jsxs(X,{onClick:()=>e("/mission-control/listings/new"),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add a Listing"]})]})}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:R==null?void 0:R.map(de=>r.jsx(f8,{listing:de,onClick:()=>e(`/mission-control/listings/${de.id}`)},de.id))})}),r.jsx(hs,{value:"map",children:r.jsx(Gnr,{listings:v||[],isLoading:_})}),r.jsx(hs,{value:"leaderboard",children:r.jsx(Hnr,{leaderboard:B})})]})]})}):r.jsx(Ur,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(Vn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Coming Soon"}),r.jsx("p",{className:"text-muted-foreground",children:"Listing Exchange is currently in development. Check back soon!"})]})})})}function Rbe(){const e=fl();return Ht({queryKey:["deal-pipeline-stages",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("deal_pipeline_stages").select("*").eq("owner_user_id",e).order("sort_order",{ascending:!0});if(s)throw s;return t},enabled:!!e})}function aZe(){const e=fl(),t=Rr();return Qt({mutationFn:async()=>{if(!e)throw new Error("Not authenticated");const{error:s}=await Y.rpc("initialize_deal_pipeline_stages",{p_user_id:e});if(s)throw s},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-stages"]})}})}function Fbe(){const e=fl();return Ht({queryKey:["deal-pipeline-deals",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.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",e).order("updated_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function iZe(){const e=fl(),t=Rr();return Qt({mutationFn:async s=>{if(!e)throw new Error("Not authenticated");const{data:n,error:a}=await Y.from("deal_pipeline").insert({deal_name:s.deal_name,deal_type:s.deal_type,stage_id:s.stage_id||null,contact_id:s.contact_id||null,listing_id:s.listing_id||null,property_address:s.property_address||null,city:s.city||null,state:s.state||null,zip_code:s.zip_code||null,expected_price:s.expected_price||null,expected_commission:s.expected_commission||null,commission_percentage:s.commission_percentage||3,target_close_date:s.target_close_date||null,contract_date:s.contract_date||null,listing_date:s.listing_date||null,priority:s.priority||"medium",probability:s.probability||50,notes:s.notes||null,owner_user_id:e}).select().single();if(a)throw a;return await Y.from("deal_activities").insert([{deal_id:n.id,activity_type:"system",title:"Deal created",description:`Deal "${s.deal_name}" was created`}]),n},onSuccess:()=>{t.invalidateQueries({queryKey:["deal-pipeline-deals"]}),t.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function oZe(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("deal_pipeline").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["deal-pipeline-deals"]}),e.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Znr(){const e=Rr();return Qt({mutationFn:async({dealId:t,stageId:s,stageName:n})=>{const{data:a,error:o}=await Y.from("deal_pipeline").update({stage_id:s}).eq("id",t).select().single();if(o)throw o;return await Y.from("deal_activities").insert({deal_id:t,activity_type:"stage_change",title:`Moved to ${n}`,metadata:{new_stage_id:s,new_stage_name:n}}),a},onSuccess:()=>{e.invalidateQueries({queryKey:["deal-pipeline-deals"]}),e.invalidateQueries({queryKey:["deal-activities"]})}})}function Ynr(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("deal_pipeline").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["deal-pipeline-deals"]}),e.invalidateQueries({queryKey:["deal-pipeline-stats"]})}})}function Xnr(e){return Ht({queryKey:["deal-activities",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("deal_activities").select("*").eq("deal_id",e).order("created_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function Qnr(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("deal_activities").insert([{deal_id:t.deal_id,activity_type:t.activity_type,title:t.title,description:t.description||null}]).select().single();if(n)throw n;return s},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["deal-activities",s.deal_id]})}})}function Jnr(e){return Ht({queryKey:["deal-checklist",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("deal_checklist_items").select("*").eq("deal_id",e).order("sort_order",{ascending:!0});if(s)throw s;return t},enabled:!!e})}function ear(){const e=Rr();return Qt({mutationFn:async({id:t,is_completed:s,deal_id:n})=>{const{data:a,error:o}=await Y.from("deal_checklist_items").update({is_completed:s,completed_at:s?new Date().toISOString():null}).eq("id",t).select().single();if(o)throw o;return a},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["deal-checklist",s.deal_id]})}})}function tar(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("deal_checklist_items").insert([{deal_id:t.deal_id,title:t.title,description:t.description||null,due_date:t.due_date||null,sort_order:t.sort_order||0}]).select().single();if(n)throw n;return s},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["deal-checklist",s.deal_id]})}})}function rar(){const e=fl();return Ht({queryKey:["deal-pipeline-stats",e],queryFn:async()=>{if(!e)return null;const{data:t,error:s}=await Y.from("deal_pipeline").select("expected_price, expected_commission, stage_id, deal_pipeline_stages(name, is_won_stage, is_lost_stage)").eq("owner_user_id",e);if(s)throw s;const n=(t==null?void 0:t.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=(t==null?void 0:t.filter(o=>{var l;return(l=o.deal_pipeline_stages)==null?void 0:l.is_won_stage}))||[];return{totalDeals:(t==null?void 0:t.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:!!e})}function sar(e){const t=fl();return Ht({queryKey:["deal-by-listing",e,t],queryFn:async()=>{if(!t||!e)return null;const{data:s,error:n}=await Y.from("deal_pipeline").select(` *, deal_pipeline_stages(id, name, color) `).eq("owner_user_id",t).eq("listing_id",e).maybeSingle();if(n)throw n;return s},enabled:!!t&&!!e})}function nar(){const e=Rr();return Qt({mutationFn:async({dealId:t,listingId:s})=>{const{data:n,error:a}=await Y.from("deal_pipeline").update({listing_id:s}).eq("id",t).select().single();if(a)throw a;return await Y.from("deal_activities").insert({deal_id:t,activity_type:"system",title:"Linked to Listing Exchange",description:"This deal is now synced with Listing Exchange",metadata:{listing_id:s}}),n},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["deal-pipeline-deals"]}),e.invalidateQueries({queryKey:["deal-by-listing",s.listingId]})}})}function aar(){const e=Rr();return Qt({mutationFn:async({dealId:t,listingId:s})=>{const{data:n,error:a}=await Y.from("deal_pipeline").update({listing_id:null}).eq("id",t).select().single();if(a)throw a;return{data:n,listingId:s}},onSuccess:t=>{e.invalidateQueries({queryKey:["deal-pipeline-deals"]}),e.invalidateQueries({queryKey:["deal-by-listing",t.listingId]})}})}function iar({listing:e}){const t=Ks(),[s,n]=A.useState(""),[a,o]=A.useState(!1),{data:l,isLoading:i}=sar(e.id),{data:d,isLoading:m}=Rbe(),{data:p,isLoading:g}=Fbe(),v=aZe(),_=nar(),k=aar(),w=iZe(),S=(p==null?void 0:p.filter(D=>!D.listing_id))||[],T=D=>{if(!(d!=null&&d.length))return null;switch(D){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")}},C=async()=>{o(!0);try{d!=null&&d.length||await v.mutateAsync();const D=T(e.status);await w.mutateAsync({deal_name:e.property_address?`${e.property_address}, ${e.city}`:`${e.city}, ${e.state}`,deal_type:"seller",stage_id:(D==null?void 0:D.id)||null,listing_id:e.id,property_address:e.property_address,city:e.city,state:e.state,expected_price:e.price,expected_commission:e.price*.03,commission_percentage:3,priority:"medium",probability:50}),we.success("Deal created and linked to listing!")}catch(D){console.error("Failed to create deal:",D),we.error("Failed to create deal")}finally{o(!1)}},I=async()=>{if(!s){we.error("Please select a deal");return}try{await _.mutateAsync({dealId:s,listingId:e.id}),we.success("Listing linked to deal!"),n("")}catch{we.error("Failed to link listing")}},R=async()=>{if(l)try{await k.mutateAsync({dealId:l.id,listingId:e.id}),we.success("Listing unlinked from deal")}catch{we.error("Failed to unlink listing")}};return i||m?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2 text-base",children:[r.jsx(By,{className:"h-4 w-4"}),"Deal Pipeline"]})}),r.jsx(qe,{children:r.jsx("div",{className:"flex items-center justify-center py-4",children:r.jsx($r,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?r.jsxs(ze,{className:"border-primary/20 bg-primary/5",children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"flex items-center gap-2 text-base",children:[r.jsx(Fm,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),r.jsxs(qe,{className:"space-y-3",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:l.deal_name}),r.jsx("div",{className:"flex items-center gap-2 mt-1",children:l.deal_pipeline_stages&&r.jsx(_t,{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})})]})}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes sync automatically between the listing and pipeline."}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>t("/mission-control/pipeline"),children:["View Pipeline",r.jsx(Ki,{className:"h-3 w-3 ml-1"})]}),r.jsx(X,{variant:"ghost",size:"sm",onClick:R,disabled:k.isPending,children:k.isPending?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(BE,{className:"h-4 w-4"})})]})]})]}):r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-2",children:r.jsxs(Zt,{className:"flex items-center gap-2 text-base",children:[r.jsx(By,{className:"h-4 w-4"}),"Deal Pipeline"]})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Link this listing to your pipeline to track the deal and sync status changes."}),r.jsxs(X,{onClick:C,disabled:a||w.isPending,className:"w-full",size:"sm",children:[a||w.isPending?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),S.length>0&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute inset-0 flex items-center",children:r.jsx("span",{className:"w-full border-t"})}),r.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:r.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(ds,{value:s,onValueChange:n,children:[r.jsx(ls,{className:"flex-1 text-sm",children:r.jsx(us,{placeholder:"Link to existing deal..."})}),r.jsx(cs,{children:S.map(D=>r.jsx(Ut,{value:D.id,children:D.deal_name},D.id))})]}),r.jsx(X,{variant:"secondary",size:"icon",onClick:I,disabled:!s||_.isPending,children:_.isPending?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(Fm,{className:"h-4 w-4"})})]})]})]})]})}const oar={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},lar={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},AIe={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function car(){var oe,se,pe,ie,de,ce,ge,Te,_e;const{listingId:e}=Bl(),t=Ks(),{user:s}=Gr(),{data:n,isLoading:a}=m9e(e||""),{data:o}=g9e(e||""),{data:l}=Ubt(e||""),i=p9e(),d=$bt(),m=Vbt(),p=f9e(),g=Hbt(),[v,_]=A.useState(!1),[k,w]=A.useState(!1),[S,T]=A.useState(!1),[C,I]=A.useState(null),[R,D]=A.useState({buyerName:"",buyerType:"",notes:""}),B=(s==null?void 0:s.id)===(n==null?void 0:n.agent_id),$=ve=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(ve),q=async ve=>{const Me=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ze=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;m.mutate({listingId:n.id,shareType:ve});try{switch(ve){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(Me)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(Me),we.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ze} ${Me}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ze)}&body=${encodeURIComponent(`Check out this listing: ${Me}`)}`);break}}catch(Ae){console.error("Share error:",Ae),we.error("Failed to share")}},W=async()=>{try{await p.mutateAsync(n.id),we.success("Listing deleted"),t("/mission-control/listings")}catch{we.error("Failed to delete listing")}},K=async()=>{if(!R.buyerName.trim()){we.error("Please enter buyer name");return}try{await g.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:R.buyerName,buyerType:R.buyerType||void 0,notes:R.notes||void 0}),we.success("Referral sent successfully!"),w(!1),D({buyerName:"",buyerType:"",notes:""})}catch{we.error("Failed to send referral")}},re=ve=>{var Ie,We;const Me=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ze=$((n==null?void 0:n.price)||0),Ae=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Le=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Ue=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Ve=[Ae,Le,Ue].filter(Boolean).join(" | ");switch(ve){case"just_listed":return`🏡 JUST LISTED! ${Me} ${Ze} ${Ve} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Ie=n==null?void 0:n.city)==null?void 0:Ie.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${Me} Now ${Ze}! ${Ve} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${AIe[(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! ${Ve} DM me for details! 📩 #ComingSoon #RealEstate #${(We=n==null?void 0:n.city)==null?void 0:We.replace(/\s/g,"")}`;default:return""}};if(a)return r.jsx(Ur,{title:"Listing",description:"",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-10 w-32"}),r.jsx(pr,{className:"h-[400px] w-full"}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[r.jsx(pr,{className:"h-48"}),r.jsx(pr,{className:"h-48"}),r.jsx(pr,{className:"h-48"})]})]})});if(!n)return r.jsx(Ur,{title:"Listing Not Found",description:"",children:r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx("p",{className:"text-muted-foreground mb-4",children:"This listing could not be found."}),r.jsx(X,{onClick:()=>t("/mission-control/listings"),children:"Back to Listings"})]})})});const ae=((oe=n.photos)==null?void 0:oe.find(ve=>ve.is_primary))||((se=n.photos)==null?void 0:se[0]);return r.jsxs(Ur,{title:"",description:"",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs(X,{variant:"ghost",onClick:()=>t("/mission-control/listings"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[r.jsx("div",{className:"md:col-span-2",children:r.jsx("div",{className:"aspect-[16/10] rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>ae&&I(ae.photo_url),children:ae?r.jsx("img",{src:ae.photo_url,alt:"Primary",className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:"No photos"})})}),r.jsx("div",{className:"grid grid-cols-2 gap-2",children:(pe=n.photos)==null?void 0:pe.slice(1,5).map((ve,Me)=>r.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>I(ve.photo_url),children:r.jsx("img",{src:ve.photo_url,alt:`Photo ${Me+2}`,className:"w-full h-full object-cover"})},ve.id))})]}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"md:col-span-2 space-y-6",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"p-6",children:[r.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-6",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(_t,{className:`${oar[n.status]} text-white border-0`,children:lar[n.status]}),n.is_featured&&r.jsxs(_t,{variant:"outline",className:"border-amber-500 text-amber-500",children:[r.jsx(Dn,{className:"h-3 w-3 mr-1 fill-amber-500"}),"Featured"]}),n.open_to_referrals&&r.jsxs(_t,{variant:"outline",children:[r.jsx(ws,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),r.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:$(n.price)}),n.property_address&&r.jsx("p",{className:"text-xl font-medium",children:n.property_address}),r.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[r.jsx(Yi,{className:"h-4 w-4"}),n.city,", ",n.state,n.neighborhood&&` • ${n.neighborhood}`]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"outline",size:"icon",onClick:()=>i.mutate(n.id),children:r.jsx(Ai,{className:`h-4 w-4 ${o?"fill-pink-500 text-pink-500":""}`})}),r.jsx(X,{variant:"outline",size:"icon",onClick:()=>d.mutate(n.id),children:l?r.jsx(mk,{className:"h-4 w-4"}):r.jsx(tg,{className:"h-4 w-4"})}),!B&&r.jsxs(X,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>T(!0),children:[r.jsx(bn,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{variant:"outline",children:[r.jsx(Uc,{className:"h-4 w-4 mr-2"}),"Share"]})}),r.jsxs(vu,{children:[r.jsxs(Ba,{onClick:()=>q("copy"),children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),r.jsxs(Ba,{onClick:()=>q("facebook"),children:[r.jsx(fu,{className:"h-4 w-4 mr-2"}),"Facebook"]}),r.jsxs(Ba,{onClick:()=>q("text"),children:[r.jsx(Vo,{className:"h-4 w-4 mr-2"}),"Text"]}),r.jsxs(Ba,{onClick:()=>q("email"),children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),B&&r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"outline",onClick:()=>t(`/mission-control/listings/${n.id}/edit`),children:[r.jsx(Lc,{className:"h-4 w-4 mr-2"}),"Edit"]}),r.jsx(X,{variant:"destructive",size:"icon",onClick:()=>_(!0),children:r.jsx(Os,{className:"h-4 w-4"})})]})]})]}),r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 py-4 border-y",children:[n.bedrooms&&r.jsxs("div",{className:"text-center",children:[r.jsx(x1,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"font-semibold",children:n.bedrooms}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Beds"})]}),n.bathrooms&&r.jsxs("div",{className:"text-center",children:[r.jsx(g1,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"font-semibold",children:n.bathrooms}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Baths"})]}),n.square_footage&&r.jsxs("div",{className:"text-center",children:[r.jsx(fx,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"font-semibold",children:n.square_footage.toLocaleString()}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Sq Ft"})]}),n.year_built&&r.jsxs("div",{className:"text-center",children:[r.jsx(An,{className:"h-5 w-5 mx-auto mb-1 text-muted-foreground"}),r.jsx("p",{className:"font-semibold",children:n.year_built}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Built"})]})]}),r.jsxs("div",{className:"pt-4 space-y-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(_t,{variant:"secondary",children:[r.jsx(Ni,{className:"h-3 w-3 mr-1"}),AIe[n.property_type]]}),n.lot_size&&r.jsxs(_t,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&r.jsx(_t,{variant:"secondary",children:"HOA"})]}),n.description&&r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium mb-2",children:"Description"}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.description})]}),n.agent_notes&&n.agent_notes_public&&r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium mb-2",children:"Agent Notes"}),r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:n.agent_notes})]}),n.mls_link&&r.jsx(X,{variant:"outline",asChild:!0,children:r.jsxs("a",{href:n.mls_link,target:"_blank",rel:"noopener noreferrer",children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]}),r.jsxs("div",{className:"flex items-center gap-4 pt-4 mt-4 border-t text-sm text-muted-foreground",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ii,{className:"h-4 w-4"}),n.view_count," views"]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Uc,{className:"h-4 w-4"}),n.share_count," shares"]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ai,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Share Content"})}),r.jsx(qe,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(ve=>r.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[r.jsxs("div",{className:"flex justify-between items-start mb-2",children:[r.jsxs("p",{className:"font-medium text-sm capitalize",children:[ve.replace("_"," ")," Caption"]}),r.jsx(X,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(re(ve)),we.success("Caption copied!")},children:r.jsx(uo,{className:"h-3 w-3"})})]}),r.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:re(ve)})]},ve))})]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"Listing Agent"})}),r.jsxs(qe,{children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:r.jsx("span",{className:"text-lg font-semibold text-primary",children:((de=(ie=n.agent)==null?void 0:ie.name)==null?void 0:de.charAt(0))||"?"})}),r.jsxs("div",{children:[r.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)&&r.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!B&&r.jsx("div",{className:"space-y-2",children:((_e=n.agent)==null?void 0:_e.email)&&r.jsx(X,{variant:"outline",className:"w-full",asChild:!0,children:r.jsxs("a",{href:`mailto:${n.agent.email}`,children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),B&&r.jsx(iar,{listing:n}),!B&&n.open_to_referrals&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"Send a Buyer"]})}),r.jsxs(qe,{children:[r.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."}),r.jsx(X,{className:"w-full",onClick:()=>w(!0),children:"Send Referral"})]})]})]})]})]}),r.jsx(Ir,{open:!!C,onOpenChange:()=>I(null),children:r.jsx(Er,{className:"max-w-4xl",children:r.jsx("img",{src:C||"",alt:"Full size",className:"w-full h-auto"})})}),r.jsx(Ir,{open:v,onOpenChange:_,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Delete Listing"}),r.jsx(Zs,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),r.jsx(X,{variant:"destructive",onClick:W,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),r.jsx(Ir,{open:k,onOpenChange:w,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Send Buyer Referral"}),r.jsx(Zs,{children:"Submit buyer information to the listing agent"})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Buyer Name *"}),r.jsx(Ye,{value:R.buyerName,onChange:ve=>D({...R,buyerName:ve.target.value}),placeholder:"Enter buyer's name"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Buyer Type"}),r.jsxs(ds,{value:R.buyerType,onValueChange:ve=>D({...R,buyerType:ve}),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select type"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"first_time",children:"First-Time Buyer"}),r.jsx(Ut,{value:"investor",children:"Investor"}),r.jsx(Ut,{value:"relocating",children:"Relocating"}),r.jsx(Ut,{value:"upgrade",children:"Upgrading"}),r.jsx(Ut,{value:"downsize",children:"Downsizing"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Notes"}),r.jsx(qs,{value:R.notes,onChange:ve=>D({...R,notes:ve.target.value}),placeholder:"Any additional information..."})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),r.jsx(X,{onClick:K,disabled:g.isPending,children:g.isPending?"Sending...":"Send Referral"})]})]})}),r.jsx(nZe,{open:S,onOpenChange:T,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 dar({selectedVideoId:e,onVideoSelect:t,listingId:s}){const n=Ks(),{user:a}=Gr(),[o,l]=A.useState(!1),[i,d]=A.useState([]),[m,p]=A.useState(!1),[g,v]=A.useState(null),[_,k]=A.useState({});A.useEffect(()=>{e&&a?w():v(null)},[e,a]);const w=async()=>{if(!e)return;const{data:W,error:K}=await Y.from("agent_videos").select("id, bunny_video_id, title, thumbnail_url, preview_url, playback_url, duration_seconds, status, created_at").eq("id",e).eq("is_deleted",!1).single();!K&&W&&(v(W),S(W))},S=async W=>{try{const{data:K,error:re}=await Y.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:W.bunny_video_id,isAgentVideo:!0}});!re&&(K!=null&&K.thumbnailUrl)&&k(ae=>({...ae,[W.id]:{thumbnailUrl:K.thumbnailUrl}}))}catch(K){console.warn("Failed to get signed URL",K)}},T=async()=>{if(a){p(!0);try{const{data:W,error:K}=await Y.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(K)throw K;d(W||[]),W!=null&&W.length&&C(W)}catch(W){console.error("Error fetching videos:",W),we.error("Failed to load videos")}finally{p(!1)}}},C=async W=>{var K;try{const re=W.map(ie=>ie.bunny_video_id),{data:ae,error:oe}=await Y.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:re,isAgentVideo:!0}});if(oe)throw oe;const se=(ae==null?void 0:ae.assets)||{},pe={};for(const ie of W)(K=se[ie.bunny_video_id])!=null&&K.thumbnailUrl&&(pe[ie.id]={thumbnailUrl:se[ie.bunny_video_id].thumbnailUrl});k(ie=>({...ie,...pe}))}catch(re){console.warn("Failed to bulk-fetch signed URLs",re)}},I=()=>{l(!0),T()},R=W=>{t(W.id),v(W),l(!1),we.success("Video selected")},D=()=>{t(null),v(null)},B=()=>{const W=s?`/mission-control/listings/${s}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(W)}`)},$=W=>{if(!W)return"0:00";const K=Math.floor(W/60),re=W%60;return`${K}:${re.toString().padStart(2,"0")}`},q=W=>{var K;return((K=_[W.id])==null?void 0:K.thumbnailUrl)||W.thumbnail_url};return r.jsxs("div",{className:"space-y-3",children:[g?r.jsx(ze,{className:"overflow-hidden",children:r.jsx(qe,{className:"p-0",children:r.jsxs("div",{className:"flex items-start gap-4 p-4",children:[r.jsxs("div",{className:"relative w-32 h-20 bg-muted rounded-lg overflow-hidden flex-shrink-0",children:[q(g)?r.jsx("img",{src:q(g),alt:g.title||"Video thumbnail",className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(ma,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx("div",{className:"absolute inset-0 bg-black/30 flex items-center justify-center",children:r.jsx(tc,{className:"h-6 w-6 text-white fill-white"})}),g.duration_seconds&&r.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)})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:g.title||"Untitled Video"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Property Video Tour"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{type:"button",variant:"outline",size:"sm",onClick:I,children:"Change"}),r.jsx(X,{type:"button",variant:"ghost",size:"sm",onClick:D,className:"text-destructive hover:text-destructive",children:r.jsx(Xs,{className:"h-4 w-4"})})]})]})})}):r.jsx(ze,{className:"border-dashed",children:r.jsx(qe,{className:"p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx(ma,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Add a video walkthrough to showcase this property"}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center",children:[r.jsxs(X,{type:"button",variant:"outline",onClick:I,className:"gap-2",children:[r.jsx(T4,{className:"h-4 w-4"}),"Select from Library"]}),r.jsxs(X,{type:"button",variant:"outline",onClick:B,className:"gap-2",children:[r.jsx(ng,{className:"h-4 w-4"}),"Record New Video"]})]})]})})}),r.jsx(Ir,{open:o,onOpenChange:l,children:r.jsxs(Er,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[r.jsx(zr,{children:r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(T4,{className:"h-5 w-5"}),"Select a Video"]})}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:m?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):i.length===0?r.jsxs("div",{className:"text-center py-12",children:[r.jsx(ma,{className:"h-12 w-12 mx-auto text-muted-foreground mb-3"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"No videos in your library yet"}),r.jsxs(X,{onClick:B,className:"gap-2",children:[r.jsx(ng,{className:"h-4 w-4"}),"Record Your First Video"]})]}):r.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 p-1",children:i.map(W=>r.jsxs("button",{type:"button",onClick:()=>R(W),className:`group relative rounded-lg overflow-hidden border-2 transition-all text-left ${e===W.id?"border-primary ring-2 ring-primary/20":"border-transparent hover:border-muted-foreground/30"}`,children:[r.jsxs("div",{className:"aspect-video bg-muted relative",children:[q(W)?r.jsx("img",{src:q(W),alt:W.title||"Video",className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center",children:r.jsx(ma,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/30 transition-colors flex items-center justify-center",children:r.jsx(tc,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity"})}),W.duration_seconds&&r.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)})]}),r.jsx("div",{className:"p-2 bg-card",children:r.jsx("p",{className:"text-xs font-medium truncate",children:W.title||"Untitled Video"})})]},W.id))})}),r.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[r.jsxs(X,{type:"button",variant:"ghost",onClick:B,className:"gap-2",children:[r.jsx(ng,{className:"h-4 w-4"}),"Record New Video"]}),r.jsx(X,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const uar=[{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"}],har=[{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 EIe(){var pe;const{listingId:e}=Bl(),[t]=Cc(),s=t.get("brokerage"),n=Ks(),{user:a}=Gr(),o=!!e&&e!=="new",l=!!s&&!o,{data:i,isLoading:d}=m9e(o?e:""),m=Dbt(),p=Obt(),g=Rbt(),v=Fbt(),_=zbt(),{data:k=[]}=Ht({queryKey:["brokerage-agents",s],queryFn:async()=>{if(!s)return[];const{data:ie,error:de}=await Y.from("profiles").select("id, name, email").eq("brokerage_id",s).order("name");if(de)throw de;return ie||[]},enabled:l}),[w,S]=A.useState(""),[T,C]=A.useState(!1),[I,R]=A.useState([]),[D,B]=A.useState([]),[$,q]=A.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});A.useEffect(()=>{var ie,de,ce,ge,Te;i&&o&&q({property_address:i.property_address||"",city:i.city||"",state:i.state||"",neighborhood:i.neighborhood||"",price:((ie=i.price)==null?void 0:ie.toString())||"",property_type:i.property_type,status:i.status,bedrooms:((de=i.bedrooms)==null?void 0:de.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=ie=>{if(!ie)return;const de=Array.from(ie);R(ge=>[...ge,...de]);const ce=de.map(ge=>URL.createObjectURL(ge));B(ge=>[...ge,...ce])},K=ie=>{URL.revokeObjectURL(D[ie]),R(de=>de.filter((ce,ge)=>ge!==ie)),B(de=>de.filter((ce,ge)=>ge!==ie))},re=async ie=>{var de;if(!(!ie||!i)){C(!0);try{for(const ce of Array.from(ie)){const ge=ce.name.split(".").pop(),Te=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${ge}`,{error:_e}=await Y.storage.from("listing-photos").upload(Te,ce);if(_e)throw _e;const{data:{publicUrl:ve}}=Y.storage.from("listing-photos").getPublicUrl(Te);await v.mutateAsync({listingId:i.id,photoUrl:ve,isPrimary:!((de=i.photos)!=null&&de.length)})}we.success("Photos uploaded!")}catch(ce){console.error("Upload error:",ce),we.error("Failed to upload photos")}finally{C(!1)}}},ae=async ie=>{for(let de=0;de{if(i)try{await _.mutateAsync({photoId:ie,listingId:i.id}),we.success("Photo removed")}catch{we.error("Failed to remove photo")}},se=async ie=>{if(ie.preventDefault(),!$.city.trim()||!$.state.trim()||!$.price){we.error("Please fill in required fields (City, State, Price)");return}if(l&&!w){we.error("Please select an agent to assign this listing to");return}try{const de={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:e,...de}),we.success("Listing updated!"),n(`/mission-control/listings/${e}`);else{C(!0);let ce;if(l&&w?ce=await p.mutateAsync({agentId:w,...de}):ce=await m.mutateAsync(de),I.length>0)try{await ae(ce.id),D.forEach(ge=>URL.revokeObjectURL(ge)),R([]),B([])}catch(ge){console.error("Photo upload error:",ge),we.error("Listing created but some photos failed to upload")}C(!1),we.success("Listing created!"),n(l?"/my-brokerage":`/mission-control/listings/${ce.id}`)}}catch(de){console.error("Save error:",de),we.error("Failed to save listing"),C(!1)}};return o&&d?r.jsx(Ur,{title:"Loading...",description:"",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-10 w-32"}),r.jsx(pr,{className:"h-[600px] w-full"})]})}):r.jsx(Ur,{title:o?"Edit Listing":l?"Add Listing for Agent":"Add Listing",description:"",children:r.jsxs("form",{onSubmit:se,className:"space-y-6",children:[r.jsxs(X,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),l?"Back to Brokerage":"Back to Listings"]}),r.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"md:col-span-2 space-y-6",children:[l&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Assign to Agent *"})}),r.jsxs(qe,{children:[r.jsxs(ds,{value:w,onValueChange:S,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select an agent..."})}),r.jsx(cs,{children:k.map(ie=>r.jsx(Ut,{value:ie.id,children:ie.name||ie.email},ie.id))})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Property Details"})}),r.jsx(qe,{className:"space-y-4",children:r.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"sm:col-span-2 space-y-2",children:[r.jsx(Ee,{children:"Property Address"}),r.jsx(Ye,{value:$.property_address,onChange:ie=>q({...$,property_address:ie.target.value}),placeholder:"123 Main St"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"City *"}),r.jsx(Ye,{value:$.city,onChange:ie=>q({...$,city:ie.target.value}),placeholder:"City",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"State *"}),r.jsx(Ye,{value:$.state,onChange:ie=>q({...$,state:ie.target.value}),placeholder:"State",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Neighborhood"}),r.jsx(Ye,{value:$.neighborhood,onChange:ie=>q({...$,neighborhood:ie.target.value}),placeholder:"Neighborhood"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Price *"}),r.jsx(Ye,{type:"number",value:$.price,onChange:ie=>q({...$,price:ie.target.value}),placeholder:"500000",required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Property Type"}),r.jsxs(ds,{value:$.property_type,onValueChange:ie=>q({...$,property_type:ie}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:har.map(ie=>r.jsx(Ut,{value:ie.value,children:ie.label},ie.value))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Status"}),r.jsxs(ds,{value:$.status,onValueChange:ie=>q({...$,status:ie}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:uar.map(ie=>r.jsx(Ut,{value:ie.value,children:ie.label},ie.value))})]})]})]})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Property Specs (Optional)"})}),r.jsx(qe,{children:r.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Bedrooms"}),r.jsx(Ye,{type:"number",value:$.bedrooms,onChange:ie=>q({...$,bedrooms:ie.target.value}),placeholder:"3"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Bathrooms"}),r.jsx(Ye,{type:"number",step:"0.5",value:$.bathrooms,onChange:ie=>q({...$,bathrooms:ie.target.value}),placeholder:"2"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Sq Ft"}),r.jsx(Ye,{type:"number",value:$.square_footage,onChange:ie=>q({...$,square_footage:ie.target.value}),placeholder:"2000"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Lot Size"}),r.jsx(Ye,{value:$.lot_size,onChange:ie=>q({...$,lot_size:ie.target.value}),placeholder:"0.25 acres"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Year Built"}),r.jsx(Ye,{type:"number",value:$.year_built,onChange:ie=>q({...$,year_built:ie.target.value}),placeholder:"2005"})]}),r.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[r.jsx(fn,{checked:$.has_hoa,onCheckedChange:ie=>q({...$,has_hoa:ie})}),r.jsx(Ee,{children:"Has HOA"})]})]})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Description & Links"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Description"}),r.jsx(qs,{value:$.description,onChange:ie=>q({...$,description:ie.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Agent Notes"}),r.jsx(qs,{value:$.agent_notes,onChange:ie=>q({...$,agent_notes:ie.target.value}),placeholder:"Notes for other agents...",rows:2}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{checked:$.agent_notes_public,onCheckedChange:ie=>q({...$,agent_notes_public:ie})}),r.jsx(Ee,{className:"text-sm text-muted-foreground",children:"Make notes visible to other agents"})]})]}),r.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"MLS Link"}),r.jsx(Ye,{value:$.mls_link,onChange:ie=>q({...$,mls_link:ie.target.value}),placeholder:"https://..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Video Link"}),r.jsx(Ye,{value:$.video_link,onChange:ie=>q({...$,video_link:ie.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ma,{className:"h-5 w-5"}),"Property Video"]})}),r.jsx(qe,{children:r.jsx(dar,{selectedVideoId:$.video_id,onVideoSelect:ie=>q({...$,video_id:ie}),listingId:o?e:void 0})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Photos"})}),r.jsxs(qe,{children:[r.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[o&&((pe=i==null?void 0:i.photos)==null?void 0:pe.map(ie=>r.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[r.jsx("img",{src:ie.photo_url,alt:"",className:"w-full h-full object-cover"}),r.jsx("button",{type:"button",onClick:()=>oe(ie.id),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:r.jsx(Xs,{className:"h-3 w-3"})}),ie.is_primary&&r.jsx("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded",children:"Primary"})]},ie.id))),!o&&D.map((ie,de)=>r.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[r.jsx("img",{src:ie,alt:"",className:"w-full h-full object-cover"}),r.jsx("button",{type:"button",onClick:()=>K(de),className:"absolute top-1 right-1 p-1 bg-destructive text-destructive-foreground rounded-full hover:bg-destructive/90",children:r.jsx(Xs,{className:"h-3 w-3"})}),de===0&&r.jsx("span",{className:"absolute bottom-1 left-1 text-[10px] bg-primary text-primary-foreground px-1.5 py-0.5 rounded",children:"Primary"})]},de)),r.jsxs("label",{className:"aspect-square rounded-lg border-2 border-dashed border-muted-foreground/25 hover:border-muted-foreground/50 cursor-pointer flex flex-col items-center justify-center gap-2 text-muted-foreground",children:[T?r.jsx($r,{className:"h-8 w-8 animate-spin"}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"h-8 w-8"}),r.jsx("span",{className:"text-xs",children:"Upload"})]}),r.jsx("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:ie=>o?re(ie.target.files):W(ie.target.files),disabled:T})]})]}),!o&&I.length>0&&r.jsxs("p",{className:"text-sm text-muted-foreground mt-4",children:[I.length," photo",I.length!==1?"s":""," will be uploaded when you save."]})]})]})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Sharing & Collaboration"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Allow Sharing"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),r.jsx(fn,{checked:$.allow_sharing,onCheckedChange:ie=>q({...$,allow_sharing:ie})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Open to Referrals"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),r.jsx(fn,{checked:$.open_to_referrals,onCheckedChange:ie=>q({...$,open_to_referrals:ie})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Social Promotion"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),r.jsx(fn,{checked:$.open_to_social_promotion,onCheckedChange:ie=>q({...$,open_to_social_promotion:ie})})]}),r.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Share with Brokerage"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),r.jsx(fn,{checked:$.share_with_brokerage,onCheckedChange:ie=>q({...$,share_with_brokerage:ie})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Make Public"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),r.jsx(fn,{checked:$.is_public,onCheckedChange:ie=>q({...$,is_public:ie})})]})]})]}),r.jsx(X,{type:"submit",className:"w-full",size:"lg",disabled:m.isPending||g.isPending,children:m.isPending||g.isPending?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}function zbe({maxDurationSeconds:e=30,onRecordingComplete:t,onError:s,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=A.useRef(null),i=A.useRef(null),d=A.useRef(null),m=A.useRef([]),p=A.useRef(null),g=A.useRef(null),v=A.useRef(null),_=A.useRef(null),k=V3(),[w,S]=A.useState(!0),[T,C]=A.useState(!0),[I,R]=A.useState(null),[D,B]=A.useState(!1),[$,q]=A.useState(!1),[W,K]=A.useState(null),[re,ae]=A.useState(null),[oe,se]=A.useState(0),[pe,ie]=A.useState("user"),[de,ce]=A.useState(0),[ge,Te]=A.useState(!1),[_e,ve]=A.useState(!0),[Me,Ze]=A.useState(null),[Ae,Le]=A.useState(!1),[Ue,Ve]=A.useState(null),Ie=A.useRef(null),We=A.useRef(s);We.current=s;const wt=A.useCallback(ft=>{S(ft)},[]),Pe=A.useRef(w),st=A.useCallback(async()=>{var ct,Tt;C(!0),Ze(null);const ft=k&&w;console.log("[VideoRecorder] initCamera start",{isMobile:k,usePortraitMode:w,shouldBePortrait:ft,facingMode:pe});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(Mr=>Mr.stop()));const Ot=k&&ft?{facingMode:{ideal:pe},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:pe},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",Ot);const rr=await navigator.mediaDevices.getUserMedia({video:Ot,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),rr.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");d.current=rr,R(!0);const cr=rr.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",cr.width,"x",cr.height),l.current){const Mr=l.current;Mr.srcObject=rr,Mr.muted=!0,Mr.playsInline=!0,Mr.autoplay=!0,Mr.setAttribute("muted",""),Mr.setAttribute("playsinline",""),Mr.setAttribute("autoplay","");try{(ct=Mr.load)==null||ct.call(Mr)}catch(Et){console.warn("[VideoRecorder] videoEl.load failed",Et)}const As=async()=>{try{return await Mr.play(),console.log("[VideoRecorder] preview play ok"),Le(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:Mr.readyState,videoWidth:Mr.videoWidth,videoHeight:Mr.videoHeight})},300),!0}catch(Et){return console.warn("[VideoRecorder] preview play blocked",Et),Le(!0),!1}};await new Promise(Et=>{let Pt=!1;const Sr=()=>{Pt||(Pt=!0,Et())},fs=()=>{As().finally(Sr)};Mr.onloadedmetadata=fs,Mr.onloadeddata=fs,setTimeout(Sr,1500)})}try{g.current=new AudioContext;const Mr=g.current.createMediaStreamSource(rr);v.current=g.current.createAnalyser(),v.current.fftSize=256,Mr.connect(v.current);const As=()=>{if(v.current){const Et=new Uint8Array(v.current.frequencyBinCount);v.current.getByteFrequencyData(Et);const Pt=Et.reduce((Sr,fs)=>Sr+fs)/Et.length;ce(Math.min(100,Pt/128*100))}_.current=requestAnimationFrame(As)};As()}catch(Mr){console.warn("Audio context not available:",Mr)}}catch(Ot){console.error("Camera initialization error:",Ot),R(!1);let rr="Failed to access camera or microphone.";Ot.name==="NotAllowedError"?rr="Camera permission denied. Please allow camera access in your browser settings.":Ot.name==="NotFoundError"?rr="No camera found. Please connect a camera and try again.":Ot.name==="NotReadableError"?rr="Camera is in use by another application. Please close other apps using the camera.":Ot.message&&(rr=Ot.message),Ze(rr),(Tt=We.current)==null||Tt.call(We,rr)}finally{C(!1)}},[pe,k,w]);A.useEffect(()=>{Pe.current!==w&&I&&!D&&!re&&(Pe.current=w,st())},[w,I,D,re,st]),A.useEffect(()=>(st(),()=>{d.current&&d.current.getTracks().forEach(ft=>ft.stop()),p.current&&clearInterval(p.current),_.current&&cancelAnimationFrame(_.current),g.current&&g.current.close(),Ie.current&&clearInterval(Ie.current),re&&URL.revokeObjectURL(re)}),[st,re]),A.useEffect(()=>{if(T||I!==!0||re)return;const ft=d.current,ct=l.current;!ft||!ct||(ct.srcObject!==ft&&(ct.srcObject=ft,ct.muted=!0,ct.playsInline=!0,ct.autoplay=!0,ct.setAttribute("muted",""),ct.setAttribute("playsinline",""),ct.setAttribute("autoplay","")),ct.play().then(()=>Le(!1)).catch(Tt=>{Le(!0),console.warn("Live preview play blocked on mount:",Tt)}))},[I,T,re]),A.useEffect(()=>{n==null||n(D)},[D,n]);const ue=A.useCallback(async()=>{if(re)return;const ft=l.current;if(ft)try{await ft.play(),Le(!1)}catch(ct){Le(!0),console.warn("Live preview still blocked (needs user gesture):",ct)}},[re]),$e=A.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),p.current&&(clearInterval(p.current),p.current=null),B(!1),q(!1)},[]),tt=A.useCallback(()=>{if(!d.current)return;ue(),m.current=[],se(0);const ct=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Ot=>MediaRecorder.isTypeSupported(Ot)),Tt=new MediaRecorder(d.current,ct?{mimeType:ct,videoBitsPerSecond:25e5}:{videoBitsPerSecond:25e5});Tt.ondataavailable=Ot=>{Ot.data.size>0&&m.current.push(Ot.data)},Tt.onstop=()=>{var cr;const Ot=Tt.mimeType||ct||((cr=m.current[0])==null?void 0:cr.type)||"video/webm",rr=new Blob(m.current,{type:Ot});K(rr);const Lr=URL.createObjectURL(rr);ae(Lr)},i.current=Tt,Tt.start(100),B(!0),p.current=setInterval(()=>{se(Ot=>Ot>=e-1?($e(),e):Ot+1)},1e3)},[ue,e,$e]),rt=A.useCallback(()=>{if(Ue!==null)return;Ve(3);let ft=3;Ie.current=setInterval(()=>{ft-=1,ft<=0?(Ie.current&&clearInterval(Ie.current),Ie.current=null,Ve(null),tt()):Ve(ft)},1e3)},[Ue,tt]),je=A.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),q(!0),p.current&&clearInterval(p.current))},[]),it=A.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),q(!1),p.current=setInterval(()=>{se(ft=>ft>=e-1?($e(),e):ft+1)},1e3))},[e,$e]),Se=A.useCallback(()=>{re&&URL.revokeObjectURL(re),K(null),ae(null),se(0),Te(!1),ve(!0),l.current&&d.current&&(l.current.srcObject=d.current,l.current.muted=!0,ue())},[ue,re]),et=A.useCallback(()=>{ie(ft=>ft==="user"?"environment":"user")},[]),Qe=A.useCallback(()=>{W&&t(W,oe)},[W,oe,t]),He=A.useCallback(()=>{l.current&&re&&(ge?l.current.pause():(ve(!1),l.current.muted=!1,l.current.play()),Te(!ge))},[re,ge]);A.useEffect(()=>{if(!re)return;const ft=l.current;if(!ft)return;ve(!1),ft.pause(),ft.removeAttribute("src"),ft.srcObject=null,ft.load(),ft.src=re,ft.currentTime=0,ft.playsInline=!0,ft.muted=!1,ft.onended=()=>Te(!1);const ct=()=>{var rr;const Tt=ft.error,Ot=Tt?`Recorded video failed to play (code ${Tt.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Tt),(rr=We.current)==null||rr.call(We,Ot)};return ft.addEventListener("error",ct),ft.load(),()=>{ft.removeEventListener("error",ct)}},[re]);const ot=ft=>{const ct=Math.floor(ft/60),Tt=ft%60;return`${ct}:${Tt.toString().padStart(2,"0")}`},ut=k&&w?"aspect-[9/16]":"aspect-video";return T?r.jsx("div",{className:Vt("flex items-center justify-center bg-black rounded-lg",ut,a),children:r.jsxs("div",{className:"text-center text-white",children:[r.jsx($r,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),r.jsx("p",{children:"Initializing camera..."})]})}):I===!1?r.jsx("div",{className:Vt("flex items-center justify-center bg-black rounded-lg",ut,a),children:r.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[r.jsx(kl,{className:"h-12 w-12 mx-auto mb-4 text-destructive"}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Camera Access Required"}),r.jsx("p",{className:"text-gray-400 mb-4 text-sm",children:Me||"Please allow camera and microphone access to record videos."}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(X,{onClick:()=>st(),variant:"secondary",className:"w-full",children:[r.jsx(Yo,{className:"h-4 w-4 mr-2"}),"Try Again"]}),r.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."})]})]})}):r.jsxs("div",{className:Vt("flex flex-col gap-2",a),children:[k&&!D&&!re&&r.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[r.jsx(jk,{className:Vt("h-4 w-4",w?"text-muted-foreground":"text-primary")}),r.jsx(Ee,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),r.jsx(fn,{id:"orientation-toggle",checked:w,onCheckedChange:wt}),r.jsx(Ee,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),r.jsx(qy,{className:Vt("h-4 w-4",w?"text-primary":"text-muted-foreground")})]}),r.jsxs("div",{className:Vt("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{ue()},children:[r.jsx("video",{ref:l,src:re??void 0,className:Vt("w-full bg-black",w&&!re?"object-contain":"object-cover",ut,pe==="user"&&!re&&"scale-x-[-1]"),playsInline:!0,controls:!!re,muted:re?_e:!0,autoPlay:!re},re??"live"),!re&&Ae&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40",children:r.jsx(X,{type:"button",variant:"secondary",onClick:()=>void ue(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!re&&r.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),Ue!==null&&!re&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30 pointer-events-none",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.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:Ue},Ue),r.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),D&&r.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[r.jsx("div",{className:Vt("w-3 h-3 rounded-full",$?"bg-yellow-500":"bg-red-500 animate-pulse")}),r.jsxs("span",{className:"text-white text-sm font-medium",children:[ot(oe)," / ",ot(e)]})]}),D&&r.jsx("div",{className:"absolute top-0 left-0 right-0",children:r.jsx(zl,{value:oe/e*100,className:"h-1 rounded-none"})}),!re&&r.jsxs("div",{className:"absolute bottom-20 left-4 flex items-center gap-2 bg-black/50 px-3 py-1.5 rounded-full",children:[r.jsx(NE,{className:"h-4 w-4 text-white"}),r.jsx("div",{className:"w-20 h-2 bg-white/20 rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-green-500 transition-all duration-75",style:{width:`${de}%`}})})]}),r.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:re?r.jsxs(r.Fragment,{children:[r.jsxs(X,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Se,children:[r.jsx(Yo,{className:"h-5 w-5 mr-2"}),"Re-record"]}),r.jsx(X,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:He,children:ge?r.jsx(Bm,{className:"h-5 w-5"}):r.jsx(tc,{className:"h-5 w-5"})}),r.jsxs(X,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:Qe,children:[r.jsx(mi,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):r.jsxs(r.Fragment,{children:[r.jsx(X,{variant:"secondary",size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:et,disabled:D||Ue!==null,children:r.jsx(Mk,{className:"h-5 w-5"})}),!D&&Ue===null?r.jsx(X,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:rt,children:r.jsx(ma,{className:"h-6 w-6"})}):r.jsxs(r.Fragment,{children:[r.jsx(X,{size:"icon",className:"h-12 w-12 rounded-full bg-white/20 hover:bg-white/30 text-white",onClick:$?it:je,children:$?r.jsx(tc,{className:"h-5 w-5"}):r.jsx(Bm,{className:"h-5 w-5"})}),r.jsx(X,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:$e,children:r.jsx(fx,{className:"h-6 w-6 fill-current"})})]}),r.jsx("div",{className:"h-12 w-12"})]})})]})]})}const lZe="teleprompter_settings",eme={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function mar(){try{const e=localStorage.getItem(lZe);return e?{...eme,...JSON.parse(e)}:eme}catch{return eme}}function far(e){try{localStorage.setItem(lZe,JSON.stringify(e))}catch{}}function cZe({text:e,isVisible:t,onToggleVisibility:s,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=A.useRef(null),d=A.useRef(null),m=A.useRef(0),p=A.useRef(0),[g,v]=A.useState(mar),{scrollSpeed:_,fontSize:k,lineHeight:w,opacity:S,position:T,isMirrored:C}=g,I=A.useCallback((ae,oe)=>{v(se=>{const pe={...se,[ae]:oe};return far(pe),pe})},[]),[R,D]=A.useState(!1),[B,$]=A.useState(null),q=A.useCallback(ae=>{if(!i.current)return;m.current===0&&(m.current=ae);const oe=ae-m.current;m.current=ae,p.current+=_*oe/1e3;const se=Math.floor(p.current);se>0&&(i.current.scrollTop+=se,p.current-=se);const{scrollTop:pe,scrollHeight:ie,clientHeight:de}=i.current;if(pe+de>=ie){D(!1);return}d.current=requestAnimationFrame(q)},[_]);A.useEffect(()=>(R?(m.current=0,p.current=0,d.current=requestAnimationFrame(q)):d.current&&cancelAnimationFrame(d.current),()=>{d.current&&cancelAnimationFrame(d.current)}),[R,q]),A.useEffect(()=>{if(n&&t)if(i.current&&(i.current.scrollTop=0),a){$(3);let ae=3;const oe=setInterval(()=>{ae-=1,ae<=0?(clearInterval(oe),$(null),o==null||o(),D(!0)):$(ae)},1e3);return()=>clearInterval(oe)}else setTimeout(()=>D(!0),100);else n||(D(!1),$(null))},[n,t,a,o]);const W=A.useCallback(()=>{i.current&&(i.current.scrollTop=0),D(!1)},[]),K=A.useCallback(()=>{D(ae=>!ae)},[]);if(!t)return r.jsx("div",{className:Vt("absolute top-4 right-4 pointer-events-auto z-10",l),children:r.jsxs(X,{variant:"secondary",size:"sm",onClick:s,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[r.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const re={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return r.jsxs("div",{className:Vt("absolute inset-0 pointer-events-none",l),children:[B!==null&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-20 pointer-events-none",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.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),r.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),r.jsx("div",{className:Vt("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",re[T],B!==null&&"opacity-30"),style:{opacity:B!==null?.3:S},children:r.jsxs("div",{ref:i,className:Vt("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",C&&"scale-x-[-1]"),style:{maskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)",WebkitMaskImage:"linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)"},children:[r.jsx("div",{className:"h-full",style:{minHeight:"100%"}}),r.jsx("p",{className:"text-white text-center font-medium drop-shadow-lg",style:{fontSize:`${k}px`,lineHeight:w,textShadow:"0 2px 4px rgba(0,0,0,0.8)"},children:e}),r.jsx("div",{className:"h-full"})]})}),r.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2 pointer-events-auto",children:[r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsx(X,{variant:"secondary",size:"icon",className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:r.jsx(ld,{className:"h-4 w-4"})})}),r.jsx(Hc,{className:"w-72",side:"left",align:"start",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("h4",{className:"font-medium",children:"Teleprompter Settings"}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs",children:"Scroll Speed"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:_})]}),r.jsx(Xp,{value:[_],onValueChange:([ae])=>I("scrollSpeed",ae),min:1,max:100,step:1})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs",children:"Font Size"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[k,"px"]})]}),r.jsx(Xp,{value:[k],onValueChange:([ae])=>I("fontSize",ae),min:16,max:48,step:2})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs",children:"Line Spacing"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:w.toFixed(1)})]}),r.jsx(Xp,{value:[w*10],onValueChange:([ae])=>I("lineHeight",ae/10),min:12,max:24,step:1})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs",children:"Opacity"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(S*100),"%"]})]}),r.jsx(Xp,{value:[S*100],onValueChange:([ae])=>I("opacity",ae/100),min:30,max:100,step:5})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{className:"text-xs",children:"Position"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx(X,{variant:T==="top"?"default":"outline",size:"sm",onClick:()=>I("position","top"),children:r.jsx(cx,{className:"h-4 w-4"})}),r.jsx(X,{variant:T==="center"?"default":"outline",size:"sm",onClick:()=>I("position","center"),children:r.jsx(k1,{className:"h-4 w-4"})}),r.jsx(X,{variant:T==="bottom"?"default":"outline",size:"sm",onClick:()=>I("position","bottom"),children:r.jsx(ad,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs",children:"Mirror Mode"}),r.jsx(fn,{checked:C,onCheckedChange:ae=>I("isMirrored",ae)})]})]})})]}),r.jsx(X,{variant:"secondary",size:"icon",onClick:K,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:R?r.jsx(Bm,{className:"h-4 w-4"}):r.jsx(tc,{className:"h-4 w-4"})}),r.jsx(X,{variant:"secondary",size:"icon",onClick:W,className:"h-9 w-9 bg-black/50 hover:bg-black/70 text-white border-0",children:r.jsx(Mk,{className:"h-4 w-4"})}),r.jsxs(X,{variant:"secondary",size:"sm",onClick:s,className:"bg-black/50 hover:bg-black/70 text-white border-0",children:[r.jsx(Lf,{className:"h-4 w-4 mr-2"}),"Hide"]})]})]})}function par({onSelectScript:e,onCreateNew:t,selectedScriptId:s,className:n}){const{toast:a}=_i(),[o,l]=A.useState(""),[i,d]=A.useState(null),[m,p]=A.useState("levelup"),{data:g,isLoading:v}=WPt(),{data:_,isLoading:k}=GPt(),{data:w,isLoading:S}=KPt(),T=ZPt(),C=A.useMemo(()=>_?_.filter($=>{const q=!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())||$.tags.some(K=>K.toLowerCase().includes(o.toLowerCase())),W=!i||$.category_id===i;return q&&W}):[],[_,o,i]),I=A.useMemo(()=>w?w.filter($=>!o||$.title.toLowerCase().includes(o.toLowerCase())||$.script_text.toLowerCase().includes(o.toLowerCase())):[],[w,o]),R=$=>{e({title:$.title,text:$.script_text})},D=async $=>{try{await T.mutateAsync($),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},B=v||k||S;return r.jsxs("div",{className:Vt("flex flex-col h-full",n),children:[r.jsx("div",{className:"p-4 border-b",children:r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search scripts...",value:o,onChange:$=>l($.target.value),className:"pl-9"})]})}),r.jsxs(ii,{value:m,onValueChange:$=>p($),className:"flex-1 flex flex-col",children:[r.jsxs(si,{className:"mx-4 mt-4 grid grid-cols-2",children:[r.jsxs(Kr,{value:"levelup",children:[r.jsx(ya,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),r.jsxs(Kr,{value:"my-scripts",children:[r.jsx(rg,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),r.jsxs(hs,{value:"levelup",className:"flex-1 flex flex-col mt-0 p-4",children:[r.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[r.jsx(_t,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>d(null),children:"All"}),g==null?void 0:g.map($=>r.jsx(_t,{variant:i===$.id?"default":"outline",className:"cursor-pointer",onClick:()=>d($.id),children:$.name},$.id))]}),r.jsx(To,{className:"flex-1 max-h-[50vh]",children:B?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(ya,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),r.jsx("p",{children:"No scripts found"})]}):r.jsx("div",{className:"space-y-2",children:C.map($=>r.jsxs(ze,{className:Vt("cursor-pointer hover:bg-accent/50 transition-colors",s===$.id&&"ring-2 ring-primary"),onClick:()=>R($),children:[r.jsx(Wt,{className:"p-3",children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(Zt,{className:"text-sm font-medium truncate",children:$.title}),$.category&&r.jsx(_t,{variant:"secondary",className:"mt-1 text-xs",children:$.category.name})]}),r.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:q=>{q.stopPropagation(),D($)},children:r.jsx(rg,{className:"h-4 w-4"})}),r.jsx(Zi,{className:"h-4 w-4 text-muted-foreground"})]})]})}),r.jsx(qe,{className:"p-3 pt-0",children:r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]}),r.jsxs(hs,{value:"my-scripts",className:"flex-1 flex flex-col mt-0 p-4",children:[t&&r.jsxs(X,{variant:"outline",className:"mb-4",onClick:t,children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create New Script"]}),r.jsx(To,{className:"flex-1 max-h-[50vh]",children:S?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):I.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(rg,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),r.jsx("p",{children:"No saved scripts"}),r.jsx("p",{className:"text-sm mt-1",children:"Save LevelUp scripts or create your own"})]}):r.jsx("div",{className:"space-y-2",children:I.map($=>r.jsxs(ze,{className:Vt("cursor-pointer hover:bg-accent/50 transition-colors",s===$.id&&"ring-2 ring-primary"),onClick:()=>R($),children:[r.jsx(Wt,{className:"p-3",children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(Zt,{className:"text-sm font-medium truncate",children:$.title}),r.jsx("div",{className:"flex items-center gap-2 mt-1",children:$.is_custom?r.jsx(_t,{variant:"outline",className:"text-xs",children:"Custom"}):r.jsx(_t,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),r.jsx(Zi,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),r.jsx(qe,{className:"p-3 pt-0",children:r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:$.script_text})})]},$.id))})})]})]})]})}function gar({selectedTemplate:e,onSelect:t,contactName:s,saving:n=!1}){const[a,o]=A.useState(()=>{const i=K4(e);return new Set([i.category])}),l=i=>{o(d=>{const m=new Set(d);return m.has(i)?m.delete(i):m.add(i),m})};return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Share Page Template"}),n&&r.jsx($r,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),r.jsx("div",{className:"space-y-3",children:Q_t.map(i=>{const d=J_t(i.id),m=a.has(i.id),p=d.some(g=>g.id===e);return r.jsxs(Ek,{open:m,onOpenChange:()=>l(i.id),children:[r.jsxs(Ik,{className:"flex items-center justify-between w-full p-2.5 rounded-lg bg-muted/50 hover:bg-muted transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-medium text-sm",children:i.name}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",d.length,")"]}),p&&!m&&r.jsx("span",{className:"text-xs bg-primary/10 text-primary px-1.5 py-0.5 rounded-full",children:"✓"})]}),r.jsx(ad,{className:Vt("h-4 w-4 text-muted-foreground transition-transform",m&&"rotate-180")})]}),r.jsx(Pk,{className:"pt-2",children:r.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:d.map(g=>{const v=e===g.id;return r.jsxs("button",{type:"button",onClick:()=>t(g.id),disabled:n,className:Vt("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&&r.jsx("div",{className:"absolute top-1 right-1 w-4 h-4 rounded-full bg-primary flex items-center justify-center",children:r.jsx(mi,{className:"h-2.5 w-2.5 text-primary-foreground"})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"opacity-70 shrink-0",children:g.icon}),r.jsx("span",{className:"text-sm font-medium truncate",children:g.name})]})]},g.id)})})})]},i.id)})}),s&&e!=="default"&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:['Will show: "',K4(e).headerText(s),'"']})]})}function dZe({open:e,onOpenChange:t,video:s,contactName:n,onTemplateUpdated:a}){const[o,l]=A.useState(s.page_template||"default"),[i,d]=A.useState(!1),[m,p]=A.useState(!1),[g,v]=A.useState(s.page_template||"default"),[_,k]=A.useState([]),[w,S]=A.useState(s.contact_id&&n?{id:s.contact_id,name:n,email:null}:null),[T,C]=A.useState(!1),[I,R]=A.useState(!1),D=s.share_token?`https://video.relevelup.com/${s.share_token}`:"";A.useEffect(()=>{e&&_.length===0&&B()},[e]);const B=async()=>{R(!0);try{const{data:pe,error:ie}=await Y.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ie)throw ie;const de=(pe||[]).map(ce=>({id:ce.id,name:[ce.first_name,ce.last_name].filter(Boolean).join(" ")||"Unnamed",email:ce.email||null}));k(de)}catch(pe){console.error("Failed to fetch contacts:",pe)}finally{R(!1)}},$=async pe=>{S(pe),C(!1),d(!0);try{const{error:ie}=await Y.from("agent_videos").update({contact_id:(pe==null?void 0:pe.id)||null,recipient_name:(pe==null?void 0:pe.name)||null}).eq("id",s.id);if(ie)throw ie;we.success(pe?`Assigned to ${pe.name}`:"Contact removed"),a==null||a()}catch(ie){console.error("Failed to update contact:",ie),we.error("Failed to update contact")}finally{d(!1)}},q=async pe=>{l(pe),d(!0);try{const{error:ie}=await Y.from("agent_videos").update({page_template:pe}).eq("id",s.id);if(ie)throw ie;v(pe),we.success("Template saved!"),a==null||a()}catch(ie){console.error("Failed to save template:",ie),we.error("Failed to save template"),l(g)}finally{d(!1)}},W=(w==null?void 0:w.name)||null,K=()=>{const pe=s.title||"Video Message",ie=s.share_token?`https://video.relevelup.com/thumb/${s.share_token}`:s.thumbnail_url||"";return``},re=async()=>{if(!s.thumbnail_url){we.error("Video thumbnail not available yet");return}const pe=K(),ie=`Watch: ${s.title||"Video Message"} ${D}`;try{const de=new Blob([pe],{type:"text/html"}),ce=new Blob([ie],{type:"text/plain"}),ge=new ClipboardItem({"text/html":de,"text/plain":ce});await navigator.clipboard.write([ge]),we.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ie+` `+pe),we.success("Copied! Paste into your email.")}},ae=async()=>{await navigator.clipboard.writeText(D),p(!0),we.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},oe=()=>{const ie=K4(o).headerText(W),de=o==="default"?`Check out this video: ${D}`:`${ie} Check out this special video: ${D}`;window.open(`sms:?body=${encodeURIComponent(de)}`,"_self")},se=()=>{const pe=K4(o),ie=pe.headerText(W),de=o==="default"?s.title||"Video Message":ie,ce=`${pe.subText} Watch the video: ${D}`,ge=w!=null&&w.email?encodeURIComponent(w.email):"";window.open(`mailto:${ge}?subject=${encodeURIComponent(de)}&body=${encodeURIComponent(ce)}`,"_self")};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Lo,{className:"h-5 w-5"}),"Share Video"]}),r.jsx(Zs,{children:"Choose a themed page template and share your video"})]}),r.jsxs("div",{className:"space-y-6 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(cd,{open:T,onOpenChange:C,children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",role:"combobox","aria-expanded":T,className:"flex-1 justify-between",disabled:i,children:[w?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"}),w.name]}):r.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),r.jsx(Ry,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),r.jsx(Hc,{className:"w-[300px] p-0",align:"start",children:r.jsxs(a0,{children:[r.jsx(i0,{placeholder:"Search contacts..."}),r.jsxs(o0,{children:[r.jsx(l0,{children:I?"Loading...":"No contacts found."}),r.jsx(c0,{children:_.map(pe=>r.jsxs(d0,{value:pe.name,onSelect:()=>$(pe),children:[r.jsx(mi,{className:Vt("mr-2 h-4 w-4",(w==null?void 0:w.id)===pe.id?"opacity-100":"opacity-0")}),pe.name]},pe.id))})]})]})})]}),w&&r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>$(null),disabled:i,className:"shrink-0",children:r.jsx(Xs,{className:"h-4 w-4"})})]}),w&&o!=="default"&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',K4(o).headerText(w.name),'"']})]}),r.jsx(gar,{selectedTemplate:o,onSelect:q,contactName:W,saving:i}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Share Link"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:D,readOnly:!0,className:"font-mono text-sm"}),r.jsx(X,{onClick:ae,variant:m?"default":"outline",className:"shrink-0 gap-2",children:m?r.jsxs(r.Fragment,{children:[r.jsx(mi,{className:"h-4 w-4"}),"Copied"]}):r.jsxs(r.Fragment,{children:[r.jsx(uo,{className:"h-4 w-4"}),"Copy"]})})]})]}),s.thumbnail_url&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Share for Email"}),r.jsxs(X,{variant:"outline",className:"w-full gap-2",onClick:re,children:[r.jsx(Nl,{className:"h-4 w-4"}),"Copy with Thumbnail (for Gmail)"]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Paste into Gmail to embed a clickable video thumbnail"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Quick Share"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{variant:"outline",className:"flex-1 gap-2",onClick:oe,children:[r.jsx(Vo,{className:"h-4 w-4"}),"Text"]}),r.jsxs(X,{variant:"outline",className:"flex-1 gap-2",onClick:se,children:[r.jsx(Vs,{className:"h-4 w-4"}),"Email"]})]})]})]}),r.jsx(Rn,{children:r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Done"})})]})})}function xar(){var rt;const e=Ks(),[t]=Cc(),{toast:s}=_i(),n=t.get("contact_id"),a=t.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:d}=lHe(),{data:m}=Xf(),p=q3(),g=e6t(),[v,_]=A.useState("record"),[k,w]=A.useState(""),[S,T]=A.useState(!1),[C,I]=A.useState(!1),[R,D]=A.useState(!1),[B,$]=A.useState(null),[q,W]=A.useState(0),[K,re]=A.useState(0),[ae,oe]=A.useState(null),[se,pe]=A.useState(null),[ie,de]=A.useState(n||""),[ce,ge]=A.useState(""),[Te,_e]=A.useState(""),[ve,Me]=A.useState(null),[Ze,Ae]=A.useState(null),[Le,Ue]=A.useState(null),[Ve,Ie]=A.useState(!1),We=A.useCallback(async(je,it)=>{$(je),_("uploading");try{const{videoId:Se,uploadUrl:et}=await boe(ce||"Quick Video Touch");oe(Se);const{apiKey:Qe}=await woe(Se),He=new XMLHttpRequest;He.upload.onprogress=ct=>{ct.lengthComputable&&W(ct.loaded/ct.total*100)},await new Promise((ct,Tt)=>{He.onload=()=>{He.status>=200&&He.status<300?ct():Tt(new Error(`Upload failed: ${He.status}`))},He.onerror=()=>Tt(new Error("Upload failed")),He.open("PUT",et),He.setRequestHeader("AccessKey",Qe),He.send(je)}),_("processing");let ot=0;const ut=Date.now(),ft=90*1e3;for(;ot<4;){if(await new Promise(Tt=>setTimeout(Tt,3e3)),Date.now()-ut>ft){const Tt=je.size/1048576,Ot=`https://iframe.mediadelivery.net/play/${Se}/${Se}`;await p.mutateAsync({bunny_video_id:Se,playback_url:Ot,file_size_mb:Tt,title:ce||"Quick Video Touch",notes:Te||void 0,contact_id:ie&&ie!=="none"?ie:void 0,status:"processing",touch_type:"video_touch"}),s({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}),e("/mission-control/video-library");return}const ct=await jne(Se);if(ot=ct.status,re(ct.encodeProgress||0),ot===4)pe({playbackUrl:ct.directPlayUrl,thumbnailUrl:ct.thumbnailUrl,previewUrl:ct.previewUrl||null,duration:ct.length||it,fileSizeMb:(ct.storageSize||je.size)/(1024*1024)});else if(ot===5||ot===6)throw new Error("Video processing failed")}_("details")}catch(Se){console.error("Upload error:",Se),s({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),_("record")}},[ce,s]),wt=async()=>{if(!(!ae||!se))try{const je=ie&&ie!=="none"?ie:null,it=await p.mutateAsync({bunny_video_id:ae,contact_id:je,playback_url:se.playbackUrl,thumbnail_url:se.thumbnailUrl,preview_url:se.previewUrl,duration_seconds:se.duration,file_size_mb:se.fileSizeMb,title:ce||"Quick Video Touch",notes:Te,task_id:a||null,status:"ready"});Me(it.id),Ae(it.share_token||null),je&&await g.mutateAsync({contactId:je,videoId:it.id,notes:Te}),s({title:"Video saved successfully!"}),_("share")}catch(je){console.error("Save video error:",je),s({title:"Failed to save video",description:(je==null?void 0:je.message)||"Please try again.",variant:"destructive"})}},Pe=(je,it)=>{navigator.clipboard.writeText(it),Ue(je),setTimeout(()=>Ue(null),2e3),s({title:"Copied to clipboard!"})},st=()=>Ze?`https://video.relevelup.com/${Ze}`:(se==null?void 0:se.playbackUrl)||"",ue=()=>{const je=m==null?void 0:m.find(He=>He.id===ie),it=je?`${je.first_name}`:"",Se=(je==null?void 0:je.phone)||"",et=(je==null?void 0:je.email)||"",Qe=st();return{text:`Hey${it?` ${it}`:""}! I recorded a quick video for you: ${Qe}`,link:Qe,contactPhone:Se,contactEmail:et}},$e=()=>{const{text:je,contactPhone:it}=ue(),Se=it?`sms:${it}?body=${encodeURIComponent(je)}`:`sms:?body=${encodeURIComponent(je)}`;window.open(Se,"_self")},tt=()=>{const{link:je,contactEmail:it}=ue(),Se="Check out this video",et=`I recorded a quick video for you: ${je}`,Qe=it?`mailto:${it}?subject=${encodeURIComponent(Se)}&body=${encodeURIComponent(et)}`:`mailto:?subject=${encodeURIComponent(Se)}&body=${encodeURIComponent(et)}`;window.open(Qe,"_self")};return o?r.jsx(Ur,{title:"Quick Video Touch",children:r.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>e(-1),children:r.jsx(gi,{className:"h-5 w-5"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Quick Video Touch"}),r.jsx("p",{className:"text-muted-foreground",children:"Record a personal video message"})]})]}),d&&r.jsxs("div",{className:"text-right",children:[r.jsxs("p",{className:"text-sm text-warning",children:["Storage: ",i.toFixed(0),"% used"]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.toFixed(0)," MB remaining"]})]})]}),v==="record"&&r.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[r.jsxs("div",{className:"lg:col-span-2",children:[r.jsx(zbe,{maxDurationSeconds:60,onRecordingComplete:We,onRecordingStateChange:D,className:"w-full",teleprompterContent:S&&k&&r.jsx(cZe,{text:k,isVisible:S,onToggleVisibility:()=>T(!1),isRecording:R,startCountdown:!0})}),!S&&k&&r.jsxs(X,{variant:"outline",className:"mt-4",onClick:()=>T(!0),children:[r.jsx(ya,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),r.jsxs(ze,{className:"lg:col-span-1",children:[r.jsx(Wt,{className:"pb-2",children:r.jsx(Zt,{className:"text-lg",children:"Teleprompter Script"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsx(qs,{placeholder:"Type or paste your script here...",value:k,onChange:je=>w(je.target.value),rows:6}),r.jsxs(Nie,{open:C,onOpenChange:I,children:[r.jsx(Bve,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:"w-full",children:[r.jsx(ya,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),r.jsxs(M6,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[r.jsx(Sie,{className:"p-4 border-b",children:r.jsx(Cie,{children:"Select a Script"})}),r.jsx(par,{onSelectScript:je=>{w(je.text),I(!1),T(!0)},className:"h-[calc(100vh-80px)]"})]})]}),k&&r.jsx(X,{className:"w-full",onClick:()=>T(!0),children:"Use Script"})]})]})]}),v==="uploading"&&r.jsx(ze,{className:"max-w-md mx-auto",children:r.jsxs(qe,{className:"pt-6 text-center",children:[r.jsx(Xi,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-pulse"}),r.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Uploading Video..."}),r.jsx(zl,{value:q,className:"mb-2"}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:[q.toFixed(0),"%"]})]})}),v==="processing"&&r.jsx(ze,{className:"max-w-md mx-auto",children:r.jsxs(qe,{className:"pt-6 text-center space-y-4",children:[r.jsx($r,{className:"h-12 w-12 mx-auto mb-4 text-primary animate-spin"}),r.jsx("h2",{className:"text-lg font-semibold mb-2",children:"Processing Video..."}),r.jsx(zl,{value:K,className:"mb-2"}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:[K.toFixed(0),"%"]}),r.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"&&r.jsxs(ze,{className:"max-w-lg mx-auto",children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Video Details"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Title"}),r.jsx(Ye,{value:ce,onChange:je=>ge(je.target.value),placeholder:"Quick Video Touch"})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Attach to Contact (Optional)"}),r.jsxs(ds,{value:ie,onValueChange:de,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"No contact - use anywhere"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[r.jsx(Lo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),m==null?void 0:m.map(je=>r.jsx(Ut,{value:je.id,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Fl,{className:"h-4 w-4"}),je.first_name," ",je.last_name]})},je.id))]})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Notes"}),r.jsx(qs,{value:Te,onChange:je=>_e(je.target.value),placeholder:"Add notes about this video...",rows:3})]}),r.jsxs(X,{className:"w-full",onClick:wt,disabled:p.isPending,children:[p.isPending&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),v==="share"&&r.jsxs(ze,{className:"max-w-lg mx-auto",children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(mi,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsx("p",{className:"text-muted-foreground",children:"Share your video with one click:"}),r.jsxs("div",{className:"grid gap-3",children:[r.jsxs(X,{variant:"outline",className:"justify-start",onClick:$e,children:[r.jsx(Vo,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),r.jsxs(X,{variant:"outline",className:"justify-start",onClick:tt,children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),r.jsxs(X,{variant:"outline",className:"justify-start",onClick:()=>Pe("link",ue().link),children:[r.jsx(Lo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Le==="link"&&r.jsx(mi,{className:"h-4 w-4 ml-auto text-green-500"})]}),r.jsxs(X,{variant:"outline",className:"justify-start",onClick:()=>Ie(!0),children:[r.jsx(id,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]})]}),r.jsxs("div",{className:"flex gap-3 pt-4",children:[r.jsx(X,{variant:"outline",onClick:()=>e("/mission-control/video-library"),children:"View Library"}),r.jsx(X,{onClick:()=>{_("record"),$(null),oe(null),pe(null)},children:"Record Another"})]})]})]}),ve&&Ze&&r.jsx(dZe,{open:Ve,onOpenChange:Ie,video:{id:ve,share_token:Ze,title:ce||null,contact_id:ie||null,thumbnail_url:(se==null?void 0:se.thumbnailUrl)||null},contactName:((rt=m==null?void 0:m.find(je=>je.id===ie))==null?void 0:rt.first_name)||null})]})}):r.jsx(Ur,{title:"Quick Video Touch",children:r.jsxs("div",{className:"max-w-2xl mx-auto text-center py-12",children:[r.jsx(ch,{className:"h-16 w-16 text-destructive mx-auto mb-4"}),r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Storage Limit Reached"}),r.jsx("p",{className:"text-muted-foreground mb-6",children:"You've reached your video storage limit. Delete videos from your library to record more."}),r.jsx(X,{onClick:()=>e("/mission-control/video-library"),children:"Open Video Library"})]})})}function yar({open:e,onOpenChange:t}){const{data:s}=Xf(),{data:n}=_oe(),a=q3(),o=A.useRef(null),[l,i]=A.useState(null),[d,m]=A.useState(""),[p,g]=A.useState(""),[v,_]=A.useState(""),[k,w]=A.useState(!1),[S,T]=A.useState(0),[C,I]=A.useState("idle"),R=(n==null?void 0:n.total_storage_mb)||0,B=((n==null?void 0:n.max_storage_mb)||1024)-R,$=re=>{var se;const ae=(se=re.target.files)==null?void 0:se[0];if(!ae)return;if(!ae.type.startsWith("video/")){we.error("Please select a video file");return}const oe=ae.size/(1024*1024);if(oe>500){we.error("Video file must be less than 500MB");return}if(oe>B){we.error(`Not enough storage. You have ${B.toFixed(1)} MB remaining.`);return}i(ae),d||m(ae.name.replace(/\.[^/.]+$/,""))},q=async()=>{if(!l){we.error("Please select a video file");return}w(!0),T(0),I("creating");try{const{data:re,error:ae}=await Y.functions.invoke("bunny-upload",{body:{action:"create",title:d||l.name,isAgentVideo:!0}});if(ae)throw new Error(ae.message);const{videoId:oe,libraryId:se}=re;I("uploading");const{data:pe,error:ie}=await Y.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:oe,isAgentVideo:!0}});if(ie)throw new Error(ie.message);await new Promise((ge,Te)=>{const _e=new XMLHttpRequest;_e.upload.addEventListener("progress",ve=>{if(ve.lengthComputable){const Me=Math.round(ve.loaded/ve.total*100);T(Me)}}),_e.addEventListener("load",()=>{_e.status>=200&&_e.status<300?ge():Te(new Error(`Upload failed with status ${_e.status}`))}),_e.addEventListener("error",()=>Te(new Error("Upload failed"))),_e.open("PUT",pe.uploadUrl),_e.setRequestHeader("AccessKey",pe.apiKey),_e.send(l)}),I("processing");const de=l.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${se}/${oe}`;await a.mutateAsync({bunny_video_id:oe,playback_url:ce,file_size_mb:de,title:d||l.name,notes:p||void 0,contact_id:v||void 0,status:"processing",touch_type:"video_upload"}),we.success("Video uploaded successfully! Processing may take a few minutes."),W()}catch(re){console.error("Upload error:",re),we.error(re instanceof Error?re.message:"Failed to upload video")}finally{w(!1),I("idle")}},W=()=>{k||(i(null),m(""),g(""),_(""),T(0),I("idle"),t(!1))},K=()=>{switch(C){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${S}%`;case"processing":return"Saving video...";default:return""}};return r.jsx(Ir,{open:e,onOpenChange:W,children:r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Upload Video"}),r.jsx(Zs,{children:"Upload a video file from your device to your video library."})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Video File"}),l?r.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[r.jsx(ma,{className:"h-8 w-8 text-primary flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:l.name}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[(l.size/(1024*1024)).toFixed(1)," MB"]})]}),!k&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:re=>{re.stopPropagation(),i(null)},children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.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 re;return(re=o.current)==null?void 0:re.click()},children:[r.jsx(Xi,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),r.jsx("input",{ref:o,type:"file",accept:"video/*",className:"hidden",onChange:$,disabled:k})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"title",children:"Title"}),r.jsx(Ye,{id:"title",value:d,onChange:re=>m(re.target.value),placeholder:"Enter video title",disabled:k})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Associate with Contact (optional)"}),r.jsxs(ds,{value:v||"__none__",onValueChange:re=>_(re==="__none__"?"":re),disabled:k,children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a contact"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"__none__",children:"No contact"}),s==null?void 0:s.map(re=>r.jsxs(Ut,{value:re.id,children:[re.first_name," ",re.last_name||""]},re.id))]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"notes",children:"Notes (optional)"}),r.jsx(qs,{id:"notes",value:p,onChange:re=>g(re.target.value),placeholder:"Add any notes about this video",rows:2,disabled:k})]}),k&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{children:K()})]}),r.jsx(zl,{value:C==="uploading"?S:C==="processing"?100:10})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:W,disabled:k,children:"Cancel"}),r.jsx(X,{onClick:q,disabled:!l||k,children:k?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function _ar({open:e,onOpenChange:t,video:s,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=A.useState([]),[d,m]=A.useState(null),[p,g]=A.useState(!1),[v,_]=A.useState(!1),[k,w]=A.useState(""),[S,T]=A.useState(""),[C,I]=A.useState(""),[R,D]=A.useState(!1),B=s.share_token?`https://video.relevelup.com/${s.share_token}`:"",$=s.share_token?`https://video.relevelup.com/thumb/${s.share_token}`:a||s.thumbnail_url||"",q=s.title||"Video Message";A.useEffect(()=>{e&&l.length===0&&W()},[e]),A.useEffect(()=>{if(e&&(T(`I recorded a video for you — ${q}`),I("Hey! I recorded a quick video just for you. Click below to watch it:"),m(null),w(""),s.contact_id)){const pe=l.find(ie=>ie.id===s.contact_id);pe&&(m(pe),w(pe.email||""))}},[e,s.contact_id,l]);const W=async()=>{_(!0);try{const{data:pe,error:ie}=await Y.from("innercircle_contacts").select("id, first_name, last_name, email").order("first_name",{ascending:!0}).limit(500);if(ie)throw ie;i(pe||[])}catch{console.error("Failed to fetch contacts")}finally{_(!1)}},K=pe=>{m(pe),g(!1),w(pe.email||""),I(`Hey ${pe.first_name}! I recorded a quick video just for you. Click below to watch it:`),T(`I recorded a video for you — ${q}`)},re=()=>{m(null),w(""),I("Hey! I recorded a quick video just for you. Click below to watch it:")},ae=pe=>`${pe.first_name} ${pe.last_name||""}`.trim(),oe=()=>`
${C.split(/\n\n+/).map(ie=>`

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

`).join("")}

▶ Watch Video

`,se=async()=>{if(!k){we.error("Please enter a recipient email");return}if(!B){we.error("Video does not have a share link");return}D(!0);try{const pe=oe(),{data:ie,error:de}=await Y.functions.invoke("gmail-send",{body:{to:k,subject:S,body:pe,contactId:(d==null?void 0:d.id)||null}});if(de)throw de;if(!(ie!=null&&ie.success))throw new Error((ie==null?void 0:ie.error)||"Failed to send");we.success("Video email sent!"),t(!1),o==null||o()}catch(pe){console.error("Gmail send error:",pe),we.error("Failed to send: "+(pe instanceof Error?pe.message:"Unknown error"))}finally{D(!1)}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-[560px] max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Vs,{className:"h-5 w-5 text-red-500"}),"Send Video via Gmail"]}),n&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Sending from ",r.jsx("span",{className:"font-medium",children:n})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Send to Contact"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(cd,{open:p,onOpenChange:g,children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",role:"combobox",className:"flex-1 justify-between",children:[d?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"}),ae(d),d.email&&r.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",d.email,")"]})]}):r.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),r.jsx(Ry,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),r.jsx(Hc,{className:"w-[350px] p-0",align:"start",children:r.jsxs(a0,{children:[r.jsx(i0,{placeholder:"Search contacts..."}),r.jsxs(o0,{children:[r.jsx(l0,{children:v?"Loading...":"No contacts found."}),r.jsx(c0,{children:l.filter(pe=>pe.email).map(pe=>r.jsxs(d0,{value:`${pe.first_name} ${pe.last_name||""} ${pe.email||""}`,onSelect:()=>K(pe),children:[r.jsx(mi,{className:Vt("mr-2 h-4 w-4",(d==null?void 0:d.id)===pe.id?"opacity-100":"opacity-0")}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:ae(pe)}),r.jsx("div",{className:"text-xs text-muted-foreground",children:pe.email})]})]},pe.id))})]})]})})]}),d&&r.jsx(X,{variant:"ghost",size:"icon",onClick:re,className:"shrink-0",children:r.jsx(Xs,{className:"h-4 w-4"})})]})]}),!d&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"video-to",children:"Or type email address"}),r.jsx(Ye,{id:"video-to",value:k,onChange:pe=>w(pe.target.value),placeholder:"recipient@example.com",type:"email"})]}),r.jsx(kd,{}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"video-subject",children:"Subject"}),r.jsx(Ye,{id:"video-subject",value:S,onChange:pe=>T(pe.target.value)})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{htmlFor:"video-message",children:"Personal Message"}),r.jsx(qs,{id:"video-message",value:C,onChange:pe=>I(pe.target.value),rows:4,className:"resize-y"})]}),r.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 space-y-2",children:[r.jsx(Ee,{className:"text-xs text-muted-foreground",children:"Video Preview (embedded in email)"}),r.jsxs("div",{className:"relative rounded-lg overflow-hidden bg-black",style:{maxWidth:320},children:[$?r.jsx("img",{src:$,alt:q,className:"w-full aspect-video object-cover"}):r.jsx("div",{className:"w-full aspect-video flex items-center justify-center bg-muted",children:r.jsx(tc,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:r.jsx("div",{className:"w-10 h-10 rounded-full bg-white/80 flex items-center justify-center shadow",children:r.jsx(tc,{className:"h-5 w-5 text-primary ml-0.5"})})})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Recipients will see the thumbnail with a play button. Clicking opens the video page."})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),disabled:R,children:"Cancel"}),r.jsxs(X,{onClick:se,disabled:R||!k||!S,className:"gap-2",children:[R?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(ai,{className:"h-4 w-4"}),R?"Sending...":"Send Video Email"]})]})]})]})})}const bar=()=>{const{user:e}=Gr();return Ht({queryKey:["team-videos",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.rpc("get_team_videos",{_user_id:e.id});if(s)throw s;return t||[]},enabled:!!e})};function war({previewSrc:e,thumbnailSrc:t,alt:s,isHovered:n}){const[a,o]=A.useState(!1),[l,i]=A.useState(!1),d=n&&e&&!a,m=t&&!l;return!m&&!d?r.jsx("div",{className:"w-full h-full flex items-center justify-center absolute inset-0 bg-muted",children:r.jsx(ma,{className:"h-12 w-12 text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[m&&r.jsx("img",{src:t,alt:s,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&&r.jsx("img",{src:e,alt:s,className:"w-full h-full object-cover absolute inset-0",onError:()=>o(!0)})]})}function jar({video:e,previewSrc:t,thumbnailSrc:s,onOpen:n,onDelete:a,onRename:o,onNavigateToContact:l,onGetEmbedCode:i,onCopyEmailHtml:d,onEmbedToCrm:m,onShareWithTemplate:p,onSendViaGmail:g,isGmailConnected:v,getContactName:_,getShareUrl:k,copyToClipboard:w,formatDuration:S}){const[T,C]=A.useState(!1);return r.jsxs(ze,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[r.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[r.jsx(war,{previewSrc:t,thumbnailSrc:s,alt:e.title||"Video preview",isHovered:T}),r.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity",children:r.jsx("div",{className:"w-12 h-12 rounded-full bg-white/90 flex items-center justify-center",children:r.jsx(tc,{className:"h-6 w-6 text-primary ml-1"})})}),r.jsx("div",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:S(e.duration_seconds)}),e.status!=="ready"&&r.jsx(_t,{variant:e.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:e.status})]}),r.jsx(qe,{className:"p-3",children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("h3",{className:"font-medium truncate",children:e.title||"Untitled Video"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[r.jsx(Fl,{className:"h-3 w-3"}),r.jsx("span",{className:"truncate",children:_(e.contact_id)})]}),r.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),r.jsx("span",{children:Xr(new Date(e.created_at),"MMM d, yyyy")})]}),(e.view_count??0)>0&&r.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[r.jsx(Ii,{className:"h-3 w-3"}),r.jsxs("span",{children:[e.view_count," ",e.view_count===1?"view":"views"]})]})]}),v&&e.share_token&&r.jsxs(X,{variant:"outline",size:"sm",className:"mt-2 gap-1.5 text-xs h-7",onClick:I=>{I.stopPropagation(),g==null||g()},children:[r.jsx(Vs,{className:"h-3 w-3"}),"Send via Gmail"]}),r.jsx("h3",{className:"font-medium truncate",children:e.title||"Untitled Video"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-1",children:[r.jsx(Fl,{className:"h-3 w-3"}),r.jsx("span",{className:"truncate",children:_(e.contact_id)})]}),r.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground mt-0.5",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),r.jsx("span",{children:Xr(new Date(e.created_at),"MMM d, yyyy")})]}),(e.view_count??0)>0&&r.jsxs("div",{className:"flex items-center gap-1 text-primary",children:[r.jsx(Ii,{className:"h-3 w-3"}),r.jsxs("span",{children:[e.view_count," ",e.view_count===1?"view":"views"]})]})]})]}),r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>I.stopPropagation(),children:r.jsx(Qg,{className:"h-4 w-4"})})}),r.jsxs(vu,{align:"end",className:"bg-popover",children:[r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),n()},children:[r.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Watch"]}),r.jsx(Yk,{}),r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),p()},children:[r.jsx(id,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),w(k(e),"Share link")},children:[r.jsx(Lo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),i()},children:[r.jsx(pk,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),d()},children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),m()},children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),v&&e.share_token&&r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),g==null||g()},children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),o()},children:[r.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Rename"]}),r.jsx(Yk,{}),e.contact_id&&r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),l()},children:[r.jsx(Fl,{className:"h-4 w-4 mr-2"}),"View Contact"]}),r.jsxs(Ba,{onClick:I=>{I.stopPropagation(),a()},className:"text-destructive",children:[r.jsx(Os,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function kar(){var ct,Tt;const e=Ks(),{data:t,isLoading:s,refetch:n}=YPt(),{data:a}=_oe(),{data:o}=Xf(),l=JPt(),i=QPt(),{isGmailConnected:d,gmailEmail:m}=kN(),{data:p}=o_(),{data:g=[],isLoading:v}=bar(),[_,k]=A.useState("my"),[w,S]=A.useState(""),[T,C]=A.useState(null),[I,R]=A.useState(!1),[D,B]=A.useState(!1),[$,q]=A.useState(!1),[W,K]=A.useState(!1),[re,ae]=A.useState(!1),[oe,se]=A.useState(""),[pe,ie]=A.useState(!1),[de,ce]=A.useState(!1),[ge,Te]=A.useState(!1),[_e,ve]=A.useState(!1),[Me,Ze]=A.useState(""),[Ae,Le]=A.useState({}),Ue=Ot=>{if(!Ot)return"Unassigned";const rr=o==null?void 0:o.find(Lr=>Lr.id===Ot);return rr?`${rr.first_name} ${rr.last_name||""}`.trim():"Unknown"},Ve=Ot=>{if(!Ot)return"0:00";const rr=Math.floor(Ot/60),Lr=Ot%60;return`${rr}:${Lr.toString().padStart(2,"0")}`},Ie=t==null?void 0:t.filter(Ot=>{if(!w)return!0;const rr=Ue(Ot.contact_id).toLowerCase(),Lr=(Ot.title||"").toLowerCase(),cr=(Ot.notes||"").toLowerCase();return rr.includes(w.toLowerCase())||Lr.includes(w.toLowerCase())||cr.includes(w.toLowerCase())}),[We,wt]=A.useState(!1);A.useEffect(()=>{if(We)return;(async()=>{if(!(t!=null&&t.length))return;const rr=t.filter(cr=>cr.status==="processing"&&cr.bunny_video_id);if(!rr.length)return;let Lr=!1;for(const cr of rr)try{const{data:Mr,error:As}=await Y.functions.invoke("bunny-upload",{body:{action:"status",videoId:cr.bunny_video_id,isAgentVideo:!0}});if(As||!Mr)continue;Mr.status===4&&(await Y.from("agent_videos").update({status:"ready",playback_url:Mr.directPlayUrl,thumbnail_url:Mr.thumbnailUrl,preview_url:Mr.previewUrl,duration_seconds:Mr.length||cr.duration_seconds,updated_at:new Date().toISOString()}).eq("id",cr.id),Lr=!0)}catch(Mr){console.warn("Reconcile check failed for video",cr.id,Mr)}wt(!0),Lr&&n()})()},[t,We,n]),A.useEffect(()=>{(async()=>{if(!(t!=null&&t.length))return;const rr=t.filter(Et=>(Et==null?void 0:Et.bunny_video_id)&&!Ae[Et.id]);if(!rr.length)return;const Lr=rr.map(Et=>Et.bunny_video_id),{data:cr,error:Mr}=await Y.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Lr,isAgentVideo:!0}});if(Mr)throw Mr;const As=(cr==null?void 0:cr.assets)||{};Le(Et=>{const Pt={...Et};for(const Sr of rr)As[Sr.bunny_video_id]&&(Pt[Sr.id]={previewUrl:As[Sr.bunny_video_id].previewUrl,thumbnailUrl:As[Sr.bunny_video_id].thumbnailUrl});return Pt})})().catch(rr=>console.warn("Failed to load signed Bunny asset URLs",rr))},[t,Ae]);const Pe=(a==null?void 0:a.total_storage_mb)||0,st=(a==null?void 0:a.max_storage_mb)||1024,ue=Pe/st*100,$e=ue>=80,tt=ue>=100,rt=async(Ot,rr)=>{await navigator.clipboard.writeText(Ot),we.success(`${rr} copied to clipboard`)},je=Ot=>Ot.share_token?`https://video.relevelup.com/${Ot.share_token}`:Ot.playback_url||"",it=Ot=>{const rr=je(Ot),Lr=o==null?void 0:o.find(Sr=>Sr.id===Ot.contact_id),cr=Ue(Ot.contact_id),Mr=cr!=="Unassigned"?cr.split(" ")[0]:"",As=(Lr==null?void 0:Lr.phone)||"",Et=`Hey${Mr?` ${Mr}`:""}! I recorded a quick video message for you. Check it out: ${rr}`,Pt=As?`sms:${As}?body=${encodeURIComponent(Et)}`:`sms:?body=${encodeURIComponent(Et)}`;window.open(Pt,"_self")},Se=Ot=>{const rr=o==null?void 0:o.find(Pt=>Pt.id===Ot.contact_id),Lr=(rr==null?void 0:rr.email)||"",cr=je(Ot),Mr="Check out this video",As=`I recorded a quick video for you: ${cr}`,Et=Lr?`mailto:${Lr}?subject=${encodeURIComponent(Mr)}&body=${encodeURIComponent(As)}`:`mailto:?subject=${encodeURIComponent(Mr)}&body=${encodeURIComponent(As)}`;window.open(Et,"_self")},et=Ot=>{var Mr;const rr=je(Ot),Lr=Ot.title||"Video Message",cr=Ot.share_token?`https://video.relevelup.com/thumb/${Ot.share_token}`:((Mr=Ae[Ot.id])==null?void 0:Mr.thumbnailUrl)||Ot.thumbnail_url||"";return``},Qe=async Ot=>{if(!Ot.thumbnail_url&&!Ot.share_token){we.error("Video thumbnail not available yet");return}const rr=et(Ot),Lr=je(Ot),cr=`Watch: ${Ot.title||"Video Message"} ${Lr}`;try{const Mr=new Blob([rr],{type:"text/html"}),As=new Blob([cr],{type:"text/plain"}),Et=new ClipboardItem({"text/html":Mr,"text/plain":As});await navigator.clipboard.write([Et]),we.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(cr+` `+rr),we.success("Copied! Paste into your email.")}},He=async Ot=>{try{we.loading("Preparing download...",{id:"download"});const{data:rr,error:Lr}=await Y.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Ot.bunny_video_id,isAgentVideo:!0}});if(Lr||!(rr!=null&&rr.downloadUrl))throw new Error((Lr==null?void 0:Lr.message)||"Failed to get download URL");const Mr=`${((Ot.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,As=await fetch(rr.downloadUrl);if(!As.ok)throw new Error("Failed to fetch video file");const Et=await As.blob(),Pt=URL.createObjectURL(Et),Sr=document.createElement("a");Sr.href=Pt,Sr.download=Mr,Sr.rel="noreferrer",document.body.appendChild(Sr),Sr.click(),Sr.remove(),URL.revokeObjectURL(Pt),we.success("Download started",{id:"download"})}catch(rr){console.error("Download error:",rr),we.error("Could not force download (your browser may block it).",{id:"download"})}},ot=async Ot=>{C(Ot),ie(!0),se(""),ae(!0);try{const{data:rr,error:Lr}=await Y.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Ot.bunny_video_id,title:Ot.title,isAgentVideo:!0,shareToken:Ot.share_token}});if(Lr||!(rr!=null&&rr.html))throw new Error("Failed to generate CRM embed code");se(rr.html)}catch(rr){console.error("CRM embed error:",rr),we.error("Failed to generate CRM embed code"),ae(!1)}finally{ie(!1)}},ut=Ot=>{C(Ot),R(!0)},ft=async()=>{if(T)try{await l.mutateAsync({id:T.id,bunnyVideoId:T.bunny_video_id,hardDelete:!0}),B(!1),C(null),we.success("Video deleted successfully")}catch{we.error("Failed to delete video")}};return r.jsx(Ur,{title:"Video Library",description:"Manage your video touches",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Video Library"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage and share your video touches"})]}),p&&((ct=p.team)==null?void 0:ct.shared_videos_enabled)&&r.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5 ml-2",children:[r.jsx("button",{onClick:()=>k("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"}),r.jsxs("button",{onClick:()=>k("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:[r.jsx(ws,{className:"h-3.5 w-3.5"}),"Team"]})]})]}),_==="my"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(X,{variant:"outline",onClick:()=>q(!0),children:[r.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Upload Video"]}),r.jsxs(X,{onClick:()=>e("/mission-control/video/record"),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Record New Video"]})]})]}),_==="team"?r.jsx(Nar,{videos:g,isLoading:v,searchTerm:w,setSearchTerm:S}):r.jsxs(r.Fragment,{children:[r.jsx(ze,{className:$e?"border-amber-500":tt?"border-destructive":"",children:r.jsxs(qe,{className:"py-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(gE,{className:`h-5 w-5 ${tt?"text-destructive":$e?"text-amber-500":"text-muted-foreground"}`}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-sm font-medium",children:"Storage Used"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:[Pe.toFixed(1)," MB / ",st>=1024?`${(st/1024).toFixed(0)} GB`:`${st} MB`]})]}),r.jsx(zl,{value:Math.min(ue,100),className:`h-2 ${tt?"[&>div]:bg-destructive":$e?"[&>div]:bg-amber-500":""}`})]}),$e&&!tt&&r.jsxs(_t,{variant:"outline",className:"border-amber-500 text-amber-600",children:[r.jsx(kl,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),tt&&r.jsxs(_t,{variant:"destructive",children:[r.jsx(kl,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),tt&&r.jsx("p",{className:"text-sm text-destructive mt-2",children:"You've reached your storage limit. Delete videos to record more."})]})}),r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search videos by contact, title, or notes...",value:w,onChange:Ot=>S(Ot.target.value),className:"pl-10"})]}),s?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):(Ie==null?void 0:Ie.length)===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(ma,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"font-semibold mb-2",children:"No videos yet"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Record your first video touch to get started"}),r.jsxs(X,{onClick:()=>e("/mission-control/video/record"),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Record Video"]})]})}):r.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Ie==null?void 0:Ie.map(Ot=>{var rr,Lr;return r.jsx(jar,{video:Ot,previewSrc:(rr=Ae[Ot.id])==null?void 0:rr.previewUrl,thumbnailSrc:(Lr=Ae[Ot.id])==null?void 0:Lr.thumbnailUrl,onOpen:()=>ut(Ot),onDelete:()=>{C(Ot),B(!0)},onRename:()=>{C(Ot),Ze(Ot.title||""),ve(!0)},onNavigateToContact:()=>e(`/mission-control/contacts/${Ot.contact_id}`),onGetEmbedCode:()=>{C(Ot),K(!0)},onCopyEmailHtml:()=>Qe(Ot),onEmbedToCrm:()=>ot(Ot),onShareWithTemplate:()=>{C(Ot),ce(!0)},onSendViaGmail:()=>{C(Ot),Te(!0)},isGmailConnected:d,getContactName:Ue,getShareUrl:je,copyToClipboard:rt,formatDuration:Ve},Ot.id)})}),r.jsx(Ir,{open:I,onOpenChange:R,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:(T==null?void 0:T.title)||"Video Preview"}),r.jsx(Zs,{children:(T==null?void 0:T.contact_id)&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Fl,{className:"h-3 w-3"}),Ue(T.contact_id)]})})]}),T&&r.jsxs("div",{className:"space-y-4",children:[T.status==="processing"?r.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:[r.jsx("div",{className:"relative",children:r.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:r.jsx($r,{className:"h-8 w-8 text-primary animate-spin"})})}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"font-semibold text-lg",children:"Video is still processing"}),r.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!"})]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>{R(!1),n()},children:[r.jsx(Yo,{className:"h-4 w-4 mr-2"}),"Refresh Library"]})]}):r.jsx("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:T.playback_url?(()=>{let Ot=T.playback_url;return Ot.includes("iframe.mediadelivery.net/play/")&&(Ot=Ot.replace("/play/","/embed/"),Ot+=(Ot.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Ot.includes("iframe.mediadelivery.net")?r.jsx("iframe",{src:Ot,title:T.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}):r.jsx("video",{src:T.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:T.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>we.error("Video preview failed to load")},T.playback_url)})():r.jsxs("div",{className:"absolute inset-0 flex items-center justify-center bg-muted rounded-lg",children:[r.jsx(ma,{className:"h-12 w-12 text-muted-foreground"}),r.jsx("p",{className:"text-muted-foreground ml-2",children:"Video not available"})]})}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs(X,{variant:"outline",onClick:()=>it(T),children:[r.jsx(Vo,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!d&&r.jsxs(X,{variant:"outline",onClick:()=>Se(T),children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),r.jsxs(X,{variant:"outline",onClick:()=>rt(je(T),"Share link"),children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),r.jsxs(X,{variant:"outline",onClick:()=>Qe(T),children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),r.jsxs(X,{variant:"outline",onClick:()=>He(T),children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Download Video"]}),r.jsxs(X,{variant:"outline",onClick:()=>{R(!1),ot(T)},children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),r.jsxs(X,{variant:"outline",onClick:()=>{R(!1),ce(!0)},children:[r.jsx(id,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),d&&(T==null?void 0:T.share_token)&&r.jsxs(X,{variant:"outline",onClick:()=>{R(!1),Te(!0)},children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]})]}),r.jsx("div",{className:"flex justify-end pt-2 border-t",children:r.jsxs(X,{variant:"destructive",onClick:()=>{R(!1),B(!0)},children:[r.jsx(Os,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),r.jsx(Ir,{open:D,onOpenChange:B,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Delete Video"}),r.jsx(Zs,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>B(!1),children:"Cancel"}),r.jsx(X,{variant:"destructive",onClick:ft,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),r.jsx(yar,{open:$,onOpenChange:q}),r.jsx(Ir,{open:W,onOpenChange:K,children:r.jsxs(Er,{className:"sm:max-w-lg",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Embed Video"}),r.jsx(Zs,{children:"Copy this code to embed the video on your website."})]}),T&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Embed Code"}),r.jsx(qs,{readOnly:!0,rows:5,value:``,className:"font-mono text-xs"})]}),r.jsx("div",{className:"flex gap-2",children:r.jsxs(X,{className:"flex-1",onClick:()=>{const Ot=``;rt(Ot,"Embed code")},children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Copy Embed Code"]})}),r.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."})]})]})}),T&&r.jsx(dZe,{open:de,onOpenChange:ce,video:T,contactName:Ue(T.contact_id)}),T&&r.jsx(_ar,{open:ge,onOpenChange:Te,video:T,gmailEmail:m,signedThumbnailUrl:(Tt=Ae[T.id])==null?void 0:Tt.thumbnailUrl}),r.jsx(Ir,{open:_e,onOpenChange:ve,children:r.jsxs(Er,{className:"max-w-sm",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Rename Video"}),r.jsx(Zs,{children:"Enter a new title for this video."})]}),r.jsx(Ye,{value:Me,onChange:Ot=>Ze(Ot.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Ot=>{Ot.key==="Enter"&&Me.trim()&&i.mutate({id:T.id,title:Me.trim()},{onSuccess:()=>{we.success("Video renamed"),ve(!1)}})}}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>ve(!1),children:"Cancel"}),r.jsx(X,{disabled:!Me.trim()||i.isPending,onClick:()=>{i.mutate({id:T.id,title:Me.trim()},{onSuccess:()=>{we.success("Video renamed"),ve(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),r.jsx(Ir,{open:re,onOpenChange:ae,children:r.jsxs(Er,{className:"sm:max-w-lg",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(jn,{className:"h-5 w-5"}),"Embed to CRM"]}),r.jsx(Zs,{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."})]}),pe?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx($r,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):oe?r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"CRM Email HTML"}),r.jsx(qs,{readOnly:!0,rows:12,value:oe,className:"font-mono text-xs"})]}),r.jsxs(X,{className:"w-full",onClick:()=>{rt(oe,"CRM embed code")},children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Copy CRM Embed Code"]}),r.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 Nar({videos:e,isLoading:t,searchTerm:s,setSearchTerm:n}){const a=A.useMemo(()=>{if(!s)return e;const i=s.toLowerCase();return e.filter(d=>(d.title||"").toLowerCase().includes(i)||(d.owner_name||"").toLowerCase().includes(i)||(d.recipient_name||"").toLowerCase().includes(i))},[e,s]),o=A.useMemo(()=>{const i=new Map;return a.forEach(d=>{const m=i.get(d.owner_user_id);m?m.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),m=i%60;return`${d}:${m.toString().padStart(2,"0")}`};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search team videos by title, owner, or recipient...",value:s,onChange:i=>n(i.target.value),className:"pl-10"})]}),t?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})}):a.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"py-12 text-center",children:[r.jsx(ws,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("h3",{className:"font-semibold mb-2",children:"No team videos"}),r.jsx("p",{className:"text-muted-foreground",children:e.length===0?"Your teammates haven't recorded any videos yet.":"No videos match your search."})]})}):r.jsx("div",{className:"space-y-6",children:o.map(([i,d])=>r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(cn,{className:"h-7 w-7",children:[r.jsx(xa,{src:d.avatar||""}),r.jsx(dn,{children:(d.name||"?").charAt(0).toUpperCase()})]}),r.jsx("h3",{className:"font-semibold text-sm",children:d.name}),r.jsx(_t,{variant:"secondary",className:"text-xs",children:d.videos.length})]}),r.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:d.videos.map(m=>r.jsxs(ze,{className:"overflow-hidden",children:[r.jsxs("div",{className:"relative aspect-video bg-muted flex items-center justify-center",children:[m.thumbnail_url?r.jsx("img",{src:m.thumbnail_url,alt:m.title||"Video",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:p=>{p.target.style.display="none"}}):r.jsx(ma,{className:"h-10 w-10 text-muted-foreground"}),m.duration_seconds&&r.jsx("span",{className:"absolute bottom-2 right-2 bg-black/70 text-white text-xs px-1.5 py-0.5 rounded",children:l(m.duration_seconds)})]}),r.jsxs(qe,{className:"p-3",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:m.title||"Untitled"}),r.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[m.recipient_name&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Fl,{className:"h-3 w-3"}),m.recipient_name]}),m.view_count!=null&&m.view_count>0&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ii,{className:"h-3 w-3"}),m.view_count]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),Xr(new Date(m.created_at),"MMM d")]})]})]})]},m.id))})]},i))})]})}const Sar=()=>{const{user:e}=Gr();return Ht({queryKey:["team-deals",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.rpc("get_team_deals",{_user_id:e.id});if(s)throw s;return t||[]},enabled:!!e})};function Car({open:e,onOpenChange:t}){const{data:s,isLoading:n}=Sar(),[a,o]=A.useState(""),[l,i]=A.useState("all"),d=A.useMemo(()=>{if(!s)return[];const v=new Map;return s.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())},[s]),m=A.useMemo(()=>{if(!s)return[];let v=s;if(l!=="all"&&(v=v.filter(_=>_.owner_user_id===l)),a.trim()){const _=a.toLowerCase();v=v.filter(k=>{var w,S,T,C;return k.deal_name.toLowerCase().includes(_)||((w=k.contact_name)==null?void 0:w.toLowerCase().includes(_))||((S=k.property_address)==null?void 0:S.toLowerCase().includes(_))||((T=k.city)==null?void 0:T.toLowerCase().includes(_))||((C=k.owner_name)==null?void 0:C.toLowerCase().includes(_))})}return v},[s,a,l]),p=A.useMemo(()=>{const v=new Map;return m.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())},[m]),g=v=>v?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(v):null;return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-2xl max-h-[80vh] flex flex-col",children:[r.jsx(zr,{children:r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"Team Pipeline"]})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search deals...",value:a,onChange:v=>o(v.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:l,onValueChange:i,children:[r.jsx(ls,{className:"w-[180px]",children:r.jsx(us,{placeholder:"All Members"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Members"}),d.map(v=>r.jsx(Ut,{value:v.id,children:v.name},v.id))]})]})]}),r.jsx("div",{className:"flex-1 overflow-y-auto space-y-4 mt-2",children:n?r.jsx("div",{className:"space-y-3",children:[1,2,3].map(v=>r.jsx(pr,{className:"h-20 w-full"},v))}):m.length===0?r.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[r.jsx(ws,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),r.jsx("p",{className:"font-medium",children:"No team deals found"}),r.jsx("p",{className:"text-sm",children:"Team members' deals will appear here based on your team's visibility settings."})]}):p.map(([v,_])=>r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2 sticky top-0 bg-background py-1 z-10",children:[r.jsxs(cn,{className:"h-6 w-6",children:[r.jsx(xa,{src:_.avatar||""}),r.jsx(dn,{className:"text-xs",children:_.name.charAt(0).toUpperCase()})]}),r.jsx("span",{className:"font-medium text-sm",children:_.name}),r.jsxs(_t,{variant:"secondary",className:"text-xs",children:[_.deals.length," deals"]})]}),r.jsx("div",{className:"space-y-2 pl-8",children:_.deals.map(k=>r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-card",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:k.deal_name}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[k.contact_name&&r.jsx("span",{className:"text-xs text-muted-foreground",children:k.contact_name}),k.property_address&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["• ",k.property_address]}),k.deal_type&&r.jsx(_t,{variant:"outline",className:"text-[10px] capitalize",children:k.deal_type})]})]}),r.jsxs("div",{className:"flex items-center gap-2 ml-2 shrink-0",children:[k.sale_price&&r.jsxs("span",{className:"text-xs font-medium flex items-center gap-0.5 text-muted-foreground",children:[r.jsx(Sd,{className:"h-3 w-3"}),g(k.sale_price)]}),k.stage_name&&r.jsxs(_t,{variant:"outline",className:"text-[10px] whitespace-nowrap",style:{borderColor:k.stage_color||void 0,color:k.stage_color||void 0,backgroundColor:k.stage_color?`${k.stage_color}10`:void 0},children:[r.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block mr-1",style:{backgroundColor:k.stage_color||void 0}}),k.stage_name]})]})]},k.id))})]},v))}),r.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-2 border-t",children:[m.length," deal",m.length!==1?"s":""," from ",p.length," team member",p.length!==1?"s":""]})]})})}function Mar({members:e,enabledMembers:t,onToggleMember:s,isOpen:n,onToggleOpen:a}){const o=t.size;return r.jsxs("div",{className:Vt("shrink-0 border-r border-border/50 bg-muted/20 transition-all duration-300 flex flex-col",n?"w-[220px]":"w-[48px]"),children:[r.jsx("div",{className:"p-2 border-b border-border/50 shrink-0",children:r.jsxs(X,{variant:"ghost",size:"sm",className:"w-full justify-start gap-2 px-2",onClick:a,children:[r.jsx(ws,{className:"h-4 w-4 shrink-0 text-primary"}),n&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-xs font-semibold flex-1 text-left",children:"Team"}),o>0&&r.jsx("span",{className:"text-[10px] bg-primary text-primary-foreground rounded-full px-1.5 py-0.5",children:o}),r.jsx(jc,{className:"h-3 w-3 text-muted-foreground"})]}),!n&&o>0&&r.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?r.jsxs(To,{className:"flex-1 p-2",children:[r.jsx("div",{className:"space-y-1",children:e.map(l=>{const i=t.has(l.id);return r.jsxs("button",{onClick:()=>s(l.id),className:Vt("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:[r.jsxs("div",{className:"relative",children:[r.jsxs(cn,{className:"h-7 w-7",children:[r.jsx(xa,{src:l.avatar_url||""}),r.jsx(dn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]}),i&&r.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-background",style:{backgroundColor:l.color}})]}),r.jsx("span",{className:Vt("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),r.jsx(fn,{checked:i,onCheckedChange:()=>s(l.id),className:"scale-75",onClick:d=>d.stopPropagation()})]},l.id)})}),e.length===0&&r.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No team members"})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center pt-2 gap-2",children:[e.slice(0,5).map(l=>{const i=t.has(l.id);return r.jsx("button",{onClick:()=>s(l.id),className:"relative",title:l.name,children:r.jsxs(cn,{className:Vt("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:[r.jsx(xa,{src:l.avatar_url||""}),r.jsx(dn,{className:"text-[10px] font-semibold text-white",style:{backgroundColor:l.color},children:l.name.charAt(0).toUpperCase()})]})},l.id)}),e.length>5&&r.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",e.length-5]})]})]})}const IIe=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Tar(){const{user:e}=Gr(),{data:t}=o_(),s=(t==null?void 0:t.role)==="team_leader",n=t==null?void 0:t.teamId,a=Ht({queryKey:["team-pipeline-members",n],queryFn:async()=>{const{data:o,error:l}=await Y.from("team_members").select("user_id, role").eq("team_id",n).neq("user_id",e.id);if(l)throw l;if(!o||o.length===0)return[];const i=o.map(p=>p.user_id),{data:d,error:m}=await Y.from("profiles").select("id, name, avatar_url").in("id",i);if(m)throw m;return(d||[]).map((p,g)=>({id:p.id,name:p.name||"Unknown",avatar_url:p.avatar_url,color:IIe[g%IIe.length]}))},enabled:!!n&&!!e&&s,staleTime:5*60*1e3});return{isTeamLeader:s,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function Aar(e){return Ht({queryKey:["team-member-deals",e],queryFn:async()=>{if(e.length===0)return[];const{data:t,error:s}=await Y.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",e).order("updated_at",{ascending:!1});if(s)throw s;return(t||[]).map(n=>{var a;return{...n,_stage_name:((a=n.deal_pipeline_stages)==null?void 0:a.name)||null}})},enabled:e.length>0})}function uZe({stages:e,currentStageId:t,onStageSelect:s,disabled:n}){const[a,o]=A.useState(!1),l=e.find(d=>d.id===t),i=d=>{d.id!==t&&s(d.id,d.name),o(!1)};return r.jsxs(Bu,{open:a,onOpenChange:o,children:[r.jsx($u,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1.5",disabled:n,onClick:d=>d.stopPropagation(),children:[l&&r.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l.color}}),r.jsx("span",{className:"max-w-[80px] truncate",children:(l==null?void 0:l.name)||"Move"}),r.jsx(Zi,{className:"h-3 w-3 shrink-0"})]})}),r.jsx(vu,{align:"end",className:"w-48 z-50 bg-popover",onClick:d=>d.stopPropagation(),children:e.map(d=>{const m=d.icon&&iOe[d.icon]||vh,p=d.id===t;return r.jsxs(Ba,{onClick:()=>i(d),className:Vt("flex items-center gap-2 cursor-pointer",p&&"bg-accent"),children:[r.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0",style:{backgroundColor:`${d.color}20`},children:r.jsx(m,{className:"h-3 w-3",style:{color:d.color}})}),r.jsx("span",{className:"flex-1",children:d.name}),p&&r.jsx(mi,{className:"h-4 w-4 text-primary"})]},d.id)})})]})}const Ear={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"}},Iar={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 hZe({deal:e,onClick:t,isDragging:s,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var C,I;const d=V3(),m=Ear[e.deal_type],p=Iar[e.priority],g=A.useMemo(()=>e.target_close_date?jx(new Date(e.target_close_date),new Date):null,[e.target_close_date]),v=g!==null&&g<0,_=g!==null&&g<=7&&g>=0,k=A.useMemo(()=>{var B;if(e.deal_type!=="seller"&&e.deal_type!=="dual")return null;const R=((B=e.listing)==null?void 0:B.created_at)||e.listing_date;if(!R)return null;const D=e.contract_date?new Date(e.contract_date):new Date;return jx(D,new Date(R))},[e]),w=l&&!e.scorecard_transaction_id,S=!!e.scorecard_transaction_id,T=R=>R?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(R):null;return r.jsx(ze,{className:Vt("cursor-pointer transition-all duration-200 hover:shadow-md hover:border-primary/30 group overflow-hidden",s&&"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:t,style:i?{borderLeftWidth:4,borderLeftColor:i.color}:void 0,children:r.jsxs(qe,{className:"p-3 space-y-2.5",children:[i&&r.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[r.jsxs(cn,{className:"h-4 w-4",children:[r.jsx(xa,{src:i.avatar_url||""}),r.jsx(dn,{className:"text-[8px] font-semibold text-white",style:{backgroundColor:i.color},children:i.name.charAt(0).toUpperCase()})]}),r.jsx("span",{className:"text-[10px] font-medium",style:{color:i.color},children:i.name})]}),r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsx("div",{className:"flex-1 min-w-0",children:r.jsx("h4",{className:"font-medium text-sm leading-tight line-clamp-2 group-hover:text-primary transition-colors",children:e.deal_name})}),r.jsx(_t,{variant:"outline",className:Vt("text-[10px] px-1.5 py-0 shrink-0",m.color),children:m.label})]}),e.contact&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(cn,{className:"h-5 w-5",children:r.jsxs(dn,{className:"text-[10px] bg-primary/10 text-primary",children:[(C=e.contact.first_name)==null?void 0:C[0],(I=e.contact.last_name)==null?void 0:I[0]]})}),r.jsxs("span",{className:"truncate",children:[e.contact.first_name," ",e.contact.last_name]})]}),e.listing&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Fm,{className:"h-3 w-3 text-primary shrink-0"}),r.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),w&&r.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:[r.jsx(go,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),S&&l&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[r.jsx(Ri,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{className:"truncate",children:"Synced to Scorecard"})]}),k!==null&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(mE,{className:"h-3 w-3 text-muted-foreground shrink-0"}),r.jsxs("span",{className:Vt("font-medium",k>90?"text-red-600":k>60?"text-amber-600":"text-muted-foreground"),children:[k," DOM"]}),e.contract_date&&r.jsx("span",{className:"text-muted-foreground",children:"(final)"})]}),!e.listing&&(e.property_address||e.city)&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[r.jsx(Vn,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{className:"truncate",children:e.property_address||`${e.city}, ${e.state}`})]}),e.expected_price&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Sd,{className:"h-3 w-3 text-emerald-500 shrink-0"}),r.jsx("span",{className:"font-semibold text-foreground",children:T(e.expected_price)}),e.expected_commission&&r.jsxs("span",{className:"text-muted-foreground",children:["• ",T(e.expected_commission)," GCI"]})]}),r.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-border/50",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:Vt("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[r.jsx("div",{className:Vt("w-1.5 h-1.5 rounded-full",p.dot)}),r.jsx("span",{className:"capitalize",children:e.priority})]}),r.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[e.probability,"%"]})]}),o&&d&&n&&a?r.jsx(uZe,{stages:n,currentStageId:e.stage_id||"",onStageSelect:(R,D)=>a(e.id,R,D)}):e.target_close_date?r.jsxs("div",{className:Vt("flex items-center gap-1 text-[10px]",v&&"text-red-600",_&&!v&&"text-amber-600",!v&&!_&&"text-muted-foreground"),children:[v?r.jsx(kl,{className:"h-3 w-3"}):r.jsx(An,{className:"h-3 w-3"}),r.jsx("span",{children:v?`${Math.abs(g)}d overdue`:_?`${g}d left`:Xr(new Date(e.target_close_date),"MMM d")})]}):null]})]})})}function Par({stage:e,deals:t,onDealClick:s,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:d=!1,getOwnerInfo:m}){const p=A.useRef(null),g=t.reduce((w,S)=>w+(S.expected_price||0),0),v=t.reduce((w,S)=>w+(S.expected_commission||0),0),_=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,k=e.icon&&iOe[e.icon]||vh;return r.jsxs("div",{ref:p,className:Vt("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,e.id),onDrop:w=>l(w,e.id),children:[r.jsxs("div",{className:"p-3 border-b border-border/50 shrink-0",style:{borderTopColor:e.color,borderTopWidth:3},children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{backgroundColor:`${e.color}20`},children:r.jsx(k,{className:"h-4 w-4",style:{color:e.color}})}),r.jsx("div",{children:r.jsx("h3",{className:"font-semibold text-sm",children:e.name})})]}),r.jsx(_t,{variant:"secondary",className:"text-xs font-medium px-2",children:t.length})]}),g>0&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{className:"font-medium text-foreground",children:_(g)}),r.jsx("span",{children:"•"}),r.jsxs("span",{children:[_(v)," GCI"]})]})]}),r.jsx(To,{className:"flex-1 p-2",children:r.jsxs("div",{className:"space-y-2",children:[t.map(w=>r.jsx("div",{draggable:!0,onDragStart:S=>{S.dataTransfer.effectAllowed="move",a(w.id,e.id)},children:r.jsx(hZe,{deal:w,onClick:()=>s(w),isWonStage:d,ownerInfo:(m==null?void 0:m(w))||null})},w.id)),t.length===0&&r.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground text-sm",children:[r.jsx("p",{className:"mb-2",children:"No deals yet"}),r.jsx("p",{className:"text-xs",children:"Drag deals here or add new"})]})]})}),r.jsx("div",{className:"p-2 border-t border-border/50 shrink-0",children:r.jsxs(X,{variant:"ghost",size:"sm",className:"w-full justify-start text-muted-foreground hover:text-foreground",onClick:()=>n(e.id),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})})]})}function Lar({stats:e,isLoading:t}){const s=a=>a>=1e6?`$${(a/1e6).toFixed(1)}M`:a>=1e3?`$${(a/1e3).toFixed(0)}K`:`$${a.toLocaleString()}`,n=[{label:"Active Deals",value:(e==null?void 0:e.activeDeals)||0,icon:Bf,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Pipeline Value",value:s((e==null?void 0:e.pipelineValue)||0),icon:Rc,color:"text-purple-500",bgColor:"bg-purple-500/10"},{label:"Expected GCI",value:s((e==null?void 0:e.expectedCommission)||0),icon:Sd,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},{label:"Won Deals",value:(e==null?void 0:e.wonDeals)||0,icon:go,color:"text-amber-500",bgColor:"bg-amber-500/10"}];return t?r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[1,2,3,4].map(a=>r.jsx(ze,{className:"animate-pulse",children:r.jsx(qe,{className:"p-4",children:r.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:n.map(a=>r.jsx(ze,{className:"border-border/50 hover:shadow-sm transition-shadow",children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:Vt("p-2 rounded-lg",a.bgColor),children:r.jsx(a.icon,{className:Vt("h-5 w-5",a.color)})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:a.label}),r.jsx("p",{className:"text-xl font-bold",children:a.value})]})]})})},a.label))})}function Dar(e){return Ht({queryKey:["client-portal",e],queryFn:async()=>{if(!e)return null;const{data:t,error:s}=await Y.from("client_portals").select("*").eq("deal_id",e).maybeSingle();if(s)throw s;return t},enabled:!!e})}function Bbe(){const e=fl(),t=Rr();return Qt({mutationFn:async s=>{if(!e)throw new Error("Not authenticated");const{data:n,error:a}=await Y.from("client_portals").insert({deal_id:s.deal_id,owner_user_id:e,slug:"",is_enabled:s.is_enabled??!0,visibility:s.visibility||"private",require_onboarding:s.require_onboarding??!0,allow_spouse:s.allow_spouse??!1,client_name:s.client_name||null,client_email:s.client_email||null,client_phone:s.client_phone||null,invite_method:s.invite_method||"email"}).select().single();if(a)throw a;return n},onSuccess:(s,n)=>{t.invalidateQueries({queryKey:["client-portal",n.deal_id]})}})}function vle(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("client_portals").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:t=>{e.invalidateQueries({queryKey:["client-portal",t.deal_id]}),e.invalidateQueries({queryKey:["all-client-portals"]})}})}function Oar(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("client_portals").update({archived_at:new Date().toISOString(),is_enabled:!1}).eq("id",t).select().single();if(n)throw n;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["client-portal",t.deal_id]}),e.invalidateQueries({queryKey:["all-client-portals"]})}})}function Rar(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("client_portals").update({archived_at:null}).eq("id",t).select().single();if(n)throw n;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["client-portal",t.deal_id]}),e.invalidateQueries({queryKey:["all-client-portals"]})}})}function Far(){const e=Rr();return Qt({mutationFn:async({id:t,dealId:s})=>{await Y.from("portal_updates").delete().eq("portal_id",t);const{error:n}=await Y.from("client_portals").delete().eq("id",t);if(n)throw n;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["client-portal",t]}),e.invalidateQueries({queryKey:["all-client-portals"]})}})}function zar(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("portal_updates").insert({portal_id:t.portal_id,title:t.title,content:t.content||null,video_url:t.video_url||null,is_stage_change:t.is_stage_change||!1}).select().single();if(n)throw n;return s},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["portal-updates",s.portal_id]})}})}function Bar(){const e=fl();return Ht({queryKey:["portal-custom-questions",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("portal_custom_questions").select("*").eq("owner_user_id",e).eq("is_active",!0).order("sort_order",{ascending:!0});if(s)throw s;return t},enabled:!!e})}function $ar(){const e=fl(),t=Rr();return Qt({mutationFn:async s=>{if(!e)throw new Error("Not authenticated");const{data:n,error:a}=await Y.from("portal_custom_questions").insert({owner_user_id:e,question_text:s.question_text,field_type:s.field_type,options:s.options||[],is_required:s.is_required||!1,sort_order:s.sort_order||0}).select().single();if(a)throw a;return n},onSuccess:()=>{t.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function Uar(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("portal_custom_questions").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function Var(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("portal_custom_questions").update({is_active:!1}).eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["portal-custom-questions"]})}})}function n5(e){const t=window.location.hostname;return t==="localhost"||t.includes("lovable.app")?`${window.location.origin}/portal/${e}`:`https://clients.relevelup.com/${e}`}function qar({formData:e,onChange:t,isEditing:s}){const{isAdmin:n}=Gr(),[a,o]=A.useState(e.portal_enabled);if(!n)return r.jsxs("div",{className:"border rounded-lg p-4 opacity-60",children:[r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bn,{className:"h-4 w-4 text-primary"}),r.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),r.jsx(_t,{variant:"secondary",className:"text-xs",children:"Coming Soon"})]})}),r.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=>{t({...e,...i})};return r.jsx(Ek,{open:a,onOpenChange:o,children:r.jsxs("div",{className:"border rounded-lg",children:[r.jsxs(Ik,{className:"w-full p-4 flex items-center justify-between hover:bg-muted/50 transition-colors rounded-t-lg",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bn,{className:"h-4 w-4 text-primary"}),r.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.portal_enabled&&r.jsx(_t,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),r.jsx(ad,{className:Vt("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),r.jsx(Pk,{children:r.jsxs("div",{className:"px-4 pb-4 space-y-5 border-t pt-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Enable Client Portal"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Create a beautiful portal your client can track their deal from"})]}),r.jsx(fn,{checked:e.portal_enabled,onCheckedChange:i=>l({portal_enabled:i})})]}),e.portal_enabled&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Portal Visibility"}),r.jsxs(i1e,{value:e.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[r.jsxs("label",{className:Vt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",e.visibility==="private"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[r.jsx(Nse,{value:"private"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(Du,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"text-sm font-medium",children:"Private"})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Link-only access"})]})]}),r.jsxs("label",{className:Vt("flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors",e.visibility==="public"?"border-primary bg-primary/5":"hover:bg-muted/50"),children:[r.jsx(Nse,{value:"public"}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(ux,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"text-sm font-medium",children:"Public"})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Shareable link"})]})]})]})]}),r.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-muted/30",children:[r.jsx(Qo,{id:"require_onboarding",checked:e.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),r.jsxs("div",{children:[r.jsx(Ee,{htmlFor:"require_onboarding",className:"text-sm font-medium cursor-pointer",children:"Require client onboarding before portal access"}),r.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."})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Qo,{id:"allow_spouse",checked:e.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),r.jsx(Ee,{htmlFor:"allow_spouse",className:"text-sm cursor-pointer",children:"Allow client to add spouse/partner during onboarding"})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Client Invite Details"}),r.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs text-muted-foreground",children:"Client Full Name"}),r.jsx(Ye,{value:e.client_name,onChange:i=>l({client_name:i.target.value}),placeholder:"Jane Smith"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs text-muted-foreground",children:"Email"}),r.jsx(Ye,{type:"email",value:e.client_email,onChange:i=>l({client_email:i.target.value}),placeholder:"jane@example.com"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs text-muted-foreground",children:"Phone"}),r.jsx(Ye,{type:"tel",value:e.client_phone,onChange:i=>l({client_phone:i.target.value}),placeholder:"(555) 123-4567"})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),r.jsxs(ds,{value:e.invite_method,onValueChange:i=>l({invite_method:i}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"email",children:"Email"}),r.jsxs(Ut,{value:"sms",disabled:!e.client_phone,children:["SMS ",!e.client_phone&&"(add phone first)"]})]})]})]})]})]})]})]})})]})})}const Har=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],War=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function Gar({open:e,onOpenChange:t,deal:s,defaultStageId:n}){const{data:a}=Rbe(),{data:o}=Xf(),{data:l}=h9e(),i=iZe(),d=oZe(),m=Bbe(),[p,g]=A.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[v,_]=A.useState(""),[k,w]=A.useState(!1),S=(l==null?void 0:l.filter($=>((s==null?void 0:s.listing_id)===$.id,!0)))||[],[T,C]=A.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:""});A.useEffect(()=>{var $,q,W;e&&(s?(C({deal_name:s.deal_name,deal_type:s.deal_type,stage_id:s.stage_id||"",contact_id:s.contact_id||"",listing_id:s.listing_id||"",property_address:s.property_address||"",city:s.city||"",state:s.state||"",zip_code:s.zip_code||"",expected_price:(($=s.expected_price)==null?void 0:$.toString())||"",commission_percentage:((q=s.commission_percentage)==null?void 0:q.toString())||"3",target_close_date:s.target_close_date?new Date(s.target_close_date):void 0,contract_date:s.contract_date?new Date(s.contract_date):void 0,listing_date:s.listing_date?new Date(s.listing_date):void 0,priority:s.priority,probability:s.probability.toString(),notes:s.notes||""}),s.contact&&_(`${s.contact.first_name} ${s.contact.last_name}`)):(C({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"})))},[e,s,n,a]);const I=o==null?void 0:o.filter($=>{var W,K,re;const q=v.toLowerCase();return((W=$.first_name)==null?void 0:W.toLowerCase().includes(q))||((K=$.last_name)==null?void 0:K.toLowerCase().includes(q))||((re=$.email)==null?void 0:re.toLowerCase().includes(q))}).slice(0,5),R=()=>{const $=parseFloat(T.expected_price)||0,q=parseFloat(T.commission_percentage)||0;return $*(q/100)},D=async $=>{var q,W,K;if($.preventDefault(),!T.deal_name.trim()){we.error("Please enter a deal name");return}try{const re={deal_name:T.deal_name,deal_type:T.deal_type,stage_id:T.stage_id||null,contact_id:T.contact_id||null,listing_id:T.listing_id||null,property_address:T.property_address||null,city:T.city||null,state:T.state||null,zip_code:T.zip_code||null,expected_price:T.expected_price?parseFloat(T.expected_price):null,expected_commission:R()||null,commission_percentage:T.commission_percentage?parseFloat(T.commission_percentage):3,target_close_date:((q=T.target_close_date)==null?void 0:q.toISOString().split("T")[0])||null,contract_date:((W=T.contract_date)==null?void 0:W.toISOString().split("T")[0])||null,listing_date:((K=T.listing_date)==null?void 0:K.toISOString().split("T")[0])||null,priority:T.priority,probability:parseInt(T.probability)||50,notes:T.notes||null};if(s)await d.mutateAsync({id:s.id,...re}),we.success("Deal updated successfully");else{const ae=await i.mutateAsync(re);if(we.success("Deal created successfully"),p.portal_enabled&&(ae!=null&&ae.id))try{await m.mutateAsync({deal_id:ae.id,visibility:p.visibility,require_onboarding:p.require_onboarding,allow_spouse:p.allow_spouse,client_name:p.client_name||null,client_email:p.client_email||null,client_phone:p.client_phone||null,invite_method:p.invite_method}),we.success("Client portal created!")}catch{we.error("Deal created, but portal setup failed")}}t(!1)}catch{we.error("Failed to save deal")}},B=i.isPending||d.isPending;return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:s?"Edit Deal":"Add New Deal"}),r.jsx(Zs,{children:s?"Update the deal details below.":"Enter the details for your new deal."})]}),r.jsxs("form",{onSubmit:D,className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"col-span-2 space-y-2",children:[r.jsx(Ee,{htmlFor:"deal_name",children:"Deal Name *"}),r.jsx(Ye,{id:"deal_name",value:T.deal_name,onChange:$=>C(q=>({...q,deal_name:$.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Deal Type"}),r.jsxs(ds,{value:T.deal_type,onValueChange:$=>C(q=>({...q,deal_type:$})),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:Har.map($=>r.jsx(Ut,{value:$.value,children:$.label},$.value))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Stage"}),r.jsxs(ds,{value:T.stage_id||"none",onValueChange:$=>C(q=>({...q,stage_id:$==="none"?"":$})),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select stage"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No Stage"}),a==null?void 0:a.map($=>r.jsx(Ut,{value:$.id,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:$.color}}),$.name]})},$.id))]})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Link to Contact"}),r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{value:v,onChange:$=>{_($.target.value),w(!0),$.target.value||C(q=>({...q,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),k&&v&&I&&I.length>0&&r.jsx("div",{className:"absolute z-10 w-full mt-1 bg-background border rounded-lg shadow-lg max-h-48 overflow-y-auto",children:I.map($=>r.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{C(q=>({...q,contact_id:$.id})),_(`${$.first_name} ${$.last_name}`),w(!1)},children:[r.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{children:[$.first_name," ",$.last_name]}),$.email&&r.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:$.email})]},$.id))})]})]}),S.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{className:"flex items-center gap-2",children:[r.jsx(Fm,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),r.jsxs(ds,{value:T.listing_id||"none",onValueChange:$=>{const q=$==="none"?"":$,W=S.find(K=>K.id===q);C(W?K=>{var re;return{...K,listing_id:q,deal_type:"seller",property_address:W.property_address||K.property_address,city:W.city||K.city,state:W.state||K.state,expected_price:((re=W.price)==null?void 0:re.toString())||K.expected_price}}:K=>({...K,listing_id:q}))},children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a listing to sync status..."})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"None"}),S.map($=>r.jsx(Ut,{value:$.id,children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{children:$.property_address||`${$.city}, ${$.state}`}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",($.price/1e3).toFixed(0),"K"]})]})},$.id))]})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Status changes will sync automatically between the deal and listing."})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("h4",{className:"font-medium text-sm",children:"Property Details"}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"col-span-2 space-y-2",children:[r.jsx(Ee,{htmlFor:"property_address",children:"Address"}),r.jsx(Ye,{id:"property_address",value:T.property_address,onChange:$=>C(q=>({...q,property_address:$.target.value})),placeholder:"123 Main Street"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"city",children:"City"}),r.jsx(Ye,{id:"city",value:T.city,onChange:$=>C(q=>({...q,city:$.target.value}))})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"state",children:"State"}),r.jsx(Ye,{id:"state",value:T.state,onChange:$=>C(q=>({...q,state:$.target.value})),maxLength:2,placeholder:"TX"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"zip_code",children:"ZIP"}),r.jsx(Ye,{id:"zip_code",value:T.zip_code,onChange:$=>C(q=>({...q,zip_code:$.target.value}))})]})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("h4",{className:"font-medium text-sm",children:"Financial Details"}),r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"expected_price",children:"Expected Price"}),r.jsxs("div",{className:"relative",children:[r.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"$"}),r.jsx(Ye,{id:"expected_price",type:"number",value:T.expected_price,onChange:$=>C(q=>({...q,expected_price:$.target.value})),className:"pl-7",placeholder:"500000"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"commission_percentage",children:"Commission %"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ye,{id:"commission_percentage",type:"number",step:"0.1",value:T.commission_percentage,onChange:$=>C(q=>({...q,commission_percentage:$.target.value})),className:"pr-7"}),r.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Expected GCI"}),r.jsx(Ye,{value:R()?`$${R().toLocaleString()}`:"-",disabled:!0,className:"bg-muted"})]})]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("h4",{className:"font-medium text-sm",children:"Dates & Status"}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Target Close Date"}),r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("w-full justify-start text-left font-normal",!T.target_close_date&&"text-muted-foreground"),children:[r.jsx(An,{className:"mr-2 h-4 w-4"}),T.target_close_date?Xr(T.target_close_date,"PPP"):"Pick a date"]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:T.target_close_date,onSelect:$=>C(q=>({...q,target_close_date:$})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Contract Date"}),r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("w-full justify-start text-left font-normal",!T.contract_date&&"text-muted-foreground"),children:[r.jsx(An,{className:"mr-2 h-4 w-4"}),T.contract_date?Xr(T.contract_date,"PPP"):"Pick a date"]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:T.contract_date,onSelect:$=>C(q=>({...q,contract_date:$})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(T.deal_type==="seller"||T.deal_type==="dual")&&!T.listing_id&&r.jsxs("div",{className:"space-y-2 col-span-2",children:[r.jsx(Ee,{children:"Listing Date (for Days on Market)"}),r.jsxs(cd,{children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",className:Vt("w-full justify-start text-left font-normal",!T.listing_date&&"text-muted-foreground"),children:[r.jsx(An,{className:"mr-2 h-4 w-4"}),T.listing_date?Xr(T.listing_date,"PPP"):"Pick a date"]})}),r.jsx(Hc,{className:"w-auto p-0",align:"start",children:r.jsx(ig,{mode:"single",selected:T.listing_date,onSelect:$=>C(q=>({...q,listing_date:$})),initialFocus:!0,className:"pointer-events-auto"})})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Used to calculate Days on Market. Auto-filled for linked listings."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Priority"}),r.jsxs(ds,{value:T.priority,onValueChange:$=>C(q=>({...q,priority:$})),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:War.map($=>r.jsx(Ut,{value:$.value,children:$.label},$.value))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Win Probability"}),r.jsxs("div",{className:"relative",children:[r.jsx(Ye,{type:"number",min:"0",max:"100",value:T.probability,onChange:$=>C(q=>({...q,probability:$.target.value})),className:"pr-7"}),r.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:"%"})]})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"notes",children:"Notes"}),r.jsx(qs,{id:"notes",value:T.notes,onChange:$=>C(q=>({...q,notes:$.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!s&&r.jsx(qar,{formData:p,onChange:g}),r.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{type:"submit",disabled:B,children:[B&&r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),s?"Update Deal":"Create Deal"]})]})]})]})})}function Kar(e){return Ht({queryKey:["deal-files",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("deal_files").select("*").eq("deal_id",e).order("created_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function Zar(){const e=fl(),t=Rr();return Qt({mutationFn:async({dealId:s,file:n})=>{if(!e)throw new Error("Not authenticated");const a=n.name.split(".").pop(),o=`${e}/${s}/${crypto.randomUUID()}.${a}`,{error:l}=await Y.storage.from("deal-files").upload(o,n);if(l)throw l;const{data:i,error:d}=await Y.from("deal_files").insert({deal_id:s,owner_user_id:e,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:(s,n)=>{t.invalidateQueries({queryKey:["deal-files",n.dealId]})}})}function Yar(){const e=Rr();return Qt({mutationFn:async({fileId:t,storagePath:s,dealId:n})=>{await Y.storage.from("deal-files").remove([s]);const{error:a}=await Y.from("deal_files").delete().eq("id",t);if(a)throw a;return n},onSuccess:t=>{e.invalidateQueries({queryKey:["deal-files",t]})}})}function Xar(){const e=Rr();return Qt({mutationFn:async({fileId:t,visible:s,dealId:n})=>{const{error:a}=await Y.from("deal_files").update({visible_on_portal:s}).eq("id",t);if(a)throw a;return n},onSuccess:t=>{e.invalidateQueries({queryKey:["deal-files",t]})}})}async function Qar(e){const{data:t,error:s}=await Y.storage.from("deal-files").createSignedUrl(e,3600);if(s)throw s;return t.signedUrl}const PIe={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function Jar({open:e,onOpenChange:t}){const{data:s,isLoading:n}=Bar(),a=$ar(),o=Uar(),l=Var(),[i,d]=A.useState(!1),[m,p]=A.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[g,v]=A.useState(""),_=async()=>{if(m.question_text.trim())try{await a.mutateAsync({question_text:m.question_text.trim(),field_type:m.field_type,options:m.field_type==="dropdown"?m.options:[],is_required:m.is_required,sort_order:((s==null?void 0:s.length)||0)+1}),p({question_text:"",field_type:"text",options:[],is_required:!1}),v(""),d(!1),we.success("Question added")}catch{we.error("Failed to add question")}},k=async C=>{try{await l.mutateAsync(C),we.success("Question removed")}catch{we.error("Failed to remove question")}},w=async(C,I)=>{try{await o.mutateAsync({id:C,is_required:I})}catch{we.error("Failed to update question")}},S=()=>{g.trim()&&(p(C=>({...C,options:[...C.options,g.trim()]})),v(""))},T=C=>{p(I=>({...I,options:I.options.filter((R,D)=>D!==C)}))};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-md max-h-[85vh] flex flex-col",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Custom Intake Questions"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"These questions appear on all your portal onboarding forms."})]}),r.jsx(To,{className:"flex-1",children:r.jsxs("div",{className:"space-y-3 pr-2",children:[n&&r.jsx("div",{className:"flex justify-center py-8",children:r.jsx($r,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),s==null?void 0:s.map(C=>{var I;return r.jsx("div",{className:"border rounded-lg p-3 space-y-2",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Df,{className:"h-4 w-4 text-muted-foreground/40 mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium",children:C.question_text}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx(_t,{variant:"secondary",className:"text-xs",children:PIe[C.field_type]||C.field_type}),C.is_required&&r.jsx(_t,{variant:"outline",className:"text-xs",children:"Required"})]}),C.field_type==="dropdown"&&((I=C.options)==null?void 0:I.length)>0&&r.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",C.options.join(", ")]})]}),r.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[r.jsx(fn,{checked:C.is_required,onCheckedChange:R=>w(C.id,R),className:"scale-75"}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>k(C.id),children:r.jsx(Os,{className:"h-3.5 w-3.5"})})]})]})},C.id)}),!n&&(s==null?void 0:s.length)===0&&!i&&r.jsxs("div",{className:"text-center py-8 border border-dashed rounded-lg",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"No custom questions yet"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Add questions that clients will answer during onboarding."})]}),i&&r.jsxs("div",{className:"border-2 border-primary/20 rounded-lg p-4 space-y-3 bg-primary/5",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Question"}),r.jsx(Ye,{value:m.question_text,onChange:C=>p(I=>({...I,question_text:C.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Answer Type"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(PIe).map(([C,I])=>r.jsx("button",{type:"button",onClick:()=>p(R=>({...R,field_type:C,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${m.field_type===C?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:I},C))})]}),m.field_type==="dropdown"&&r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Options"}),r.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[m.options.map((C,I)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"flex-1 text-sm bg-muted/50 rounded px-2 py-1",children:C}),r.jsx("button",{onClick:()=>T(I),className:"text-muted-foreground hover:text-destructive",children:r.jsx(Xs,{className:"h-3.5 w-3.5"})})]},I)),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:g,onChange:C=>v(C.target.value),onKeyDown:C=>C.key==="Enter"&&(C.preventDefault(),S()),placeholder:"Add option...",className:"h-8 text-sm"}),r.jsx(X,{variant:"outline",size:"sm",onClick:S,disabled:!g.trim(),className:"h-8",children:r.jsx(gs,{className:"h-3 w-3"})})]})]})]}),r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{checked:m.is_required,onCheckedChange:C=>p(I=>({...I,is_required:C}))}),r.jsx(Ee,{className:"text-xs text-muted-foreground",children:"Required"})]})}),r.jsxs("div",{className:"flex gap-2 pt-1",children:[r.jsx(X,{variant:"outline",size:"sm",onClick:()=>d(!1),className:"flex-1",children:"Cancel"}),r.jsxs(X,{size:"sm",onClick:_,disabled:!m.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?r.jsx($r,{className:"h-3 w-3 mr-1 animate-spin"}):null,"Add Question"]})]})]})]})}),r.jsxs("div",{className:"flex justify-between pt-4 border-t shrink-0",children:[i?r.jsx("div",{}):r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>d(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-1"})," Add Question"]}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>t(!1),children:"Done"})]})]})})}function mZe({open:e,onOpenChange:t,portal:s,dealOwnerId:n}){const a=vle(),[o,l]=A.useState(!1),[i,d]=A.useState(s.next_step_text||""),[m,p]=A.useState(s.next_step_video_url||""),[g,v]=A.useState(s.inspection_date||""),[_,k]=A.useState(s.appraisal_date||""),[w,S]=A.useState(s.welcome_message||""),[T,C]=A.useState(s.review_url||""),[I,R]=A.useState(s.show_post_close_tips),[D,B]=A.useState(s.require_onboarding),[$,q]=A.useState(s.allow_spouse),[W,K]=A.useState(s.visibility),[re,ae]=A.useState(s.stage_mapping||[]),{data:oe}=Ht({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:ge,error:Te}=await Y.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Te)throw Te;return ge},enabled:e});A.useEffect(()=>{d(s.next_step_text||""),p(s.next_step_video_url||""),v(s.inspection_date||""),k(s.appraisal_date||""),S(s.welcome_message||""),C(s.review_url||""),R(s.show_post_close_tips),B(s.require_onboarding),q(s.allow_spouse),K(s.visibility),ae(s.stage_mapping||[])},[s]);const se=async()=>{try{await a.mutateAsync({id:s.id,next_step_text:i||null,next_step_video_url:m||null,inspection_date:g||null,appraisal_date:_||null,welcome_message:w||null,review_url:T||null,show_post_close_tips:I,require_onboarding:D,allow_spouse:$,visibility:W,stage_mapping:re.length>0?re:null}),we.success("Portal settings saved"),t(!1)}catch{we.error("Failed to save settings")}},pe=()=>{ae([...re,{label:""}])},ie=ge=>{ae(re.filter((Te,_e)=>_e!==ge))},de=(ge,Te)=>{const _e=[...re];_e[ge]={..._e[ge],label:Te},ae(_e)},ce=()=>{const Te=L7e(null).map(_e=>({label:_e.label,stageId:void 0}));ae(Te)};return r.jsxs(r.Fragment,{children:[r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-lg max-h-[85vh] flex flex-col",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Portal Settings"})}),r.jsxs(ii,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[r.jsxs(si,{className:"grid grid-cols-3 shrink-0",children:[r.jsx(Kr,{value:"general",children:"General"}),r.jsx(Kr,{value:"timeline",children:"Timeline"}),r.jsx(Kr,{value:"content",children:"Content"})]}),r.jsxs(To,{className:"flex-1 mt-4",children:[r.jsxs(hs,{value:"general",className:"space-y-4 mt-0 px-1",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Visibility"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Public portals appear without restrictions"})]}),r.jsx("div",{className:"flex gap-1",children:["private","public"].map(ge=>r.jsx("button",{onClick:()=>K(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))})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Require Onboarding"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Clients must fill out intake form"})]}),r.jsx(fn,{checked:D,onCheckedChange:B})]}),D&&r.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Custom Questions"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage intake form questions"})]}),r.jsx(X,{variant:"outline",size:"sm",onClick:()=>l(!0),className:"text-xs",children:"Manage"})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Allow Spouse/Partner"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Show spouse fields on onboarding"})]}),r.jsx(fn,{checked:$,onCheckedChange:q})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Post-Close Celebration"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Show congrats card when deal closes"})]}),r.jsx(fn,{checked:I,onCheckedChange:R})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Inspection Date"}),r.jsx(Ye,{type:"date",value:g,onChange:ge=>v(ge.target.value),className:"mt-1"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Appraisal Date"}),r.jsx(Ye,{type:"date",value:_,onChange:ge=>k(ge.target.value),className:"mt-1"})]})]}),r.jsx(hs,{value:"timeline",className:"space-y-4 mt-0 px-1",children:r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Client-Facing Stages"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Customize the client-friendly stage labels shown on the portal timeline"})]}),r.jsx(X,{variant:"outline",size:"sm",onClick:ce,className:"text-xs",children:"Auto-map"})]}),r.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."'}),re.length===0&&r.jsxs("div",{className:"border border-dashed rounded-lg p-4 text-center",children:[r.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No custom mapping — using default client-friendly journey stages"}),r.jsx(X,{variant:"outline",size:"sm",onClick:ce,children:"Customize journey labels"})]}),r.jsx("div",{className:"space-y-2 mt-2",children:re.map((ge,Te)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Df,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),r.jsx(Ye,{value:ge.label,onChange:_e=>de(Te,_e.target.value),placeholder:`Stage ${Te+1} label`,className:"flex-1 h-9 text-sm"}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>ie(Te),children:r.jsx(Os,{className:"h-3.5 w-3.5"})})]},Te))}),re.length>0&&r.jsxs(X,{variant:"outline",size:"sm",onClick:pe,className:"mt-2 text-xs w-full",children:[r.jsx(gs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),r.jsxs(hs,{value:"content",className:"space-y-4 mt-0 px-1",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Welcome Message"}),r.jsx("textarea",{value:w,onChange:ge=>S(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."})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"What's Next"}),r.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Tell your client what to expect next"}),r.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..."})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),r.jsx(Ye,{value:m,onChange:ge=>p(ge.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Review URL"}),r.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Shown after deal closes"}),r.jsx(Ye,{value:T,onChange:ge=>C(ge.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t shrink-0",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{onClick:se,disabled:a.isPending,children:[a.isPending?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(zf,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),r.jsx(Jar,{open:o,onOpenChange:l})]})}function fZe({open:e,onOpenChange:t,portalId:s}){const[n,a]=A.useState(""),[o,l]=A.useState(""),[i,d]=A.useState(""),[m,p]=A.useState(!1),g=zar(),v=async()=>{if(n.trim())try{await g.mutateAsync({portal_id:s,title:n.trim(),content:o.trim()||void 0,video_url:i.trim()||void 0,is_stage_change:m}),we.success("Update posted to portal"),a(""),l(""),d(""),p(!1),t(!1)}catch{we.error("Failed to post update")}};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-md",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Post Portal Update"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Title *"}),r.jsx(Ye,{value:n,onChange:_=>a(_.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Message"}),r.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..."})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Video URL (optional)"}),r.jsxs("div",{className:"relative mt-1",children:[r.jsx(Ye,{value:i,onChange:_=>d(_.target.value),className:"pl-9",placeholder:"YouTube or Loom link"}),r.jsx(ma,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{type:"button",onClick:()=>p(!m),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${m?"bg-emerald-500/10 text-emerald-700 border-emerald-200":"bg-background text-muted-foreground border-input"}`,children:"📊 Stage Change"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Mark as a milestone update"})]})]}),r.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),r.jsxs(X,{onClick:v,disabled:!n.trim()||g.isPending,children:[g.isPending?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function pZe({open:e,onOpenChange:t,portal:s,dealName:n}){const a=vle(),{isGmailConnected:o,gmailEmail:l}=kN(),[i,d]=A.useState(s.client_name||""),[m,p]=A.useState(s.client_email||""),[g,v]=A.useState(!1),[_,k]=A.useState(!1),w=n5(s.slug),S=i.split(" ")[0]||"there",T=`Your Transaction Portal – ${n}`,C=`Hi ${S}, 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!`,I=()=>{navigator.clipboard.writeText(w),k(!0),setTimeout(()=>k(!1),2e3),we.success("Portal link copied!")},R=async()=>{if(!m.trim()){we.error("Please enter the client email");return}v(!0);try{await a.mutateAsync({id:s.id,client_name:i||null,client_email:m||null,invite_sent_at:new Date().toISOString(),invite_method:"email"});const{error:B}=await Y.functions.invoke("gmail-send",{body:{to:m,subject:T,body:C.replace(/\n/g,"
")}});if(B)throw B;we.success(`Invite sent to ${m}`),t(!1)}catch(B){we.error(B.message||"Failed to send invite")}finally{v(!1)}},D=()=>{const B=encodeURIComponent(T),$=encodeURIComponent(C);window.open(`mailto:${m}?subject=${B}&body=${$}`,"_blank"),a.mutateAsync({id:s.id,client_name:i||null,client_email:m||null,invite_sent_at:new Date().toISOString(),invite_method:"email"}).catch(()=>{})};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"max-w-md",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Invite Client to Portal"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Client Name"}),r.jsx(Ye,{value:i,onChange:B=>d(B.target.value),className:"mt-1",placeholder:"John Doe"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Client Email"}),r.jsx(Ye,{type:"email",value:m,onChange:B=>p(B.target.value),className:"mt-1",placeholder:"john@example.com"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Portal Link"}),r.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[r.jsx("div",{className:"flex-1 bg-muted/50 rounded-md px-3 py-2",children:r.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:w})}),r.jsx(X,{variant:"outline",size:"icon",onClick:I,className:"shrink-0",children:_?r.jsx(mi,{className:"h-4 w-4 text-emerald-600"}):r.jsx(uo,{className:"h-4 w-4"})})]})]}),r.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?r.jsxs(X,{onClick:R,disabled:g||!m.trim(),className:"w-full",children:[g?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):r.jsxs(X,{onClick:D,disabled:!m.trim(),className:"w-full",variant:"outline",children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Open in Email App"]}),r.jsxs(X,{variant:"ghost",onClick:I,className:"w-full text-muted-foreground",children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function eir({deal:e}){const{isAdmin:t,user:s}=Gr(),{data:n,isLoading:a}=Dar(e.id),o=Bbe(),l=vle(),[i,d]=A.useState(!1),[m,p]=A.useState(!1),[g,v]=A.useState(!1),[_,k]=A.useState(!1);if(a)return r.jsx("div",{className:"border rounded-lg p-4",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bn,{className:"h-4 w-4 text-primary"}),r.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),r.jsx($r,{className:"h-3 w-3 animate-spin ml-auto"})]})});const w=async()=>{var D,B;d(!0);try{await o.mutateAsync({deal_id:e.id,visibility:"private",require_onboarding:!0,client_name:e.contact?`${e.contact.first_name} ${e.contact.last_name}`:void 0,client_email:((D=e.contact)==null?void 0:D.email)||void 0,client_phone:((B=e.contact)==null?void 0:B.phone)||void 0}),we.success("Client portal enabled!")}catch{we.error("Failed to create portal")}finally{d(!1)}},S=async D=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:D}),we.success(D?"Portal enabled":"Portal disabled")}catch{we.error("Failed to update portal")}},T=()=>{if(!n)return;const D=n5(n.slug);navigator.clipboard.writeText(D),we.success("Portal link copied!")},C=()=>{if(!n)return;const D=n5(n.slug);window.open(D,"_blank")};if(!n)return r.jsxs("div",{className:"border rounded-lg p-4 border-dashed",children:[r.jsx("div",{className:"flex items-center justify-between mb-3",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bn,{className:"h-4 w-4 text-primary"}),r.jsx("span",{className:"font-medium text-sm",children:"Client Portal"})]})}),r.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."}),r.jsxs(X,{onClick:w,disabled:i,size:"sm",className:"w-full",children:[i?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(bn,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const I=n5(n.slug),R=(s==null?void 0:s.id)||"";return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bn,{className:"h-4 w-4 text-primary"}),r.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),r.jsx(_t,{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"})]}),r.jsx(fn,{checked:n.is_enabled,onCheckedChange:S})]}),r.jsxs("div",{className:"space-y-1.5 mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Visibility:"}),r.jsx(_t,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:n.visibility==="private"?"Private":"Public"})]}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Onboarding:"}),r.jsx("span",{className:"text-foreground",children:n.require_onboarding?"Required":"Disabled"})]}),n.client_name&&r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx("span",{children:"Client:"}),r.jsx("span",{className:"text-foreground",children:n.client_name})]})]}),r.jsx("div",{className:"bg-muted/50 rounded-md p-2 mb-3",children:r.jsx("p",{className:"text-xs font-mono text-muted-foreground truncate",children:I})}),r.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:T,className:"text-xs flex-1 min-w-0",children:[r.jsx(uo,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:C,className:"text-xs flex-1 min-w-0",children:[r.jsx(jn,{className:"h-3 w-3 mr-1 shrink-0"}),"Preview"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>k(!0),className:"text-xs flex-1 min-w-0",children:[r.jsx(ai,{className:"h-3 w-3 mr-1 shrink-0"}),"Invite"]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>v(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[r.jsx(D4,{className:"h-3 w-3 mr-1 shrink-0"}),"Post Update"]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>p(!0),className:"text-xs text-muted-foreground flex-1 min-w-0",children:[r.jsx(ld,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),r.jsx(mZe,{open:m,onOpenChange:p,portal:n,dealOwnerId:R}),r.jsx(fZe,{open:g,onOpenChange:v,portalId:n.id}),r.jsx(pZe,{open:_,onOpenChange:k,portal:n,dealName:e.deal_name})]})}const tir={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"}},rir={note:Vo,call:fi,email:Vs,meeting:An,stage_change:jn,task_completed:Ri,document:Vn,system:Pa};function sir({deal:e,open:t,onOpenChange:s,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Ue,Ve;const{data:l,isLoading:i}=Xnr((e==null?void 0:e.id)||""),{data:d,isLoading:m}=Jnr((e==null?void 0:e.id)||""),p=Qnr(),g=tar(),v=ear(),_=Ynr(),{data:k,isLoading:w}=Kar((e==null?void 0:e.id)||""),S=Zar(),T=Yar(),C=Xar(),I=A.useRef(null),[R,D]=A.useState(""),[B,$]=A.useState(""),[q,W]=A.useState(!1),[K,re]=A.useState(!1);if(!e)return null;const ae=tir[e.deal_type],oe=(()=>{var wt;if(e.deal_type!=="seller"&&e.deal_type!=="dual")return null;const Ie=((wt=e.listing)==null?void 0:wt.created_at)||e.listing_date;if(!Ie)return null;const We=e.contract_date?new Date(e.contract_date):new Date;return jx(We,new Date(Ie))})(),se=Ie=>Ie?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Ie):"-",pe=async()=>{if(R.trim())try{await p.mutateAsync({deal_id:e.id,activity_type:"note",title:"Note added",description:R}),D(""),we.success("Note added")}catch{we.error("Failed to add note")}},ie=async()=>{if(B.trim())try{await g.mutateAsync({deal_id:e.id,title:B,sort_order:((d==null?void 0:d.length)||0)+1}),$(""),we.success("Task added")}catch{we.error("Failed to add task")}},de=async(Ie,We)=>{try{await v.mutateAsync({id:Ie,is_completed:We,deal_id:e.id})}catch{we.error("Failed to update task")}},ce=async()=>{try{await _.mutateAsync(e.id),we.success("Deal deleted"),s(!1)}catch{we.error("Failed to delete deal")}},ge=(d==null?void 0:d.filter(Ie=>Ie.is_completed).length)||0,Te=(d==null?void 0:d.length)||0,_e=(k==null?void 0:k.length)||0,ve=Ie=>Ie<1024?`${Ie} B`:Ie<1024*1024?`${(Ie/1024).toFixed(1)} KB`:`${(Ie/(1024*1024)).toFixed(1)} MB`,Me=Ie=>Ie?Ie.startsWith("image/")?Nl:Ie.includes("pdf")?ya:N4:N4,Ze=async Ie=>{const We=Ie.target.files;if(!(!We||!e)){re(!0);try{for(const wt of Array.from(We)){if(wt.size>20*1024*1024){we.error(`${wt.name} exceeds 20MB limit`);continue}await S.mutateAsync({dealId:e.id,file:wt})}we.success("File(s) uploaded")}catch{we.error("Failed to upload file")}finally{re(!1),I.current&&(I.current.value="")}}},Ae=async(Ie,We)=>{if(e)try{await T.mutateAsync({fileId:Ie,storagePath:We,dealId:e.id}),we.success("File deleted")}catch{we.error("Failed to delete file")}},Le=async(Ie,We)=>{try{const wt=await Qar(Ie),Pe=document.createElement("a");Pe.href=wt,Pe.download=We,Pe.target="_blank",document.body.appendChild(Pe),Pe.click(),document.body.removeChild(Pe)}catch{we.error("Failed to download file")}};return r.jsxs(r.Fragment,{children:[r.jsx(Nie,{open:t,onOpenChange:s,children:r.jsxs(M6,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[r.jsx(Sie,{className:"p-6 pb-4 border-b shrink-0",children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(_t,{variant:"outline",className:Vt("text-xs",ae.color),children:ae.label}),r.jsxs(_t,{variant:"secondary",className:"text-xs capitalize",children:[e.priority," priority"]})]}),r.jsx(Cie,{className:"text-xl",children:e.deal_name})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{variant:"outline",size:"icon",onClick:()=>n(e),children:r.jsx(Lc,{className:"h-4 w-4"})}),r.jsx(X,{variant:"outline",size:"icon",className:"text-destructive hover:bg-destructive/10",onClick:()=>W(!0),children:r.jsx(Os,{className:"h-4 w-4"})})]})]})}),r.jsx(To,{className:"flex-1",children:r.jsxs("div",{className:"p-6 space-y-6",children:[e.contact&&r.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[r.jsx(cn,{className:"h-10 w-10",children:r.jsxs(dn,{className:"bg-primary/10 text-primary",children:[(Ue=e.contact.first_name)==null?void 0:Ue[0],(Ve=e.contact.last_name)==null?void 0:Ve[0]]})}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("p",{className:"font-medium",children:[e.contact.first_name," ",e.contact.last_name]}),e.contact.email&&r.jsx("p",{className:"text-sm text-muted-foreground",children:e.contact.email})]}),r.jsxs("div",{className:"flex gap-2",children:[e.contact.phone&&r.jsx(X,{variant:"outline",size:"icon",asChild:!0,children:r.jsx("a",{href:`tel:${e.contact.phone}`,children:r.jsx(fi,{className:"h-4 w-4"})})}),e.contact.email&&r.jsx(X,{variant:"outline",size:"icon",asChild:!0,children:r.jsx("a",{href:`mailto:${e.contact.email}`,children:r.jsx(Vs,{className:"h-4 w-4"})})})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(e.property_address||e.city)&&r.jsxs("div",{className:"col-span-2 flex items-start gap-2 text-sm",children:[r.jsx(Vn,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:e.property_address||"Address TBD"}),r.jsx("p",{className:"text-muted-foreground",children:[e.city,e.state,e.zip_code].filter(Boolean).join(", ")})]})]}),r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3",children:[r.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected Price"}),r.jsx("p",{className:"text-lg font-bold",children:se(e.expected_price)})]}),r.jsxs("div",{className:"bg-emerald-500/10 rounded-lg p-3",children:[r.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Expected GCI"}),r.jsx("p",{className:"text-lg font-bold text-emerald-600",children:se(e.expected_commission)})]}),o&&!e.scorecard_transaction_id&&a&&r.jsxs(X,{onClick:()=>a(e),className:"w-full bg-green-600 hover:bg-green-700",children:[r.jsx(go,{className:"h-4 w-4 mr-2"}),"Add to Scorecard"]}),e.scorecard_transaction_id&&r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-muted/50 rounded-lg p-3",children:[r.jsx(Ri,{className:"h-4 w-4 text-green-600"}),r.jsx("span",{children:"Synced to Scorecard"})]}),oe!==null&&r.jsxs("div",{className:"bg-muted/50 rounded-lg p-3 col-span-2",children:[r.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Days on Market"}),r.jsxs("p",{className:Vt("text-lg font-bold",oe>90?"text-red-600":oe>60?"text-amber-600":"text-foreground"),children:[oe," ",e.contract_date?"(final)":"days"]})]}),e.target_close_date&&r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx(An,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{children:["Close: ",Xr(new Date(e.target_close_date),"MMM d, yyyy")]})]}),r.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r.jsx(Sd,{className:"h-4 w-4 text-muted-foreground"}),r.jsxs("span",{children:[e.probability,"% probability"]})]})]}),e.notes&&r.jsxs("div",{className:"text-sm",children:[r.jsx("p",{className:"font-medium mb-1",children:"Notes"}),r.jsx("p",{className:"text-muted-foreground",children:e.notes})]}),r.jsx(eir,{deal:e}),r.jsxs(ii,{defaultValue:"tasks",className:"w-full",children:[r.jsxs(si,{className:"w-full grid grid-cols-3",children:[r.jsxs(Kr,{value:"tasks",className:"gap-1",children:[r.jsx(Ri,{className:"h-4 w-4"}),"Tasks ",Te>0&&`(${ge}/${Te})`]}),r.jsxs(Kr,{value:"files",className:"gap-1",children:[r.jsx(kk,{className:"h-4 w-4"}),"Files ",_e>0&&`(${_e})`]}),r.jsxs(Kr,{value:"activity",className:"gap-1",children:[r.jsx(Pa,{className:"h-4 w-4"}),"Activity"]})]}),r.jsxs(hs,{value:"tasks",className:"mt-4 space-y-3",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{placeholder:"Add a new task...",value:B,onChange:Ie=>$(Ie.target.value),onKeyDown:Ie=>Ie.key==="Enter"&&ie()}),r.jsx(X,{onClick:ie,disabled:!B.trim(),children:r.jsx(gs,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"space-y-2",children:[d==null?void 0:d.map(Ie=>r.jsxs("div",{className:Vt("flex items-center gap-3 p-3 rounded-lg border transition-colors",Ie.is_completed?"bg-muted/50 border-border":"bg-background"),children:[r.jsx(Qo,{checked:Ie.is_completed,onCheckedChange:We=>de(Ie.id,!!We)}),r.jsx("span",{className:Vt("flex-1 text-sm",Ie.is_completed&&"line-through text-muted-foreground"),children:Ie.title}),Ie.due_date&&r.jsx("span",{className:"text-xs text-muted-foreground",children:Xr(new Date(Ie.due_date),"MMM d")})]},Ie.id)),(d==null?void 0:d.length)===0&&r.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No tasks yet. Add one above!"})]})]}),r.jsxs(hs,{value:"files",className:"mt-4 space-y-3",children:[r.jsx("input",{type:"file",ref:I,className:"hidden",multiple:!0,onChange:Ze,accept:".pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.webp,.gif,.txt,.csv"}),r.jsxs(X,{variant:"outline",className:"w-full border-dashed",onClick:()=>{var Ie;return(Ie=I.current)==null?void 0:Ie.click()},disabled:K,children:[K?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(Xi,{className:"h-4 w-4 mr-2"}),K?"Uploading...":"Upload Files"]}),r.jsxs("div",{className:"space-y-2",children:[k==null?void 0:k.map(Ie=>{const We=Me(Ie.file_type);return r.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-background",children:[r.jsx("div",{className:"w-8 h-8 rounded bg-muted flex items-center justify-center shrink-0",children:r.jsx(We,{className:"h-4 w-4 text-muted-foreground"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:Ie.file_name}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[ve(Ie.file_size)," · ",Xr(new Date(Ie.created_at),"MMM d, yyyy")]})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(xN,{children:r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Ie.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>C.mutate({fileId:Ie.id,visible:!Ie.visible_on_portal,dealId:e.id}),children:Ie.visible_on_portal?r.jsx(Ii,{className:"h-4 w-4"}):r.jsx(Lf,{className:"h-4 w-4"})})}),r.jsx(dh,{side:"top",children:Ie.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Le(Ie.storage_path,Ie.file_name),children:r.jsx(Fi,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Ae(Ie.id,Ie.storage_path),children:r.jsx(Xs,{className:"h-4 w-4"})})]})]},Ie.id)}),(k==null?void 0:k.length)===0&&r.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No files yet. Upload contracts, disclosures, or other documents."})]})]}),r.jsxs(hs,{value:"activity",className:"mt-4 space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(qs,{placeholder:"Add a note...",value:R,onChange:Ie=>D(Ie.target.value),rows:2}),r.jsxs(X,{onClick:pe,disabled:!R.trim(),size:"sm",className:"w-full",children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),r.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Ie=>{const We=rir[Ie.activity_type]||Pa;return r.jsxs("div",{className:"flex gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center shrink-0",children:r.jsx(We,{className:"h-4 w-4 text-muted-foreground"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium",children:Ie.title}),Ie.description&&r.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Ie.description}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:gu(new Date(Ie.created_at),{addSuffix:!0})})]})]},Ie.id)}),(l==null?void 0:l.length)===0&&r.jsx("p",{className:"text-center text-muted-foreground text-sm py-4",children:"No activity yet"})]})]})]})]})})]})}),r.jsx($c,{open:q,onOpenChange:W,children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Delete Deal?"}),r.jsxs(bc,{children:['This will permanently delete "',e.deal_name,'" and all associated data. This action cannot be undone.']})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:ce,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function nir({open:e,onOpenChange:t,deal:s,onComplete:n}){const a=Vie(),o=oZe(),{data:l}=Uie(),{data:i}=gg(),[d,m]=A.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:Xr(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});A.useEffect(()=>{if(s&&e){const v=s.deal_type==="seller"?"seller":"buyer",_=s.expected_price||0,k=s.commission_percentage||3,w=s.expected_commission||_*k/100;m({property_address:s.property_address||s.deal_name||"",city:s.city||"",state:s.state||"",zip:s.zip_code||"",transaction_type:v,close_date:s.actual_close_date||s.target_close_date||Xr(new Date,"yyyy-MM-dd"),sale_price:_,commission_amount:w,lead_source_id:"",client_type_id:"",notes:s.notes||""})}},[s,e]);const p=async v=>{if(v.preventDefault(),!!s)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:s.contact_id||null,notes:d.notes||null,is_win:!0});await o.mutateAsync({id:s.id,scorecard_transaction_id:_.id,actual_close_date:d.close_date}),we.success("Deal added to Scorecard! 🎉"),t(!1),n==null||n()}catch(_){console.error("Error syncing to scorecard:",_),we.error("Failed to add to scorecard")}},g=v=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0}).format(v);return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{className:"space-y-3",children:[r.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:r.jsx(go,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),r.jsx(Fr,{className:"text-center text-xl",children:"Congratulations on Closing! 🎉"}),r.jsx(Zs,{className:"text-center",children:"Review and confirm the details before adding this deal to your Scorecard."})]}),r.jsxs("form",{onSubmit:p,className:"space-y-4 mt-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{htmlFor:"property_address",className:"flex items-center gap-2",children:[r.jsx(Vn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),r.jsx(Ye,{id:"property_address",value:d.property_address,onChange:v=>m(_=>({..._,property_address:v.target.value})),placeholder:"123 Main St",required:!0})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"city",children:"City"}),r.jsx(Ye,{id:"city",value:d.city,onChange:v=>m(_=>({..._,city:v.target.value})),placeholder:"City"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"state",children:"State"}),r.jsx(Ye,{id:"state",value:d.state,onChange:v=>m(_=>({..._,state:v.target.value})),placeholder:"TX",maxLength:2})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"zip",children:"Zip"}),r.jsx(Ye,{id:"zip",value:d.zip,onChange:v=>m(_=>({..._,zip:v.target.value})),placeholder:"75001"})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Transaction Type *"}),r.jsxs(ds,{value:d.transaction_type,onValueChange:v=>m(_=>({..._,transaction_type:v})),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"buyer",children:"Buyer"}),r.jsx(Ut,{value:"seller",children:"Seller"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{htmlFor:"close_date",className:"flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4 text-muted-foreground"}),"Close Date *"]}),r.jsx(Ye,{id:"close_date",type:"date",value:d.close_date,onChange:v=>m(_=>({..._,close_date:v.target.value})),required:!0})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[r.jsx(Sd,{className:"h-4 w-4 text-muted-foreground"}),"Sale Price *"]}),r.jsx(Ye,{id:"sale_price",type:"number",value:d.sale_price||"",onChange:v=>m(_=>({..._,sale_price:Number(v.target.value)})),placeholder:"450000",required:!0,min:0}),d.sale_price>0&&r.jsx("p",{className:"text-xs text-muted-foreground",children:g(d.sale_price)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs(Ee,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[r.jsx(O4,{className:"h-4 w-4 text-muted-foreground"}),"GCI (Commission)"]}),r.jsx(Ye,{id:"commission_amount",type:"number",value:d.commission_amount||"",onChange:v=>m(_=>({..._,commission_amount:Number(v.target.value)})),placeholder:"13500",min:0}),d.commission_amount>0&&r.jsx("p",{className:"text-xs text-muted-foreground",children:g(d.commission_amount)})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Lead Source"}),r.jsxs(ds,{value:d.lead_source_id,onValueChange:v=>m(_=>({..._,lead_source_id:v})),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select source"})}),r.jsx(cs,{children:l==null?void 0:l.map(v=>r.jsx(Ut,{value:v.id,children:v.name},v.id))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Client Type"}),r.jsxs(ds,{value:d.client_type_id,onValueChange:v=>m(_=>({..._,client_type_id:v})),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select type"})}),r.jsx(cs,{children:i==null?void 0:i.map(v=>r.jsx(Ut,{value:v.id,children:v.name},v.id))})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"notes",children:"Notes"}),r.jsx(qs,{id:"notes",value:d.notes,onChange:v=>m(_=>({..._,notes:v.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),r.jsxs(Rn,{className:"gap-2 sm:gap-0 pt-4",children:[r.jsx(X,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Skip for now"}),r.jsx(X,{type:"submit",disabled:a.isPending||o.isPending,className:"bg-green-600 hover:bg-green-700",children:a.isPending?"Adding...":r.jsxs(r.Fragment,{children:["Add to Scorecard",r.jsx(Ki,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const air={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"}},LIe={urgent:0,high:1,medium:2,low:3};function iir({deals:e,stages:t,onDealClick:s,onStageChange:n}){const[a,o]=A.useState("target_close_date"),[l,i]=A.useState("asc"),d=_=>{a===_?i(k=>k==="asc"?"desc":"asc"):(o(_),i("asc"))},m=A.useMemo(()=>[...e].sort((_,k)=>{var S,T;let w=0;switch(a){case"deal_name":w=_.deal_name.localeCompare(k.deal_name);break;case"stage":{const C=((S=t.find(R=>R.id===_.stage_id))==null?void 0:S.sort_order)||0,I=((T=t.find(R=>R.id===k.stage_id))==null?void 0:T.sort_order)||0;w=C-I;break}case"expected_price":w=(_.expected_price||0)-(k.expected_price||0);break;case"expected_commission":w=(_.expected_commission||0)-(k.expected_commission||0);break;case"target_close_date":{const C=_.target_close_date?new Date(_.target_close_date).getTime():1/0,I=k.target_close_date?new Date(k.target_close_date).getTime():1/0;w=C-I;break}case"priority":w=LIe[_.priority]-LIe[k.priority];break}return l==="asc"?w:-w}),[e,t,a,l]),p=_=>_?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_):"—",g=_=>_?t.find(k=>k.id===_):null,v=({field:_,children:k})=>r.jsxs(X,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>d(_),children:[k,a===_?l==="asc"?r.jsx(Pf,{className:"ml-2 h-4 w-4"}):r.jsx(Ly,{className:"ml-2 h-4 w-4"}):r.jsx(eg,{className:"ml-2 h-4 w-4 opacity-50"})]});return e.length===0?r.jsx("div",{className:"text-center py-16",children:r.jsx("p",{className:"text-muted-foreground",children:"No deals to display"})}):r.jsx("div",{className:"border rounded-lg overflow-hidden",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{className:"bg-muted/50",children:[r.jsx(Mt,{className:"w-[250px]",children:r.jsx(v,{field:"deal_name",children:"Deal Name"})}),r.jsx(Mt,{className:"w-[150px]",children:r.jsx(v,{field:"stage",children:"Stage"})}),r.jsx(Mt,{className:"w-[100px]",children:"Type"}),r.jsx(Mt,{className:"w-[120px]",children:r.jsx(v,{field:"expected_price",children:"Price"})}),r.jsx(Mt,{className:"w-[120px]",children:r.jsx(v,{field:"expected_commission",children:"GCI"})}),r.jsx(Mt,{className:"w-[130px]",children:r.jsx(v,{field:"target_close_date",children:"Close Date"})}),r.jsx(Mt,{className:"w-[100px]",children:r.jsx(v,{field:"priority",children:"Priority"})})]})}),r.jsx(Bn,{children:m.map(_=>{g(_.stage_id);const k=air[_.deal_type],w=_.target_close_date?jx(new Date(_.target_close_date),new Date):null,S=w!==null&&w<0,T=w!==null&&w<=7&&w>=0;return r.jsxs(Nr,{className:Vt("cursor-pointer hover:bg-muted/50 transition-colors",S&&"bg-red-50/50"),onClick:()=>s(_),children:[r.jsx(dt,{className:"font-medium",children:r.jsxs("div",{children:[r.jsx("p",{className:"truncate max-w-[230px]",children:_.deal_name}),_.contact&&r.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[_.contact.first_name," ",_.contact.last_name]})]})}),r.jsx(dt,{onClick:C=>C.stopPropagation(),children:r.jsx(uZe,{stages:t,currentStageId:_.stage_id||"",onStageSelect:(C,I)=>n(_.id,C,I)})}),r.jsx(dt,{children:r.jsx(_t,{variant:"outline",className:Vt("text-xs",k.color),children:k.label})}),r.jsx(dt,{children:r.jsx("span",{className:"font-medium",children:p(_.expected_price)})}),r.jsx(dt,{children:r.jsx("span",{className:"text-emerald-600",children:p(_.expected_commission)})}),r.jsx(dt,{children:_.target_close_date?r.jsxs("div",{className:Vt("flex items-center gap-1 text-sm",S&&"text-red-600",T&&!S&&"text-amber-600"),children:[S&&r.jsx(kl,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:Xr(new Date(_.target_close_date),"MMM d, yyyy")})]}):r.jsx("span",{className:"text-muted-foreground",children:"—"})}),r.jsx(dt,{children:r.jsx(_t,{variant:"outline",className:Vt("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 oir(){const e=fl();return Ht({queryKey:["all-client-portals",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("client_portals").select("*").eq("owner_user_id",e);if(s)throw s;return t||[]},enabled:!!e})}function lir({dealId:e,dealName:t,contactName:s,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const d=Bbe(),m=vle(),p=Oar(),g=Rar(),[v,_]=A.useState(!1),k=!!(n!=null&&n.archived_at),w=async()=>{_(!0);try{await d.mutateAsync({deal_id:e,visibility:"private",require_onboarding:!0}),we.success("Portal enabled!")}catch{we.error("Failed to create portal")}finally{_(!1)}},S=async D=>{if(n)try{await m.mutateAsync({id:n.id,is_enabled:D}),we.success(D?"Portal enabled":"Portal disabled")}catch{we.error("Failed to update portal")}},T=()=>{n&&(navigator.clipboard.writeText(n5(n.slug)),we.success("Link copied!"))},C=()=>{n&&window.open(n5(n.slug),"_blank")},I=async()=>{if(n)try{await p.mutateAsync(n.id),we.success("Portal archived")}catch{we.error("Failed to archive portal")}},R=async()=>{if(n)try{await g.mutateAsync(n.id),we.success("Portal restored")}catch{we.error("Failed to restore portal")}};return n?k?r.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg opacity-60 bg-muted/30",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:t}),r.jsx(_t,{variant:"outline",className:"text-[10px] bg-muted text-muted-foreground",children:"Archived"})]}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||s||"No client name"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsxs(X,{variant:"ghost",size:"sm",onClick:R,className:"text-xs gap-1",children:[r.jsx(dE,{className:"h-3.5 w-3.5"}),"Restore"]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>i(n),className:"text-xs gap-1 text-destructive hover:text-destructive",children:[r.jsx(Os,{className:"h-3.5 w-3.5"}),"Delete"]})]})]}):r.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:t}),r.jsx(_t,{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"})]}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:n.client_name||s||"No client name"})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:T,title:"Copy link",children:r.jsx(uo,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:C,title:"Preview",children:r.jsx(jn,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(n,t),title:"Invite client",children:r.jsx(ai,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>o(n.id),title:"Post update",children:r.jsx(D4,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a(n),title:"Settings",children:r.jsx(ld,{className:"h-3.5 w-3.5"})}),r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",children:r.jsx(Nf,{className:"h-3.5 w-3.5"})})}),r.jsx(vu,{align:"end",children:r.jsxs(Ba,{onClick:I,children:[r.jsx(_4,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),r.jsx(fn,{checked:n.is_enabled,onCheckedChange:S,className:"ml-1"})]})]}):r.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg border-dashed bg-muted/20",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:t}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s||"No contact"})]}),r.jsxs(X,{size:"sm",onClick:w,disabled:v,className:"shrink-0 ml-4",children:[v?r.jsx($r,{className:"h-3 w-3 animate-spin mr-1"}):r.jsx(bn,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function cir(){const{data:e,isLoading:t}=Fbe(),{data:s,isLoading:n}=oir(),[a,o]=A.useState(""),[l,i]=A.useState("all"),d=Far(),[m,p]=A.useState(null),[g,v]=A.useState(null),[_,k]=A.useState(null),[w,S]=A.useState(null),T=fl(),C=t||n,I=new Map;s==null||s.forEach(K=>I.set(K.deal_id,K));const D=[...(e||[]).filter(K=>{var pe,ie,de,ce,ge;const re=I.get(K.id),ae=a.toLowerCase(),oe=!ae||K.deal_name.toLowerCase().includes(ae)||((ie=(pe=K.contact)==null?void 0:pe.first_name)==null?void 0:ie.toLowerCase().includes(ae))||((ce=(de=K.contact)==null?void 0:de.last_name)==null?void 0:ce.toLowerCase().includes(ae))||((ge=re==null?void 0:re.client_name)==null?void 0:ge.toLowerCase().includes(ae));let se=!0;return l==="active"?se=!!(re!=null&&re.is_enabled)&&!(re!=null&&re.archived_at):l==="disabled"?se=!!re&&!re.is_enabled&&!re.archived_at:l==="archived"?se=!!(re!=null&&re.archived_at):l==="none"?se=!re:l==="all"&&(se=!(re!=null&&re.archived_at)||!re),oe&&se})].sort((K,re)=>{const ae=I.get(K.id),oe=I.get(re.id);if(ae!=null&&ae.archived_at&&!(oe!=null&&oe.archived_at))return 1;if(!(ae!=null&&ae.archived_at)&&(oe!=null&&oe.archived_at)||ae&&!oe)return-1;if(!ae&&oe)return 1;if(ae&&oe){if(ae.is_enabled&&!oe.is_enabled)return-1;if(!ae.is_enabled&&oe.is_enabled)return 1}return 0}),B=(s==null?void 0:s.filter(K=>!K.archived_at).length)||0,$=(s==null?void 0:s.filter(K=>K.is_enabled&&!K.archived_at).length)||0,q=(s==null?void 0:s.filter(K=>K.archived_at).length)||0,W=async()=>{if(w)try{await d.mutateAsync({id:w.id,dealId:w.deal_id}),we.success("Portal permanently deleted"),S(null)}catch{we.error("Failed to delete portal")}};return C?r.jsx("div",{className:"flex items-center justify-center py-16",children:r.jsx($r,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(bn,{className:"h-4 w-4 text-primary"}),r.jsxs("span",{className:"font-medium",children:[B," Portals"]})]}),r.jsxs("span",{className:"text-muted-foreground",children:[$," active · ",B-$," disabled",q>0&&` · ${q} archived`]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search deals or clients...",value:a,onChange:K=>o(K.target.value),className:"pl-9 pr-8"}),a&&r.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:r.jsx(Xs,{className:"h-4 w-4"})})]}),r.jsx("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:["all","active","disabled","archived","none"].map(K=>r.jsx(X,{variant:l===K?"secondary":"ghost",size:"sm",onClick:()=>i(K),className:"text-xs px-3 capitalize",children:K==="none"?"No Portal":K},K))})]}),r.jsx(To,{className:"h-[calc(100vh-22rem)]",children:r.jsxs("div",{className:"space-y-2 pb-4",children:[D.map(K=>{const re=I.get(K.id)||null,ae=K.contact?`${K.contact.first_name||""} ${K.contact.last_name||""}`.trim():"";return r.jsx(lir,{dealId:K.id,dealName:K.deal_name,contactName:ae,portal:re,onSettingsOpen:p,onComposerOpen:v,onInviteOpen:(oe,se)=>k({portal:oe,dealName:se}),onDeleteConfirm:S},K.id)}),D.length===0&&r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"w-12 h-12 mx-auto mb-3 bg-muted rounded-full flex items-center justify-center",children:r.jsx(bn,{className:"h-5 w-5 text-muted-foreground"})}),r.jsx("p",{className:"text-sm font-medium",children:"No matching deals"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Try adjusting your search or filters"})]})]})})]}),m&&r.jsx(mZe,{open:!!m,onOpenChange:K=>!K&&p(null),portal:m,dealOwnerId:T||""}),g&&r.jsx(fZe,{open:!!g,onOpenChange:K=>!K&&v(null),portalId:g}),_&&r.jsx(pZe,{open:!!_,onOpenChange:K=>!K&&k(null),portal:_.portal,dealName:_.dealName}),r.jsx($c,{open:!!w,onOpenChange:K=>!K&&S(null),children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Permanently delete this portal?"}),r.jsx(bc,{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."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:W,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class dir extends A.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,s){console.error("DealPipeline error:",t,s)}render(){return this.state.hasError?r.jsx(Ur,{children:r.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-4 text-center px-4",children:[r.jsx("div",{className:"w-16 h-16 bg-destructive/10 rounded-full flex items-center justify-center",children:r.jsx("span",{className:"text-2xl",children:"⚠️"})}),r.jsx("h2",{className:"text-xl font-semibold",children:"Something went wrong"}),r.jsx("p",{className:"text-muted-foreground max-w-md",children:"There was an error in the deal pipeline. Click below to try again."}),r.jsxs("div",{className:"flex gap-3",children:[r.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"}),r.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 uir(){var ct;const e=V3(),{data:t,isLoading:s}=Rbe(),{data:n,isLoading:a,refetch:o}=Fbe(),{data:l,isLoading:i}=rar(),d=aZe(),m=Znr(),[p,g]=A.useState("board"),[v,_]=A.useState(!1),[k,w]=A.useState(!1),[S,T]=A.useState(null),[C,I]=A.useState(null),[R,D]=A.useState(null),[B,$]=A.useState(null),[q,W]=A.useState(!1),[K,re]=A.useState(null),[ae,oe]=A.useState(""),[se,pe]=A.useState("all"),[ie,de]=A.useState(!1),[ce,ge]=A.useState(!1),[Te,_e]=A.useState(new Set),{data:ve}=o_(),{isTeamLeader:Me,teamMembers:Ze}=Tar(),Ae=A.useMemo(()=>Array.from(Te),[Te]),{data:Le}=Aar(Ae),Ue=A.useMemo(()=>{const Tt=new Map;return Ze.forEach(Ot=>Tt.set(Ot.id,{name:Ot.name,avatar_url:Ot.avatar_url,color:Ot.color})),Tt},[Ze]),Ve=A.useCallback(Tt=>Tt.owner_user_id&&Ue.get(Tt.owner_user_id)||null,[Ue]),Ie=A.useCallback(Tt=>{_e(Ot=>{const rr=new Set(Ot);return rr.has(Tt)?rr.delete(Tt):rr.add(Tt),rr})},[]);A.useEffect(()=>{!s&&t&&t.length===0&&d.mutate()},[s,t]);const[We,wt]=Cc(),Pe=A.useRef(!1);A.useEffect(()=>{const Tt=We.get("deal");if(Tt&&n&&n.length>0&&!Pe.current){const Ot=n.find(rr=>rr.id===Tt);Ot&&(Pe.current=!0,T(Ot),w(!0),We.delete("deal"),wt(We,{replace:!0}))}},[n,We]);const st=A.useMemo(()=>{if(!Le||!t)return[];const Tt=new Map(t.map(Ot=>[Ot.name,Ot.id]));return Le.map(Ot=>{const rr=Ot._stage_name&&Tt.get(Ot._stage_name)||null;return{...Ot,stage_id:rr||Ot.stage_id}})},[Le,t]),ue=A.useMemo(()=>[...n||[],...st],[n,st]),$e=ue.filter(Tt=>{var cr,Mr,As,Et,Pt,Sr;const Ot=ae.toLowerCase(),rr=!Ot||Tt.deal_name.toLowerCase().includes(Ot)||((Mr=(cr=Tt.contact)==null?void 0:cr.first_name)==null?void 0:Mr.toLowerCase().includes(Ot))||((Et=(As=Tt.contact)==null?void 0:As.last_name)==null?void 0:Et.toLowerCase().includes(Ot))||((Pt=Tt.property_address)==null?void 0:Pt.toLowerCase().includes(Ot))||((Sr=Tt.city)==null?void 0:Sr.toLowerCase().includes(Ot)),Lr=se==="all"||Tt.deal_type===se;return rr&&Lr}),tt=A.useMemo(()=>{if(!t)return l||null;const Tt=new Set(t.filter(cr=>cr.is_won_stage).map(cr=>cr.id)),Ot=new Set(t.filter(cr=>cr.is_lost_stage).map(cr=>cr.id)),rr=ue.filter(cr=>!Tt.has(cr.stage_id)&&!Ot.has(cr.stage_id)),Lr=ue.filter(cr=>Tt.has(cr.stage_id));return{totalDeals:ue.length,activeDeals:rr.length,wonDeals:Lr.length,pipelineValue:rr.reduce((cr,Mr)=>cr+(Mr.expected_price||0),0),expectedCommission:rr.reduce((cr,Mr)=>cr+(Mr.expected_commission||0),0),wonValue:Lr.reduce((cr,Mr)=>cr+(Mr.expected_price||0),0)}},[ue,t,l]),rt=Tt=>{T(Tt),w(!0)},je=Tt=>{I(Tt||null),T(null),_(!0)},it=Tt=>{T(Tt),w(!1),_(!0)},Se=(Tt,Ot)=>{D(Tt)},et=(Tt,Ot)=>{Tt.preventDefault(),Tt.dataTransfer.dropEffect="move",$(Ot)},Qe=async(Tt,Ot)=>{if(Tt.preventDefault(),$(null),!R)return;const rr=n==null?void 0:n.find(cr=>cr.id===R),Lr=t==null?void 0:t.find(cr=>cr.id===Ot);if(!rr||!Lr||rr.stage_id===Ot){D(null);return}try{if(await m.mutateAsync({dealId:R,stageId:Ot,stageName:Lr.name}),we.success(`Moved to ${Lr.name}`),Lr.is_won_stage&&!rr.scorecard_transaction_id){const cr={...rr,stage_id:Ot};re(cr),W(!0)}}catch{we.error("Failed to move deal")}D(null)},He=A.useCallback(async(Tt,Ot,rr)=>{const Lr=n==null?void 0:n.find(Mr=>Mr.id===Tt),cr=t==null?void 0:t.find(Mr=>Mr.id===Ot);if(!(!Lr||!cr||Lr.stage_id===Ot))try{if(await m.mutateAsync({dealId:Tt,stageId:Ot,stageName:rr}),we.success(`Moved to ${rr}`),cr.is_won_stage&&!Lr.scorecard_transaction_id){const Mr={...Lr,stage_id:Ot};re(Mr),W(!0)}}catch{we.error("Failed to move deal")}},[n,t,m]),ot=Tt=>$e.filter(Ot=>Ot.stage_id===Tt),ut=s||a,ft=e?"list":p;return r.jsxs(Ur,{children:[r.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)]",children:[r.jsxs("div",{className:"shrink-0 p-4 md:p-6 pb-0 space-y-4",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Deal Pipeline"}),r.jsx("p",{className:"text-muted-foreground text-sm",children:"Track and manage your active deals"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(X,{variant:"outline",size:"icon",onClick:()=>o(),className:"shrink-0",children:r.jsx(Yo,{className:"h-4 w-4"})}),!e&&r.jsx(xN,{children:r.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsxs(X,{variant:p==="board"?"secondary":"ghost",size:"sm",onClick:()=>g("board"),className:"px-3 gap-1.5",children:[r.jsx(Of,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline text-xs",children:"Board"})]})}),r.jsx(dh,{children:"Kanban board view"})]}),r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsxs(X,{variant:p==="list"?"secondary":"ghost",size:"sm",onClick:()=>g("list"),className:"px-3 gap-1.5",children:[r.jsx(Rf,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),r.jsx(dh,{children:"Grouped list view"})]}),r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsxs(X,{variant:p==="table"?"secondary":"ghost",size:"sm",onClick:()=>g("table"),className:"px-3 gap-1.5",children:[r.jsx(F4,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),r.jsx(dh,{children:"Sortable table view"})]}),r.jsxs(Gh,{children:[r.jsx(Kh,{asChild:!0,children:r.jsxs(X,{variant:p==="portals"?"secondary":"ghost",size:"sm",onClick:()=>g("portals"),className:"px-3 gap-1.5",children:[r.jsx(bn,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),r.jsx(dh,{children:"Client portal management"})]})]})}),ve&&!Me&&r.jsxs(X,{variant:"outline",onClick:()=>de(!0),children:[r.jsx(ws,{className:"h-4 w-4 mr-2"}),"Team"]}),r.jsxs(X,{onClick:()=>je(),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),ft!=="portals"&&r.jsx(Lar,{stats:tt,isLoading:i}),ft!=="portals"&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1 max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search deals, contacts, addresses...",value:ae,onChange:Tt=>oe(Tt.target.value),className:"pl-9 pr-8"}),ae&&r.jsx("button",{onClick:()=>oe(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:r.jsx(Xs,{className:"h-4 w-4"})})]}),r.jsxs(ds,{value:se,onValueChange:pe,children:[r.jsx(ls,{className:"w-[140px]",children:r.jsx(us,{placeholder:"All Types"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Types"}),r.jsx(Ut,{value:"buyer",children:"Buyer"}),r.jsx(Ut,{value:"seller",children:"Seller"}),r.jsx(Ut,{value:"dual",children:"Dual"}),r.jsx(Ut,{value:"referral",children:"Referral"}),r.jsx(Ut,{value:"lease",children:"Lease"})]})]}),(ae||se!=="all")&&r.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[$e.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Me&&!e&&Ze.length>0&&r.jsx(Mar,{members:Ze,enabledMembers:Te,onToggleMember:Ie,isOpen:ce,onToggleOpen:()=>ge(Tt=>!Tt)}),r.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:ut?r.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Tt=>r.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:r.jsx(pr,{className:"h-full rounded-xl"})},Tt))}):ft==="board"?r.jsxs(To,{className:"h-full -mx-4 md:-mx-6 px-4 md:px-6",children:[r.jsx("div",{className:"flex gap-4 h-full pb-4",children:t==null?void 0:t.map(Tt=>r.jsx(Par,{stage:Tt,deals:ot(Tt.id),onDealClick:rt,onAddDeal:je,onDragStart:Se,onDragOver:et,onDrop:Qe,isDragOver:B===Tt.id,isWonStage:Tt.is_won_stage,getOwnerInfo:Ve},Tt.id))}),r.jsx(Hve,{orientation:"horizontal"})]}):ft==="table"?r.jsx(To,{className:"h-full",children:r.jsx(iir,{deals:$e,stages:t||[],onDealClick:rt,onStageChange:He})}):ft==="portals"?r.jsx(cir,{}):r.jsx(To,{className:"h-full",children:r.jsxs("div",{className:"space-y-6",children:[t==null?void 0:t.map(Tt=>{const Ot=ot(Tt.id);return Ot.length===0?null:r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Tt.color}}),r.jsx("h3",{className:"font-semibold",children:Tt.name}),r.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",Ot.length,")"]})]}),r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:Ot.map(rr=>r.jsx(hZe,{deal:rr,onClick:()=>rt(rr),stages:t,onStageChange:He,showStagePicker:!0,isWonStage:Tt.is_won_stage,ownerInfo:Ve(rr)},rr.id))})]},Tt.id)}),(n==null?void 0:n.length)===0&&r.jsxs("div",{className:"text-center py-16",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:r.jsx(Of,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No deals yet"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Start tracking your opportunities by adding your first deal"}),r.jsxs(X,{onClick:()=>je(),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&$e.length===0&&r.jsxs("div",{className:"text-center py-16",children:[r.jsx("div",{className:"w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center",children:r.jsx(qn,{className:"h-8 w-8 text-muted-foreground"})}),r.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No matching deals"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filters"}),r.jsx(X,{variant:"outline",onClick:()=>{oe(""),pe("all")},children:"Clear Filters"})]})]})})})]})]}),r.jsx(Gar,{open:v,onOpenChange:_,deal:S,defaultStageId:C}),r.jsx(sir,{deal:S,open:k,onOpenChange:w,onEdit:it,isWonStage:S?(ct=t==null?void 0:t.find(Tt=>Tt.id===S.stage_id))==null?void 0:ct.is_won_stage:!1,onAddToScorecard:Tt=>{re(Tt),W(!0),w(!1)}}),r.jsx(nir,{open:q,onOpenChange:W,deal:K,onComplete:()=>{o(),re(null)}}),r.jsx(Car,{open:ie,onOpenChange:de})]})}function hir(){return r.jsx(dir,{children:r.jsx(uir,{})})}const tye=[{value:"video_intro",label:"Video Intro",icon:ma,description:"Add an intro video"},{value:"testimonials",label:"Testimonials",icon:kE,description:"Client testimonials carousel"},{value:"specialties",label:"Specialties",icon:px,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:Fm,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:Uc,description:"Links to your social profiles"}],mir=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],fir={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function gZe({cardId:e}){const{data:t,isLoading:s}=ugt(e),n=hgt(),a=mgt(),o=fgt(),[l,i]=A.useState(!1),[d,m]=A.useState(""),[p,g]=A.useState(null);if(s)return r.jsxs("div",{className:"space-y-3",children:[r.jsx(pr,{className:"h-16 w-full"}),r.jsx(pr,{className:"h-16 w-full"})]});const v=()=>{d&&n.mutate({card_id:e,block_type:d,sort_order:(t==null?void 0:t.length)||0,config:fir[d]||{}},{onSuccess:()=>{i(!1),m("")}})},_=C=>{a.mutate({id:C.id,is_visible:!C.is_visible})},k=(C,I)=>{if(!t)return;const R=t.findIndex($=>$.id===C.id),D=I==="up"?R-1:R+1;if(D<0||D>=t.length)return;const B=t[D];a.mutate({id:C.id,sort_order:B.sort_order}),a.mutate({id:B.id,sort_order:C.sort_order})},w=C=>{confirm("Remove this block from this card?")&&o.mutate(C.id)},S=(C,I)=>{a.mutate({id:C.id,config:I},{onSuccess:()=>g(null)})},T=C=>tye.find(I=>I.value===C);return r.jsxs("div",{className:"space-y-3",children:[!t||t.length===0?r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-muted-foreground mb-4 text-sm",children:"No blocks yet. Add a block to customize this card."}),r.jsxs(X,{size:"sm",onClick:()=>i(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}):r.jsxs(r.Fragment,{children:[t.map((C,I)=>{const R=T(C.block_type),D=(R==null?void 0:R.icon)||px;return r.jsx(ze,{className:C.is_visible?"":"opacity-50",children:r.jsx(qe,{className:"p-3",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Df,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),r.jsx(D,{className:"h-4 w-4 text-primary flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium text-xs",children:(R==null?void 0:R.label)||C.block_type}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:pir(C)})]}),r.jsxs("div",{className:"flex items-center gap-0.5",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>k(C,"up"),disabled:I===0,children:r.jsx(Pf,{className:"h-3 w-3"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>k(C,"down"),disabled:I===t.length-1,children:r.jsx(Ly,{className:"h-3 w-3"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C),children:C.is_visible?r.jsx(Ii,{className:"h-3 w-3"}):r.jsx(Lf,{className:"h-3 w-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>g(C),children:"Edit"}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>w(C),children:r.jsx(Os,{className:"h-3 w-3"})})]})]})})},C.id)}),r.jsxs(X,{variant:"outline",size:"sm",className:"w-full",onClick:()=>i(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-1"})," Add Block"]})]}),r.jsx(Ir,{open:l,onOpenChange:i,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Add Block"})}),r.jsx("div",{className:"grid gap-3",children:tye.map(C=>{const I=C.icon;return r.jsxs("button",{onClick:()=>m(C.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${d===C.value?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[r.jsx(I,{className:"h-5 w-5 text-primary flex-shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:C.label}),r.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]})]},C.value)})}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),r.jsx(X,{onClick:v,disabled:!d||n.isPending,children:"Add Block"})]})]})}),p&&r.jsx(gir,{block:p,onSave:C=>S(p,C),onClose:()=>g(null)})]})}function pir(e){var s;const t=e.config;switch(e.block_type){case"video_intro":return t.video_url?"Video configured":"No video set";case"testimonials":{const n=((s=t.testimonials)==null?void 0:s.length)||0;return`${n} testimonial${n!==1?"s":""}`}case"specialties":{const n=t.tags||[];return n.length?n.slice(0,3).join(", ")+(n.length>3?"...":""):"No tags"}case"custom_links":{const n=t.links||[];return`${n.length} link${n.length!==1?"s":""}`}case"social_media":{const n=t.platforms||[];return n.length?n.map(a=>a.platform).join(", "):"No platforms"}default:return""}}function gir({block:e,onSave:t,onClose:s}){const[n,a]=A.useState(e.config),o=tye.find(l=>l.value===e.block_type);return r.jsx(Ir,{open:!0,onOpenChange:s,children:r.jsxs(Er,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Edit ",o==null?void 0:o.label]})}),e.block_type==="video_intro"&&r.jsx(xir,{config:n,onChange:a,cardId:e.card_id}),e.block_type==="testimonials"&&r.jsx(yir,{config:n,onChange:a}),e.block_type==="specialties"&&r.jsx(vir,{config:n,onChange:a}),e.block_type==="custom_links"&&r.jsx(_ir,{config:n,onChange:a}),e.block_type==="social_media"&&r.jsx(bir,{config:n,onChange:a}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:s,children:"Cancel"}),r.jsx(X,{onClick:()=>t(n),children:"Save"})]})]})})}function xir({config:e,onChange:t,cardId:s}){var _,k;const[n,a]=A.useState(""),[o,l]=A.useState((_=e.video_url)!=null&&_.includes("youtube")||(k=e.video_url)!=null&&k.includes("youtu.be")?"youtube":"library"),{data:i}=Ht({queryKey:["card-owner",s],queryFn:async()=>{const{data:w}=await Y.from("agent_cards").select("user_id").eq("id",s).single();return w==null?void 0:w.user_id},enabled:!!s}),{data:d,isLoading:m}=Ht({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:w,error:S}=await Y.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(S)throw S;return w||[]},enabled:!!i}),p=(d==null?void 0:d.filter(w=>!n||(w.title||"").toLowerCase().includes(n.toLowerCase())))||[],g=e.bunny_video_id,v=w=>{var I;const S=(I=w.playback_url)==null?void 0:I.match(/\/(?:play|embed)\/(\d+)\//),C=`https://iframe.mediadelivery.net/embed/${S?S[1]:"570924"}/${w.bunny_video_id}?autoplay=false&responsive=true`;t({...e,video_url:C,bunny_video_id:w.bunny_video_id,video_source:"library"})};return r.jsx("div",{className:"space-y-4",children:r.jsxs(ii,{value:o,onValueChange:l,children:[r.jsxs(si,{className:"w-full",children:[r.jsx(Kr,{value:"library",className:"flex-1",children:"Video Library"}),r.jsx(Kr,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),r.jsxs(hs,{value:"library",className:"space-y-3 mt-3",children:[r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search videos...",value:n,onChange:w=>a(w.target.value),className:"pl-9"})]}),r.jsx(To,{className:"h-[240px]",children:m?r.jsxs("div",{className:"space-y-2",children:[r.jsx(pr,{className:"h-14 w-full"}),r.jsx(pr,{className:"h-14 w-full"})]}):p.length===0?r.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"}):r.jsx("div",{className:"space-y-1.5 pr-3",children:p.map(w=>r.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?r.jsx("img",{src:w.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:S=>{var T;S.currentTarget.style.display="none",(T=S.currentTarget.nextElementSibling)==null||T.classList.remove("hidden")}}):null,r.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${w.thumbnail_url?"hidden":""}`,children:r.jsx(ma,{className:"h-4 w-4 text-muted-foreground"})}),r.jsx("span",{className:"text-sm font-medium truncate flex-1",children:w.title||"Untitled Video"}),g===w.bunny_video_id&&r.jsx(mi,{className:"h-4 w-4 text-primary flex-shrink-0"})]},w.id))})})]}),r.jsx(hs,{value:"youtube",className:"space-y-3 mt-3",children:r.jsxs("div",{children:[r.jsx(Ee,{children:"YouTube URL"}),r.jsx(Ye,{placeholder:"https://www.youtube.com/watch?v=...",value:e.video_source==="youtube"&&e.video_url||"",onChange:w=>t({...e,video_url:w.target.value,bunny_video_id:null,video_source:"youtube"})}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Paste a YouTube video link"})]})})]})})}function yir({config:e,onChange:t}){const s=e.testimonials||[],n=(l,i,d)=>{const m=[...s];m[l]={...m[l],[i]:d},t({...e,testimonials:m})},a=()=>t({...e,testimonials:[...s,{name:"",quote:"",role:""}]}),o=l=>t({...e,testimonials:s.filter((i,d)=>d!==l)});return r.jsxs("div",{className:"space-y-4",children:[s.map((l,i)=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(Ee,{className:"text-xs font-medium",children:["Testimonial ",i+1]}),s.length>1&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>o(i),children:r.jsx(Os,{className:"h-3 w-3"})})]}),r.jsx(Ye,{placeholder:"Client name",value:l.name,onChange:d=>n(i,"name",d.target.value)}),r.jsx(Ye,{placeholder:"Role/title (optional)",value:l.role||"",onChange:d=>n(i,"role",d.target.value)}),r.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)),r.jsxs(X,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[r.jsx(gs,{className:"h-4 w-4 mr-1"})," Add Testimonial"]})]})}function vir({config:e,onChange:t}){const s=e.tags||[],[n,a]=A.useState(""),o=i=>{t({...e,tags:s.includes(i)?s.filter(d=>d!==i):[...s,i]})},l=()=>{n.trim()&&!s.includes(n.trim())&&(t({...e,tags:[...s,n.trim()]}),a(""))};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm mb-2 block",children:"Preset Specialties"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:mir.map(i=>r.jsx("button",{onClick:()=>o(i),className:`px-3 py-1.5 text-xs rounded-full border transition-colors ${s.includes(i)?"bg-primary text-primary-foreground border-primary":"bg-muted border-border hover:bg-muted/80"}`,children:i},i))})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm mb-2 block",children:"Custom Tag"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{placeholder:"Add your own...",value:n,onChange:i=>a(i.target.value),onKeyDown:i=>i.key==="Enter"&&(i.preventDefault(),l())}),r.jsx(X,{variant:"outline",size:"sm",onClick:l,children:"Add"})]})]}),s.length>0&&r.jsxs("div",{children:[r.jsxs(Ee,{className:"text-xs text-muted-foreground mb-1 block",children:["Selected (",s.length,")"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(i=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs bg-primary/10 text-primary rounded-full",children:[i,r.jsx("button",{onClick:()=>o(i),className:"hover:text-destructive",children:"×"})]},i))})]})]})}function _ir({config:e,onChange:t}){const s=e.links||[],n=(l,i,d)=>{const m=[...s];m[l]={...m[l],[i]:d},t({...e,links:m})},a=()=>t({...e,links:[...s,{label:"",url:""}]}),o=l=>t({...e,links:s.filter((i,d)=>d!==l)});return r.jsxs("div",{className:"space-y-3",children:[s.map((l,i)=>r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsxs("div",{className:"flex-1 space-y-2",children:[r.jsx(Ye,{placeholder:"Button label",value:l.label,onChange:d=>n(i,"label",d.target.value)}),r.jsx(Ye,{placeholder:"https://...",value:l.url,onChange:d=>n(i,"url",d.target.value)})]}),s.length>1&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 mt-1 text-destructive",onClick:()=>o(i),children:r.jsx(Os,{className:"h-3 w-3"})})]},i)),r.jsxs(X,{variant:"outline",size:"sm",onClick:a,className:"w-full",children:[r.jsx(gs,{className:"h-4 w-4 mr-1"})," Add Link"]})]})}const DIe=[{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 bir({config:e,onChange:t}){const s=e.platforms||[],n=d=>{s.find(m=>m.platform===d)||t({...e,platforms:[...s,{platform:d,url:""}]})},a=(d,m)=>{const p=[...s];p[d]={...p[d],url:m},t({...e,platforms:p})},o=d=>{t({...e,platforms:s.filter((m,p)=>p!==d)})},l=DIe.filter(d=>!s.find(m=>m.platform===d.value)),i=d=>{const m=ppe[d],p=DIe.find(g=>g.value===d);return{label:(p==null?void 0:p.label)||d,color:(m==null?void 0:m.color)||"#666",iconPath:m==null?void 0:m.icon}};return r.jsxs("div",{className:"space-y-4",children:[s.length>0&&r.jsx("div",{className:"space-y-3",children:s.map((d,m)=>{const p=i(d.platform);return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center flex-shrink-0 border",style:{borderColor:p.color+"30",backgroundColor:p.color+"10"},children:p.iconPath&&r.jsx("svg",{viewBox:"0 0 24 24",width:16,height:16,fill:p.color,children:r.jsx("path",{d:p.iconPath})})}),r.jsx("div",{className:"flex-1",children:r.jsx(Ye,{placeholder:`Your ${p.label} profile URL`,value:d.url,onChange:g=>a(m,g.target.value)})}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive flex-shrink-0",onClick:()=>o(m),children:r.jsx(Os,{className:"h-3.5 w-3.5"})})]},m)})}),l.length>0&&r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs text-muted-foreground mb-2 block",children:"Add a platform"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(d=>{const m=ppe[d.value];return r.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:[(m==null?void 0:m.icon)&&r.jsx("svg",{viewBox:"0 0 24 24",width:12,height:12,fill:m.color,children:r.jsx("path",{d:m.icon})}),d.label]},d.value)})})]}),s.length===0&&r.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Tap a platform above to add your social media profile."})]})}var wir=Object.defineProperty,wae=Object.getOwnPropertySymbols,xZe=Object.prototype.hasOwnProperty,yZe=Object.prototype.propertyIsEnumerable,OIe=(e,t,s)=>t in e?wir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,rye=(e,t)=>{for(var s in t||(t={}))xZe.call(t,s)&&OIe(e,s,t[s]);if(wae)for(var s of wae(t))yZe.call(t,s)&&OIe(e,s,t[s]);return e},sye=(e,t)=>{var s={};for(var n in e)xZe.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(e!=null&&wae)for(var n of wae(e))t.indexOf(n)<0&&yZe.call(e,n)&&(s[n]=e[n]);return s};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var fN;(e=>{const t=class Wi{constructor(d,m,p,g){if(this.version=d,this.errorCorrectionLevel=m,this.modules=[],this.isFunction=[],dWi.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 k=0;k7)throw new RangeError("Invalid value");let k,w;for(k=p;;k++){const I=Wi.getNumDataCodewords(k,m)*8,R=l.getTotalBits(d,k);if(R<=I){w=R;break}if(k>=g)throw new RangeError("Data too long")}for(const I of[Wi.Ecc.MEDIUM,Wi.Ecc.QUARTILE,Wi.Ecc.HIGH])_&&w<=Wi.getNumDataCodewords(k,I)*8&&(m=I);let S=[];for(const I of d){s(I.mode.modeBits,4,S),s(I.numChars,I.mode.numCharCountBits(k),S);for(const R of I.getData())S.push(R)}a(S.length==w);const T=Wi.getNumDataCodewords(k,m)*8;a(S.length<=T),s(0,Math.min(4,T-S.length),S),s(0,(8-S.length%8)%8,S),a(S.length%8==0);for(let I=236;S.lengthC[R>>>3]|=I<<7-(R&7)),new Wi(k,m,C,v)}getModule(d,m){return 0<=d&&d>>9)*1335;const g=(m<<10|p)^21522;a(g>>>15==0);for(let v=0;v<=5;v++)this.setFunctionModule(8,v,n(g,v));this.setFunctionModule(8,7,n(g,6)),this.setFunctionModule(8,8,n(g,7)),this.setFunctionModule(7,8,n(g,8));for(let v=9;v<15;v++)this.setFunctionModule(14-v,8,n(g,v));for(let v=0;v<8;v++)this.setFunctionModule(this.size-1-v,8,n(g,v));for(let v=8;v<15;v++)this.setFunctionModule(8,this.size-15+v,n(g,v));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let d=this.version;for(let p=0;p<12;p++)d=d<<1^(d>>>11)*7973;const m=this.version<<12|d;a(m>>>18==0);for(let p=0;p<18;p++){const g=n(m,p),v=this.size-11+p%3,_=Math.floor(p/3);this.setFunctionModule(v,_,g),this.setFunctionModule(_,v,g)}}drawFinderPattern(d,m){for(let p=-4;p<=4;p++)for(let g=-4;g<=4;g++){const v=Math.max(Math.abs(g),Math.abs(p)),_=d+g,k=m+p;0<=_&&_{(I!=w-v||D>=k)&&C.push(R[I])});return a(C.length==_),C}drawCodewords(d){if(d.length!=Math.floor(Wi.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let m=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let g=0;g>>3],7-(m&7)),m++)}}a(m==d.length*8)}applyMask(d){if(d<0||d>7)throw new RangeError("Mask value out of range");for(let m=0;m5&&d++):(this.finderPenaltyAddHistory(k,w),_||(d+=this.finderPenaltyCountPatterns(w)*Wi.PENALTY_N3),_=this.modules[v][S],k=1);d+=this.finderPenaltyTerminateAndCount(_,k,w)*Wi.PENALTY_N3}for(let v=0;v5&&d++):(this.finderPenaltyAddHistory(k,w),_||(d+=this.finderPenaltyCountPatterns(w)*Wi.PENALTY_N3),_=this.modules[S][v],k=1);d+=this.finderPenaltyTerminateAndCount(_,k,w)*Wi.PENALTY_N3}for(let v=0;v_+(k?1:0),m);const p=this.size*this.size,g=Math.ceil(Math.abs(m*20-p*10)/p)-1;return a(0<=g&&g<=9),d+=g*Wi.PENALTY_N4,a(0<=d&&d<=2568888),d}getAlignmentPatternPositions(){if(this.version==1)return[];{const d=Math.floor(this.version/7)+2,m=this.version==32?26:Math.ceil((this.version*4+4)/(d*2-2))*2;let p=[6];for(let g=this.size-7;p.lengthWi.MAX_VERSION)throw new RangeError("Version number out of range");let m=(16*d+128)*d+64;if(d>=2){const p=Math.floor(d/7)+2;m-=(25*p-10)*p-55,d>=7&&(m-=36)}return a(208<=m&&m<=29648),m}static getNumDataCodewords(d,m){return Math.floor(Wi.getNumRawDataModules(d)/8)-Wi.ECC_CODEWORDS_PER_BLOCK[m.ordinal][d]*Wi.NUM_ERROR_CORRECTION_BLOCKS[m.ordinal][d]}static reedSolomonComputeDivisor(d){if(d<1||d>255)throw new RangeError("Degree out of range");let m=[];for(let g=0;g0);for(const g of d){const v=g^p.shift();p.push(0),m.forEach((_,k)=>p[k]^=Wi.reedSolomonMultiply(_,v))}return p}static reedSolomonMultiply(d,m){if(d>>>8||m>>>8)throw new RangeError("Byte out of range");let p=0;for(let g=7;g>=0;g--)p=p<<1^(p>>>7)*285,p^=(m>>>g&1)*d;return a(p>>>8==0),p}finderPenaltyCountPatterns(d){const m=d[1];a(m<=this.size*3);const p=m>0&&d[2]==m&&d[3]==m*3&&d[4]==m&&d[5]==m;return(p&&d[0]>=m*4&&d[6]>=m?1:0)+(p&&d[6]>=m*4&&d[0]>=m?1:0)}finderPenaltyTerminateAndCount(d,m,p){return d&&(this.finderPenaltyAddHistory(m,p),m=0),m+=this.size,this.finderPenaltyAddHistory(m,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(d,m){m[0]==0&&(d+=this.size),m.pop(),m.unshift(d)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.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]],t.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]],e.QrCode=t;function s(i,d,m){if(d<0||d>31||i>>>d)throw new RangeError("Value out of range");for(let p=d-1;p>=0;p--)m.push(i>>>p&1)}function n(i,d){return(i>>>d&1)!=0}function a(i){if(!i)throw new Error("Assertion error")}const o=class ic{constructor(d,m,p){if(this.mode=d,this.numChars=m,this.bitData=p,m<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(d){let m=[];for(const p of d)s(p,8,m);return new ic(ic.Mode.BYTE,d.length,m)}static makeNumeric(d){if(!ic.isNumeric(d))throw new RangeError("String contains non-numeric characters");let m=[];for(let p=0;p=1<{(t=>{const s=class{constructor(a,o){this.ordinal=a,this.formatBits=o}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),t.Ecc=s})(e.QrCode||(e.QrCode={}))})(fN||(fN={}));(e=>{(t=>{const s=class{constructor(a,o){this.modeBits=a,this.numBitsCharCount=o}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),t.Mode=s})(e.QrSegment||(e.QrSegment={}))})(fN||(fN={}));var a4=fN;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var jir={L:a4.QrCode.Ecc.LOW,M:a4.QrCode.Ecc.MEDIUM,Q:a4.QrCode.Ecc.QUARTILE,H:a4.QrCode.Ecc.HIGH},vZe=128,_Ze="L",bZe="#FFFFFF",wZe="#000000",jZe=!1,kZe=1,kir=4,Nir=0,Sir=.1;function NZe(e,t=0){const s=[];return e.forEach(function(n,a){let o=null;n.forEach(function(l,i){if(!l&&o!==null){s.push(`M${o+t} ${a+t}h${i-o}v1H${o+t}z`),o=null;return}if(i===n.length-1){if(!l)return;o===null?s.push(`M${i+t},${a+t} h1v1H${i+t}z`):s.push(`M${o+t},${a+t} h${i+1-o}v1H${o+t}z`);return}l&&o===null&&(o=i)})}),s.join("")}function SZe(e,t){return e.slice().map((s,n)=>n=t.y+t.h?s:s.map((a,o)=>o=t.x+t.w?a:!1))}function Cir(e,t,s,n){if(n==null)return null;const a=e.length+s*2,o=Math.floor(t*Sir),l=a/t,i=(n.width||o)*l,d=(n.height||o)*l,m=n.x==null?e.length/2-i/2:n.x*l,p=n.y==null?e.length/2-d/2:n.y*l,g=n.opacity==null?1:n.opacity;let v=null;if(n.excavate){let k=Math.floor(m),w=Math.floor(p),S=Math.ceil(i+m-k),T=Math.ceil(d+p-w);v={x:k,y:w,w:S,h:T}}const _=n.crossOrigin;return{x:m,y:p,h:d,w:i,excavation:v,opacity:g,crossOrigin:_}}function Mir(e,t){return t!=null?Math.max(Math.floor(t),0):e?kir:Nir}function CZe({value:e,level:t,minVersion:s,includeMargin:n,marginSize:a,imageSettings:o,size:l,boostLevel:i}){let d=lt.useMemo(()=>{const k=(Array.isArray(e)?e:[e]).reduce((w,S)=>(w.push(...a4.QrSegment.makeSegments(S)),w),[]);return a4.QrCode.encodeSegments(k,jir[t],s,void 0,void 0,i)},[e,t,s,i]);const{cells:m,margin:p,numCells:g,calculatedImageSettings:v}=lt.useMemo(()=>{let _=d.getModules();const k=Mir(n,a),w=_.length+k*2,S=Cir(_,l,k,o);return{cells:_,margin:k,numCells:w,calculatedImageSettings:S}},[d,l,o,n,a]);return{qrcode:d,margin:p,cells:m,numCells:g,calculatedImageSettings:v}}var Tir=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Air=lt.forwardRef(function(t,s){const n=t,{value:a,size:o=vZe,level:l=_Ze,bgColor:i=bZe,fgColor:d=wZe,includeMargin:m=jZe,minVersion:p=kZe,boostLevel:g,marginSize:v,imageSettings:_}=n,w=sye(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:S}=w,T=sye(w,["style"]),C=_==null?void 0:_.src,I=lt.useRef(null),R=lt.useRef(null),D=lt.useCallback(se=>{I.current=se,typeof s=="function"?s(se):s&&(s.current=se)},[s]),[B,$]=lt.useState(!1),{margin:q,cells:W,numCells:K,calculatedImageSettings:re}=CZe({value:a,level:l,minVersion:p,boostLevel:g,includeMargin:m,marginSize:v,imageSettings:_,size:o});lt.useEffect(()=>{if(I.current!=null){const se=I.current,pe=se.getContext("2d");if(!pe)return;let ie=W;const de=R.current,ce=re!=null&&de!==null&&de.complete&&de.naturalHeight!==0&&de.naturalWidth!==0;ce&&re.excavation!=null&&(ie=SZe(W,re.excavation));const ge=window.devicePixelRatio||1;se.height=se.width=o*ge;const Te=o/K*ge;pe.scale(Te,Te),pe.fillStyle=i,pe.fillRect(0,0,K,K),pe.fillStyle=d,Tir?pe.fill(new Path2D(NZe(ie,q))):W.forEach(function(_e,ve){_e.forEach(function(Me,Ze){Me&&pe.fillRect(Ze+q,ve+q,1,1)})}),re&&(pe.globalAlpha=re.opacity),ce&&pe.drawImage(de,re.x+q,re.y+q,re.w,re.h)}}),lt.useEffect(()=>{$(!1)},[C]);const ae=rye({height:o,width:o},S);let oe=null;return C!=null&&(oe=lt.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{$(!0)},ref:R,crossOrigin:re==null?void 0:re.crossOrigin})),lt.createElement(lt.Fragment,null,lt.createElement("canvas",rye({style:ae,height:o,width:o,ref:D,role:"img"},T)),oe)});Air.displayName="QRCodeCanvas";var $be=lt.forwardRef(function(t,s){const n=t,{value:a,size:o=vZe,level:l=_Ze,bgColor:i=bZe,fgColor:d=wZe,includeMargin:m=jZe,minVersion:p=kZe,boostLevel:g,title:v,marginSize:_,imageSettings:k}=n,w=sye(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:S,cells:T,numCells:C,calculatedImageSettings:I}=CZe({value:a,level:l,minVersion:p,boostLevel:g,includeMargin:m,marginSize:_,imageSettings:k,size:o});let R=T,D=null;k!=null&&I!=null&&(I.excavation!=null&&(R=SZe(T,I.excavation)),D=lt.createElement("image",{href:k.src,height:I.h,width:I.w,x:I.x+S,y:I.y+S,preserveAspectRatio:"none",opacity:I.opacity,crossOrigin:I.crossOrigin}));const B=NZe(R,S);return lt.createElement("svg",rye({height:o,width:o,viewBox:`0 0 ${C} ${C}`,ref:s,role:"img"},w),!!v&<.createElement("title",null,v),lt.createElement("path",{fill:i,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),lt.createElement("path",{fill:d,d:B,shapeRendering:"crispEdges"}),D)});$be.displayName="QRCodeSVG";function Eir({slug:e,agentName:t}){const s=A.useRef(null),n=`https://cards.relevelup.com/${e}`,a=A.useCallback(()=>{var g;const o=(g=s.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 m=new XMLSerializer().serializeToString(o),p=new Image;p.onload=()=>{d.fillStyle="#ffffff",d.fillRect(0,0,i,i),d.drawImage(p,0,0,i,i);const v=document.createElement("a");v.download=`${e}-qr-code.png`,v.href=l.toDataURL("image/png"),v.click(),we.success("QR code downloaded!")},p.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(m)))},[e]);return r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"QR Code"}),r.jsxs("div",{className:"flex items-start gap-4",children:[r.jsx("div",{ref:s,className:"bg-white p-3 rounded-lg border shadow-sm shrink-0",children:r.jsx($be,{value:n,size:120,level:"H",bgColor:"#ffffff",fgColor:"#000000"})}),r.jsxs("div",{className:"space-y-2 min-w-0",children:[r.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."}),r.jsxs(X,{variant:"outline",size:"sm",onClick:a,className:"gap-1.5",children:[r.jsx(Fi,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function tme(e){return{is_published:e.is_published,theme:e.theme,title:e.title||"",positioning_statement:e.positioning_statement||"",bio:e.bio||"",review_snippet:e.review_snippet||"",review_source_url:e.review_source_url||"",booking_url:e.booking_url||"",custom_cta_label:e.custom_cta_label||"",show_photo:e.show_photo,show_bio:e.show_bio,show_credentials:e.show_credentials,show_social_links:e.show_social_links,show_save_contact:e.show_save_contact,show_leave_review:e.show_leave_review,show_refer_friend:e.show_refer_friend,brokerage_display_name:e.brokerage_display_name||"",brokerage_logo_url:e.brokerage_logo_url||"",brokerage_logo_size:e.brokerage_logo_size||56,team_name:e.team_name||"",team_logo_url:e.team_logo_url||"",team_logo_size:e.team_logo_size||56,bold_theme_colors:e.bold_theme_colors||null,display_email:e.display_email||""}}function Iir(){const{user:e}=Gr(),{data:t,isLoading:s}=lgt(e==null?void 0:e.id),n=V3(),[a,o]=A.useState(null),l=A.useMemo(()=>a||(t?tme(t):null),[a,t]);if(s)return r.jsx(Ur,{children:r.jsxs("div",{className:"max-w-2xl mx-auto p-4 space-y-4",children:[r.jsx(pr,{className:"h-8 w-48"}),r.jsx(pr,{className:"h-32 w-full"}),r.jsx(pr,{className:"h-32 w-full"})]})});if(!t)return r.jsx(Ur,{children:r.jsx(Lir,{userId:e==null?void 0:e.id})});const i=l||tme(t),d=m=>{o(p=>{const g=p||tme(t);return typeof m=="function"?m(g):m})};return r.jsx(Ur,{children:r.jsxs("div",{className:"flex gap-6 items-start",children:[r.jsxs("div",{className:`${n?"w-full":"flex-1 min-w-0"} max-w-2xl p-4 space-y-6 animate-fade-in`,children:[r.jsx(Dir,{card:t}),r.jsx(zir,{card:t,form:i,setForm:d})]}),!n&&r.jsx("div",{className:"w-[400px] shrink-0","aria-hidden":"true"}),!n&&r.jsx("div",{className:"fixed right-8 top-[5.5rem] w-[400px] z-30",style:{height:"calc(100vh - 6.5rem)"},children:r.jsxs("div",{className:"rounded-xl border bg-muted/30 overflow-hidden h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b bg-card shrink-0",children:[r.jsx(jk,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm font-medium",children:"Live Preview"})]}),r.jsx("div",{className:"flex-1 overflow-y-auto",children:r.jsx(Pir,{card:t,form:i})})]})})]})})}function Pir({card:e,form:t}){const{data:s}=Ht({queryKey:["card-preview-profile",e.user_id],queryFn:async()=>{const{data:a}=await Y.from("profiles").select("name, email, phone, avatar_url, brokerage_id").eq("id",e.user_id).single();let o=(a==null?void 0:a.avatar_url)||null;if(!o){const{data:l}=await Y.storage.from("avatars").list(`${e.user_id}`);if(l&&l.length>0){const{data:i}=Y.storage.from("avatars").getPublicUrl(`${e.user_id}/${l[0].name}`);o=`${i.publicUrl}?t=${Date.now()}`}}return{...a,avatar_url:o}}}),n=A.useMemo(()=>({...e,is_published:t.is_published,theme:t.theme,title:t.title||null,positioning_statement:t.positioning_statement||null,bio:t.bio||null,review_snippet:t.review_snippet||null,review_source_url:t.review_source_url||null,booking_url:t.booking_url||null,custom_cta_label:t.custom_cta_label||null,custom_cta_url:e.custom_cta_url,show_photo:t.show_photo,show_bio:t.show_bio,show_video:e.show_video,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||null,brokerage_logo_url:t.brokerage_logo_url||null,brokerage_logo_size:t.brokerage_logo_size,team_name:t.team_name||null,team_logo_url:t.team_logo_url||null,team_logo_size:t.team_logo_size,display_email:t.display_email||null,social_links:e.social_links||[],profile:{name:(s==null?void 0:s.name)||null,email:t.display_email||(s==null?void 0:s.email)||null,phone:(s==null?void 0:s.phone)||null,brokerage_id:(s==null?void 0:s.brokerage_id)||null},brokerage_name:t.brokerage_display_name||null,avatar_url:(s==null?void 0:s.avatar_url)||null}),[e,t,s]);return r.jsx("div",{className:"transform scale-[0.85] origin-top",children:r.jsx(Sve,{card:n})})}function Lir({userId:e}){var d;const[t,s]=A.useState(""),n=i7e(),{data:a}=Ht({queryKey:["my-profile-for-card",e],queryFn:async()=>{if(!e)return null;const{data:m}=await Y.from("profiles").select("name").eq("id",e).single();return m},enabled:!!e}),o=((d=a==null?void 0:a.name)==null?void 0:d.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",l=()=>{if(!e)return;const m=(t.trim()||o).toLowerCase().replace(/[^a-z0-9-]/g,"-");if(!m){we.error("Please enter a URL slug for your card");return}n.mutate({user_id:e,slug:m,is_published:!0},{onSuccess:()=>we.success("Your digital card has been created!")})},i=[{icon:ux,title:"Shareable Link",desc:"One link that works everywhere"},{icon:gx,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Ou,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:id,title:"Fully Customizable",desc:"Themes, colors, and content blocks"}];return r.jsxs("div",{className:"max-w-2xl mx-auto p-4 animate-fade-in",children:[r.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:[r.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_30%_20%,rgba(255,255,255,0.15),transparent_50%)]"}),r.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(circle_at_80%_80%,rgba(0,0,0,0.1),transparent_50%)]"}),r.jsxs("div",{className:"relative z-10",children:[r.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:[r.jsx(bn,{className:"h-3.5 w-3.5"}),"New Feature"]}),r.jsx("h1",{className:"text-3xl md:text-4xl font-bold mb-3 tracking-tight",children:"Your Digital Business Card"}),r.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."})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-3 mb-8",children:i.map(m=>r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl border bg-card hover:shadow-md transition-shadow",children:[r.jsx("div",{className:"mt-0.5 p-2 rounded-lg bg-primary/10 shrink-0",children:r.jsx(m.icon,{className:"h-4 w-4 text-primary"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-sm",children:m.title}),r.jsx("p",{className:"text-xs text-muted-foreground",children:m.desc})]})]},m.title))}),r.jsxs(ze,{className:"shadow-lg border-2",children:[r.jsxs(Wt,{className:"text-center pb-2",children:[r.jsx(Zt,{className:"text-xl",children:"Set Up Your Card"}),r.jsx(Cs,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),r.jsxs(qe,{className:"p-6 pt-2 space-y-5",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Your Card URL"}),r.jsxs("div",{className:"flex items-center gap-0 mt-1.5",children:[r.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/"}),r.jsx(Ye,{value:t||o,onChange:m=>s(m.target.value),placeholder:"your-name",className:"rounded-l-none"})]})]}),r.jsxs(X,{onClick:l,disabled:n.isPending,className:"w-full h-11 text-base font-semibold",size:"lg",children:[r.jsx(bn,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function Dir({card:e}){const s=`https://cards.relevelup.com/${e.slug}`,n=()=>{navigator.clipboard.writeText(s),we.success("Card link copied!")};return r.jsx("div",{className:"rounded-xl border bg-card p-5",children:r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-xl font-bold",children:"My Digital Card"}),r.jsx(_t,{variant:e.is_published?"default":"secondary",className:"text-[10px] uppercase tracking-wider",children:e.is_published?"Live":"Draft"})]}),r.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[r.jsx(ux,{className:"h-3.5 w-3.5"}),"cards.relevelup.com/",e.slug]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:n,className:"gap-1.5",children:[r.jsx(uo,{className:"h-3.5 w-3.5"})," Copy Link"]}),r.jsx(X,{size:"sm",asChild:!0,className:"gap-1.5",children:r.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",children:[r.jsx(jn,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function Oir({userId:e}){const t=Rr(),s=A.useRef(null),[n,a]=A.useState(!1),[o,l]=A.useState(""),{data:i,isLoading:d}=Ht({queryKey:["card-editor-profile",e],queryFn:async()=>{const{data:re}=await Y.from("profiles").select("name, email, phone, avatar_url").eq("id",e).single();let ae=(re==null?void 0:re.avatar_url)||null;if(!ae){const{data:oe}=await Y.storage.from("avatars").list(`${e}`);if(oe&&oe.length>0){const{data:se}=Y.storage.from("avatars").getPublicUrl(`${e}/${oe[0].name}`);ae=`${se.publicUrl}?t=${Date.now()}`,await Y.from("profiles").update({avatar_url:ae}).eq("id",e)}}return{...re,avatar_url:ae}}}),[m,p]=A.useState(null),[g,v]=A.useState(null),[_,k]=A.useState(null),[w,S]=A.useState(!1),T=m??(i==null?void 0:i.name)??"",C=g??(i==null?void 0:i.phone)??"",I=_??(i==null?void 0:i.email)??"",R=i==null?void 0:i.avatar_url,D=((i==null?void 0:i.name)||"A").split(" ").map(re=>re[0]).join("").toUpperCase().slice(0,2),B=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),$=Qt({mutationFn:async re=>{const{error:ae}=await Y.from("profiles").update(re).eq("id",e);if(ae)throw ae},onSuccess:()=>{t.invalidateQueries({queryKey:["card-editor-profile",e]}),t.invalidateQueries({queryKey:["card-preview-profile",e]}),t.invalidateQueries({queryKey:["agent-card-user"]}),we.success("Profile updated!")},onError:()=>we.error("Failed to update profile")}),q=()=>{const re={};if(m!==null&&m!==(i==null?void 0:i.name)&&(re.name=m),g!==null&&g!==(i==null?void 0:i.phone)&&(re.phone=g||null),_!==null&&_!==(i==null?void 0:i.email)&&(re.email=_),Object.keys(re).length===0){we.info("No changes to save");return}$.mutate(re)},W=re=>{var se;const ae=(se=re.target.files)==null?void 0:se[0];if(!ae)return;if(!ae.type.startsWith("image/")){we.error("Please select an image file");return}const oe=new FileReader;oe.onloadend=()=>{l(oe.result),a(!0)},oe.readAsDataURL(ae),re.target.value=""},K=async re=>{S(!0);try{const{data:ae}=await Y.storage.from("avatars").list(`${e}`);ae&&ae.length>0&&await Y.storage.from("avatars").remove(ae.map(de=>`${e}/${de.name}`));const oe=`${e}/avatar.jpg`,{error:se}=await Y.storage.from("avatars").upload(oe,re,{upsert:!0,contentType:"image/jpeg"});if(se)throw se;const{data:pe}=Y.storage.from("avatars").getPublicUrl(oe),ie=pe.publicUrl+"?t="+Date.now();await Y.from("profiles").update({avatar_url:ie}).eq("id",e),t.invalidateQueries({queryKey:["card-editor-profile",e]}),t.invalidateQueries({queryKey:["card-preview-profile",e]}),t.invalidateQueries({queryKey:["agent-card-user"]}),we.success("Photo updated!")}catch{we.error("Failed to upload photo")}finally{S(!1)}};return d?r.jsx(pr,{className:"h-32 w-full rounded-xl"}):r.jsxs(r.Fragment,{children:[r.jsx(ze,{className:B?"border-amber-300 dark:border-amber-700":"",children:r.jsxs(qe,{className:"p-5 space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Ee,{className:"text-sm font-semibold",children:"Profile Info"}),B&&r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[r.jsx(kl,{className:"h-3 w-3"}),"Missing info — complete below so your card looks great"]})]}),r.jsx("p",{className:"text-xs text-muted-foreground -mt-3",children:"This info shows on your digital card and updates your profile everywhere."}),r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"relative group cursor-pointer",onClick:()=>{var re;return(re=s.current)==null?void 0:re.click()},children:[r.jsxs(cn,{className:"h-16 w-16 ring-2 ring-muted",children:[r.jsx(xa,{src:R||void 0,alt:T}),r.jsx(dn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:D})]}),r.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:r.jsx(ng,{className:"h-5 w-5 text-white"})}),r.jsx("input",{ref:s,type:"file",accept:"image/*",className:"hidden",onChange:W})]}),r.jsxs("div",{className:"flex-1 space-y-0.5",children:[r.jsx("p",{className:"text-sm font-medium",children:w?"Uploading...":R?"Tap to change photo":"Add a profile photo"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"This photo appears on your card, profile, and community posts"})]})]}),r.jsxs("div",{className:"grid gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),r.jsx(Ye,{value:T,onChange:re=>p(re.target.value),placeholder:"Your full name",className:"h-10"})]}),r.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),r.jsx(Ye,{value:C,onChange:re=>v(re.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),r.jsx(Ye,{value:I,onChange:re=>k(re.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),r.jsx(X,{variant:"outline",size:"sm",onClick:q,disabled:$.isPending,className:"w-full",children:$.isPending?"Saving...":"Update Profile Info"})]})}),r.jsx(s_e,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:K,aspectRatio:1})]})}function Rir({form:e,setForm:t,userId:s}){const[n,a]=A.useState(null),[o,l]=A.useState(e.brokerage_logo_url?"logo":"name"),[i,d]=A.useState(e.team_logo_url?"logo":"name"),m=_=>{l(_),t(_==="name"?k=>({...k,brokerage_logo_url:""}):k=>({...k,brokerage_display_name:""}))},p=_=>{d(_),t(_==="name"?k=>({...k,team_logo_url:""}):k=>({...k,team_name:""}))},g=async(_,k)=>{var S;const w=(S=_.target.files)==null?void 0:S[0];if(w){if(!w.type.startsWith("image/")){we.error("Please select an image file");return}a(k);try{const T=w.name.split(".").pop()||"png",I=`${s}/${k==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${T}`,{error:R}=await Y.storage.from("card-logos").upload(I,w,{upsert:!0});if(R)throw R;const{data:D}=Y.storage.from("card-logos").getPublicUrl(I),B=D.publicUrl+"?t="+Date.now();t(k==="brokerage_logo_url"?$=>({...$,[k]:B,brokerage_display_name:""}):$=>({...$,[k]:B,team_name:""})),we.success("Logo uploaded!")}catch{we.error("Failed to upload logo")}finally{a(null),_.target.value=""}}},v=_=>{t(k=>({...k,[_]:""}))};return r.jsx(ze,{children:r.jsxs(qe,{className:"p-5 space-y-5",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-semibold",children:"Brokerage & Team Branding"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Choose either a name or a logo for each — not both."})]}),r.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[r.jsx(Ee,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{type:"button",variant:o==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>m("name"),children:"Use Name"}),r.jsx(X,{type:"button",variant:o==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>m("logo"),children:"Use Logo"})]}),o==="name"?r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),r.jsx(Ye,{value:e.brokerage_display_name,onChange:_=>t(k=>({...k,brokerage_display_name:_.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Logo"}),r.jsxs("div",{className:"flex items-center gap-3",children:[e.brokerage_logo_url?r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:e.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${e.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),r.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,r.jsxs("label",{className:"cursor-pointer",children:[r.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:[r.jsx(ng,{className:"h-3.5 w-3.5"}),n==="brokerage_logo_url"?"Uploading...":e.brokerage_logo_url?"Change":"Upload Logo"]}),r.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:_=>g(_,"brokerage_logo_url"),disabled:n!==null})]})]}),e.brokerage_logo_url&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.brokerage_logo_size||56,"px"]})]}),r.jsx(Xp,{value:[e.brokerage_logo_size||56],onValueChange:([_])=>t(k=>({...k,brokerage_logo_size:_})),min:24,max:120,step:4})]})]})]}),r.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[r.jsx(Ee,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(X,{type:"button",variant:i==="name"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("name"),children:"Use Name"}),r.jsx(X,{type:"button",variant:i==="logo"?"default":"outline",size:"sm",className:"text-xs",onClick:()=>p("logo"),children:"Use Logo"})]}),i==="name"?r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),r.jsx(Ye,{value:e.team_name,onChange:_=>t(k=>({...k,team_name:_.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Team Logo"}),r.jsxs("div",{className:"flex items-center gap-3",children:[e.team_logo_url?r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:e.team_logo_url,alt:"Team logo",style:{height:`${e.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),r.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,r.jsxs("label",{className:"cursor-pointer",children:[r.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:[r.jsx(ng,{className:"h-3.5 w-3.5"}),n==="team_logo_url"?"Uploading...":e.team_logo_url?"Change":"Upload Logo"]}),r.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:_=>g(_,"team_logo_url"),disabled:n!==null})]})]}),e.team_logo_url&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.team_logo_size||56,"px"]})]}),r.jsx(Xp,{value:[e.team_logo_size||56],onValueChange:([_])=>t(k=>({...k,team_logo_size:_})),min:24,max:120,step:4})]})]})]})]})})}function Fir({form:e,setForm:t}){const s={accent:"#ff5722",dark:"#1a1a2e",button:"#ff5722"},n=e.bold_theme_colors||s,a=(i,d)=>{t(m=>({...m,bold_theme_colors:{...s,...m.bold_theme_colors,[i]:d}}))},o=()=>{t(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 r.jsxs("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/30",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(Ee,{className:"text-sm font-semibold flex items-center gap-1.5",children:[r.jsx(id,{className:"h-4 w-4"})," Brand Colors"]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Customize colors to match your brand"})]}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-xs h-7",onClick:o,children:"Reset to Default"})]}),r.jsx("div",{className:"grid gap-3",children:l.map(({key:i,label:d,desc:m})=>r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("label",{className:"relative shrink-0",children:[r.jsx("input",{type:"color",value:n[i],onChange:p=>a(i,p.target.value),className:"sr-only"}),r.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]}})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium",children:d}),r.jsx("p",{className:"text-xs text-muted-foreground",children:m})]}),r.jsx(Ye,{value:n[i],onChange:p=>{const g=p.target.value;/^#[0-9a-fA-F]{0,6}$/.test(g)&&a(i,g)},className:"w-24 h-8 text-xs font-mono",placeholder:"#ff5722"})]},i))}),r.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Preview:"}),r.jsxs("div",{className:"flex gap-1",children:[r.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.accent}}),r.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.dark}}),r.jsx("div",{className:"h-6 w-12 rounded",style:{backgroundColor:n.button}})]})]})]})}function zir({card:e,form:t,setForm:s}){var w;const n=o7e(),a=Rr(),{data:o}=l7e(e.id),[l,i]=A.useState(e.slug),[d,m]=A.useState(!1),[p,g]=A.useState("idle"),v=A.useRef(JSON.stringify(t)),_=A.useRef(null);A.useEffect(()=>{const S=JSON.stringify(t);if(S!==v.current)return _.current&&clearTimeout(_.current),_.current=setTimeout(()=>{g("saving"),n.mutate({id:e.id,...t,is_published:!0,title:t.title||null,positioning_statement:t.positioning_statement||null,bio:t.bio||null,review_snippet:t.review_snippet||null,review_source_url:t.review_source_url||null,booking_url:t.booking_url||null,custom_cta_label:t.custom_cta_label||null,brokerage_display_name:t.brokerage_display_name||null,brokerage_logo_url:t.brokerage_logo_url||null,brokerage_logo_size:t.brokerage_logo_size,team_name:t.team_name||null,team_logo_url:t.team_logo_url||null,team_logo_size:t.team_logo_size,bold_theme_colors:t.bold_theme_colors||null,display_email:t.display_email||null},{onSuccess:()=>{v.current=S,g("saved"),setTimeout(()=>g("idle"),2e3)},onError:()=>g("idle")})},1500),()=>{_.current&&clearTimeout(_.current)}},[t]);const k=async()=>{const S=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!S){we.error("Please enter a valid URL");return}if(S===e.slug){we.info("No changes to save");return}m(!0);try{const{data:T}=await Y.from("agent_cards").select("id").eq("slug",S).neq("id",e.id).maybeSingle();if(T){we.error("This URL is already taken. Try another one.");return}const{error:C}=await Y.from("agent_cards").update({slug:S}).eq("id",e.id);if(C)throw C;i(S),a.invalidateQueries({queryKey:["agent-card"]}),we.success("Card address updated!")}catch{we.error("Failed to update card address")}finally{m(!1)}};return r.jsxs("div",{className:"space-y-4",children:[r.jsxs(ii,{defaultValue:"content",children:[r.jsxs(si,{className:"w-full h-11 p-1",children:[r.jsxs(Kr,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[r.jsx(Dm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),r.jsxs(Kr,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[r.jsx(Ii,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),r.jsxs(Kr,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[r.jsx(gx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),r.jsxs(Kr,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[r.jsx(Sk,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),r.jsxs(Kr,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[r.jsx(N1,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),r.jsxs(hs,{value:"content",className:"mt-4 space-y-4",children:[r.jsx(Oir,{userId:e.user_id}),r.jsx(Rir,{form:t,setForm:s,userId:e.user_id}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-5 space-y-5",children:[r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-sm font-semibold",children:"Card Status"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Toggle your card on or off"})]}),r.jsx(fn,{checked:t.is_published,onCheckedChange:S=>s(T=>({...T,is_published:S}))})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Card Address"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"flex flex-1",children:[r.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/"}),r.jsx(Ye,{value:l,onChange:S=>i(S.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"your-name",className:"rounded-l-none h-10"})]}),r.jsx(X,{variant:"outline",size:"sm",onClick:k,disabled:d||l===e.slug,className:"shrink-0",children:d?"Saving...":"Update"})]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"This is your unique card URL. Only letters, numbers, and dashes allowed."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Card Email (Override)"}),r.jsx(Ye,{value:t.display_email,onChange:S=>s(T=>({...T,display_email:S.target.value})),placeholder:"you@yourbusiness.com",className:"h-11",type:"email"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional — use a different email on your card instead of your sign-in email."})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Theme"}),r.jsxs(ds,{value:t.theme,onValueChange:S=>s(T=>({...T,theme:S})),children:[r.jsx(ls,{className:"h-11",children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"standard",children:"✨ Standard — Modern & Clean"}),r.jsx(Ut,{value:"luxury",children:"🌙 Luxury — Dark & Gold"}),r.jsx(Ut,{value:"bold",children:"🔥 Bold — Vibrant & Punchy"}),r.jsx(Ut,{value:"classic",children:"📋 Classic — Professional"})]})]})]}),t.theme==="bold"&&r.jsx(Fir,{form:t,setForm:s}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Title / Tagline"}),r.jsx(Ye,{value:t.title,onChange:S=>s(T=>({...T,title:S.target.value})),placeholder:"e.g. Luxury Real Estate Specialist",className:"h-11"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown below your name on the card"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Positioning Statement"}),r.jsx(Ye,{value:t.positioning_statement,onChange:S=>s(T=>({...T,positioning_statement:S.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Bio"}),r.jsx(qs,{value:t.bio,onChange:S=>s(T=>({...T,bio:S.target.value})),placeholder:"A short intro about you and what makes you different...",rows:3})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Review Snippet"}),r.jsx(Ye,{value:t.review_snippet,onChange:S=>s(T=>({...T,review_snippet:S.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Review Source URL"}),r.jsx(Ye,{value:t.review_source_url,onChange:S=>s(T=>({...T,review_source_url:S.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Booking URL"}),r.jsx(Ye,{value:t.booking_url,onChange:S=>s(T=>({...T,booking_url:S.target.value})),placeholder:"https://calendly.com/your-link",className:"h-11"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty to show a built-in lead form instead"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:"Custom CTA Label"}),r.jsx(Ye,{value:t.custom_cta_label,onChange:S=>s(T=>({...T,custom_cta_label:S.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),r.jsx(hs,{value:"sections",className:"mt-4",children:r.jsx(ze,{children:r.jsx(qe,{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:S,label:T,desc:C})=>r.jsxs("div",{className:"flex items-center justify-between py-4 first:pt-0 last:pb-0",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Ee,{className:"text-sm font-medium",children:T}),r.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),r.jsx(fn,{checked:t[S],onCheckedChange:I=>s(R=>({...R,[S]:I}))})]},S))})})}),r.jsx(hs,{value:"blocks",className:"mt-4",children:r.jsx(gZe,{cardId:e.id})}),r.jsx(hs,{value:"analytics",className:"mt-4",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"grid grid-cols-3 gap-3",children:[{label:"Views",value:(o==null?void 0:o.views)??0,icon:Ii,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:N1,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:Kd,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(S=>r.jsx(ze,{className:"overflow-hidden",children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("div",{className:`p-1.5 rounded-md ${S.color}`,children:r.jsx(S.icon,{className:"h-3.5 w-3.5"})}),r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:S.label})]}),r.jsx("div",{className:"text-2xl font-bold",children:S.value})]})},S.label))}),o&&o.leads.length>0&&r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsx(Zt,{className:"text-base",children:"Recent Leads"})}),r.jsx(qe,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(S=>r.jsxs("div",{className:"flex items-center justify-between text-sm p-3 rounded-lg bg-muted/50",children:[r.jsxs("div",{children:[r.jsx("span",{className:"font-medium",children:S.name}),S.phone&&r.jsx("span",{className:"text-muted-foreground ml-2",children:S.phone})]}),S.intent&&r.jsx(_t,{variant:"secondary",className:"text-xs",children:S.intent})]},S.id))})]}),(!o||o.leads.length===0)&&r.jsx(ze,{children:r.jsxs(qe,{className:"p-8 text-center",children:[r.jsx(N1,{className:"h-10 w-10 text-muted-foreground/40 mx-auto mb-3"}),r.jsx("p",{className:"font-medium text-muted-foreground",children:"No analytics data yet"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Share your card link to start tracking"})]})})]})}),r.jsx(hs,{value:"qrcode",className:"mt-4 space-y-4",children:r.jsx(ze,{children:r.jsx(qe,{className:"p-6",children:r.jsx(Eir,{slug:e.slug})})})})]}),r.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-sm text-muted-foreground",children:[p==="saving"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"h-2 w-2 rounded-full bg-amber-400 animate-pulse"})," Saving..."]}),p==="saved"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"h-2 w-2 rounded-full bg-green-500"})," All changes saved"]}),p==="idle"&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"})," Changes auto-save"]})]})]})}function Bir(){const{isAdmin:e}=Gr(),t=Rr(),[s,n]=A.useState(!1),[a,o]=A.useState(!1),[l,i]=A.useState(!1),{data:d,isLoading:m}=Ht({queryKey:["gmail-integration"],queryFn:async()=>{const{data:R,error:D}=await Y.from("gmail_integrations").select("*").maybeSingle();if(D)throw D;return R}}),{data:p}=Ht({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:R}}=await Y.auth.getUser();if(!R)return[];const{data:D,error:B}=await Y.from("social_accounts").select("*").eq("user_id",R.id).order("created_at",{ascending:!1});if(B)throw B;return D}}),g=async()=>{n(!0);try{const{data:R,error:D}=await Y.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(D)throw D;if(R!=null&&R.authUrl)window.location.href=R.authUrl;else throw new Error("Failed to get authorization URL")}catch(R){console.error("Gmail OAuth error:",R),we.error("Failed to start Gmail connection"),n(!1)}},v=async()=>{o(!0);try{const{data:R,error:D}=await Y.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(D)throw D;if(R!=null&&R.authUrl)window.location.href=R.authUrl;else throw new Error("Failed to get authorization URL")}catch(R){console.error("Meta OAuth error:",R),we.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},_=async()=>{i(!0);try{const{data:R,error:D}=await Y.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(D)throw D;if(R!=null&&R.authUrl)window.location.href=R.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(R){console.error("LinkedIn OAuth error:",R),we.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},k=Qt({mutationFn:async R=>{const{error:D}=await Y.from("gmail_integrations").delete().eq("id",R);if(D)throw D},onSuccess:()=>{t.invalidateQueries({queryKey:["gmail-integration"]}),we.success("Gmail disconnected")},onError:()=>{we.error("Failed to disconnect Gmail")}}),w=Qt({mutationFn:async R=>{const{error:D}=await Y.from("social_accounts").delete().eq("id",R);if(D)throw D},onSuccess:()=>{t.invalidateQueries({queryKey:["social-accounts"]}),we.success("Account disconnected")},onError:()=>{we.error("Failed to disconnect account")}}),S=!!(d!=null&&d.is_active),T=(p==null?void 0:p.filter(R=>R.platform==="facebook"))||[],C=(p==null?void 0:p.filter(R=>R.platform==="instagram"))||[],I=(p==null?void 0:p.filter(R=>R.platform==="linkedin"))||[];return r.jsx(Ur,{children:r.jsxs("div",{className:"max-w-3xl mx-auto space-y-6 animate-fade-in",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Integrations"}),r.jsx("p",{className:"text-muted-foreground",children:"Connect third-party services to supercharge your Agent OS workflow."})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 rounded-lg bg-destructive/10 flex items-center justify-center",children:r.jsx(Vs,{className:"h-5 w-5 text-destructive"})}),r.jsxs("div",{children:[r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:["Gmail",S&&r.jsx(_t,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),r.jsx(Cs,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),r.jsx(qe,{children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[r.jsx(ui,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),r.jsx("span",{children:"Send personalized emails from your Gmail account"})]}),r.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[r.jsx(ui,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),r.jsx("span",{children:"Automatically log emails as activity touchpoints"})]}),r.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[r.jsx(ui,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),r.jsx("span",{children:"Quick compose from any contact detail page"})]}),S?r.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 rounded-lg border",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:d.gmail_email}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Gmail account"})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect Gmail?"}),r.jsx(bc,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>k.mutate(d.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}):r.jsxs(X,{className:"mt-4",onClick:g,disabled:s||m,children:[s?r.jsx(Yo,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"Connect Gmail",r.jsx(Ki,{className:"h-4 w-4 ml-2"})]})]})})]}),r.jsxs(ze,{className:e?"":"opacity-70",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center",children:r.jsx(fu,{className:"h-5 w-5 text-blue-600"})}),r.jsxs("div",{children:[r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:["Facebook",e?T.length>0?r.jsx(_t,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:r.jsxs(_t,{variant:"secondary",className:"text-xs gap-1",children:[r.jsx(Du,{className:"h-3 w-3"}),"Coming Soon"]})]}),r.jsx(Cs,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),e&&r.jsxs(qe,{className:"space-y-3",children:[T.length>0&&r.jsx("div",{className:"space-y-2",children:T.map(R=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:R.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(fu,{className:"h-4 w-4"})})]}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:R.page_name||R.platform_username||"Facebook Page"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect Facebook?"}),r.jsx(bc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>w.mutate(R.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},R.id))}),r.jsxs(X,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?r.jsx(Yo,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4"}),"Connect Facebook Page"]})]})]}),r.jsxs(ze,{className:e?"":"opacity-70",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 rounded-lg bg-pink-500/10 flex items-center justify-center",children:r.jsx(Lu,{className:"h-5 w-5 text-pink-600"})}),r.jsxs("div",{children:[r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:["Instagram",e?C.length>0?r.jsx(_t,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:r.jsxs(_t,{variant:"secondary",className:"text-xs gap-1",children:[r.jsx(Du,{className:"h-3 w-3"}),"Coming Soon"]})]}),r.jsx(Cs,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),e&&r.jsxs(qe,{className:"space-y-3",children:[C.length>0&&r.jsx("div",{className:"space-y-2",children:C.map(R=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:R.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(Lu,{className:"h-4 w-4"})})]}),r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium text-sm",children:["@",R.platform_username||"Instagram Account"]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect Instagram?"}),r.jsx(bc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>w.mutate(R.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},R.id))}),r.jsxs(X,{onClick:v,disabled:a,variant:"outline",className:"gap-2",children:[a?r.jsx(Yo,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4"}),"Connect Instagram Business"]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Instagram Business accounts must be connected to a Facebook Page."})]})]}),r.jsxs(ze,{className:e?"":"opacity-70",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 rounded-lg bg-blue-700/10 flex items-center justify-center",children:r.jsx(zm,{className:"h-5 w-5 text-blue-700"})}),r.jsxs("div",{children:[r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",e?I.length>0?r.jsx(_t,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:r.jsxs(_t,{variant:"secondary",className:"text-xs gap-1",children:[r.jsx(Du,{className:"h-3 w-3"}),"Coming Soon"]})]}),r.jsx(Cs,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),e&&r.jsxs(qe,{className:"space-y-3",children:[I.length>0&&r.jsx("div",{className:"space-y-2",children:I.map(R=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-8 w-8",children:[r.jsx(xa,{src:R.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(zm,{className:"h-4 w-4"})})]}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:R.platform_username||"LinkedIn Account"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect LinkedIn?"}),r.jsx(bc,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>w.mutate(R.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},R.id))}),r.jsxs(X,{onClick:_,disabled:l,variant:"outline",className:"gap-2",children:[l?r.jsx(Yo,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4"}),"Connect LinkedIn"]})]})]})]})})}function $ir(){const[e]=Cc(),t=Ks(),[s,n]=A.useState("loading"),[a,o]=A.useState("Connecting your Gmail account...");return A.useEffect(()=>{(async()=>{const i=e.get("code"),d=e.get("error"),m=e.get("error_description"),p=e.get("state");if(d){n("error"),o(m||"Authorization was denied"),we.error("Connection failed: "+(m||d));return}if(!i){n("error"),o("No authorization code received"),we.error("No authorization code received");return}try{const{data:g,error:v}=await Y.functions.invoke("gmail-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Gmail connected successfully!"),we.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"),we.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[e]),r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"text-center",children:[s==="loading"&&r.jsx($r,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),s==="success"&&r.jsx(ui,{className:"h-12 w-12 mx-auto text-green-500"}),s==="error"&&r.jsx(Fc,{className:"h-12 w-12 mx-auto text-destructive"}),r.jsxs(Zt,{className:"mt-4",children:[s==="loading"&&"Connecting...",s==="success"&&"Connected!",s==="error"&&"Connection Failed"]}),r.jsx(Cs,{children:a})]}),r.jsx(qe,{className:"flex justify-center",children:s!=="loading"&&r.jsx(X,{onClick:()=>t("/mission-control/integrations"),children:s==="success"?"Back to Integrations":"Try Again"})})]})})}function Uir(){const e=Ks();return A.useEffect(()=>{const t=setTimeout(()=>{e("/mission-control/integrations",{replace:!0})},1500);return()=>clearTimeout(t)},[e]),r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background",children:r.jsxs("div",{className:"text-center space-y-4",children:[r.jsx("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Finishing Canva connection…"})]})})}function Vir(){const[e]=Cc(),t=Ks(),[s,n]=A.useState("loading"),[a,o]=A.useState("Processing your connection...");return A.useEffect(()=>{(async()=>{var g;const i=e.get("code"),d=e.get("error"),m=e.get("error_description"),p=e.get("state");if(d){n("error"),o(m||"Authorization was denied"),we.error("Connection failed: "+(m||d));return}if(!i){n("error"),o("No authorization code received"),we.error("No authorization code received");return}try{const{data:v,error:_}=await Y.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||0} account(s)!`),we.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"),we.error("Failed to connect: "+(v instanceof Error?v.message:"Unknown error"))}})()},[e]),r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"text-center",children:[s==="loading"&&r.jsx($r,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),s==="success"&&r.jsx(ui,{className:"h-12 w-12 mx-auto text-green-500"}),s==="error"&&r.jsx(Fc,{className:"h-12 w-12 mx-auto text-destructive"}),r.jsxs(Zt,{className:"mt-4",children:[s==="loading"&&"Connecting...",s==="success"&&"Connected!",s==="error"&&"Connection Failed"]}),r.jsx(Cs,{children:a})]}),r.jsx(qe,{className:"flex justify-center",children:s!=="loading"&&r.jsx(X,{onClick:()=>t("/mission-control/integrations"),children:s==="success"?"View Integrations":"Try Again"})})]})})}const MZe=new Date().getFullYear(),qir=Array.from({length:5},(e,t)=>MZe-t);function Hir(){const[e,t]=A.useState(MZe),s=Ks(),{data:n,isLoading:a}=nwt();return a?r.jsx(Ur,{title:"Scorecard Admin",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-8 w-64"}),r.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(o=>r.jsx(pr,{className:"h-24"},o))}),r.jsx(pr,{className:"h-96"})]})}):r.jsx(Ur,{title:"Scorecard Admin",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Scorecard Admin"}),r.jsx("p",{className:"text-muted-foreground",children:"View agent performance and scorecards"})]}),r.jsxs(ds,{value:String(e),onValueChange:o=>t(Number(o)),children:[r.jsx(ls,{className:"w-[120px]",children:r.jsx(us,{})}),r.jsx(cs,{children:qir.map(o=>r.jsx(Ut,{value:String(o),children:o},o))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(ws,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Agents Tracking"})]}),r.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Rc,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),r.jsx("p",{className:"text-2xl font-bold",children:(n==null?void 0:n.length)||0}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"with transactions"})]})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Agents with Scorecards"}),r.jsx(Cs,{children:"Click to view individual agent scorecards"})]}),r.jsx(qe,{children:!n||n.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(Rc,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No agents have added transactions yet"})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:n.map(o=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:o.name}),r.jsx(dt,{className:"text-muted-foreground",children:o.email}),r.jsx(dt,{className:"text-right",children:r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>s(`/admin/scorecard/${o.id}`),children:[r.jsx(Ii,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const TZe=new Date().getFullYear(),Wir=Array.from({length:10},(e,t)=>TZe-t);function Gir(){var v;const{userId:e}=Bl(),t=Ks(),[s,n]=A.useState(TZe),{data:a,isLoading:o}=Ht({queryKey:["agent-profile",e],queryFn:async()=>{const{data:_,error:k}=await Y.from("profiles").select("id, name, email").eq("id",e).single();if(k)throw k;return _},enabled:!!e}),{data:l,isLoading:i}=f1e(s,e),{yearStats:d,lifetimeStats:m,showCommission:p}=j9e(s,e),{data:g}=w9e(s,e);return o?r.jsx(Ur,{title:"Agent Scorecard",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-8 w-64"}),r.jsx("div",{className:"grid grid-cols-4 gap-4",children:[1,2,3,4].map(_=>r.jsx(pr,{className:"h-24"},_))})]})}):r.jsx(Ur,{title:`${a==null?void 0:a.name}'s Scorecard`,children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>t("/admin/scorecard"),children:r.jsx(gi,{className:"h-5 w-5"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:a==null?void 0:a.name}),r.jsx("p",{className:"text-muted-foreground",children:a==null?void 0:a.email})]})]}),r.jsxs(ds,{value:String(s),onValueChange:_=>n(Number(_)),children:[r.jsx(ls,{className:"w-[120px]",children:r.jsx(us,{})}),r.jsx(cs,{children:Wir.map(_=>r.jsx(Ut,{value:String(_),children:_},_))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Vn,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),r.jsx("p",{className:"text-2xl font-bold",children:d.totalTransactions}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[m.totalTransactions," lifetime"]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(ws,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Buyer/Seller"})]}),r.jsxs("p",{className:"text-2xl font-bold",children:[d.buyerCount,"/",d.sellerCount]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Sd,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),r.jsx("p",{className:"text-2xl font-bold",children:du(d.totalVolume,!0)})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(pu,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Avg Price"})]}),r.jsx("p",{className:"text-2xl font-bold",children:du(d.averagePrice,!0)})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Yl,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Top Source"})]}),r.jsx("p",{className:"text-lg font-bold truncate",children:((v=d.topLeadSource)==null?void 0:v.name)||"-"})]})})]}),g&&r.jsx(uHe,{goals:g,stats:d,year:s,showCommission:p}),r.jsxs(ii,{defaultValue:"transactions",className:"space-y-4",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"transactions",children:"Transactions"}),r.jsx(Kr,{value:"charts",children:"Charts"}),r.jsxs(Kr,{value:"map",children:[r.jsx(Yi,{className:"h-4 w-4 mr-1"}),"Map"]})]}),r.jsx(hs,{value:"transactions",children:r.jsx(dHe,{transactions:l||[],showCommission:p,isLoading:i})}),r.jsx(hs,{value:"charts",children:r.jsx(tZe,{stats:d,year:s})}),r.jsx(hs,{value:"map",children:r.jsx(rZe,{transactions:l||[],isLoading:i})})]})]})})}function Kir(){const e=Rr(),[t,s]=A.useState(""),[n,a]=A.useState("all");F7e();const{data:o,refetch:l}=Ht({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:C}=await Y.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(C==null?void 0:C.enabled)??!1}}),{data:i,isLoading:d}=Ht({queryKey:["admin-listings"],queryFn:async()=>{const{data:C,error:I}=await Y.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(I)throw I;return C}}),{data:m}=Ht({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:C}=await Y.from("listings").select("id, is_approved, status"),{data:I}=await Y.from("listing_shares").select("id"),{data:R}=await Y.from("listing_views").select("id");return{total:(C==null?void 0:C.length)||0,pending:(C==null?void 0:C.filter(D=>!D.is_approved).length)||0,active:(C==null?void 0:C.filter(D=>D.status==="active").length)||0,totalShares:(I==null?void 0:I.length)||0,totalViews:(R==null?void 0:R.length)||0}}}),p=Qt({mutationFn:async({id:C,approved:I})=>{const{error:R}=await Y.from("listings").update({is_approved:I}).eq("id",C);if(R)throw R},onSuccess:(C,{approved:I})=>{e.invalidateQueries({queryKey:["admin-listings"]}),e.invalidateQueries({queryKey:["admin-listing-stats"]}),we.success(I?"Listing approved":"Listing unapproved")}}),g=Qt({mutationFn:async({id:C,featured:I})=>{const{error:R}=await Y.from("listings").update({is_featured:I}).eq("id",C);if(R)throw R},onSuccess:(C,{featured:I})=>{e.invalidateQueries({queryKey:["admin-listings"]}),we.success(I?"Listing featured":"Listing unfeatured")}}),v=Qt({mutationFn:async C=>{const{error:I}=await Y.from("listings").delete().eq("id",C);if(I)throw I},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-listings"]}),e.invalidateQueries({queryKey:["admin-listing-stats"]}),we.success("Listing deleted")}}),_=Qt({mutationFn:async C=>{const{error:I}=await Y.from("feature_flags").update({enabled:C}).eq("key","listing_exchange_enabled");if(I)throw I},onSuccess:()=>{l(),we.success("Feature flag updated")}}),k=o??!1,w=i==null?void 0:i.filter(C=>{var D,B,$,q;const I=((D=C.city)==null?void 0:D.toLowerCase().includes(t.toLowerCase()))||(($=(B=C.agent)==null?void 0:B.name)==null?void 0:$.toLowerCase().includes(t.toLowerCase()))||((q=C.property_address)==null?void 0:q.toLowerCase().includes(t.toLowerCase())),R=n==="all"||n==="pending"&&!C.is_approved||n==="approved"&&C.is_approved;return I&&R}),S=C=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(C),T=C=>{const I={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 I[C]||I.active};return r.jsx(Ur,{title:"Listing Exchange Admin",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Listing Exchange"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage community listings"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:"Feature visible to agents"}),r.jsx(fn,{checked:k,onCheckedChange:C=>_.mutate(C)})]})]}),r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ni,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Listings"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:(m==null?void 0:m.total)||0})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(pu,{className:"h-4 w-4 text-green-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Active"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:(m==null?void 0:m.active)||0})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-4 w-4 text-amber-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Pending Review"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:(m==null?void 0:m.pending)||0})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Ii,{className:"h-4 w-4 text-blue-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Views"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:(m==null?void 0:m.totalViews)||0})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Uc,{className:"h-4 w-4 text-purple-500"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:"Total Shares"})]}),r.jsx("p",{className:"text-2xl font-bold mt-1",children:(m==null?void 0:m.totalShares)||0})]})})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by city, address, or agent...",value:t,onChange:C=>s(C.target.value),className:"pl-9"})]}),r.jsx(ii,{value:n,onValueChange:C=>a(C),children:r.jsxs(si,{children:[r.jsx(Kr,{value:"all",children:"All"}),r.jsx(Kr,{value:"pending",children:"Pending"}),r.jsx(Kr,{value:"approved",children:"Approved"})]})})]})})}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{children:["Listings (",(w==null?void 0:w.length)||0,")"]})}),r.jsx(qe,{children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Property"}),r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{children:"Price"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-center",children:"Approved"}),r.jsx(Mt,{className:"text-center",children:"Featured"}),r.jsx(Mt,{children:"Views"}),r.jsx(Mt,{children:"Shares"}),r.jsx(Mt,{children:"Date"}),r.jsx(Mt,{})]})}),r.jsx(Bn,{children:d?r.jsx(Nr,{children:r.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(w==null?void 0:w.length)===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):w==null?void 0:w.map(C=>{var I,R,D,B,$;return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[(R=(I=C.photos)==null?void 0:I[0])!=null&&R.photo_url?r.jsx("img",{src:C.photos[0].photo_url,alt:"",className:"w-12 h-12 object-cover rounded"}):r.jsx("div",{className:"w-12 h-12 bg-muted rounded flex items-center justify-center",children:r.jsx(Ni,{className:"h-5 w-5 text-muted-foreground"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:C.property_address||`${C.city}, ${C.state}`}),r.jsx("p",{className:"text-xs text-muted-foreground",children:(D=C.property_type)==null?void 0:D.replace("_"," ")})]})]})}),r.jsx(dt,{children:r.jsx("p",{className:"text-sm",children:((B=C.agent)==null?void 0:B.name)||"Unknown"})}),r.jsx(dt,{className:"font-medium",children:S(C.price)}),r.jsx(dt,{children:r.jsx(_t,{variant:"outline",className:T(C.status),children:($=C.status)==null?void 0:$.replace("_"," ")})}),r.jsx(dt,{className:"text-center",children:r.jsx(fn,{checked:C.is_approved??!1,onCheckedChange:q=>p.mutate({id:C.id,approved:q})})}),r.jsx(dt,{className:"text-center",children:r.jsx(fn,{checked:C.is_featured??!1,onCheckedChange:q=>g.mutate({id:C.id,featured:q})})}),r.jsx(dt,{children:C.view_count||0}),r.jsx(dt,{children:C.share_count||0}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:Xr(new Date(C.created_at),"MMM d, yyyy")}),r.jsx(dt,{children:r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",children:r.jsx(Nf,{className:"h-4 w-4"})})}),r.jsxs(vu,{align:"end",children:[r.jsxs(Ba,{onClick:()=>window.open(`/mission-control/listings/${C.id}`,"_blank"),children:[r.jsx(Ii,{className:"h-4 w-4 mr-2"}),"View Listing"]}),r.jsxs(Ba,{onClick:()=>g.mutate({id:C.id,featured:!C.is_featured}),children:[r.jsx(Dn,{className:"h-4 w-4 mr-2"}),C.is_featured?"Unfeature":"Feature"]}),r.jsxs(Ba,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&v.mutate(C.id)},children:[r.jsx(Xs,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},C.id)})})]})})})]})]})})}const Zir=()=>{var g,v;const[e,t]=A.useState(""),[s,n]=A.useState(null),{data:a,isLoading:o}=Ht({queryKey:["membership-reviews"],queryFn:async()=>{const{data:_,error:k}=await Y.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(k)throw k;const w=(_==null?void 0:_.map(C=>C.user_id))||[],{data:S}=await Y.from("profiles").select("id, name, email").in("id",w);return _==null?void 0:_.map(C=>({...C,profiles:(S==null?void 0:S.find(I=>I.id===C.user_id))||null}))}}),l=a==null?void 0:a.filter(_=>{var w,S,T,C,I;const k=e.toLowerCase();return((S=(w=_.profiles)==null?void 0:w.name)==null?void 0:S.toLowerCase().includes(k))||((C=(T=_.profiles)==null?void 0:T.email)==null?void 0:C.toLowerCase().includes(k))||((I=_.review_text)==null?void 0:I.toLowerCase().includes(k))}),i=a!=null&&a.length?(a.reduce((_,k)=>_+k.rating,0)/a.length).toFixed(1):"0.0",d=a==null?void 0:a.reduce((_,k)=>(_[k.rating]=(_[k.rating]||0)+1,_),{}),m=(a==null?void 0:a.filter(_=>_.posted_to_google).length)||0,p=_=>r.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(k=>r.jsx(Dn,{className:Vt("h-4 w-4",_>=k?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},k))});return r.jsx(Ur,{children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Membership Reviews",description:"View and manage feedback from LevelUp members"}),r.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"Total Reviews"}),r.jsx(Zt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"Average Rating"}),r.jsxs(Zt,{className:"flex items-center gap-2 text-3xl",children:[i,r.jsx(Dn,{className:"h-6 w-6 fill-yellow-400 text-yellow-400"})]})]})}),r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"5-Star Reviews"}),r.jsx(Zt,{className:"text-3xl",children:(d==null?void 0:d[5])||0})]})}),r.jsx(ze,{children:r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Cs,{children:"Posted to Google"}),r.jsxs(Zt,{className:"flex items-center gap-2 text-3xl",children:[m,r.jsx(jn,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),r.jsxs("div",{className:"relative max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name, email, or review...",value:e,onChange:_=>t(_.target.value),className:"pl-9"})]}),r.jsx(ze,{children:r.jsx(qe,{className:"p-0",children:r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Member"}),r.jsx(Mt,{children:"Rating"}),r.jsx(Mt,{className:"hidden md:table-cell",children:"Review"}),r.jsx(Mt,{children:"Google"}),r.jsx(Mt,{children:"Date"})]})}),r.jsx(Bn,{children:o?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?r.jsx(Nr,{children:r.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(_=>{var k,w;return r.jsxs(Nr,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(_),children:[r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:((k=_.profiles)==null?void 0:k.name)||"Unknown"}),r.jsx("div",{className:"text-sm text-muted-foreground",children:(w=_.profiles)==null?void 0:w.email})]})}),r.jsx(dt,{children:p(_.rating)}),r.jsx(dt,{className:"hidden md:table-cell max-w-xs",children:r.jsx("p",{className:"truncate text-sm text-muted-foreground",children:_.review_text||"-"})}),r.jsx(dt,{children:_.posted_to_google?r.jsx(_t,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):r.jsx(_t,{variant:"outline",children:"No"})}),r.jsx(dt,{className:"text-sm text-muted-foreground",children:Xr(new Date(_.created_at),"MMM d, yyyy")})]},_.id)})})]})})}),r.jsx(Ir,{open:!!s,onOpenChange:()=>n(null),children:r.jsxs(Er,{className:"max-w-lg",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Review Details"})}),s&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-start gap-4 p-4 bg-muted/50 rounded-lg",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("h3",{className:"font-semibold text-lg",children:((g=s.profiles)==null?void 0:g.name)||"Unknown Member"}),((v=s.profiles)==null?void 0:v.email)&&r.jsxs("a",{href:`mailto:${s.profiles.email}`,className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-primary",children:[r.jsx(Vs,{className:"h-3 w-3"}),s.profiles.email]})]}),r.jsxs("div",{className:"text-right",children:[p(s.rating),r.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[s.rating," out of 5 stars"]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-medium mb-2",children:"Review"}),r.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:s.review_text||"No written review provided."})]}),r.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(An,{className:"h-4 w-4"}),Xr(new Date(s.created_at),"MMMM d, yyyy 'at' h:mm a")]}),s.posted_to_google?r.jsxs(_t,{variant:"secondary",className:"bg-green-100 text-green-800",children:[r.jsx(jn,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):r.jsx(_t,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},Yir=[{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"}],Xir=Array.from({length:24},(e,t)=>({value:String(t),label:t===0?"12:00 AM":t<12?`${t}:00 AM`:t===12?"12:00 PM":`${t-12}:00 PM`}));function Qir(){const e=Rr(),{user:t}=Gr(),[s,n]=A.useState(!1),[a,o]=A.useState(!1),[l,i]=A.useState(!1),{data:d,isLoading:m}=Ht({queryKey:["weekly-digest-settings"],queryFn:async()=>{const{data:q,error:W}=await Y.from("weekly_digest_settings").select("*").single();if(W)throw W;return q}}),{data:p,isLoading:g}=Ht({queryKey:["weekly-digest-logs"],queryFn:async()=>{const{data:q,error:W}=await Y.from("weekly_digest_logs").select("*").order("sent_at",{ascending:!1}).limit(100);if(W)throw W;return q}}),{data:v}=Ht({queryKey:["digest-subscriber-count"],queryFn:async()=>{const{count:q,error:W}=await Y.from("profiles").select("id",{count:"exact",head:!0}).eq("digest_opt_out",!1).not("email","is",null);if(W)throw W;return q||0}}),{data:_,refetch:k}=Ht({queryKey:["digest-queue-status"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const[W,K,re,ae]=await Promise.all([Y.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","pending").gte("created_at",q.toISOString()),Y.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","processing").gte("created_at",q.toISOString()),Y.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","sent").gte("created_at",q.toISOString()),Y.from("weekly_digest_send_queue").select("id",{count:"exact",head:!0}).eq("status","failed").gte("created_at",q.toISOString())]);return{pending:W.count||0,processing:K.count||0,sent:re.count||0,failed:ae.count||0,total:(W.count||0)+(K.count||0)+(re.count||0)+(ae.count||0)}},refetchInterval:5e3});A.useEffect(()=>{if(_&&(_.pending>0||_.processing>0)){const q=setInterval(()=>{k(),e.invalidateQueries({queryKey:["weekly-digest-logs"]}),e.invalidateQueries({queryKey:["digest-today-failed-count"]}),e.invalidateQueries({queryKey:["digest-today-missing-count"]})},5e3);return()=>clearInterval(q)}},[_,k,e]);const{data:w=0}=Ht({queryKey:["digest-today-failed-count"],queryFn:async()=>{const q=new Date;q.setUTCHours(0,0,0,0);const{count:W,error:K}=await Y.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString());if(K)throw K;return W||0}}),S=Qt({mutationFn:async q=>{const{error:W}=await Y.from("weekly_digest_settings").update(q).eq("id",d==null?void 0:d.id);if(W)throw W},onSuccess:()=>{e.invalidateQueries({queryKey:["weekly-digest-settings"]}),we.success("Settings updated")},onError:q=>{we.error("Failed to update settings: "+q.message)}}),T=async()=>{n(!0);try{const{data:q,error:W}=await Y.functions.invoke("send-weekly-digest",{body:{manual:!0}});if(W)throw W;q.queued?we.success(`${q.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):q.sent!==void 0&&we.success(`Digest sent! ${q.sent} emails delivered, ${q.failed} failed`),k(),e.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(q){we.error("Failed to send digest: "+q.message)}finally{n(!1)}},C=async()=>{var q,W,K,re,ae,oe;if(!(t!=null&&t.email)){we.error("No email found for your account");return}o(!0);try{const{data:se,error:pe}=await Y.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:t.email}});if(pe)throw pe;const ie=se==null?void 0:se.resendId,de=se==null?void 0:se.resendDetails,ce=de==null?void 0:de.status,ge=((q=de==null?void 0:de.body)==null?void 0:q.status)||((K=(W=de==null?void 0:de.body)==null?void 0:W.data)==null?void 0:K.status),Te=((ae=(re=de==null?void 0:de.body)==null?void 0:re.error)==null?void 0:ae.message)||((oe=de==null?void 0:de.body)==null?void 0:oe.message);we.success(ie?`Preview accepted by email provider (id: ${ie})${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(se){we.error("Failed to send preview: "+se.message)}finally{o(!1)}},I=async()=>{i(!0);try{const{data:q,error:W}=await Y.functions.invoke("send-weekly-digest",{body:{retryFailed:!0}});if(W)throw W;q.queued===0||q.sent===0&&q.failed===0&&!q.queued?we.info("No failed emails to retry"):q.queued?we.success(`${q.queued} emails queued for retry!`):we.success(`Retry complete! ${q.sent} emails delivered, ${q.failed} failed`),k(),e.invalidateQueries({queryKey:["weekly-digest-logs"]}),e.invalidateQueries({queryKey:["digest-today-failed-count"]}),e.invalidateQueries({queryKey:["digest-today-missing-count"]})}catch(q){we.error("Failed to retry: "+q.message)}finally{i(!1)}},R=_!=null&&_.total?Math.round((_.sent+_.failed)/_.total*100):0,D=((_==null?void 0:_.pending)||0)>0||((_==null?void 0:_.processing)||0)>0,{data:B}=Ht({queryKey:["digest-delivery-stats"],queryFn:async()=>{var oe,se;const q=new Date;q.setUTCHours(0,0,0,0);const[W,K,re,ae]=await Promise.all([Y.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","sent").gte("sent_at",q.toISOString()),Y.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("delivery_status","failed").gte("sent_at",q.toISOString()),Y.from("weekly_digest_logs").select("id",{count:"exact",head:!0}).eq("has_agent_os_activity",!0).gte("sent_at",q.toISOString()),Y.from("weekly_digest_logs").select("sent_at").order("sent_at",{ascending:!1}).limit(1)]);return{totalSent:W.count||0,totalFailed:K.count||0,agentOsEngaged:re.count||0,lastSent:((se=(oe=ae.data)==null?void 0:oe[0])==null?void 0:se.sent_at)||null}},refetchInterval:D?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 m?r.jsx(Ur,{title:"Weekly Digest",description:"Manage automated weekly email digests",children:r.jsxs("div",{className:"animate-pulse space-y-4",children:[r.jsx("div",{className:"h-32 bg-muted rounded-lg"}),r.jsx("div",{className:"h-64 bg-muted rounded-lg"})]})}):r.jsx(Ur,{title:"Weekly Digest",description:"Configure and manage automated weekly email digests for members",children:r.jsxs(ii,{defaultValue:"settings",className:"space-y-6",children:[r.jsxs(si,{children:[r.jsxs(Kr,{value:"settings",className:"flex items-center gap-2",children:[r.jsx(ld,{className:"h-4 w-4"}),"Settings"]}),r.jsxs(Kr,{value:"stats",className:"flex items-center gap-2",children:[r.jsx(Rc,{className:"h-4 w-4"}),"Delivery Stats"]})]}),r.jsxs(hs,{value:"settings",className:"space-y-6",children:[D&&_&&r.jsx(ze,{className:"border-primary/50 bg-primary/5",children:r.jsxs(qe,{className:"pt-6",children:[r.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[r.jsx($r,{className:"h-5 w-5 animate-spin text-primary"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"font-medium",children:"Sending emails..."}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.sent.toLocaleString()," sent, ",_.pending.toLocaleString()," pending",_.failed>0&&`, ${_.failed} failed`]})]}),r.jsxs("span",{className:"text-sm font-medium",children:[R,"%"]})]}),r.jsx(zl,{value:R,className:"h-2"}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Processing ~80 emails per minute. Estimated time remaining: ~",Math.ceil(_.pending/80)," min"]})]})}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:r.jsx(ws,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:v}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribers"})]})]})})}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"p-3 rounded-full bg-emerald-500/10",children:r.jsx(Ri,{className:"h-5 w-5 text-emerald-500"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:$.totalSent}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"p-3 rounded-full bg-destructive/10",children:r.jsx(Fc,{className:"h-5 w-5 text-destructive"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:$.totalFailed}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),r.jsx(ze,{children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"p-3 rounded-full bg-primary/10",children:r.jsx(Pa,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-2xl font-bold",children:$.lastSent?Xr(new Date($.lastSent),"MMM d"):"Never"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Sent"})]})]})})})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Pa,{className:"h-5 w-5"}),"Schedule"]}),r.jsx(Cs,{children:"Configure when the digest is sent"})]}),r.jsxs(qe,{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Enable Weekly Digest"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),r.jsx(fn,{checked:d==null?void 0:d.is_enabled,onCheckedChange:q=>S.mutate({is_enabled:q})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Cron Frequency"}),r.jsxs(ds,{value:(d==null?void 0:d.cron_frequency)||"daily",onValueChange:q=>S.mutate({cron_frequency:q}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"daily",children:"Daily (runs once at selected time)"}),r.jsx(Ut,{value:"hourly",children:"Hourly (checks every hour)"})]})]}),r.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)."})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Day of Week"}),r.jsxs(ds,{value:String(d==null?void 0:d.send_day),onValueChange:q=>S.mutate({send_day:parseInt(q)}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:Yir.map(q=>r.jsx(Ut,{value:q.value,children:q.label},q.value))})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Time (UTC)"}),r.jsxs(ds,{value:String(d==null?void 0:d.send_hour),onValueChange:q=>S.mutate({send_hour:parseInt(q)}),disabled:(d==null?void 0:d.cron_frequency)==="daily",children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:Xir.map(q=>r.jsx(Ut,{value:q.value,children:q.label},q.value))})]})]})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{onClick:C,disabled:a,variant:"outline",className:"flex-1",children:[r.jsx(Ii,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),r.jsxs(X,{onClick:T,disabled:s,className:"flex-1",children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),s?"Sending...":"Send to All"]})]}),w>0&&r.jsxs(X,{onClick:I,disabled:l,variant:"outline",className:"w-full",children:[r.jsx(Yo,{className:`h-4 w-4 mr-2 ${l?"animate-spin":""}`}),l?"Retrying...":`Retry ${w} Failed`]})]})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ya,{className:"h-5 w-5"}),"Content Sections"]}),r.jsx(Cs,{children:"Choose what to include in the digest"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ee,{children:"New Resources"})]}),r.jsx(fn,{checked:d==null?void 0:d.include_new_resources,onCheckedChange:q=>S.mutate({include_new_resources:q})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ee,{children:"Community Highlights"})]}),r.jsx(fn,{checked:d==null?void 0:d.include_community_posts,onCheckedChange:q=>S.mutate({include_community_posts:q})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Rc,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ee,{children:"Agent OS Stats"})]}),r.jsx(fn,{checked:d==null?void 0:d.include_agent_os_stats,onCheckedChange:q=>S.mutate({include_agent_os_stats:q})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(An,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ee,{children:"Upcoming Events"})]}),r.jsx(fn,{checked:d==null?void 0:d.include_upcoming_events,onCheckedChange:q=>S.mutate({include_upcoming_events:q})})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Bf,{className:"h-4 w-4 text-muted-foreground"}),r.jsx(Ee,{children:"Goals Progress"})]}),r.jsx(fn,{checked:d==null?void 0:d.include_goals_progress,onCheckedChange:q=>S.mutate({include_goals_progress:q})})]})]})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Custom Introduction"}),r.jsx(Cs,{children:"Personalize the intro message (optional)"})]}),r.jsx(qe,{children:r.jsx(qs,{placeholder:"Here's what's new this week to help you grow your business...",value:(d==null?void 0:d.custom_intro_text)||"",onChange:q=>S.mutate({custom_intro_text:q.target.value||null}),rows:3})})]})]}),r.jsx(hs,{value:"stats",children:r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Vs,{className:"h-5 w-5"}),"Delivery History"]}),r.jsx(Cs,{children:"Recent digest emails sent to members"})]}),r.jsx(qe,{children:g?r.jsx("div",{className:"animate-pulse space-y-2",children:[1,2,3,4,5].map(q=>r.jsx("div",{className:"h-12 bg-muted rounded"},q))}):p&&p.length>0?r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Email"}),r.jsx(Mt,{children:"Sent At"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{children:"Resources"}),r.jsx(Mt,{children:"Agent OS"})]})}),r.jsx(Bn,{children:p.map(q=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:q.email_sent_to}),r.jsx(dt,{children:Xr(new Date(q.sent_at),"MMM d, yyyy h:mm a")}),r.jsx(dt,{children:r.jsx(_t,{variant:q.delivery_status==="sent"?"default":"destructive",children:q.delivery_status})}),r.jsx(dt,{children:q.resources_count}),r.jsx(dt,{children:q.has_agent_os_activity?r.jsx(_t,{variant:"secondary",children:"Active"}):r.jsx(_t,{variant:"outline",children:"Not Started"})})]},q.id))})]}):r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(Vs,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No digests sent yet"}),r.jsx("p",{className:"text-sm",children:"Send your first digest to see delivery stats"})]})})]})})]})})}const Jir={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 eor(){var ve,Me,Ze;const e=Rr(),[t,s]=A.useState(""),[n,a]=A.useState(null),[o,l]=A.useState(!1),[i,d]=A.useState(!1),[m,p]=A.useState(""),[g,v]=A.useState(""),[_,k]=A.useState(!0),[w,S]=A.useState(!1),[T,C]=A.useState(""),[I,R]=A.useState(null),{data:D,isLoading:B}=Ht({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Ae,error:Le}=await Y.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Le)throw Le;const Ue=(Ae==null?void 0:Ae.map(We=>We.user_id))||[],{data:Ve}=await Y.from("profiles").select("id, name, email").in("id",Ue),Ie=new Map((Ve==null?void 0:Ve.map(We=>[We.id,{name:We.name,email:We.email}]))||[]);return Ae==null?void 0:Ae.map(We=>({...We,profile:Ie.get(We.user_id)||null}))}}),{data:$}=Ht({queryKey:["all-profiles-for-points",D],queryFn:async()=>{const{data:Ae,error:Le}=await Y.from("profiles").select("id, name, email").order("name");if(Le)throw Le;return Ae}}),W=(($==null?void 0:$.filter(Ae=>!(D!=null&&D.some(Le=>Le.user_id===Ae.id))))||[]).filter(Ae=>{var Ue,Ve;if(!T)return!0;const Le=T.toLowerCase();return((Ue=Ae.name)==null?void 0:Ue.toLowerCase().includes(Le))||((Ve=Ae.email)==null?void 0:Ve.toLowerCase().includes(Le))}),{data:K,isLoading:re}=Ht({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ae,error:Le}=await Y.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Le)throw Le;return Ae},enabled:!!(n!=null&&n.user_id)&&i}),{data:ae}=Ht({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ae,error:Le}=await Y.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Le)throw Le;return Ae},enabled:!!(n!=null&&n.user_id)}),oe=Qt({mutationFn:async({userId:Ae,points:Le,reason:Ue})=>{const{error:Ve}=await Y.from("agent_points").insert({user_id:Ae,points:Le,reason:Ue});if(Ve)throw Ve;const{data:Ie}=await Y.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Ae).maybeSingle(),We=((Ie==null?void 0:Ie.total_points)||0)+Le,wt=((Ie==null?void 0:Ie.spendable_points)||0)+Le,{error:Pe}=await Y.from("agent_attendance_stats").upsert({user_id:Ae,total_points:Math.max(0,We),spendable_points:Math.max(0,wt),updated_at:new Date().toISOString()},{onConflict:"user_id"});if(Pe)throw Pe},onSuccess:()=>{e.invalidateQueries({queryKey:["admin-agent-points"]}),e.invalidateQueries({queryKey:["agent-point-history"]}),l(!1),p(""),v(""),we.success(_?"Points awarded successfully!":"Points deducted successfully!")},onError:Ae=>{console.error("Error modifying points:",Ae),we.error("Failed to modify points")}}),se=()=>{if(!n||!m||!g){we.error("Please fill in all fields");return}const Ae=parseInt(m);if(isNaN(Ae)||Ae<=0){we.error("Please enter a valid positive number");return}oe.mutate({userId:n.user_id,points:_?Ae:-Ae,reason:g})},pe=()=>{if(!I||!m||!g){we.error("Please fill in all fields");return}const Ae=parseInt(m);if(isNaN(Ae)||Ae<=0){we.error("Please enter a valid positive number");return}oe.mutate({userId:I.id,points:Ae,reason:g},{onSuccess:()=>{S(!1),R(null),C("")}})},ie=(Ae,Le)=>{a(Ae),k(Le),l(!0)},de=Ae=>{a(Ae),d(!0)},ce=D==null?void 0:D.filter(Ae=>{var Ie,We,wt,Pe;const Le=((We=(Ie=Ae.profile)==null?void 0:Ie.name)==null?void 0:We.toLowerCase())||"",Ue=((Pe=(wt=Ae.profile)==null?void 0:wt.email)==null?void 0:Pe.toLowerCase())||"",Ve=t.toLowerCase();return Le.includes(Ve)||Ue.includes(Ve)}),ge=(D==null?void 0:D.reduce((Ae,Le)=>Ae+Le.total_points,0))||0,Te=(D==null?void 0:D.length)||0,_e=Te>0?Math.round(ge/Te):0;return B?r.jsx(Ur,{title:"Agent Points",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-8 w-64"}),r.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,2,3].map(Ae=>r.jsx(pr,{className:"h-24"},Ae))}),r.jsx(pr,{className:"h-96"})]})}):r.jsx(Ur,{title:"Agent Points",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Agent Points Management"}),r.jsx("p",{className:"text-muted-foreground",children:"Track, view, and manage agent gamification points"})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(ws,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Total Agents"})]}),r.jsx("p",{className:"text-2xl font-bold",children:Te}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(go,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Total Points"})]}),r.jsx("p",{className:"text-2xl font-bold",children:ge.toLocaleString()}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(pu,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Average Points"})]}),r.jsx("p",{className:"text-2xl font-bold",children:_e}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"per agent"})]})})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[r.jsxs("div",{className:"relative max-w-sm w-full",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search agents...",value:t,onChange:Ae=>s(Ae.target.value),className:"pl-10"})]}),r.jsxs(X,{onClick:()=>S(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsx(Zt,{children:"Agent Leaderboard"}),r.jsx(Cs,{children:"All agents with their points, events, and streaks"})]}),r.jsx(qe,{children:!ce||ce.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(go,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No agents with points yet"})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{className:"w-12",children:"#"}),r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{className:"text-center",children:"Total Points"}),r.jsx(Mt,{className:"text-center",children:"Spendable"}),r.jsx(Mt,{className:"text-center",children:"Events"}),r.jsx(Mt,{className:"text-center",children:"Streak"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:ce.map((Ae,Le)=>{var Ue,Ve,Ie,We;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:Le<3?r.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Le===0?"bg-yellow-100 text-yellow-700":Le===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Le+1}):r.jsx("span",{className:"text-muted-foreground",children:Le+1})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(cn,{className:"h-8 w-8",children:r.jsx(dn,{children:((Ve=(Ue=Ae.profile)==null?void 0:Ue.name)==null?void 0:Ve.charAt(0))||"?"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:((Ie=Ae.profile)==null?void 0:Ie.name)||"Unknown"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:(We=Ae.profile)==null?void 0:We.email})]})]})}),r.jsx(dt,{className:"text-center",children:r.jsxs(_t,{variant:"secondary",className:"font-bold",children:[r.jsx(Dn,{className:"h-3 w-3 mr-1"}),Ae.total_points]})}),r.jsx(dt,{className:"text-center",children:r.jsxs(_t,{variant:"outline",className:"font-bold text-primary",children:[r.jsx(po,{className:"h-3 w-3 mr-1"}),Ae.spendable_points||0]})}),r.jsx(dt,{className:"text-center",children:r.jsxs("div",{className:"flex items-center justify-center gap-1",children:[r.jsx(An,{className:"h-3 w-3 text-muted-foreground"}),Ae.total_events_attended]})}),r.jsx(dt,{className:"text-center",children:r.jsxs("div",{className:"flex items-center justify-center gap-1",children:[r.jsx(Om,{className:"h-3 w-3 text-orange-500"}),Ae.current_streak]})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>ie(Ae,!0),title:"Award points",children:r.jsx(gs,{className:"h-4 w-4 text-green-600"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>ie(Ae,!1),title:"Deduct points",children:r.jsx(k1,{className:"h-4 w-4 text-red-600"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>de(Ae),title:"View history",children:r.jsx(C4,{className:"h-4 w-4"})})]})})]},Ae.user_id)})})]})})]}),r.jsx(Ir,{open:o,onOpenChange:l,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:_?"Award Points":"Deduct Points"}),r.jsxs(Zs,{children:[_?"Award":"Deduct"," points ",_?"to":"from"," ",((ve=n==null?void 0:n.profile)==null?void 0:ve.name)||"this agent"]})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"points",children:"Points Amount"}),r.jsx(Ye,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:m,onChange:Ae=>p(Ae.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"reason",children:"Reason"}),r.jsx(qs,{id:"reason",placeholder:"Enter reason for this adjustment...",value:g,onChange:Ae=>v(Ae.target.value)})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),r.jsx(X,{onClick:se,disabled:oe.isPending,className:_?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:oe.isPending?"Saving...":_?"Award Points":"Deduct Points"})]})]})}),r.jsx(Ir,{open:i,onOpenChange:d,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{children:["Point History: ",(Me=n==null?void 0:n.profile)==null?void 0:Me.name]}),r.jsx(Zs,{children:"View all point transactions and badges for this agent"})]}),r.jsxs(ii,{defaultValue:"history",className:"w-full",children:[r.jsxs(si,{className:"grid w-full grid-cols-2",children:[r.jsx(Kr,{value:"history",children:"Point History"}),r.jsx(Kr,{value:"badges",children:"Badges"})]}),r.jsx(hs,{value:"history",className:"mt-4",children:re?r.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ae=>r.jsx(pr,{className:"h-12"},Ae))}):!K||K.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(C4,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),r.jsx("p",{children:"No point history yet"})]}):r.jsx("div",{className:"max-h-80 overflow-y-auto space-y-2",children:K.map(Ae=>r.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"font-medium",children:Ae.reason}),r.jsx("p",{className:"text-xs text-muted-foreground",children:Xr(new Date(Ae.created_at),"MMM d, yyyy h:mm a")})]}),r.jsxs(_t,{variant:Ae.points>=0?"default":"destructive",className:Ae.points>=0?"bg-green-100 text-green-800":"",children:[Ae.points>=0?"+":"",Ae.points]})]},Ae.id))})}),r.jsx(hs,{value:"badges",className:"mt-4",children:!ae||ae.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(Yl,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),r.jsx("p",{children:"No badges earned yet"})]}):r.jsx("div",{className:"grid grid-cols-2 gap-3",children:ae.map(Ae=>r.jsxs("div",{className:`p-3 rounded-lg ${Jir[Ae.badge_type]||"bg-gray-100"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Yl,{className:"h-5 w-5"}),r.jsx("span",{className:"font-medium",children:Ae.badge_name})]}),Ae.badge_description&&r.jsx("p",{className:"text-xs mt-1 opacity-80",children:Ae.badge_description}),r.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",Xr(new Date(Ae.earned_at),"MMM d, yyyy")]})]},Ae.id))})})]})]})}),r.jsx(Ir,{open:w,onOpenChange:Ae=>{S(Ae),Ae||(R(null),C(""),p(""),v(""))},children:r.jsxs(Er,{className:"max-w-md",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Award Points to New Agent"}),r.jsx(Zs,{children:"Select an agent who doesn't have points yet and award them points"})]}),r.jsx("div",{className:"space-y-4 py-4",children:I?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[r.jsx(cn,{className:"h-10 w-10",children:r.jsx(dn,{children:((Ze=I.name)==null?void 0:Ze.charAt(0))||"?"})}),r.jsxs("div",{className:"flex-1",children:[r.jsx("p",{className:"font-medium",children:I.name||"Unknown"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:I.email})]}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>R(null),children:"Change"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"new-points",children:"Points Amount"}),r.jsx(Ye,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:m,onChange:Ae=>p(Ae.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"new-reason",children:"Reason"}),r.jsx(qs,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:g,onChange:Ae=>v(Ae.target.value)})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Search Agent"}),r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name or email...",value:T,onChange:Ae=>C(Ae.target.value),className:"pl-10"})]})]}),r.jsx("div",{className:"max-h-60 overflow-y-auto border rounded-lg",children:W.length===0?r.jsxs("div",{className:"text-center py-4 text-muted-foreground",children:[r.jsx(ws,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),r.jsx("p",{className:"text-sm",children:T?"No matching agents found":"All agents already have points"})]}):W.slice(0,20).map(Ae=>{var Le;return r.jsxs("button",{onClick:()=>R(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:[r.jsx(cn,{className:"h-8 w-8",children:r.jsx(dn,{children:((Le=Ae.name)==null?void 0:Le.charAt(0))||"?"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium truncate",children:Ae.name||"Unknown"}),r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ae.email})]})]},Ae.id)})})]})}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),I&&r.jsxs(X,{onClick:pe,disabled:oe.isPending,className:"bg-green-600 hover:bg-green-700",children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function tor(){const{data:e,isLoading:t}=ogt(),[s,n]=A.useState(null),[a,o]=A.useState(!1),[l,i]=A.useState(""),[d,m]=A.useState("all"),[p,g]=A.useState("newest"),[v,_]=A.useState("table"),k=A.useMemo(()=>(e==null?void 0:e.map(I=>I.user_id))||[],[e]),w=A.useMemo(()=>(e==null?void 0:e.map(I=>I.id))||[],[e]),{data:S}=Ht({queryKey:["card-profiles-lookup",k],queryFn:async()=>{if(k.length===0)return{};const{data:I}=await Y.from("profiles").select("id, name, email").in("id",k),R={};return I==null||I.forEach(D=>{R[D.id]={name:D.name||"",email:D.email||""}}),R},enabled:k.length>0}),{data:T}=Ht({queryKey:["card-stats-all",w],queryFn:async()=>{if(w.length===0)return{};const I={};w.forEach(B=>{I[B]={views:0,leads:0}});const{data:R}=await Y.from("agent_card_interactions").select("card_id").in("card_id",w).eq("interaction_type","card_view");R==null||R.forEach(B=>{I[B.card_id]&&I[B.card_id].views++});const{data:D}=await Y.from("agent_card_leads").select("card_id").in("card_id",w);return D==null||D.forEach(B=>{I[B.card_id]&&I[B.card_id].leads++}),I},enabled:w.length>0}),C=A.useMemo(()=>{if(!e)return[];let I=[...e];if(d==="live"?I=I.filter(R=>R.is_published):d==="draft"&&(I=I.filter(R=>!R.is_published)),l.trim()){const R=l.toLowerCase();I=I.filter(D=>{var $,q;const B=S==null?void 0:S[D.user_id];return D.slug.toLowerCase().includes(R)||(($=B==null?void 0:B.name)==null?void 0:$.toLowerCase().includes(R))||((q=B==null?void 0:B.email)==null?void 0:q.toLowerCase().includes(R))})}return p==="newest"?I.sort((R,D)=>new Date(D.created_at).getTime()-new Date(R.created_at).getTime()):p==="oldest"?I.sort((R,D)=>new Date(R.created_at).getTime()-new Date(D.created_at).getTime()):p==="name"?I.sort((R,D)=>{var B,$;return(((B=S==null?void 0:S[R.user_id])==null?void 0:B.name)||"").localeCompare((($=S==null?void 0:S[D.user_id])==null?void 0:$.name)||"")}):p==="slug"?I.sort((R,D)=>R.slug.localeCompare(D.slug)):p==="views_desc"?I.sort((R,D)=>{var B,$;return(((B=T==null?void 0:T[D.id])==null?void 0:B.views)||0)-((($=T==null?void 0:T[R.id])==null?void 0:$.views)||0)}):p==="views_asc"?I.sort((R,D)=>{var B,$;return(((B=T==null?void 0:T[R.id])==null?void 0:B.views)||0)-((($=T==null?void 0:T[D.id])==null?void 0:$.views)||0)}):p==="leads_desc"?I.sort((R,D)=>{var B,$;return(((B=T==null?void 0:T[D.id])==null?void 0:B.leads)||0)-((($=T==null?void 0:T[R.id])==null?void 0:$.leads)||0)}):p==="leads_asc"&&I.sort((R,D)=>{var B,$;return(((B=T==null?void 0:T[R.id])==null?void 0:B.leads)||0)-((($=T==null?void 0:T[D.id])==null?void 0:$.leads)||0)}),I},[e,d,l,p,S]);return r.jsxs(Ur,{title:"Digital Agent Cards",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Digital Agent Cards"}),r.jsx("p",{className:"text-muted-foreground",children:"Create and manage agent digital business cards"})]}),r.jsxs(X,{onClick:()=>o(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsxs("div",{className:"relative flex-1",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name, email, or slug...",value:l,onChange:I=>i(I.target.value),className:"pl-9"})]}),r.jsxs(ds,{value:d,onValueChange:m,children:[r.jsx(ls,{className:"w-full sm:w-36",children:r.jsx(us,{placeholder:"Status"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"all",children:"All Status"}),r.jsx(Ut,{value:"live",children:"Live"}),r.jsx(Ut,{value:"draft",children:"Draft"})]})]}),r.jsxs(ds,{value:p,onValueChange:g,children:[r.jsx(ls,{className:"w-full sm:w-44",children:r.jsx(us,{placeholder:"Sort by"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"newest",children:"Newest First"}),r.jsx(Ut,{value:"oldest",children:"Oldest First"}),r.jsx(Ut,{value:"name",children:"Name A–Z"}),r.jsx(Ut,{value:"slug",children:"Slug A–Z"}),r.jsx(Ut,{value:"views_desc",children:"Most Views"}),r.jsx(Ut,{value:"views_asc",children:"Fewest Views"}),r.jsx(Ut,{value:"leads_desc",children:"Most Leads"}),r.jsx(Ut,{value:"leads_asc",children:"Fewest Leads"})]})]}),r.jsxs("div",{className:"flex border rounded-md",children:[r.jsx(X,{variant:v==="table"?"default":"ghost",size:"sm",onClick:()=>_("table"),className:"rounded-r-none",children:r.jsx(F4,{className:"h-4 w-4"})}),r.jsx(X,{variant:v==="grid"?"default":"ghost",size:"sm",onClick:()=>_("grid"),className:"rounded-l-none",children:r.jsx(Of,{className:"h-4 w-4"})})]})]}),!t&&e&&e.length>0&&r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",C.length," of ",e.length," cards"]}),t?r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(I=>r.jsx(pr,{className:"h-48"},I))}):C.length>0?v==="table"?r.jsx(ror,{cards:C,cardProfiles:S,cardStats:T,onEdit:n,sortBy:p,setSortBy:g}):r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(I=>r.jsx(sor,{card:I,onEdit:()=>n(I),stats:T==null?void 0:T[I.id]},I.id))}):e&&e.length>0?r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12",children:[r.jsx(qn,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No matching cards"}),r.jsx("p",{className:"text-muted-foreground text-sm",children:"Try adjusting your search or filters"})]})}):r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12",children:[r.jsx(ws,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No cards yet"}),r.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"Create your first digital agent card"}),r.jsxs(X,{onClick:()=>o(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create Card"]})]})})]}),r.jsx(nor,{open:a,onOpenChange:o}),s&&r.jsx(aor,{card:s,open:!!s,onOpenChange:I=>!I&&n(null)})]})}function ror({cards:e,cardProfiles:t,cardStats:s,onEdit:n,sortBy:a,setSortBy:o}){const l=d=>{a===`${d}_desc`?o(`${d}_asc`):o(`${d}_desc`)},i=({field:d})=>a===`${d}_desc`?r.jsx(Ly,{className:"h-3 w-3"}):a===`${d}_asc`?r.jsx(Pf,{className:"h-3 w-3"}):r.jsx(eg,{className:"h-3 w-3 opacity-40"});return r.jsx(ze,{children:r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b bg-muted/50",children:[r.jsx("th",{className:"text-left p-3 font-medium",children:r.jsxs("button",{onClick:()=>{o(a==="name"?"newest":"name")},className:"flex items-center gap-1 hover:text-foreground text-muted-foreground",children:["Agent ",a==="name"&&r.jsx(Pf,{className:"h-3 w-3"})]})}),r.jsx("th",{className:"text-left p-3 font-medium text-muted-foreground hidden md:table-cell",children:"Slug"}),r.jsx("th",{className:"text-center p-3 font-medium text-muted-foreground",children:"Status"}),r.jsx("th",{className:"text-right p-3 font-medium",children:r.jsxs("button",{onClick:()=>l("views"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Views ",r.jsx(i,{field:"views"})]})}),r.jsx("th",{className:"text-right p-3 font-medium",children:r.jsxs("button",{onClick:()=>l("leads"),className:"flex items-center gap-1 ml-auto hover:text-foreground text-muted-foreground",children:["Leads ",r.jsx(i,{field:"leads"})]})}),r.jsx("th",{className:"text-right p-3 font-medium text-muted-foreground",children:"Actions"})]})}),r.jsx("tbody",{children:e.map(d=>{const m=t==null?void 0:t[d.user_id],p=s==null?void 0:s[d.id],g=`https://cards.relevelup.com/${d.slug}`;return r.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30 transition-colors",children:[r.jsx("td",{className:"p-3",children:r.jsxs("div",{children:[r.jsx("span",{className:"font-medium",children:(m==null?void 0:m.name)||"Unknown"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:(m==null?void 0:m.email)||""})]})}),r.jsx("td",{className:"p-3 hidden md:table-cell",children:r.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["/",d.slug]})}),r.jsx("td",{className:"p-3 text-center",children:r.jsx(_t,{variant:d.is_published?"default":"secondary",className:"text-xs",children:d.is_published?"Live":"Draft"})}),r.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.views)??0}),r.jsx("td",{className:"p-3 text-right tabular-nums font-medium",children:(p==null?void 0:p.leads)??0}),r.jsx("td",{className:"p-3",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>n(d),className:"h-8 w-8 p-0",children:r.jsx(Qa,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{navigator.clipboard.writeText(g),we.success("Link copied!")},children:r.jsx(uo,{className:"h-3.5 w-3.5"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",asChild:!0,children:r.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",children:r.jsx(jn,{className:"h-3.5 w-3.5"})})})]})})]},d.id)})})]})})})}function sor({card:e,onEdit:t,stats:s}){const[n,a]=A.useState(null);A.useEffect(()=>{(async()=>{const{data:d}=await Y.from("profiles").select("name").eq("id",e.user_id).single();let m=null;try{const{data:p}=await Y.storage.from("avatars").list(`${e.user_id}`);if(p&&p.length>0){const{data:g}=Y.storage.from("avatars").getPublicUrl(`${e.user_id}/${p[0].name}`);m=g.publicUrl}}catch{}a({name:(d==null?void 0:d.name)||"Unknown",avatar_url:m})})()},[e.user_id]);const o=`https://cards.relevelup.com/${e.slug}`,l=()=>{navigator.clipboard.writeText(o),we.success("Link copied!")};return r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:(n==null?void 0:n.avatar_url)||void 0}),r.jsx(dn,{children:((n==null?void 0:n.name)||"U")[0]})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-semibold truncate",children:(n==null?void 0:n.name)||"Loading..."}),r.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["/card/",e.slug]})]}),r.jsx(_t,{variant:e.is_published?"default":"secondary",children:e.is_published?"Live":"Draft"})]}),r.jsxs("div",{className:"flex items-center gap-3 mb-3 text-xs text-muted-foreground",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ii,{className:"h-3.5 w-3.5"}),(s==null?void 0:s.views)??0," views"]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ws,{className:"h-3.5 w-3.5"}),(s==null?void 0:s.leads)??0," leads"]})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:t,className:"flex-1",children:[r.jsx(Qa,{className:"h-3 w-3 mr-1"}),"Edit"]}),r.jsx(X,{variant:"outline",size:"sm",onClick:l,children:r.jsx(uo,{className:"h-3 w-3"})}),r.jsx(X,{variant:"outline",size:"sm",asChild:!0,children:r.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",children:r.jsx(jn,{className:"h-3 w-3"})})})]})]})})}function nor({open:e,onOpenChange:t}){const[s,n]=A.useState(""),[a,o]=A.useState(""),[l,i]=A.useState(""),[d,m]=A.useState(!1),p=i7e(),g=l.trim(),{data:v}=Ht({queryKey:["profiles-search-for-cards",g],queryFn:async()=>{let C=Y.from("profiles").select("id, name, email").order("name").limit(50);g.length>=2&&(C=C.or(`name.ilike.%${g}%,email.ilike.%${g}%`));const{data:I}=await C;return I||[]},enabled:e}),[_,k]=A.useState(null),w=(v==null?void 0:v.find(C=>C.id===s))||_,S=()=>{if(!s||!a.trim()){we.error("Select an agent and enter a slug");return}p.mutate({user_id:s,slug:a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-"),is_published:!0},{onSuccess:()=>{t(!1),n(""),o(""),i("")}})},T=C=>{var R;n(C),m(!1);const I=v==null?void 0:v.find(D=>D.id===C);I&&(k(I),o(((R=I.name)==null?void 0:R.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return r.jsx(Ir,{open:e,onOpenChange:t,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create Agent Card"}),r.jsx(Zs,{children:"Select an agent and set their card URL slug."})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Agent"}),r.jsxs(cd,{open:d,onOpenChange:m,children:[r.jsx(dd,{asChild:!0,children:r.jsxs(X,{variant:"outline",role:"combobox","aria-expanded":d,className:"w-full justify-between font-normal",children:[w?`${w.name} (${w.email})`:"Search for an agent...",r.jsx(Ry,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),r.jsx(Hc,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:r.jsxs(a0,{shouldFilter:!1,children:[r.jsx(i0,{placeholder:"Search by name or email...",value:l,onValueChange:i}),r.jsxs(o0,{children:[r.jsx(l0,{children:"No agents found."}),r.jsx(c0,{children:(v||[]).map(C=>r.jsxs(d0,{value:C.id,onSelect:T,children:[r.jsx(mi,{className:Vt("mr-2 h-4 w-4",s===C.id?"opacity-100":"opacity-0")}),C.name," (",C.email,")"]},C.id))})]})]})})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"URL Slug"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm text-muted-foreground",children:"/card/"}),r.jsx(Ye,{value:a,onChange:C=>o(C.target.value),placeholder:"john-doe"})]})]}),r.jsx(X,{onClick:S,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function aor({card:e,open:t,onOpenChange:s}){const n=o7e(),{data:a}=l7e(e.id),o=Rr(),[l,i]=A.useState(null),[d,m]=A.useState(!1),[p,g]=A.useState(!1),[v,_]=A.useState(""),[k,w]=A.useState(e.slug),[S,T]=A.useState(!1),[C,I]=A.useState({is_published:e.is_published,theme:e.theme,title:e.title||"",positioning_statement:e.positioning_statement||"",bio:e.bio||"",review_snippet:e.review_snippet||"",review_source_url:e.review_source_url||"",booking_url:e.booking_url||"",custom_cta_label:e.custom_cta_label||"",custom_cta_url:e.custom_cta_url||"",show_photo:e.show_photo,show_bio:e.show_bio,show_credentials:e.show_credentials,show_social_links:e.show_social_links,show_save_contact:e.show_save_contact,show_leave_review:e.show_leave_review,show_refer_friend:e.show_refer_friend,brokerage_display_name:e.brokerage_display_name||"",brokerage_logo_url:e.brokerage_logo_url||"",brokerage_logo_size:e.brokerage_logo_size||56,team_name:e.team_name||"",team_logo_url:e.team_logo_url||"",team_logo_size:e.team_logo_size||56});A.useEffect(()=>{t&&(async()=>{try{const{data:K}=await Y.storage.from("avatars").list(`${e.user_id}`);if(K&&K.length>0){const{data:re}=Y.storage.from("avatars").getPublicUrl(`${e.user_id}/${K[0].name}`);i(`${re.publicUrl}?t=${Date.now()}`)}}catch{}})()},[e.user_id,t]);const R=W=>{var ae;const K=(ae=W.target.files)==null?void 0:ae[0];if(!K)return;if(!K.type.startsWith("image/")){we.error("Please select an image file");return}if(K.size>5*1024*1024){we.error("Image must be under 5MB");return}const re=new FileReader;re.onloadend=()=>{_(re.result),g(!0)},re.readAsDataURL(K),W.target.value=""},D=async W=>{m(!0);try{const{data:K}=await Y.storage.from("avatars").list(`${e.user_id}`);K&&K.length>0&&await Y.storage.from("avatars").remove(K.map(pe=>`${e.user_id}/${pe.name}`));const re=`${e.user_id}/avatar.jpg`,{error:ae}=await Y.storage.from("avatars").upload(re,W,{upsert:!0,contentType:"image/jpeg"});if(ae)throw ae;const{data:oe}=Y.storage.from("avatars").getPublicUrl(re),se=`${oe.publicUrl}?t=${Date.now()}`;i(se),await Y.from("profiles").update({avatar_url:se}).eq("id",e.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),we.success("Photo updated!")}catch(K){we.error(K.message||"Upload failed")}finally{m(!1)}},B=async()=>{const W=k.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!W){we.error("Please enter a valid URL");return}if(W===e.slug){we.info("No changes to save");return}T(!0);try{const{data:K}=await Y.from("agent_cards").select("id").eq("slug",W).neq("id",e.id).maybeSingle();if(K){we.error("This URL is already taken. Try another one.");return}const{error:re}=await Y.from("agent_cards").update({slug:W}).eq("id",e.id);if(re)throw re;w(W),o.invalidateQueries({queryKey:["agent-cards-admin"]}),we.success("Card address updated!")}catch{we.error("Failed to update card address")}finally{T(!1)}},$=async(W,K)=>{var ae;const re=(ae=W.target.files)==null?void 0:ae[0];if(re){if(!re.type.startsWith("image/")){we.error("Please select an image file");return}try{const oe=re.name.split(".").pop()||"png",se=K==="brokerage_logo_url"?"brokerage-logo":"team-logo",pe=`${e.user_id}/${se}.${oe}`,{error:ie}=await Y.storage.from("card-logos").upload(pe,re,{upsert:!0});if(ie)throw ie;const{data:de}=Y.storage.from("card-logos").getPublicUrl(pe),ce=de.publicUrl+"?t="+Date.now();I(K==="brokerage_logo_url"?ge=>({...ge,[K]:ce,brokerage_display_name:""}):ge=>({...ge,[K]:ce,team_name:""})),we.success("Logo uploaded!")}catch{we.error("Failed to upload logo")}finally{W.target.value=""}}},q=()=>{n.mutate({id:e.id,...C,title:C.title||null,positioning_statement:C.positioning_statement||null,bio:C.bio||null,review_snippet:C.review_snippet||null,review_source_url:C.review_source_url||null,booking_url:C.booking_url||null,custom_cta_label:C.custom_cta_label||null,custom_cta_url:C.custom_cta_url||null,brokerage_display_name:C.brokerage_display_name||null,brokerage_logo_url:C.brokerage_logo_url||null,brokerage_logo_size:C.brokerage_logo_size,team_name:C.team_name||null,team_logo_url:C.team_logo_url||null,team_logo_size:C.team_logo_size},{onSuccess:()=>s(!1)})};return r.jsxs(r.Fragment,{children:[r.jsx(Ir,{open:t,onOpenChange:s,children:r.jsxs(Er,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Edit Agent Card"}),r.jsxs(Zs,{children:["/card/",e.slug]})]}),r.jsxs(ii,{defaultValue:"content",children:[r.jsxs(si,{className:"w-full",children:[r.jsx(Kr,{value:"content",className:"flex-1",children:"Content"}),r.jsx(Kr,{value:"sections",className:"flex-1",children:"Sections"}),r.jsx(Kr,{value:"blocks",className:"flex-1",children:"Blocks"}),r.jsx(Kr,{value:"analytics",className:"flex-1",children:"Analytics"})]}),r.jsxs(hs,{value:"content",className:"space-y-4 mt-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{children:"Published"}),r.jsx(fn,{checked:C.is_published,onCheckedChange:W=>I(K=>({...K,is_published:W}))})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Agent Photo"}),r.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[r.jsxs(cn,{className:"h-16 w-16",children:[r.jsx(xa,{src:l||void 0}),r.jsx(dn,{children:"?"})]}),r.jsxs("label",{className:"cursor-pointer",children:[r.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:R,disabled:d}),r.jsx(X,{variant:"outline",size:"sm",asChild:!0,disabled:d,children:r.jsx("span",{children:d?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Card Address"}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsxs("div",{className:"flex flex-1",children:[r.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/"}),r.jsx(Ye,{value:k,onChange:W=>w(W.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),r.jsx(X,{variant:"outline",size:"sm",onClick:B,disabled:S||k===e.slug,className:"shrink-0",children:S?"Saving...":"Update"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Theme"}),r.jsxs(ds,{value:C.theme,onValueChange:W=>I(K=>({...K,theme:W})),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"standard",children:"✨ Standard (Modern Clean)"}),r.jsx(Ut,{value:"luxury",children:"🌙 Luxury (Dark & Gold)"}),r.jsx(Ut,{value:"bold",children:"🔥 Bold (Vibrant & Punchy)"}),r.jsx(Ut,{value:"classic",children:"📋 Classic (Professional)"})]})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Title / Tagline"}),r.jsx(Ye,{value:C.title,onChange:W=>I(K=>({...K,title:W.target.value})),placeholder:"e.g. Luxury Real Estate Specialist"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Shown below the agent's name on the card"})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Positioning Statement"}),r.jsx(Ye,{value:C.positioning_statement,onChange:W=>I(K=>({...K,positioning_statement:W.target.value})),placeholder:"Your home journey, handled with care."})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Bio"}),r.jsx(qs,{value:C.bio,onChange:W=>I(K=>({...K,bio:W.target.value})),placeholder:"Short about me...",rows:3})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Review Snippet"}),r.jsx(Ye,{value:C.review_snippet,onChange:W=>I(K=>({...K,review_snippet:W.target.value})),placeholder:"Best agent we've ever worked with..."})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Review Source URL"}),r.jsx(Ye,{value:C.review_source_url,onChange:W=>I(K=>({...K,review_source_url:W.target.value})),placeholder:"https://g.page/your-business/review"})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Booking URL (optional — if empty, shows lead form)"}),r.jsx(Ye,{value:C.booking_url,onChange:W=>I(K=>({...K,booking_url:W.target.value})),placeholder:"https://calendly.com/your-link"})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Custom CTA Label (optional)"}),r.jsx(Ye,{value:C.custom_cta_label,onChange:W=>I(K=>({...K,custom_cta_label:W.target.value})),placeholder:"Book a Call"})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Custom CTA URL (optional)"}),r.jsx(Ye,{value:C.custom_cta_url,onChange:W=>I(K=>({...K,custom_cta_url:W.target.value})),placeholder:"https://example.com/landing"})]}),r.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[r.jsx(Ee,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Brokerage Branding"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ye,{value:C.brokerage_display_name,onChange:W=>I(K=>({...K,brokerage_display_name:W.target.value,brokerage_logo_url:""})),placeholder:"Brokerage name (or upload logo below)",disabled:!!C.brokerage_logo_url}),r.jsxs("div",{className:"flex items-center gap-3",children:[C.brokerage_logo_url&&r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:C.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${C.brokerage_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),r.jsx("button",{onClick:()=>I(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:"×"})]}),r.jsxs("label",{className:"cursor-pointer",children:[r.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:[r.jsx(Xi,{className:"h-3.5 w-3.5"}),C.brokerage_logo_url?"Change Logo":"Upload Logo"]}),r.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:W=>$(W,"brokerage_logo_url")})]})]}),C.brokerage_logo_url&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.brokerage_logo_size||56,"px"]})]}),r.jsx(Xp,{value:[C.brokerage_logo_size||56],onValueChange:([W])=>I(K=>({...K,brokerage_logo_size:W})),min:24,max:120,step:4})]})]})]}),r.jsxs("div",{className:"space-y-3 p-3 rounded-lg bg-muted/30 border",children:[r.jsx(Ee,{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Team Branding"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ye,{value:C.team_name,onChange:W=>I(K=>({...K,team_name:W.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!C.team_logo_url}),r.jsxs("div",{className:"flex items-center gap-3",children:[C.team_logo_url&&r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:C.team_logo_url,alt:"Team logo",style:{height:`${C.team_logo_size||56}px`},className:"max-w-[200px] object-contain rounded border bg-white p-1"}),r.jsx("button",{onClick:()=>I(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:"×"})]}),r.jsxs("label",{className:"cursor-pointer",children:[r.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:[r.jsx(Xi,{className:"h-3.5 w-3.5"}),C.team_logo_url?"Change Logo":"Upload Logo"]}),r.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:W=>$(W,"team_logo_url")})]})]}),C.team_logo_url&&r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ee,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.team_logo_size||56,"px"]})]}),r.jsx(Xp,{value:[C.team_logo_size||56],onValueChange:([W])=>I(K=>({...K,team_logo_size:W})),min:24,max:120,step:4})]})]})]})]}),r.jsx(hs,{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:K,hint:re})=>r.jsxs("div",{className:"flex items-center justify-between py-2",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:K}),re&&r.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[re," ",W==="show_photo"&&r.jsx("a",{href:"/profile",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:"Update Profile"})]})]}),r.jsx(fn,{checked:C[W],onCheckedChange:ae=>I(oe=>({...oe,[W]:ae}))})]},W))}),r.jsx(hs,{value:"blocks",className:"mt-4",children:r.jsx(gZe,{cardId:e.id})}),r.jsx(hs,{value:"analytics",className:"mt-4",children:a?r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:a.views}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Views"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:a.clicks}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Clicks"})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"p-4 text-center",children:[r.jsx("div",{className:"text-2xl font-bold",children:a.leads.length}),r.jsx("div",{className:"text-xs text-muted-foreground",children:"Leads"})]})})]}),a.leads.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"font-semibold mb-2",children:"Recent Leads"}),r.jsx("div",{className:"space-y-2",children:a.leads.slice(0,5).map(W=>r.jsxs("div",{className:"text-sm p-2 bg-muted/50 rounded-lg",children:[r.jsx("span",{className:"font-medium",children:W.name}),W.phone&&r.jsxs("span",{className:"text-muted-foreground",children:[" · ",W.phone]}),W.intent&&r.jsx(_t,{variant:"secondary",className:"ml-2 text-xs",children:W.intent})]},W.id))})]})]}):r.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No analytics data yet"})})]}),r.jsx(X,{onClick:q,disabled:n.isPending,className:"w-full mt-4",children:n.isPending?"Saving...":"Save Changes"})]})}),r.jsx(s_e,{open:p,onClose:()=>g(!1),imageSrc:v,onCropComplete:D,aspectRatio:1})]})}const a5={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"},Ube={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 Vbe(e=!0){return Ht({queryKey:["marketplace-categories",e],queryFn:async()=>{let t=Y.from("marketplace_categories").select("*").order("sort_order",{ascending:!0});e&&(t=t.eq("is_active",!0));const{data:s,error:n}=await t;if(n)throw n;return s}})}function ior(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("marketplace_categories").insert([t]).select().single();if(n)throw n;return s},onSuccess:()=>{e.invalidateQueries({queryKey:["marketplace-categories"]}),we.success("Category created successfully")},onError:t=>{we.error("Failed to create category: "+t.message)}})}function oor(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("marketplace_categories").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["marketplace-categories"]}),we.success("Category updated successfully")},onError:t=>{we.error("Failed to update category: "+t.message)}})}function lor(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("marketplace_categories").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["marketplace-categories"]}),we.success("Category deleted successfully")},onError:t=>{we.error("Failed to delete category: "+t.message)}})}function AZe(e,t=!0){return Ht({queryKey:["marketplace-products",e,t],queryFn:async()=>{let s=Y.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).order("sort_order",{ascending:!0});e&&(s=s.eq("category_id",e)),t&&(s=s.eq("is_active",!0));const{data:n,error:a}=await s;if(a)throw a;return n}})}function cor(e){return Ht({queryKey:["marketplace-product",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("marketplace_products").select(` *, category:marketplace_categories(*), images:marketplace_product_images(*), video:marketplace_product_videos(*), variants:marketplace_product_variants(*) `).eq("id",e).single();if(s)throw s;return t},enabled:!!e})}function dor(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("marketplace_products").insert([t]).select().single();if(n)throw n;return s},onSuccess:()=>{e.invalidateQueries({queryKey:["marketplace-products"]}),we.success("Product created successfully")},onError:t=>{we.error("Failed to create product: "+t.message)}})}function uor(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("marketplace_products").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["marketplace-products"]}),e.invalidateQueries({queryKey:["marketplace-product",s.id]}),we.success("Product updated successfully")},onError:t=>{we.error("Failed to update product: "+t.message)}})}function hor(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("marketplace_products").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["marketplace-products"]}),we.success("Product deleted successfully")},onError:t=>{we.error("Failed to delete product: "+t.message)}})}function mor(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("marketplace_product_images").insert([t]).select().single();if(n)throw n;return s},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["marketplace-products"]}),e.invalidateQueries({queryKey:["marketplace-product",s.product_id]})}})}function por(){const e=Rr();return Qt({mutationFn:async({id:t,productId:s})=>{const{error:n}=await Y.from("marketplace_product_images").delete().eq("id",t);if(n)throw n;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-products"]}),e.invalidateQueries({queryKey:["marketplace-product",t]}),we.success("Image deleted successfully")},onError:t=>{we.error("Failed to delete image: "+t.message)}})}function gor(){const e=Rr();return Qt({mutationFn:async({imageId:t,productId:s})=>{const{error:n}=await Y.from("marketplace_product_images").update({is_primary:!1}).eq("product_id",s);if(n)throw n;const{error:a}=await Y.from("marketplace_product_images").update({is_primary:!0}).eq("id",t);if(a)throw a;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-products"]}),e.invalidateQueries({queryKey:["marketplace-product",t]}),we.success("Primary image updated")},onError:t=>{we.error("Failed to set primary image: "+t.message)}})}function xor(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("marketplace_product_variants").insert([t]).select().single();if(n)throw n;return s},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["marketplace-products"]}),e.invalidateQueries({queryKey:["marketplace-product",s.product_id]}),we.success("Variant added successfully")}})}function yor(){const e=Rr();return Qt({mutationFn:async({id:t,productId:s})=>{const{error:n}=await Y.from("marketplace_product_variants").delete().eq("id",t);if(n)throw n;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-products"]}),e.invalidateQueries({queryKey:["marketplace-product",t]}),we.success("Variant deleted successfully")}})}function vor(){const e=Rr();return Qt({mutationFn:async({productId:t,videoUrl:s})=>{await Y.from("marketplace_product_videos").delete().eq("product_id",t);const{data:n,error:a}=await Y.from("marketplace_product_videos").insert({product_id:t,video_url:s}).select().single();if(a)throw a;return n},onSuccess:(t,s)=>{e.invalidateQueries({queryKey:["marketplace-products"]}),e.invalidateQueries({queryKey:["marketplace-product",s.productId]}),we.success("Video updated successfully")}})}function _or(e){const{isAdmin:t}=Gr();return Ht({queryKey:["marketplace-orders",e,t],queryFn:async()=>{let s=Y.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 s;if(a)throw a;if(t&&n){const o=[...new Set(n.map(d=>d.user_id))],{data:l}=await Y.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 bor(){const{user:e}=Gr();return Ht({queryKey:["my-marketplace-orders",e==null?void 0:e.id],queryFn:async()=>{const{data:t,error:s}=await Y.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("user_id",e.id).order("created_at",{ascending:!1});if(s)throw s;return t},enabled:!!(e!=null&&e.id)})}function wor(e){return Ht({queryKey:["marketplace-order",e],queryFn:async()=>{const{data:t,error:s}=await Y.from("marketplace_orders").select(` *, items:marketplace_order_items(*), status_history:marketplace_order_status_history(*) `).eq("id",e).single();if(s)throw s;return t},enabled:!!e})}function jor(){const e=Rr(),{user:t}=Gr();return Qt({mutationFn:async({orderId:s,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:m}=await Y.from("marketplace_orders").update(d).eq("id",s);if(m)throw m;const{error:p}=await Y.from("marketplace_order_status_history").insert({order_id:s,status:n,notes:a,created_by:t==null?void 0:t.id});if(p)throw p;if(["shipped","in_production","processing","completed"].includes(n)&&n!==i)try{await Y.functions.invoke("marketplace-order-notify",{body:{orderId:s,notificationType:n==="shipped"?"shipped":"status_update",newStatus:n,trackingNumber:o,trackingUrl:l}})}catch(v){console.error("Failed to send notification email:",v)}},onSuccess:(s,n)=>{e.invalidateQueries({queryKey:["marketplace-orders"]}),e.invalidateQueries({queryKey:["marketplace-order",n.orderId]}),e.invalidateQueries({queryKey:["my-marketplace-orders"]}),we.success("Order status updated")},onError:s=>{we.error("Failed to update order: "+s.message)}})}function kor(){const e=Rr();return Qt({mutationFn:async({itemId:t,proofUrl:s,proofNotes:n,orderId:a})=>{const{error:o}=await Y.from("marketplace_order_items").update({proof_url:s,proof_notes:n,proof_status:"pending"}).eq("id",t);if(o)throw o;await Y.from("marketplace_orders").update({status:"awaiting_proof_approval"}).eq("id",a);try{await Y.functions.invoke("marketplace-order-notify",{body:{orderId:a,notificationType:"proof_ready"}})}catch(l){console.error("Failed to send proof notification:",l)}return a},onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-orders"]}),e.invalidateQueries({queryKey:["marketplace-order",t]}),e.invalidateQueries({queryKey:["my-marketplace-orders"]}),we.success("Proof uploaded & customer notified")}})}function Nor(){const e=Rr();return Qt({mutationFn:async({itemId:t,orderId:s})=>{const{error:n}=await Y.from("marketplace_order_items").update({proof_status:"approved"}).eq("id",t);if(n)throw n;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-orders"]}),e.invalidateQueries({queryKey:["marketplace-order",t]}),e.invalidateQueries({queryKey:["my-marketplace-orders"]}),we.success("Proof approved")}})}function Sor(){const e=Rr();return Qt({mutationFn:async({itemId:t,orderId:s,reason:n})=>{const{error:a}=await Y.from("marketplace_order_items").update({proof_status:"rejected",proof_notes:n}).eq("id",t);if(a)throw a;return s},onSuccess:t=>{e.invalidateQueries({queryKey:["marketplace-orders"]}),e.invalidateQueries({queryKey:["marketplace-order",t]}),e.invalidateQueries({queryKey:["my-marketplace-orders"]}),we.success("Proof rejected - please upload a new proof")}})}function Cor(){const{data:e,isLoading:t}=Vbe(!1),s=ior(),n=oor(),a=lor(),[o,l]=A.useState(!1),[i,d]=A.useState(null),[m,p]=A.useState({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),g=()=>{p({name:"",description:"",image_url:"",sort_order:0,is_active:!0}),d(null)},v=w=>{d(w),p({name:w.name,description:w.description||"",image_url:w.image_url||"",sort_order:w.sort_order,is_active:w.is_active}),l(!0)},_=async w=>{w.preventDefault(),i?await n.mutateAsync({id:i.id,...m}):await s.mutateAsync(m),l(!1),g()},k=async w=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(w)};return t?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(pr,{className:"h-8 w-48"})}),r.jsx(qe,{children:r.jsx("div",{className:"space-y-4",children:[1,2,3].map(w=>r.jsx(pr,{className:"h-12 w-full"},w))})})]}):r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsx(Zt,{children:"Categories"}),r.jsxs(Ir,{open:o,onOpenChange:w=>{l(w),w||g()},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Category"]})}),r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:i?"Edit Category":"Add Category"})}),r.jsxs("form",{onSubmit:_,className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Name"}),r.jsx(Ye,{id:"name",value:m.name,onChange:w=>p({...m,name:w.target.value}),required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",value:m.description,onChange:w=>p({...m,description:w.target.value})})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"image_url",children:"Image URL"}),r.jsx(Ye,{id:"image_url",value:m.image_url,onChange:w=>p({...m,image_url:w.target.value}),placeholder:"https://..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"sort_order",children:"Sort Order"}),r.jsx(Ye,{id:"sort_order",type:"number",value:m.sort_order,onChange:w=>p({...m,sort_order:parseInt(w.target.value)||0})})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"is_active",checked:m.is_active,onCheckedChange:w=>p({...m,is_active:w})}),r.jsx(Ee,{htmlFor:"is_active",children:"Active"})]}),r.jsx(X,{type:"submit",className:"w-full",disabled:s.isPending||n.isPending,children:i?"Update Category":"Create Category"})]})]})]})]}),r.jsx(qe,{children:e&&e.length>0?r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{children:"Sort Order"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:e.map(w=>r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-medium",children:w.name}),r.jsx(dt,{className:"max-w-xs truncate",children:w.description}),r.jsx(dt,{children:w.sort_order}),r.jsx(dt,{children:r.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"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>v(w),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>k(w.id),disabled:a.isPending,children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},w.id))})]}):r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function Mor(){var _e,ve;const{data:e,isLoading:t}=AZe(void 0,!1),{data:s}=Vbe(!1),n=dor(),a=uor(),o=hor(),l=mor(),i=por(),d=gor(),m=xor(),p=yor(),g=vor(),[v,_]=A.useState(!1),[k,w]=A.useState(!1),[S,T]=A.useState(!1),[C,I]=A.useState(null),[R,D]=A.useState(null),[B,$]=A.useState(!1),[q,W]=A.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}),[K,re]=A.useState({name:"",price_adjustment:0}),[ae,oe]=A.useState(""),se=()=>{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}),I(null)},pe=Me=>{I(Me),W({name:Me.name,description:Me.description||"",base_price:Number(Me.base_price),shipping_fee:Number(Me.shipping_fee),category_id:Me.category_id||"",allow_artwork_upload:Me.allow_artwork_upload,requires_proof_approval:Me.requires_proof_approval,is_active:Me.is_active,sort_order:Me.sort_order}),_(!0)},ie=async Me=>{Me.preventDefault();const Ze={...q,category_id:q.category_id||null};C?await a.mutateAsync({id:C.id,...Ze}):await n.mutateAsync(Ze),_(!1),se()},de=async Me=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(Me)},ce=async Me=>{if(!R||!Me.target.files||Me.target.files.length===0)return;$(!0);const Ze=Me.target.files[0],Ae=Ze.name.split(".").pop(),Le=`products/${R.id}/${Date.now()}.${Ae}`;try{const{error:Ue}=await Y.storage.from("marketplace").upload(Le,Ze);if(Ue)throw Ue;const{data:{publicUrl:Ve}}=Y.storage.from("marketplace").getPublicUrl(Le);await l.mutateAsync({product_id:R.id,image_url:Ve,is_primary:!R.images||R.images.length===0}),we.success("Image uploaded successfully")}catch(Ue){we.error("Failed to upload image: "+Ue.message)}finally{$(!1)}},ge=async Me=>{Me.preventDefault(),R&&(await m.mutateAsync({product_id:R.id,name:K.name,price_adjustment:K.price_adjustment}),re({name:"",price_adjustment:0}))},Te=async()=>{!R||!ae||(await g.mutateAsync({productId:R.id,videoUrl:ae}),oe(""))};return t?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(pr,{className:"h-8 w-48"})}),r.jsx(qe,{children:r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(Me=>r.jsx(pr,{className:"h-64 w-full"},Me))})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsx(Zt,{children:"Products"}),r.jsxs(Ir,{open:v,onOpenChange:Me=>{_(Me),Me||se()},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Product"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:C?"Edit Product":"Add Product"})}),r.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"name",children:"Product Name"}),r.jsx(Ye,{id:"name",value:q.name,onChange:Me=>W({...q,name:Me.target.value}),required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"category",children:"Category"}),r.jsxs(ds,{value:q.category_id,onValueChange:Me=>W({...q,category_id:Me}),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select category"})}),r.jsx(cs,{children:s==null?void 0:s.map(Me=>r.jsx(Ut,{value:Me.id,children:Me.name},Me.id))})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"description",children:"Description"}),r.jsx(qs,{id:"description",value:q.description,onChange:Me=>W({...q,description:Me.target.value}),rows:4})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"base_price",children:"Base Price ($)"}),r.jsx(Ye,{id:"base_price",type:"number",step:"0.01",min:"0",value:q.base_price,onChange:Me=>W({...q,base_price:parseFloat(Me.target.value)||0}),required:!0})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),r.jsx(Ye,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:q.shipping_fee,onChange:Me=>W({...q,shipping_fee:parseFloat(Me.target.value)||0})})]})]}),r.jsx("div",{className:"grid grid-cols-2 gap-4",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"sort_order",children:"Sort Order"}),r.jsx(Ye,{id:"sort_order",type:"number",value:q.sort_order,onChange:Me=>W({...q,sort_order:parseInt(Me.target.value)||0})})]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"allow_artwork_upload",checked:q.allow_artwork_upload,onCheckedChange:Me=>W({...q,allow_artwork_upload:Me})}),r.jsx(Ee,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"requires_proof_approval",checked:q.requires_proof_approval,onCheckedChange:Me=>W({...q,requires_proof_approval:Me})}),r.jsx(Ee,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"is_active",checked:q.is_active,onCheckedChange:Me=>W({...q,is_active:Me})}),r.jsx(Ee,{htmlFor:"is_active",children:"Active"})]})]}),r.jsx(X,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:C?"Update Product":"Create Product"})]})]})]})]}),r.jsx(qe,{children:e&&e.length>0?r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:e.map(Me=>{var Ze,Ae;return r.jsxs(ze,{className:"overflow-hidden",children:[r.jsxs("div",{className:"aspect-video bg-muted relative",children:[Me.images&&Me.images.length>0?r.jsx("img",{src:((Ze=Me.images.find(Le=>Le.is_primary))==null?void 0:Ze.image_url)||Me.images[0].image_url,alt:Me.name,className:"w-full h-full object-cover"}):r.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:"No image"}),!Me.is_active&&r.jsx(_t,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),r.jsxs(qe,{className:"p-4",children:[r.jsx("h3",{className:"font-semibold mb-1",children:Me.name}),r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Ae=Me.category)==null?void 0:Ae.name)||"No category"}),r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("span",{className:"font-bold",children:["$",Number(Me.base_price).toFixed(2)]}),Number(Me.shipping_fee)>0&&r.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(Me.shipping_fee).toFixed(2)," shipping"]})]}),r.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[Me.allow_artwork_upload&&r.jsx(_t,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),Me.requires_proof_approval&&r.jsx(_t,{variant:"outline",className:"text-xs",children:"Proof Required"}),Me.variants&&Me.variants.length>0&&r.jsxs(_t,{variant:"outline",className:"text-xs",children:[Me.variants.length," Variants"]})]}),r.jsxs("div",{className:"flex gap-2 flex-wrap",children:[r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>pe(Me),children:[r.jsx(Qa,{className:"h-3 w-3 mr-1"}),"Edit"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>{D(Me),w(!0)},children:[r.jsx(j1,{className:"h-3 w-3 mr-1"}),"Images"]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>{D(Me),T(!0)},children:[r.jsx(px,{className:"h-3 w-3 mr-1"}),"Variants"]}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>de(Me.id),children:r.jsx(Os,{className:"h-3 w-3 text-destructive"})})]})]})]},Me.id)})}):r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No products yet. Create your first product to get started."})})]}),r.jsx(Ir,{open:k,onOpenChange:w,children:r.jsxs(Er,{className:"max-w-2xl",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Manage Images - ",R==null?void 0:R.name]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"grid grid-cols-3 gap-4",children:(_e=R==null?void 0:R.images)==null?void 0:_e.map(Me=>r.jsxs("div",{className:"relative group",children:[r.jsx("img",{src:Me.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),Me.is_primary&&r.jsx(_t,{className:"absolute top-2 left-2",variant:"default",children:"Primary"}),r.jsxs("div",{className:"absolute top-2 right-2 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[!Me.is_primary&&r.jsx(X,{variant:"secondary",size:"icon",onClick:async()=>{var Ze;await d.mutateAsync({imageId:Me.id,productId:R.id}),D({...R,images:(Ze=R.images)==null?void 0:Ze.map(Ae=>({...Ae,is_primary:Ae.id===Me.id}))})},disabled:d.isPending,title:"Set as primary",children:r.jsx(Dn,{className:"h-4 w-4"})}),r.jsx(X,{variant:"destructive",size:"icon",onClick:async()=>{var Ae;await i.mutateAsync({id:Me.id,productId:R.id});const Ze=e==null?void 0:e.find(Le=>Le.id===R.id);Ze&&D({...Ze,images:(Ae=Ze.images)==null?void 0:Ae.filter(Le=>Le.id!==Me.id)})},disabled:i.isPending,children:r.jsx(Os,{className:"h-4 w-4"})})]})]},Me.id))}),r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[r.jsx("input",{type:"file",accept:"image/*",onChange:ce,className:"hidden",id:"image-upload",disabled:B}),r.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[r.jsx(j1,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:B?"Uploading...":"Click to upload an image"})]})]}),r.jsxs("div",{className:"border-t pt-4 mt-4",children:[r.jsx(Ee,{children:"Product Video (optional)"}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx(Ye,{placeholder:"Enter video URL (YouTube, Vimeo, etc.)",value:ae,onChange:Me=>oe(Me.target.value)}),r.jsxs(X,{onClick:Te,disabled:!ae,children:[r.jsx(ma,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(R==null?void 0:R.video)&&r.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",R.video.video_url]})]})]})]})}),r.jsx(Ir,{open:S,onOpenChange:T,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Manage Variants - ",R==null?void 0:R.name]})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("form",{onSubmit:ge,className:"flex gap-2",children:[r.jsx(Ye,{placeholder:"Variant name (e.g., 500 count)",value:K.name,onChange:Me=>re({...K,name:Me.target.value}),required:!0}),r.jsx(Ye,{type:"number",step:"0.01",placeholder:"Price adj.",value:K.price_adjustment,onChange:Me=>re({...K,price_adjustment:parseFloat(Me.target.value)||0}),className:"w-32"}),r.jsx(X,{type:"submit",children:"Add"})]}),r.jsxs("div",{className:"space-y-2",children:[(ve=R==null?void 0:R.variants)==null?void 0:ve.map(Me=>r.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[r.jsxs("div",{children:[r.jsx("span",{className:"font-medium",children:Me.name}),r.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(Me.price_adjustment)>=0?"+":"","$",Number(Me.price_adjustment).toFixed(2)]})]}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:Me.id,productId:R.id}),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]},Me.id)),(!(R!=null&&R.variants)||R.variants.length===0)&&r.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 Tor=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function Aor(){var w,S,T;const{data:e,isLoading:t}=_or(),s=jor(),n=kor(),[a,o]=A.useState(null),[l,i]=A.useState(!1),[d,m]=A.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,g]=A.useState(!1),v=C=>{o(C),m({status:C.status,notes:"",trackingNumber:C.tracking_number||"",trackingUrl:C.tracking_url||""}),i(!0)},_=async()=>{a&&(await s.mutateAsync({orderId:a.id,status:d.status,notes:d.notes,trackingNumber:d.trackingNumber,trackingUrl:d.trackingUrl,previousStatus:a.status}),i(!1))},k=async(C,I)=>{if(!a||!C.target.files||C.target.files.length===0)return;g(!0);const R=C.target.files[0],D=R.name.split(".").pop(),B=`proofs/${a.id}/${I}/${Date.now()}.${D}`;try{const{error:$}=await Y.storage.from("marketplace").upload(B,R);if($)throw $;const{data:{publicUrl:q}}=Y.storage.from("marketplace").getPublicUrl(B);await n.mutateAsync({itemId:I,proofUrl:q,orderId:a.id}),we.success("Proof uploaded successfully")}catch($){we.error("Failed to upload proof: "+$.message)}finally{g(!1)}};return t?r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(pr,{className:"h-8 w-48"})}),r.jsx(qe,{children:r.jsx("div",{className:"space-y-4",children:[1,2,3].map(C=>r.jsx(pr,{className:"h-16 w-full"},C))})})]}):r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Orders"})}),r.jsx(qe,{children:e&&e.length>0?r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Order #"}),r.jsx(Mt,{children:"Customer"}),r.jsx(Mt,{children:"Date"}),r.jsx(Mt,{children:"Total"}),r.jsx(Mt,{children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:e.map(C=>{var I,R;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"font-mono",children:C.order_number}),r.jsx(dt,{children:r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:((I=C.user)==null?void 0:I.name)||"Unknown"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:(R=C.user)==null?void 0:R.email})]})}),r.jsx(dt,{children:Xr(new Date(C.created_at),"MMM d, yyyy")}),r.jsxs(dt,{className:"font-bold",children:["$",Number(C.total).toFixed(2)]}),r.jsx(dt,{children:r.jsx(_t,{className:Ube[C.status],children:a5[C.status]})}),r.jsx(dt,{className:"text-right",children:r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>v(C),children:[r.jsx(Ii,{className:"h-4 w-4 mr-1"}),"View"]})})]},C.id)})})]}):r.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No orders yet."})})]}),r.jsx(Ir,{open:l,onOpenChange:i,children:r.jsxs(Er,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:["Order ",a==null?void 0:a.order_number]})}),a&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"font-medium mb-2",children:"Customer"}),r.jsx("p",{children:(w=a.user)==null?void 0:w.name}),r.jsx("p",{className:"text-sm text-muted-foreground",children:(S=a.user)==null?void 0:S.email})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"font-medium mb-2",children:"Shipping Address"}),r.jsx("p",{children:a.shipping_name}),r.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.shipping_address,r.jsx("br",{}),a.shipping_city,", ",a.shipping_state," ",a.shipping_zip]})]})]}),r.jsxs("div",{children:[r.jsx("h4",{className:"font-medium mb-2",children:"Order Items"}),r.jsx("div",{className:"space-y-3",children:(T=a.items)==null?void 0:T.map(C=>r.jsxs("div",{className:"border rounded-lg p-4",children:[r.jsxs("div",{className:"flex justify-between items-start mb-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:C.product_name}),C.variant_name&&r.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name})]}),r.jsxs("p",{className:"font-bold",children:["$",Number(C.unit_price).toFixed(2)," x ",C.quantity]})]}),C.artwork_url&&r.jsxs("div",{className:"mt-2",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Customer Artwork:"}),r.jsx("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Artwork"})]}),r.jsx("div",{className:"mt-3 pt-3 border-t",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",children:"Proof Status: "}),r.jsx(_t,{variant:C.proof_status==="approved"?"default":"secondary",children:C.proof_status||"No proof yet"})]}),C.proof_url?r.jsx("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline text-sm",children:"View Proof"}):r.jsxs("div",{children:[r.jsx("input",{type:"file",accept:"image/*,.pdf",onChange:I=>k(I,C.id),className:"hidden",id:`proof-${C.id}`,disabled:p}),r.jsx("label",{htmlFor:`proof-${C.id}`,children:r.jsx(X,{variant:"outline",size:"sm",asChild:!0,children:r.jsxs("span",{children:[r.jsx(Xi,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},C.id))})]}),r.jsxs("div",{className:"border-t pt-4",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{children:"Subtotal"}),r.jsxs("span",{children:["$",Number(a.subtotal).toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{children:"Shipping"}),r.jsxs("span",{children:["$",Number(a.shipping_total).toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between font-bold text-lg mt-2",children:[r.jsx("span",{children:"Total"}),r.jsxs("span",{children:["$",Number(a.total).toFixed(2)]})]})]}),r.jsxs("div",{className:"border-t pt-4",children:[r.jsx("h4",{className:"font-medium mb-3",children:"Update Order Status"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Status"}),r.jsxs(ds,{value:d.status,onValueChange:C=>m({...d,status:C}),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:Tor.map(C=>r.jsx(Ut,{value:C,children:a5[C]},C))})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Tracking Number"}),r.jsx(Ye,{value:d.trackingNumber,onChange:C=>m({...d,trackingNumber:C.target.value}),placeholder:"Enter tracking number"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Tracking URL"}),r.jsx(Ye,{value:d.trackingUrl,onChange:C=>m({...d,trackingUrl:C.target.value}),placeholder:"https://..."})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Notes (optional)"}),r.jsx(qs,{value:d.notes,onChange:C=>m({...d,notes:C.target.value}),placeholder:"Add a note about this status change..."})]}),r.jsxs(X,{onClick:_,disabled:s.isPending,className:"w-full",children:[r.jsx(ec,{className:"h-4 w-4 mr-2"}),"Update Status"]})]})]}),a.status_history&&a.status_history.length>0&&r.jsxs("div",{className:"border-t pt-4",children:[r.jsx("h4",{className:"font-medium mb-3",children:"Status History"}),r.jsx("div",{className:"space-y-2",children:a.status_history.map(C=>r.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[r.jsxs("div",{children:[r.jsx(_t,{variant:"outline",children:a5[C.status]}),C.notes&&r.jsx("p",{className:"text-muted-foreground mt-1",children:C.notes})]}),r.jsx("span",{className:"text-muted-foreground",children:Xr(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function Eor(){const[e,t]=A.useState("products"),s=Ks();return r.jsx(Ur,{title:"Marketplace Management",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold",children:"Marketplace Management"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage products, categories, and orders"})]}),r.jsxs(X,{variant:"outline",onClick:()=>s("/marketplace"),children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),r.jsxs(ii,{value:e,onValueChange:t,children:[r.jsxs(si,{className:"grid w-full grid-cols-3",children:[r.jsxs(Kr,{value:"products",className:"flex items-center gap-2",children:[r.jsx(ec,{className:"h-4 w-4"}),"Products"]}),r.jsxs(Kr,{value:"categories",className:"flex items-center gap-2",children:[r.jsx(Jh,{className:"h-4 w-4"}),"Categories"]}),r.jsxs(Kr,{value:"orders",className:"flex items-center gap-2",children:[r.jsx(Wh,{className:"h-4 w-4"}),"Orders"]})]}),r.jsx(hs,{value:"products",children:r.jsx(Mor,{})}),r.jsx(hs,{value:"categories",children:r.jsx(Cor,{})}),r.jsx(hs,{value:"orders",children:r.jsx(Aor,{})})]})]})})}function EZe(){return Ht({queryKey:["reward-categories"],queryFn:async()=>{const{data:e,error:t}=await Y.from("reward_store_categories").select("*").order("sort_order",{ascending:!0});if(t)throw t;return e}})}function Ior(e){return Ht({queryKey:["reward-items",e],queryFn:async()=>{let t=Y.from("reward_store_items").select(` *, category:reward_store_categories(*) `).order("created_at",{ascending:!1});const{data:s,error:n}=await t;if(n)throw n;return s}})}function Por(e){return Ht({queryKey:["active-reward-items",e],queryFn:async()=>{let t=Y.from("reward_store_items").select(` *, category:reward_store_categories(*) `).eq("is_active",!0).order("created_at",{ascending:!1});e&&(t=t.eq("category_id",e));const{data:s,error:n}=await t;if(n)throw n;return s}})}function Lor(e){return Ht({queryKey:["user-purchases",e],queryFn:async()=>{if(!e)return[];const{data:t,error:s}=await Y.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).eq("user_id",e).order("purchased_at",{ascending:!1});if(s)throw s;return t},enabled:!!e})}function Dor(){return Ht({queryKey:["all-reward-purchases"],queryFn:async()=>{const{data:e,error:t}=await Y.from("reward_store_purchases").select(` *, item:reward_store_items(*) `).order("purchased_at",{ascending:!1});if(t)throw t;if(!e||e.length===0)return[];const s=[...new Set(e.map(l=>l.user_id))],{data:n,error:a}=await Y.from("profiles").select("id, name, email").in("id",s);if(a)throw a;const o=new Map((n==null?void 0:n.map(l=>[l.id,l]))||[]);return e.map(l=>({...l,user:o.get(l.user_id)||null}))}})}function Oor(e){return Ht({queryKey:["spendable-points",e],queryFn:async()=>{if(!e)return 0;const{data:t,error:s}=await Y.from("agent_attendance_stats").select("spendable_points").eq("user_id",e).single();if(s&&s.code!=="PGRST116")throw s;return(t==null?void 0:t.spendable_points)||0},enabled:!!e})}function Ror(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.rpc("purchase_reward_item",{p_item_id:t});if(n)throw n;const a=s;if(!a.success)throw new Error(a.error||"Purchase failed");return a},onSuccess:()=>{e.invalidateQueries({queryKey:["user-purchases"]}),e.invalidateQueries({queryKey:["spendable-points"]}),e.invalidateQueries({queryKey:["active-reward-items"]}),e.invalidateQueries({queryKey:["reward-items"]})}})}function For(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("reward_store_categories").insert([t]).select().single();if(n)throw n;return s},onSuccess:()=>{e.invalidateQueries({queryKey:["reward-categories"]})}})}function zor(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("reward_store_categories").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["reward-categories"]})}})}function Bor(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("reward_store_categories").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["reward-categories"]})}})}function $or(){const e=Rr();return Qt({mutationFn:async t=>{const{data:s,error:n}=await Y.from("reward_store_items").insert([t]).select().single();if(n)throw n;return s},onSuccess:()=>{e.invalidateQueries({queryKey:["reward-items"]}),e.invalidateQueries({queryKey:["active-reward-items"]})}})}function Uor(){const e=Rr();return Qt({mutationFn:async({id:t,...s})=>{const{data:n,error:a}=await Y.from("reward_store_items").update(s).eq("id",t).select().single();if(a)throw a;return n},onSuccess:()=>{e.invalidateQueries({queryKey:["reward-items"]}),e.invalidateQueries({queryKey:["active-reward-items"]})}})}function Vor(){const e=Rr();return Qt({mutationFn:async t=>{const{error:s}=await Y.from("reward_store_items").delete().eq("id",t);if(s)throw s},onSuccess:()=>{e.invalidateQueries({queryKey:["reward-items"]}),e.invalidateQueries({queryKey:["active-reward-items"]})}})}function qor(e){const t=e.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return t?{bucket:t[1],path:t[2]}:null}async function rme(e,t){const s=qor(e);if(s)try{const{data:n,error:a}=await Y.storage.from(s.bucket).download(s.path);if(a){console.error("Error downloading file:",a),we.error("Failed to download file");return}const o=URL.createObjectURL(n),l=document.createElement("a");l.href=o,l.download=t||s.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),we.error("Failed to download file")}else try{const a=await(await fetch(e)).blob(),o=URL.createObjectURL(a),l=document.createElement("a");l.href=o,l.download=t||e.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),we.error("Failed to download file")}}function IZe(){return Ht({queryKey:["point-reward-settings"],queryFn:async()=>{const{data:e,error:t}=await Y.from("point_reward_settings").select("*").order("action_name");if(t)throw t;return e}})}function Hor(){const e=Rr();return Qt({mutationFn:async({id:t,points:s,is_active:n})=>{const a={points:s};n!==void 0&&(a.is_active=n);const{data:o,error:l}=await Y.from("point_reward_settings").update(a).eq("id",t).select().single();if(l)throw l;return o},onSuccess:()=>{e.invalidateQueries({queryKey:["point-reward-settings"]})}})}function Wor(){const{user:e}=Gr(),[t,s]=A.useState("items"),[n,a]=A.useState(!1),[o,l]=A.useState(null),[i,d]=A.useState(""),[m,p]=A.useState(""),[g,v]=A.useState(""),[_,k]=A.useState(null),[w,S]=A.useState(!1),[T,C]=A.useState(null),[I,R]=A.useState(""),[D,B]=A.useState(""),[$,q]=A.useState(null),[W,K]=A.useState(""),[re,ae]=A.useState("file"),[oe,se]=A.useState(""),[pe,ie]=A.useState(""),[de,ce]=A.useState(""),[ge,Te]=A.useState(!0),[_e,ve]=A.useState(null),[Me,Ze]=A.useState(!1),[Ae,Le]=A.useState(!1),Ue=A.useRef(null),Ve=A.useRef(null),{data:Ie,isLoading:We}=EZe(),{data:wt,isLoading:Pe}=Ior(),{data:st,isLoading:ue}=Dor(),{data:$e,isLoading:tt}=IZe(),rt=For(),je=zor(),it=Bor(),Se=$or(),et=Uor(),Qe=Vor(),He=Hor(),[ot,ut]=A.useState({}),ft=Et=>{Et?(l(Et),d(Et.name),p(Et.description||""),v(Et.icon||"")):(l(null),d(""),p(""),v("")),a(!0)},ct=async()=>{if(!i.trim()){we.error("Please enter a category name");return}try{o?(await je.mutateAsync({id:o.id,name:i,description:m||null,icon:g||null}),we.success("Category updated successfully")):(await rt.mutateAsync({name:i,description:m||null,icon:g||null,sort_order:((Ie==null?void 0:Ie.length)||0)+1}),we.success("Category created successfully")),a(!1)}catch(Et){console.error("Error saving category:",Et),we.error("Failed to save category")}},Tt=async()=>{if(_)try{await it.mutateAsync(_),we.success("Category deleted successfully"),k(null)}catch(Et){console.error("Error deleting category:",Et),we.error("Failed to delete category")}},Ot=Et=>{var Pt;Et?(C(Et),R(Et.name),B(Et.description||""),q(Et.category_id),K(Et.points_cost.toString()),ae(Et.item_type),se(Et.file_url||""),ie(Et.preview_image_url||""),ce(((Pt=Et.max_quantity)==null?void 0:Pt.toString())||""),Te(Et.is_active)):(C(null),R(""),B(""),q(null),K(""),ae("file"),se(""),ie(""),ce(""),Te(!0)),S(!0)},rr=async(Et,Pt)=>{Pt==="file"?Ze(!0):Le(!0);try{const Sr=Et.name.split(".").pop(),fs=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Sr}`,Ws=`${Pt==="file"?"items":"previews"}/${fs}`,{error:tn}=await Y.storage.from("reward-store").upload(Ws,Et);if(tn)throw tn;const{data:{publicUrl:xi}}=Y.storage.from("reward-store").getPublicUrl(Ws);Pt==="file"?se(xi):ie(xi),we.success("File uploaded successfully")}catch(Sr){console.error("Error uploading file:",Sr),we.error("Failed to upload file")}finally{Pt==="file"?Ze(!1):Le(!1)}},Lr=async()=>{if(!I.trim()){we.error("Please enter an item name");return}if(!W||parseInt(W)<0){we.error("Please enter a valid points cost");return}try{const Et={name:I,description:D||null,category_id:$,points_cost:parseInt(W),item_type:re,file_url:oe||null,preview_image_url:pe||null,max_quantity:de?parseInt(de):null,current_quantity:de?parseInt(de):null,is_active:ge,created_by:e==null?void 0:e.id};T?(await et.mutateAsync({id:T.id,...Et,current_quantity:T.max_quantity!==(de?parseInt(de):null)?de?parseInt(de):null:T.current_quantity}),we.success("Item updated successfully")):(await Se.mutateAsync(Et),we.success("Item created successfully")),S(!1)}catch(Et){console.error("Error saving item:",Et),we.error("Failed to save item")}},cr=async()=>{if(_e)try{await Qe.mutateAsync(_e),we.success("Item deleted successfully"),ve(null)}catch(Et){console.error("Error deleting item:",Et),we.error("Failed to delete item")}},Mr=async(Et,Pt)=>{const Sr=ot[Et];if(Sr===void 0||Sr===Pt.toString())return;const fs=parseInt(Sr);if(isNaN(fs)||fs<0){we.error("Please enter a valid positive number");return}try{await He.mutateAsync({id:Et,points:fs}),we.success("Points updated successfully"),ut(Ws=>{const tn={...Ws};return delete tn[Et],tn})}catch(Ws){console.error("Error updating points:",Ws),we.error("Failed to update points")}};return We||Pe||ue||tt?r.jsx(Ur,{title:"Reward Store",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-8 w-64"}),r.jsx(pr,{className:"h-96"})]})}):r.jsxs(Ur,{title:"Reward Store",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Reward Store Management"}),r.jsx("p",{className:"text-muted-foreground",children:"Manage store items that agents can purchase with their points"})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(ec,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Total Items"})]}),r.jsx("p",{className:"text-2xl font-bold",children:(wt==null?void 0:wt.length)||0}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[(wt==null?void 0:wt.filter(Et=>Et.is_active).length)||0," active"]})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Jh,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),r.jsx("p",{className:"text-2xl font-bold",children:(Ie==null?void 0:Ie.length)||0})]})}),r.jsx(ze,{children:r.jsxs(qe,{className:"pt-4",children:[r.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[r.jsx(Dn,{className:"h-4 w-4"}),r.jsx("span",{className:"text-xs font-medium",children:"Avg. Cost"})]}),r.jsxs("p",{className:"text-2xl font-bold",children:[wt&&wt.length>0?Math.round(wt.reduce((Et,Pt)=>Et+Pt.points_cost,0)/wt.length):0," pts"]})]})})]}),r.jsxs(ii,{value:t,onValueChange:s,children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"items",children:"Items"}),r.jsx(Kr,{value:"categories",children:"Categories"}),r.jsx(Kr,{value:"purchases",children:"Purchases"}),r.jsx(Kr,{value:"point-settings",children:"Point Settings"})]}),r.jsx(hs,{value:"items",className:"mt-4",children:r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Store Items"}),r.jsx(Cs,{children:"Manage rewards that agents can purchase"})]}),r.jsxs(X,{onClick:()=>Ot(),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),r.jsx(qe,{children:!wt||wt.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(po,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No items yet. Add your first reward item!"})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Item"}),r.jsx(Mt,{children:"Category"}),r.jsx(Mt,{className:"text-center",children:"Cost"}),r.jsx(Mt,{className:"text-center",children:"Type"}),r.jsx(Mt,{className:"text-center",children:"Quantity"}),r.jsx(Mt,{className:"text-center",children:"Status"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:wt.map(Et=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[Et.preview_image_url?r.jsx("img",{src:Et.preview_image_url,alt:Et.name,className:"h-10 w-10 rounded object-cover"}):r.jsx("div",{className:"h-10 w-10 rounded bg-muted flex items-center justify-center",children:r.jsx(po,{className:"h-5 w-5 text-muted-foreground"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:Et.name}),r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:Et.description||"No description"})]})]})}),r.jsx(dt,{children:Et.category?r.jsx(_t,{variant:"outline",children:Et.category.name}):r.jsx("span",{className:"text-muted-foreground",children:"—"})}),r.jsx(dt,{className:"text-center",children:r.jsxs(_t,{variant:"secondary",className:"font-bold",children:[r.jsx(Dn,{className:"h-3 w-3 mr-1"}),Et.points_cost]})}),r.jsx(dt,{className:"text-center",children:r.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Et.item_type==="file"?r.jsx(ya,{className:"h-4 w-4 text-muted-foreground"}):r.jsx(Lo,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"text-xs capitalize",children:Et.item_type})]})}),r.jsx(dt,{className:"text-center",children:Et.max_quantity!==null?r.jsxs("span",{className:Et.current_quantity===0?"text-red-500":"",children:[Et.current_quantity,"/",Et.max_quantity]}):r.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),r.jsx(dt,{className:"text-center",children:r.jsx(_t,{variant:Et.is_active?"default":"secondary",children:Et.is_active?"Active":"Inactive"})}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>Ot(Et),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>ve(Et.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},Et.id))})]})})]})}),r.jsx(hs,{value:"categories",className:"mt-4",children:r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(Zt,{children:"Categories"}),r.jsx(Cs,{children:"Organize your store items into categories"})]}),r.jsxs(X,{onClick:()=>ft(),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),r.jsx(qe,{children:!Ie||Ie.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(Jh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No categories yet. Add your first category!"})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Name"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{className:"text-center",children:"Items"}),r.jsx(Mt,{className:"text-right",children:"Actions"})]})}),r.jsx(Bn,{children:Ie.map(Et=>r.jsxs(Nr,{children:[r.jsxs(dt,{className:"font-medium",children:[Et.icon&&r.jsx("span",{className:"mr-2",children:Et.icon}),Et.name]}),r.jsx(dt,{className:"text-muted-foreground",children:Et.description||"—"}),r.jsx(dt,{className:"text-center",children:(wt==null?void 0:wt.filter(Pt=>Pt.category_id===Et.id).length)||0}),r.jsx(dt,{className:"text-right",children:r.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>ft(Et),children:r.jsx(Qa,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>k(Et.id),children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})})]})})]},Et.id))})]})})]})}),r.jsx(hs,{value:"purchases",className:"mt-4",children:r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Wh,{className:"h-5 w-5"}),"Purchase History"]}),r.jsx(Cs,{children:"View all reward redemptions by agents"})]}),r.jsx(qe,{children:!st||st.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(Wh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No purchases yet."})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Date"}),r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{children:"Item"}),r.jsx(Mt,{className:"text-center",children:"Points Spent"})]})}),r.jsx(Bn,{children:st.map(Et=>{var Pt,Sr,fs,Ws;return r.jsxs(Nr,{children:[r.jsx(dt,{className:"text-muted-foreground",children:Xr(new Date(Et.purchased_at),"MMM d, yyyy 'at' h:mm a")}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center",children:r.jsx(Fl,{className:"h-4 w-4 text-muted-foreground"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:((Pt=Et.user)==null?void 0:Pt.name)||"Unknown"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:((Sr=Et.user)==null?void 0:Sr.email)||"—"})]})]})}),r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-2",children:[(fs=Et.item)!=null&&fs.preview_image_url?r.jsx("img",{src:Et.item.preview_image_url,alt:Et.item.name,className:"h-8 w-8 rounded object-cover"}):r.jsx("div",{className:"h-8 w-8 rounded bg-muted flex items-center justify-center",children:r.jsx(po,{className:"h-4 w-4 text-muted-foreground"})}),r.jsx("span",{children:((Ws=Et.item)==null?void 0:Ws.name)||"Deleted item"})]})}),r.jsx(dt,{className:"text-center",children:r.jsxs(_t,{variant:"secondary",className:"font-bold",children:[r.jsx(Dn,{className:"h-3 w-3 mr-1"}),Et.points_spent]})})]},Et.id)})})]})})]})})]})]}),r.jsx(Ir,{open:n,onOpenChange:a,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:o?"Edit Category":"Add Category"}),r.jsx(Zs,{children:o?"Update the category details":"Create a new category for your store items"})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"categoryName",children:"Name"}),r.jsx(Ye,{id:"categoryName",value:i,onChange:Et=>d(Et.target.value),placeholder:"e.g., Templates, Resources"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"categoryDescription",children:"Description"}),r.jsx(qs,{id:"categoryDescription",value:m,onChange:Et=>p(Et.target.value),placeholder:"Optional description..."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),r.jsx(Ye,{id:"categoryIcon",value:g,onChange:Et=>v(Et.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),r.jsx(X,{onClick:ct,disabled:rt.isPending||je.isPending,children:rt.isPending||je.isPending?"Saving...":"Save"})]})]})}),r.jsx(Ir,{open:w,onOpenChange:S,children:r.jsxs(Er,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:T?"Edit Item":"Add Item"}),r.jsx(Zs,{children:T?"Update the item details":"Create a new reward item for agents to purchase"})]}),r.jsxs("div",{className:"space-y-4 py-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"itemName",children:"Name *"}),r.jsx(Ye,{id:"itemName",value:I,onChange:Et=>R(Et.target.value),placeholder:"e.g., Premium Template Pack"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"itemDescription",children:"Description"}),r.jsx(qs,{id:"itemDescription",value:D,onChange:Et=>B(Et.target.value),placeholder:"Describe the item..."})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"itemCategory",children:"Category"}),r.jsxs(ds,{value:$||"none",onValueChange:Et=>q(Et==="none"?null:Et),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select category"})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"none",children:"No category"}),Ie==null?void 0:Ie.map(Et=>r.jsxs(Ut,{value:Et.id,children:[Et.icon&&`${Et.icon} `,Et.name]},Et.id))]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"itemPointsCost",children:"Points Cost *"}),r.jsx(Ye,{id:"itemPointsCost",type:"number",min:"0",value:W,onChange:Et=>K(Et.target.value),placeholder:"e.g., 100"})]})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"itemType",children:"Type"}),r.jsxs(ds,{value:re,onValueChange:ae,children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"file",children:"File Download"}),r.jsx(Ut,{value:"link",children:"External Link"})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),r.jsx(Ye,{id:"itemMaxQuantity",type:"number",min:"1",value:de,onChange:Et=>ce(Et.target.value),placeholder:"Leave empty for unlimited"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"File / Link URL"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:oe,onChange:Et=>se(Et.target.value),placeholder:re==="file"?"Upload a file or paste URL":"Paste external link"}),re==="file"&&r.jsxs(r.Fragment,{children:[r.jsx(X,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Et;return(Et=Ue.current)==null?void 0:Et.click()},disabled:Me,children:r.jsx(Xi,{className:"h-4 w-4"})}),r.jsx("input",{ref:Ue,type:"file",className:"hidden",onChange:Et=>{var Sr;const Pt=(Sr=Et.target.files)==null?void 0:Sr[0];Pt&&rr(Pt,"file")}})]})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Preview Image"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Ye,{value:pe,onChange:Et=>ie(Et.target.value),placeholder:"Upload an image or paste URL"}),r.jsx(X,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Et;return(Et=Ve.current)==null?void 0:Et.click()},disabled:Ae,children:r.jsx(Nl,{className:"h-4 w-4"})}),r.jsx("input",{ref:Ve,type:"file",accept:"image/*",className:"hidden",onChange:Et=>{var Sr;const Pt=(Sr=Et.target.files)==null?void 0:Sr[0];Pt&&rr(Pt,"preview")}})]}),pe&&r.jsx("img",{src:pe,alt:"Preview",className:"mt-2 h-24 rounded object-cover"})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(fn,{id:"itemIsActive",checked:ge,onCheckedChange:Te}),r.jsx(Ee,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),r.jsx(X,{onClick:Lr,disabled:Se.isPending||et.isPending,children:Se.isPending||et.isPending?"Saving...":"Save"})]})]})}),r.jsx($c,{open:!!_,onOpenChange:()=>k(null),children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Delete Category"}),r.jsx(bc,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:Tt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),r.jsx($c,{open:!!_e,onOpenChange:()=>ve(null),children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Delete Item"}),r.jsx(bc,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:cr,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),t==="point-settings"&&r.jsxs(ze,{className:"mt-4",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ld,{className:"h-5 w-5"}),r.jsxs("div",{children:[r.jsx(Zt,{children:"Point Reward Settings"}),r.jsx(Cs,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),r.jsx(qe,{children:!$e||$e.length===0?r.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[r.jsx(ld,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{children:"No point settings configured."})]}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Action"}),r.jsx(Mt,{children:"Description"}),r.jsx(Mt,{className:"text-center w-32",children:"Points"}),r.jsx(Mt,{className:"text-right w-24",children:"Save"})]})}),r.jsx(Bn,{children:$e.map(Et=>r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsx("p",{className:"font-medium",children:Et.action_name})}),r.jsx(dt,{children:r.jsx("p",{className:"text-sm text-muted-foreground",children:Et.description})}),r.jsx(dt,{className:"text-center",children:r.jsx(Ye,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:ot[Et.id]??Et.points.toString(),onChange:Pt=>ut(Sr=>({...Sr,[Et.id]:Pt.target.value}))})}),r.jsx(dt,{className:"text-right",children:r.jsx(X,{size:"sm",variant:"outline",disabled:ot[Et.id]===void 0||ot[Et.id]===Et.points.toString()||He.isPending,onClick:()=>Mr(Et.id,Et.points),children:r.jsx(zf,{className:"h-4 w-4"})})})]},Et.id))})]})})]})]})}const RIe=()=>r.jsxs("svg",{viewBox:"0 0 100 100",className:"h-5 w-5",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("rect",{width:"100",height:"100",rx:"20",fill:"#7D2AE8"}),r.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"})]}),FIe=[{value:"template",label:"Templates"},{value:"brand",label:"Brand Assets"},{value:"listing",label:"Listing Assets"},{value:"social",label:"Social Media"},{value:"general",label:"General"}];function Gor(){const e=Rr(),[t,s]=A.useState(!1),[n,a]=A.useState(!1),[o,l]=A.useState(!1),[i,d]=A.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:m,isLoading:p}=Ht({queryKey:["canva-integration"],queryFn:async()=>{const{data:C,error:I}=await Y.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(I)throw I;return C}}),{data:g}=Ht({queryKey:["brokerages-list"],queryFn:async()=>{const{data:C,error:I}=await Y.from("brokerages").select("id, name").order("name");if(I)throw I;return C}}),{data:v}=Ht({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:C,error:I}=await Y.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(I)throw I;return C}}),_=async()=>{var C;s(!0);try{const{data:I}=await Y.auth.getSession(),R=(C=I==null?void 0:I.session)==null?void 0:C.access_token;if(!R)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 ${R}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to get authorization URL");if(q!=null&&q.authUrl){localStorage.setItem("canva_code_verifier",q.codeVerifier),localStorage.setItem("canva_oauth_state",q.state);const W=window.open(q.authUrl,"canva-oauth","width=600,height=700,scrollbars=yes,resizable=yes");if(!W){we.error("Popup was blocked. Please allow popups for this site and try again."),s(!1);return}const K=ae=>{var oe,se;ae.origin===window.location.origin&&(((oe=ae.data)==null?void 0:oe.type)==="canva-oauth-success"?(window.removeEventListener("message",K),we.success("Canva connected successfully!"),e.invalidateQueries({queryKey:["canva-integration"]}),s(!1)):((se=ae.data)==null?void 0:se.type)==="canva-oauth-error"&&(window.removeEventListener("message",K),we.error("Canva connection failed: "+(ae.data.error||"Unknown error")),s(!1)))};window.addEventListener("message",K);const re=setInterval(()=>{W.closed&&(clearInterval(re),window.removeEventListener("message",K),e.invalidateQueries({queryKey:["canva-integration"]}),s(!1))},500)}else throw new Error("Failed to get authorization URL")}catch(I){console.error("Canva connect error:",I);const R=(I==null?void 0:I.message)||"";R.includes("CANVA_CLIENT_ID")?we.error("Canva app credentials not configured yet."):we.error(R||"Failed to start Canva connection"),s(!1)}},k=Qt({mutationFn:async C=>{var W;const{data:I}=await Y.auth.getSession(),R=(W=I==null?void 0:I.session)==null?void 0:W.access_token;if(!R)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 ${R}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:C})}),q=await $.json();if(!$.ok||q!=null&&q.error)throw new Error((q==null?void 0:q.error)||"Failed to disconnect")},onSuccess:()=>{e.invalidateQueries({queryKey:["canva-integration"]}),we.success("Canva disconnected")},onError:C=>{we.error(C.message||"Failed to disconnect Canva")}}),w=Qt({mutationFn:async C=>{const{error:I}=await Y.from("canva_brokerage_folders").insert({brokerage_id:C.brokerage_id,folder_id:C.folder_id.trim(),folder_name:C.folder_name.trim(),folder_type:C.folder_type,description:C.description.trim()||null,sort_order:(v==null?void 0:v.length)||0});if(I)throw I},onSuccess:()=>{e.invalidateQueries({queryKey:["canva-brokerage-folders"]}),we.success("Folder added"),l(!1),d({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>we.error("Failed to add folder")}),S=Qt({mutationFn:async C=>{const{error:I}=await Y.from("canva_brokerage_folders").delete().eq("id",C);if(I)throw I},onSuccess:()=>{e.invalidateQueries({queryKey:["canva-brokerage-folders"]}),we.success("Folder removed")},onError:()=>we.error("Failed to remove folder")}),T=!!m;return r.jsxs(r.Fragment,{children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 rounded-lg bg-accent flex items-center justify-center",children:r.jsx(RIe,{})}),r.jsxs("div",{children:[r.jsxs(Zt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",T&&r.jsx(_t,{variant:"default",className:"text-xs",children:"Connected"}),r.jsx(_t,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),r.jsx(Cs,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),r.jsx(qe,{children:r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[r.jsx(ui,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),r.jsx("span",{children:"OAuth 2.0 + PKCE for secure authorization"})]}),r.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[r.jsx(ui,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),r.jsx("span",{children:"Map brokerage folders to auto-share with agents on connection"})]}),r.jsxs("div",{className:"flex items-start gap-2 text-sm text-muted-foreground",children:[r.jsx(ui,{className:"h-4 w-4 mt-0.5 text-primary shrink-0"}),r.jsx("span",{children:"Multiple folders per brokerage (templates, brand assets, listings)"})]}),r.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-muted border border-dashed",children:[r.jsx("p",{className:"text-xs font-medium text-foreground mb-1",children:"Canva App Redirect URL"}),r.jsx("code",{className:"text-xs text-muted-foreground break-all select-all",children:"https://dashboard.relevelup.com/canva-callback.html"})]}),T?r.jsxs("div",{className:"space-y-3 mt-4",children:[r.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-sm",children:m.canva_team_id?`Team: ${m.canva_team_id}`:"Canva Account"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:m.expires_at?`Token expires ${new Date(m.expires_at).toLocaleDateString()}`:"Platform integration active"})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect Canva?"}),r.jsx(bc,{children:"This will remove the Canva platform integration. Agents who have already connected will not be affected, but new folder sharing will stop."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>k.mutate(m.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]}),r.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[r.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:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Jh,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",v&&v.length>0&&r.jsx(_t,{variant:"secondary",className:"text-xs",children:v.length})]}),n?r.jsx(cx,{className:"h-4 w-4"}):r.jsx(ad,{className:"h-4 w-4"})]}),n&&r.jsxs("div",{className:"border-t p-3 space-y-2",children:[v&&v.length>0?v.map(C=>{var I,R;return r.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 text-sm",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"font-medium truncate",children:C.folder_name}),r.jsx(_t,{variant:"outline",className:"text-xs shrink-0",children:((I=FIe.find(D=>D.value===C.folder_type))==null?void 0:I.label)||C.folder_type})]}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[(R=C.brokerages)==null?void 0:R.name," · ID: ",r.jsx("span",{className:"font-mono",children:C.folder_id})]})]}),r.jsx(X,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive shrink-0 ml-2",onClick:()=>S.mutate(C.id),children:r.jsx(Xs,{className:"h-3.5 w-3.5"})})]},C.id)}):r.jsx("p",{className:"text-sm text-muted-foreground text-center py-2",children:"No folders mapped yet"}),r.jsxs(X,{variant:"outline",size:"sm",className:"w-full gap-1.5 mt-1",onClick:()=>l(!0),children:[r.jsx(gs,{className:"h-3.5 w-3.5"}),"Add Folder Mapping"]})]})]})]}):r.jsxs(X,{className:"mt-4",onClick:_,disabled:t||p,children:[t?r.jsx(Yo,{className:"h-4 w-4 mr-2 animate-spin"}):r.jsx("div",{className:"mr-2",children:r.jsx(RIe,{})}),"Connect Canva",r.jsx(Ki,{className:"h-4 w-4 ml-2"})]})]})})]}),r.jsx(Ir,{open:o,onOpenChange:l,children:r.jsxs(Er,{children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Add Brokerage Folder Mapping"})}),r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Brokerage"}),r.jsxs(ds,{value:i.brokerage_id,onValueChange:C=>d(I=>({...I,brokerage_id:C})),children:[r.jsx(ls,{children:r.jsx(us,{placeholder:"Select a brokerage…"})}),r.jsx(cs,{children:g==null?void 0:g.map(C=>r.jsx(Ut,{value:C.id,children:C.name},C.id))})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Canva Folder ID"}),r.jsx(Ye,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:C=>d(I=>({...I,folder_id:C.target.value}))}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Found in the Canva folder URL: canva.com/folder/",r.jsx("strong",{children:"FOLDER_ID"})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Folder Display Name"}),r.jsx(Ye,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:C=>d(I=>({...I,folder_name:C.target.value}))})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx(Ee,{children:"Folder Type"}),r.jsxs(ds,{value:i.folder_type,onValueChange:C=>d(I=>({...I,folder_type:C})),children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:FIe.map(C=>r.jsx(Ut,{value:C.value,children:C.label},C.value))})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs(Ee,{children:["Description ",r.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),r.jsx(Ye,{placeholder:"What's in this folder?",value:i.description,onChange:C=>d(I=>({...I,description:C.target.value}))})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),r.jsxs(X,{onClick:()=>w.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||w.isPending,children:[w.isPending?r.jsx(Yo,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function Kor(){return r.jsx(Ur,{children:r.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[r.jsx(Hu,{title:"Integrations",description:"Manage platform-level service connections"}),r.jsx(Gor,{})]})})}const Zor={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 PA(e,t=18,s=10){return e.length<=t+s+3?e:`${e.slice(0,t)}…${e.slice(-s)}`}function Yor(){var re,ae,oe,se,pe;const e=Rr(),[t,s]=A.useState("Test Push"),[n,a]=A.useState("Testing web push notification"),[o,l]=A.useState("/community"),[i,d]=A.useState(!1),[m,p]=A.useState(!1),[g,v]=A.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[_,k]=A.useState(null),[w,S]=A.useState(null),{data:T,isLoading:C}=Ht({queryKey:["push-notification-settings"],queryFn:async()=>{const{data:ie,error:de}=await Y.from("push_notification_settings").select("*").order("setting_key");if(de)throw de;return ie}}),{data:I,isLoading:R}=Ht({queryKey:["push-subscription-stats"],queryFn:async()=>{const{count:ie,error:de}=await Y.from("push_subscriptions").select("*",{count:"exact",head:!0});if(de)throw de;return{totalSubscriptions:ie||0}}}),D=Qt({mutationFn:async({settingKey:ie,isEnabled:de})=>{const{error:ce}=await Y.from("push_notification_settings").update({is_enabled:de}).eq("setting_key",ie);if(ce)throw ce},onSuccess:()=>{e.invalidateQueries({queryKey:["push-notification-settings"]}),we.success("Notification setting updated")},onError:ie=>{we.error("Failed to update setting: "+ie.message)}}),B=A.useMemo(()=>{var ie,de;return g.isSupported?`perm=${g.permission??"unknown"} · controller=${g.controllerPresent?"yes":"no"} · sw=${((ie=g.serviceWorker)==null?void 0:ie.activeState)??"unknown"} · sub=${(de=g.subscription)!=null&&de.endpoint?"yes":"no"}`:"Push not supported in this browser."},[g]);A.useEffect(()=>{let ie=!0;const de=async()=>{var _e,ve,Me,Ze,Ae,Le,Ue;const ge="serviceWorker"in navigator&&"PushManager"in window,Te={isSupported:ge,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((_e=navigator.serviceWorker)!=null&&_e.controller)};if(!ge){ie&&v(Te);return}try{const{data:Ve,error:Ie}=await Y.functions.invoke("get-vapid-public-key",{body:{}});if(Ie)throw Ie;Te.vapidPublicKey=Ve==null?void 0:Ve.vapidPublicKey;const wt=(await navigator.serviceWorker.getRegistrations()).find(Pe=>{var ue,$e,tt;return(((ue=Pe.active)==null?void 0:ue.scriptURL)||(($e=Pe.waiting)==null?void 0:$e.scriptURL)||((tt=Pe.installing)==null?void 0:tt.scriptURL)||"").includes("/sw.js")});if(wt){Te.pushWorkerScriptUrl=((ve=wt.active)==null?void 0:ve.scriptURL)||((Me=wt.waiting)==null?void 0:Me.scriptURL)||((Ze=wt.installing)==null?void 0:Ze.scriptURL),Te.serviceWorker={scope:wt.scope,activeState:(Ae=wt.active)==null?void 0:Ae.state};const Pe=await wt.pushManager.getSubscription();if(Pe){const st=Pe.toJSON();Te.subscription={endpoint:st.endpoint,p256dh:(Le=st.keys)==null?void 0:Le.p256dh,auth:(Ue=st.keys)==null?void 0:Ue.auth}}}}catch(Ve){Te.error=(Ve==null?void 0:Ve.message)||String(Ve)}ie&&v(Te)};de();const ce=window.setInterval(de,4e3);return()=>{ie=!1,window.clearInterval(ce)}},[]);const $=async()=>{if(typeof Notification>"u"){we.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){we.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),we.success("Triggered a local notification (not push).")}catch(ie){we.error(`Local notification failed: ${(ie==null?void 0:ie.message)||String(ie)}`)}},q=async()=>{d(!0),k(null);try{const{data:ie,error:de}=await Y.functions.invoke("send-push-notification",{body:{title:t,body:n,url:o}});if(de)throw de;k({sent:ie==null?void 0:ie.sent,failed:ie==null?void 0:ie.failed,expiredCleaned:ie==null?void 0:ie.expiredCleaned,vapidPublicKey:ie==null?void 0:ie.vapidPublicKey}),(ie==null?void 0:ie.sent)>0?we.success(`Test notification sent to ${ie.sent} subscriber(s)`):(ie==null?void 0:ie.failed)>0?we.warning(`Notification failed for ${ie.failed} subscriber(s). ${ie.expired||0} expired subscriptions cleaned up.`):we.info("No active subscriptions to send to")}catch(ie){console.error("Error sending test notification:",ie),k({error:(ie==null?void 0:ie.message)||String(ie)}),we.error("Failed to send test notification: "+(ie.message||"Unknown error"))}finally{d(!1)}},W=async()=>{p(!0),S(null);try{const{data:ie,error:de}=await Y.functions.invoke("generate-vapid-keys",{body:{}});if(de)throw de;const ce=ie==null?void 0:ie.publicKey,ge=ie==null?void 0:ie.privateKey;if(!ce||!ge)throw new Error("generate-vapid-keys did not return keys");S({publicKey:ce,privateKey:ge}),we.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ie){console.error("Error generating VAPID keys:",ie),we.error("Failed to generate VAPID keys: "+((ie==null?void 0:ie.message)||"Unknown error"))}finally{p(!1)}},K=Qt({mutationFn:async()=>{const{error:ie}=await Y.from("push_subscriptions").delete().neq("id","00000000-0000-0000-0000-000000000000");if(ie)throw ie},onSuccess:()=>{we.success("All subscriptions cleared. Users will need to re-enable notifications."),e.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ie=>{we.error("Failed to clear subscriptions: "+ie.message)}});return r.jsx(Ur,{title:"Notification Settings",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Hu,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ws,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),r.jsx(Cs,{children:"Current active push notification subscriptions"})]}),r.jsx(qe,{children:r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"text-4xl font-bold",children:R?"...":(I==null?void 0:I.totalSubscriptions)||0}),r.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(ld,{className:"h-5 w-5"}),"Notification Types"]}),r.jsx(Cs,{children:"Control which types of push notifications are sent to users"})]}),r.jsx(qe,{children:C?r.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):r.jsx("div",{className:"space-y-4",children:T==null?void 0:T.map(ie=>{const de=Zor[ie.setting_key]||{label:ie.setting_key,icon:"🔔"};return r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("span",{className:"text-2xl",children:de.icon}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium",children:de.label}),r.jsx("div",{className:"text-sm text-muted-foreground",children:ie.description})]})]}),r.jsx(fn,{checked:ie.is_enabled,onCheckedChange:ce=>D.mutate({settingKey:ie.setting_key,isEnabled:ce}),disabled:D.isPending})]},ie.id)})})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(tg,{className:"h-5 w-5"}),"Send Test Notification"]}),r.jsx(Cs,{children:"Send a test push notification to all subscribed users"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[r.jsx("div",{className:"font-medium",children:"Client push debug"}),r.jsx("div",{className:"mt-1 text-muted-foreground",children:B}),g.error&&r.jsx("div",{className:"mt-2 text-destructive",children:g.error}),r.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Backend VAPID public key"}),r.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:g.vapidPublicKey?PA(g.vapidPublicKey):"(not loaded)"})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Service worker"}),r.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[r.jsxs("div",{children:["scope: ",(re=g.serviceWorker)!=null&&re.scope?PA(g.serviceWorker.scope,24,8):"none"]}),r.jsxs("div",{children:["active: ",((ae=g.serviceWorker)==null?void 0:ae.activeState)??"none"]})]})]}),r.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Current browser subscription"}),r.jsxs("div",{className:"rounded-md border bg-background p-2 font-mono text-xs",children:[r.jsxs("div",{children:["endpoint: ",(oe=g.subscription)!=null&&oe.endpoint?PA(g.subscription.endpoint,40,12):"none"]}),r.jsxs("div",{children:["p256dh: ",(se=g.subscription)!=null&&se.p256dh?PA(g.subscription.p256dh,22,10):"none"]}),r.jsxs("div",{children:["auth: ",(pe=g.subscription)!=null&&pe.auth?PA(g.subscription.auth,22,10):"none"]})]})]})]}),r.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[r.jsx(X,{variant:"outline",onClick:$,children:"Local notification test"}),r.jsx(X,{variant:"outline",onClick:()=>window.location.reload(),children:"Reload page"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"test-title",children:"Notification Title"}),r.jsx(Ye,{id:"test-title",value:t,onChange:ie=>s(ie.target.value),placeholder:"Enter notification title"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"test-body",children:"Notification Body"}),r.jsx(qs,{id:"test-body",value:n,onChange:ie=>a(ie.target.value),placeholder:"Enter notification message",rows:3})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"test-url",children:"Click URL (optional)"}),r.jsx(Ye,{id:"test-url",value:o,onChange:ie=>l(ie.target.value),placeholder:"/community or full URL"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Where users will be taken when they click the notification"})]}),r.jsxs(X,{onClick:q,disabled:i||!t||!n,className:"w-full sm:w-auto",children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),_&&r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[r.jsx("div",{className:"font-medium",children:"Last send debug"}),_.error?r.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",_.error]}):r.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[r.jsxs("div",{children:["Result: ",_.sent??0," sent, ",_.failed??0," failed, ",_.expiredCleaned??0," expired cleaned"]}),_.vapidPublicKey?r.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",r.jsx("span",{className:"font-mono",children:_.vapidPublicKey})]}):r.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2 text-destructive",children:[r.jsx(Os,{className:"h-5 w-5"}),"Subscription Maintenance"]}),r.jsx(Cs,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),r.jsxs(qe,{className:"space-y-4",children:[r.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."}),r.jsxs(X,{variant:"destructive",onClick:()=>K.mutate(),disabled:K.isPending,children:[r.jsx(Os,{className:"h-4 w-4 mr-2"}),K.isPending?"Clearing...":"Clear All Subscriptions"]}),r.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 text-sm",children:[r.jsx("div",{className:"font-medium",children:"VAPID key rotation helper"}),r.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."}),r.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:r.jsx(X,{variant:"outline",onClick:W,disabled:m,children:m?"Generating…":"Generate VAPID keys"})}),w&&r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"text-muted-foreground",children:["Copy these into backend secrets ",r.jsx("span",{className:"font-mono",children:"VAPID_PUBLIC_KEY"})," and ",r.jsx("span",{className:"font-mono",children:"VAPID_PRIVATE_KEY"}),"."]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Public key"}),r.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.publicKey})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Private key (keep secret)"}),r.jsx("div",{className:"break-all rounded-md border bg-background p-2 font-mono text-xs",children:w.privateKey})]})]})]})]})]})]})})}function Xor(){const{toast:e}=_i(),[t,s]=A.useState([]),[n,a]=A.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=A.useState(!0);A.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:m,error:p}=await Y.rpc("get_admin_presentation_stats");if(p)throw p;if(!m||m.length===0){l(!1);return}const g=m.map(S=>S.owner_user_id),{data:v,error:_}=await Y.from("profiles").select("id, name, email, avatar_url").in("id",g);if(_)throw _;const k=new Map((v==null?void 0:v.map(S=>[S.id,S]))||[]),w=m.map(S=>{const T=k.get(S.owner_user_id);return{owner_user_id:S.owner_user_id,name:(T==null?void 0:T.name)||"Unknown",email:(T==null?void 0:T.email)||"",avatar_url:(T==null?void 0:T.avatar_url)||null,presentation_count:Number(S.presentation_count),total_views:Number(S.total_views),total_leads:Number(S.total_leads),total_cta_clicks:Number(S.total_cta_clicks)}});w.sort((S,T)=>T.presentation_count-S.presentation_count),s(w),a({totalPresentations:w.reduce((S,T)=>S+T.presentation_count,0),totalViews:w.reduce((S,T)=>S+T.total_views,0),totalLeads:w.reduce((S,T)=>S+T.total_leads,0),totalCtaClicks:w.reduce((S,T)=>S+T.total_cta_clicks,0),agentsUsing:w.length})}catch(m){console.error("Error loading presentation stats:",m),e({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:ws,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Ff,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:Ii,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:Kd,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:N1,color:"text-rose-600"}];return r.jsx(Ur,{title:"Presentation Analytics",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Presentation Analytics"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Track Smart Presentations usage and engagement across all agents"})]}),r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:d.map(m=>r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:m.label}),r.jsx(m.icon,{className:`h-4 w-4 ${m.color}`})]}),r.jsx(qe,{children:o?r.jsx(pr,{className:"h-8 w-16"}):r.jsx("div",{className:"text-2xl font-bold",children:m.value.toLocaleString()})})]},m.label))}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(pu,{className:"h-5 w-5"}),"Agent Breakdown"]})}),r.jsx(qe,{children:o?r.jsx("div",{className:"space-y-3",children:[...Array(5)].map((m,p)=>r.jsx(pr,{className:"h-12 w-full"},p))}):t.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{className:"text-center",children:"Presentations"}),r.jsx(Mt,{className:"text-center",children:"Views"}),r.jsx(Mt,{className:"text-center",children:"Leads"}),r.jsx(Mt,{className:"text-center",children:"CTA Clicks"}),r.jsx(Mt,{className:"text-center",children:"Conversion"})]})}),r.jsx(Bn,{children:t.map(m=>{var g,v;const p=m.total_views>0?(m.total_leads/m.total_views*100).toFixed(1):"0.0";return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:m.avatar_url?r.jsx("img",{src:m.avatar_url,alt:"",className:"h-full w-full object-cover"}):r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((v=(g=m.name)==null?void 0:g.charAt(0))==null?void 0:v.toUpperCase())||"?"})}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-sm",children:m.name}),r.jsx("div",{className:"text-xs text-muted-foreground",children:m.email})]})]})}),r.jsx(dt,{className:"text-center font-medium",children:m.presentation_count}),r.jsx(dt,{className:"text-center",children:m.total_views.toLocaleString()}),r.jsx(dt,{className:"text-center",children:m.total_leads>0?r.jsx(_t,{variant:"secondary",children:m.total_leads}):r.jsx("span",{className:"text-muted-foreground",children:"0"})}),r.jsx(dt,{className:"text-center",children:m.total_cta_clicks}),r.jsx(dt,{className:"text-center",children:r.jsxs("span",{className:Number(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},m.owner_user_id)})})]})})]})]})})}function Qor(){const{toast:e}=_i(),[t,s]=A.useState([]),[n,a]=A.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=A.useState(!0);A.useEffect(()=>{i()},[]);const i=async()=>{try{l(!0);const{data:m,error:p}=await Y.rpc("get_admin_guest_book_stats");if(p)throw p;if(!m||m.length===0){l(!1);return}const g=m.map(S=>S.agent_id),{data:v,error:_}=await Y.from("profiles").select("id, name, email, avatar_url").in("id",g);if(_)throw _;const k=new Map((v==null?void 0:v.map(S=>[S.id,S]))||[]),w=m.map(S=>{const T=k.get(S.agent_id);return{agent_id:S.agent_id,name:(T==null?void 0:T.name)||"Unknown",email:(T==null?void 0:T.email)||"",avatar_url:(T==null?void 0:T.avatar_url)||null,open_house_count:Number(S.open_house_count),total_visitors:Number(S.total_visitors),total_leads:Number(S.total_leads),active_count:Number(S.active_count)}});w.sort((S,T)=>T.total_visitors-S.total_visitors),s(w),a({totalOpenHouses:w.reduce((S,T)=>S+T.open_house_count,0),totalVisitors:w.reduce((S,T)=>S+T.total_visitors,0),totalLeads:w.reduce((S,T)=>S+T.total_leads,0),activeOpenHouses:w.reduce((S,T)=>S+T.active_count,0),agentsUsing:w.length})}catch(m){console.error("Error loading guest book stats:",m),e({title:"Error",description:"Failed to load guest book analytics",variant:"destructive"})}finally{l(!1)}},d=[{label:"Agents Using",value:n.agentsUsing,icon:ws,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Vn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:ui,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:Ii,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:Kd,color:"text-rose-600"}];return r.jsx(Ur,{title:"Guest Book Analytics",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Guest Book Analytics"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Track open house sign-in usage and lead generation across all agents"})]}),r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4",children:d.map(m=>r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(Zt,{className:"text-sm font-medium",children:m.label}),r.jsx(m.icon,{className:`h-4 w-4 ${m.color}`})]}),r.jsx(qe,{children:o?r.jsx(pr,{className:"h-8 w-16"}):r.jsx("div",{className:"text-2xl font-bold",children:m.value.toLocaleString()})})]},m.label))}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(pu,{className:"h-5 w-5"}),"Agent Breakdown"]})}),r.jsx(qe,{children:o?r.jsx("div",{className:"space-y-3",children:[...Array(5)].map((m,p)=>r.jsx(pr,{className:"h-12 w-full"},p))}):t.length===0?r.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No open houses created yet."}):r.jsxs(Fn,{children:[r.jsx(zn,{children:r.jsxs(Nr,{children:[r.jsx(Mt,{children:"Agent"}),r.jsx(Mt,{className:"text-center",children:"Open Houses"}),r.jsx(Mt,{className:"text-center",children:"Active"}),r.jsx(Mt,{className:"text-center",children:"Visitors"}),r.jsx(Mt,{className:"text-center",children:"Leads"}),r.jsx(Mt,{className:"text-center",children:"Conversion"})]})}),r.jsx(Bn,{children:t.map(m=>{var g,v;const p=m.total_visitors>0?(m.total_leads/m.total_visitors*100).toFixed(1):"0.0";return r.jsxs(Nr,{children:[r.jsx(dt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-8 w-8 rounded-full bg-muted flex items-center justify-center overflow-hidden",children:m.avatar_url?r.jsx("img",{src:m.avatar_url,alt:"",className:"h-full w-full object-cover"}):r.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:((v=(g=m.name)==null?void 0:g.charAt(0))==null?void 0:v.toUpperCase())||"?"})}),r.jsxs("div",{children:[r.jsx("div",{className:"font-medium text-sm",children:m.name}),r.jsx("div",{className:"text-xs text-muted-foreground",children:m.email})]})]})}),r.jsx(dt,{className:"text-center font-medium",children:m.open_house_count}),r.jsx(dt,{className:"text-center",children:m.active_count>0?r.jsx(_t,{variant:"secondary",className:"bg-emerald-100 text-emerald-700",children:m.active_count}):r.jsx("span",{className:"text-muted-foreground",children:"0"})}),r.jsx(dt,{className:"text-center",children:m.total_visitors.toLocaleString()}),r.jsx(dt,{className:"text-center",children:m.total_leads>0?r.jsx(_t,{variant:"secondary",children:m.total_leads}):r.jsx("span",{className:"text-muted-foreground",children:"0"})}),r.jsx(dt,{className:"text-center",children:r.jsxs("span",{className:Number(p)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[p,"%"]})})]},m.agent_id)})})]})})]})]})})}function Jor(){const[e]=Cc(),t=Ks(),[s,n]=A.useState("loading"),[a,o]=A.useState("Processing connection...");return A.useEffect(()=>{(async()=>{const i=e.get("code"),d=e.get("error"),m=e.get("error_description"),p=e.get("state");if(d){n("error"),o(m||"Authorization was denied"),we.error("Failed to connect: "+(m||d));return}if(!i){n("error"),o("No authorization code received"),we.error("Failed to connect: No authorization code");return}try{const{data:g,error:v}=await Y.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Accounts connected successfully!"),we.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"),we.error(g.message||"Failed to connect accounts")}})()},[e]),r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-background p-4",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"text-center",children:[r.jsxs("div",{className:"mx-auto mb-4",children:[s==="loading"&&r.jsx($r,{className:"h-12 w-12 animate-spin text-primary"}),s==="success"&&r.jsx(ui,{className:"h-12 w-12 text-green-500"}),s==="error"&&r.jsx(Fc,{className:"h-12 w-12 text-destructive"})]}),r.jsxs(Zt,{children:[s==="loading"&&"Connecting...",s==="success"&&"Connected!",s==="error"&&"Connection Failed"]}),r.jsx(Cs,{children:a})]}),r.jsx(qe,{className:"flex justify-center",children:r.jsx(X,{onClick:()=>t("/admin/integrations"),children:s==="success"?"View Integrations":"Back to Integrations"})})]})})}function elr(){const e=Rr(),[t,s]=A.useState(""),[n,a]=A.useState(""),[o,l]=A.useState([]),i=A.useRef(null),{data:d,isLoading:m}=Ht({queryKey:["prospect-emails"],queryFn:async()=>{const{data:S,error:T}=await Y.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(T)throw T;return S}}),p={total:(d==null?void 0:d.length)||0,sent:(d==null?void 0:d.filter(S=>S.status==="sent").length)||0,converted:(d==null?void 0:d.filter(S=>S.status==="converted").length)||0,conversionRate:d!=null&&d.length?Math.round(d.filter(S=>S.status==="converted").length/d.length*100):0},g=Qt({mutationFn:async S=>{const{data:T,error:C}=await Y.functions.invoke("send-prospect-email",{body:{emails:S}});if(C)throw C;return T},onSuccess:S=>{e.invalidateQueries({queryKey:["prospect-emails"]}),we.success(`${S.sent} email${S.sent>1?"s":""} sent successfully!`),s(""),a(""),l([])},onError:S=>{we.error("Failed to send: "+S.message)}}),v=Qt({mutationFn:async()=>{var I,R;const{data:{user:S}}=await Y.auth.getUser();if(!(S!=null&&S.email))throw new Error("Could not get your email");const{data:T,error:C}=await Y.functions.invoke("send-prospect-email",{body:{emails:[{email:S.email,first_name:(R=(I=S.user_metadata)==null?void 0:I.name)==null?void 0:R.split(" ")[0]}],test_mode:!0}});if(C)throw C;return T},onSuccess:()=>{we.success("Test email sent to your inbox!")},onError:S=>{we.error("Failed to send test: "+S.message)}}),_=()=>{if(!t.trim()){we.error("Please enter an email address");return}if(d==null?void 0:d.find(T=>T.email.toLowerCase()===t.trim().toLowerCase())){we.error("This email has already been prospected");return}g.mutate([{email:t.trim(),first_name:n.trim()||void 0}])},k=S=>{var I;const T=(I=S.target.files)==null?void 0:I[0];if(!T)return;const C=new FileReader;C.onload=R=>{var W,K;const B=((W=R.target)==null?void 0:W.result).split(` `).filter(re=>re.trim()),$=[],q=(K=B[0])!=null&&K.toLowerCase().includes("email")?1:0;for(let re=q;repe.trim().replace(/"/g,"")),oe=ae[0],se=ae[1];oe&&oe.includes("@")&&$.push({email:oe,first_name:se||void 0})}l($),we.success(`${$.length} entries loaded from CSV`)},C.readAsText(T),i.current&&(i.current.value="")},w=()=>{if(o.length===0){we.error("No entries to send");return}const S=new Set((d==null?void 0:d.map(C=>C.email.toLowerCase()))||[]),T=o.filter(C=>!S.has(C.email.toLowerCase()));if(T.length===0){we.error("All emails have already been prospected");return}T.lengthv.mutate(),disabled:v.isPending,className:"gap-2 ml-4 shrink-0",children:[v.isPending?r.jsx($r,{className:"h-3 w-3 animate-spin"}):r.jsx(Vs,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),r.jsx(qe,{children:r.jsxs(ii,{defaultValue:"single",children:[r.jsxs(si,{className:"mb-4",children:[r.jsxs(Kr,{value:"single",children:[r.jsx(ai,{className:"h-4 w-4 mr-2"}),"Single Send"]}),r.jsxs(Kr,{value:"bulk",children:[r.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),r.jsx(hs,{value:"single",children:r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx(Ee,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),r.jsx(Ye,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:t,onChange:S=>s(S.target.value),onKeyDown:S=>S.key==="Enter"&&_()})]}),r.jsxs("div",{className:"w-full sm:w-48",children:[r.jsx(Ee,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),r.jsx(Ye,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:S=>a(S.target.value),onKeyDown:S=>S.key==="Enter"&&_()})]}),r.jsxs(X,{onClick:_,disabled:g.isPending,className:"gap-2",children:[g.isPending?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(ai,{className:"h-4 w-4"}),"Send Invite"]})]})}),r.jsx(hs,{value:"bulk",children:r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("input",{ref:i,type:"file",accept:".csv",onChange:k,className:"hidden"}),r.jsxs(X,{variant:"outline",onClick:()=>{var S;return(S=i.current)==null?void 0:S.click()},className:"gap-2",children:[r.jsx(ya,{className:"h-4 w-4"}),"Upload CSV"]}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Format: email, first_name (one per line)"})]}),o.length>0&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs(_t,{variant:"secondary",className:"gap-1",children:[r.jsx(ws,{className:"h-3 w-3"}),o.length," entries ready"]}),r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[r.jsx(Xs,{className:"h-4 w-4"}),"Clear"]})]}),r.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((S,T)=>r.jsxs("div",{className:"text-muted-foreground",children:[S.email,S.first_name?` — ${S.first_name}`:""]},T)),o.length>20&&r.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),r.jsxs(X,{onClick:w,disabled:g.isPending,className:"gap-2",children:[g.isPending?r.jsx($r,{className:"h-4 w-4 animate-spin"}):r.jsx(ai,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),r.jsxs(ze,{children:[r.jsxs(Wt,{children:[r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(Vs,{className:"h-5 w-5"}),"Prospect Log"]}),r.jsx(Cs,{children:"Track all sent invitations and their conversion status"})]}),r.jsx(qe,{children:m?r.jsx("div",{className:"space-y-3",children:[...Array(5)].map((S,T)=>r.jsx(pr,{className:"h-12 w-full"},T))}):d&&d.length>0?r.jsx("div",{className:"overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b",children:[r.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Email"}),r.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Name"}),r.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Sent"}),r.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Status"}),r.jsx("th",{className:"text-left py-3 px-4 text-sm font-medium text-muted-foreground",children:"Converted"})]})}),r.jsx("tbody",{children:d.map(S=>r.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[r.jsx("td",{className:"py-3 px-4 text-sm font-medium text-foreground",children:S.email}),r.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:S.first_name||"—"}),r.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:Xr(new Date(S.sent_at),"MMM d, yyyy")}),r.jsx("td",{className:"py-3 px-4",children:S.status==="converted"?r.jsxs(_t,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[r.jsx(Ri,{className:"h-3 w-3 mr-1"}),"Converted"]}):r.jsxs(_t,{variant:"secondary",className:"gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),"Sent"]})}),r.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:S.converted_at?Xr(new Date(S.converted_at),"MMM d, yyyy"):"—"})]},S.id))})]})}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(Bf,{className:"h-12 w-12 text-muted-foreground/30 mx-auto mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"No prospects yet. Send your first invite above!"})]})})]})]})})}function tlr(){const e=Ks(),t=Rr(),{isAdmin:s}=Gr(),[n,a]=A.useState(!1),[o,l]=A.useState(null),[i,d]=A.useState(null),{data:m,isLoading:p}=Ht({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:D},error:B}=await Y.auth.getUser();if(B)throw B;if(!D)return[];const{data:$,error:q}=await Y.from("social_accounts").select("*").eq("user_id",D.id).order("created_at",{ascending:!1});if(q)throw q;return $}}),g=Qt({mutationFn:async D=>{const{data:{user:B},error:$}=await Y.auth.getUser();if($)throw $;if(!B)throw new Error("Not authenticated");const{error:q}=await Y.from("social_accounts").delete().eq("id",D).eq("user_id",B.id);if(q)throw q},onSuccess:()=>{t.invalidateQueries({queryKey:["my-social-accounts"]}),t.invalidateQueries({queryKey:["social-accounts-for-post"]}),we.success("Account disconnected successfully")},onError:()=>{we.error("Failed to disconnect account")}}),v=async()=>{a(!0);try{const{data:D,error:B}=await Y.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(B)throw B;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),we.error("Failed to start connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:D,error:B}=await Y.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(B)throw B;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),we.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},k=async()=>{a(!0);try{const{data:D,error:B}=await Y.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(B)throw B;if(D!=null&&D.authUrl)window.location.href=D.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(D){console.error("Google OAuth error:",D),we.error("Failed to start Google connection. Please try again."),a(!1)}},w=(m==null?void 0:m.filter(D=>D.platform==="facebook"))||[],S=(m==null?void 0:m.filter(D=>D.platform==="instagram"))||[],T=(m==null?void 0:m.filter(D=>D.platform==="linkedin"))||[],C=(m==null?void 0:m.filter(D=>D.platform==="google_business"))||[],I=((m==null?void 0:m.length)||0)>0,R=async(D,B)=>{l(D),d(null);try{const{data:$,error:q}=await Y.functions.invoke("meta-api-test",{body:{testType:"all",accountId:D}});if(q)throw q;d($.results||[]),we.success($.summary||"API tests completed")}catch($){console.error("Meta API test error:",$),we.error("Failed to run API tests")}finally{l(null)}};return r.jsx(Ur,{title:"Social Connections",children:r.jsxs("div",{className:"space-y-6",children:[r.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:[r.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzMiAyIDIgNC0yIDQtMiA0LTItMi0yLTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsxs(_t,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[r.jsx(bn,{className:"h-3 w-3 mr-1"}),"Post directly from Social Swag"]})}),r.jsx("h1",{className:"text-2xl md:text-3xl font-bold mb-2",children:"Connect Your Social Accounts"}),r.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."})]})]}),r.jsxs(X,{variant:"ghost",onClick:()=>e("/social-swag-2"),className:"gap-2",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back to Social Swag"]}),!s&&r.jsx(ze,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx("div",{className:"rounded-full bg-amber-100 dark:bg-amber-900/30 p-4 mb-4",children:r.jsx(Pa,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),r.jsx(_t,{variant:"secondary",className:"mb-3 bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Social Connections Coming Soon!"}),r.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."})]})}),s&&r.jsxs(r.Fragment,{children:[I&&r.jsx(ze,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:r.jsxs(qe,{className:"flex items-center gap-4 p-4",children:[r.jsx("div",{className:"rounded-full bg-green-500 p-2",children:r.jsx(ui,{className:"h-5 w-5 text-white"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium text-green-800 dark:text-green-200",children:"You're all set!"}),r.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."})]})]})}),r.jsxs("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"rounded-full bg-blue-500/10 p-3",children:r.jsx(fu,{className:"h-6 w-6 text-blue-600"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-lg",children:"Facebook"}),r.jsx(Cs,{children:"Connect your Facebook Pages"})]})]})}),r.jsxs(qe,{className:"space-y-4",children:[p?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Yo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.length>0?r.jsx("div",{className:"space-y-3",children:w.map(D=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:D.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(fu,{className:"h-5 w-5"})})]}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:D.page_name||D.platform_username||"Facebook Page"}),r.jsx(_t,{variant:D.is_active?"default":"secondary",className:"text-xs",children:D.is_active?"Connected":"Inactive"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect Facebook?"}),r.jsx(bc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>g.mutate(D.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},D.id))}):r.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Facebook pages connected yet"}),r.jsxs(X,{onClick:v,disabled:n,className:"w-full gap-2",variant:w.length>0?"outline":"default",children:[n?r.jsx(Yo,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4"}),w.length>0?"Connect Another Page":"Connect Facebook Page"]})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"rounded-full bg-gradient-to-br from-purple-500/10 via-pink-500/10 to-orange-500/10 p-3",children:r.jsx(Lu,{className:"h-6 w-6 text-pink-600"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-lg",children:"Instagram"}),r.jsx(Cs,{children:"Connect Instagram Business accounts"})]})]})}),r.jsxs(qe,{className:"space-y-4",children:[p?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Yo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):S.length>0?r.jsx("div",{className:"space-y-3",children:S.map(D=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:D.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(Lu,{className:"h-5 w-5"})})]}),r.jsxs("div",{children:[r.jsxs("p",{className:"font-medium",children:["@",D.platform_username||"Instagram Account"]}),r.jsx(_t,{variant:D.is_active?"default":"secondary",className:"text-xs",children:D.is_active?"Connected":"Inactive"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect Instagram?"}),r.jsx(bc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>g.mutate(D.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},D.id))}):r.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No Instagram accounts connected yet"}),r.jsxs(X,{onClick:v,disabled:n,className:"w-full gap-2",variant:S.length>0?"outline":"default",children:[n?r.jsx(Yo,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4"}),S.length>0?"Connect Another Account":"Connect Instagram"]}),r.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Instagram Business accounts must be connected to a Facebook Page"})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"rounded-full bg-blue-600/10 p-3",children:r.jsx(zm,{className:"h-6 w-6 text-blue-700"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-lg",children:"LinkedIn"}),r.jsx(Cs,{children:"Connect your LinkedIn profile"})]})]})}),r.jsxs(qe,{className:"space-y-4",children:[p?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Yo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):T.length>0?r.jsx("div",{className:"space-y-3",children:T.map(D=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:D.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(zm,{className:"h-5 w-5"})})]}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:D.platform_username||"LinkedIn Account"}),r.jsx(_t,{variant:D.is_active?"default":"secondary",className:"text-xs",children:D.is_active?"Connected":"Inactive"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect LinkedIn?"}),r.jsx(bc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>g.mutate(D.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},D.id))}):r.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),r.jsxs(X,{onClick:_,disabled:n,className:"w-full gap-2",variant:T.length>0?"outline":"default",children:[n?r.jsx(Yo,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4"}),T.length>0?"Reconnect LinkedIn":"Connect LinkedIn"]}),r.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Share content directly to your LinkedIn profile"})]})]}),r.jsxs(ze,{className:`relative overflow-hidden ${s?"":"opacity-75"}`,children:[!s&&r.jsx("div",{className:"absolute top-3 right-3 z-10",children:r.jsx(_t,{variant:"secondary",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-400",children:"Coming Soon"})}),s&&r.jsx("div",{className:"absolute top-3 right-3 z-10",children:r.jsx(_t,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"rounded-full bg-red-500/10 p-3",children:r.jsx(Yi,{className:"h-6 w-6 text-red-600"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-lg",children:"Google Business"}),r.jsx(Cs,{children:"Connect your Google Business Profile"})]})]})}),r.jsxs(qe,{className:"space-y-4",children:[p?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Yo,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length>0?r.jsx("div",{className:"space-y-3",children:C.map(D=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:D.profile_picture_url||""}),r.jsx(dn,{children:r.jsx(Yi,{className:"h-5 w-5"})})]}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:D.page_name||D.platform_username||"Google Business"}),r.jsx(_t,{variant:D.is_active?"default":"secondary",className:"text-xs",children:D.is_active?"Connected":"Inactive"})]})]}),r.jsxs($c,{children:[r.jsx(Im,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})}),r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Disconnect Google Business?"}),r.jsx(bc,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:()=>g.mutate(D.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},D.id))}):r.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:s?"No Google Business account connected yet":"Google Business Profile integration is coming soon!"}),r.jsxs(X,{onClick:s?k:void 0,disabled:!s||n,className:"w-full gap-2",variant:C.length>0?"outline":"default",children:[n?r.jsx(Yo,{className:"h-4 w-4 animate-spin"}):r.jsx(gs,{className:"h-4 w-4"}),C.length>0?"Reconnect Google Business":"Connect Google Business"]}),r.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Post updates directly to your Google Business Profile"})]})]})]}),s&&(w.length>0||S.length>0)&&r.jsxs(ze,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[r.jsx(Wt,{children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"rounded-full bg-amber-500/10 p-3",children:r.jsx(yk,{className:"h-6 w-6 text-amber-600"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),r.jsx(Cs,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:['Click "Run Tests" on an account to trigger API calls for: ',r.jsx("strong",{children:"public_profile"}),", ",r.jsx("strong",{children:"pages_show_list"}),", ",r.jsx("strong",{children:"pages_read_engagement"}),", ",r.jsx("strong",{children:"instagram_basic"}),", ",r.jsx("strong",{children:"pages_manage_posts"}),", and ",r.jsx("strong",{children:"instagram_content_publish"}),"."]}),r.jsxs("div",{className:"space-y-3",children:[w.map(D=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(fu,{className:"h-5 w-5 text-blue-600"}),r.jsx("span",{className:"font-medium",children:D.page_name||"Facebook Page"})]}),r.jsx(X,{size:"sm",variant:"outline",onClick:()=>R(D.id),disabled:o===D.id,children:o===D.id?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(yk,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${D.id}`)),S.map(D=>r.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-background p-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Lu,{className:"h-5 w-5 text-pink-600"}),r.jsxs("span",{className:"font-medium",children:["@",D.platform_username||"Instagram"]})]}),r.jsx(X,{size:"sm",variant:"outline",onClick:()=>R(D.id),disabled:o===D.id,children:o===D.id?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):r.jsxs(r.Fragment,{children:[r.jsx(yk,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${D.id}`))]}),i&&i.length>0&&r.jsxs("div",{className:"mt-4 rounded-lg border bg-background p-4",children:[r.jsx("h4",{className:"font-medium mb-3",children:"Test Results"}),r.jsx("div",{className:"space-y-2",children:i.map((D,B)=>r.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[D.status==="success"?r.jsx(Ri,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):D.status==="pending"?r.jsx($r,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):r.jsx(Fc,{className:"h-4 w-4 text-red-600 mt-0.5 shrink-0"}),r.jsxs("div",{children:[r.jsx("span",{className:"font-mono text-xs bg-muted px-1 rounded",children:D.test}),r.jsx("span",{className:"ml-2 text-muted-foreground",children:D.details})]})]},B))})]}),r.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."})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-lg",children:"How it works"})}),r.jsx(qe,{children:r.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[r.jsxs("div",{className:"flex gap-3",children:[r.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"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Connect your accounts"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Link your Facebook, Instagram, or LinkedIn account"})]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.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"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Browse Social Swag"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Find the perfect image and caption for your post"})]})]}),r.jsxs("div",{className:"flex gap-3",children:[r.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"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Post with one click"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:'Click "Create Post" to share directly to your accounts'})]})]})]})})]})]})]})})}function rlr(){const[e]=Cc(),t=Ks(),[s,n]=A.useState("loading"),[a,o]=A.useState("Processing your connection...");return A.useEffect(()=>{(async()=>{var g;const i=e.get("code"),d=e.get("error"),m=e.get("error_description"),p=e.get("state");if(d){n("error"),o(m||"Authorization was denied"),we.error("Connection failed: "+(m||d));return}if(!i){n("error"),o("No authorization code received"),we.error("No authorization code received");return}try{const{data:v,error:_}=await Y.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(_)throw _;if(v!=null&&v.success)n("success"),o(`Successfully connected ${((g=v.accounts)==null?void 0:g.length)||0} account(s)!`),we.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"),we.error("Failed to connect: "+(v instanceof Error?v.message:"Unknown error"))}})()},[e]),r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"text-center",children:[s==="loading"&&r.jsx($r,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),s==="success"&&r.jsx(ui,{className:"h-12 w-12 mx-auto text-green-500"}),s==="error"&&r.jsx(Fc,{className:"h-12 w-12 mx-auto text-destructive"}),r.jsxs(Zt,{className:"mt-4",children:[s==="loading"&&"Connecting...",s==="success"&&"Connected!",s==="error"&&"Connection Failed"]}),r.jsx(Cs,{children:a})]}),r.jsx(qe,{className:"flex justify-center",children:s!=="loading"&&r.jsx(X,{onClick:()=>t("/mission-control/integrations"),children:s==="success"?"View Connected Accounts":"Try Again"})})]})})}function slr(){const[e]=Cc(),t=Ks(),[s,n]=A.useState("loading"),[a,o]=A.useState("Connecting your Google Business Profile...");return A.useEffect(()=>{(async()=>{const i=e.get("code"),d=e.get("error"),m=e.get("error_description"),p=e.get("state");if(d){n("error"),o(m||"Authorization was denied"),we.error("Connection failed: "+(m||d));return}if(!i){n("error"),o("No authorization code received"),we.error("No authorization code received");return}try{const{data:g,error:v}=await Y.functions.invoke("google-business-oauth",{body:{action:"exchange_code",code:i,state:p}});if(v)throw v;if(g!=null&&g.success)n("success"),o(g.message||"Successfully connected Google Business Profile!"),we.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"),we.error("Failed to connect: "+(g instanceof Error?g.message:"Unknown error"))}})()},[e]),r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"text-center",children:[s==="loading"&&r.jsx($r,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),s==="success"&&r.jsx(ui,{className:"h-12 w-12 mx-auto text-green-500"}),s==="error"&&r.jsx(Fc,{className:"h-12 w-12 mx-auto text-destructive"}),r.jsxs(Zt,{className:"mt-4",children:[s==="loading"&&"Connecting...",s==="success"&&"Connected!",s==="error"&&"Connection Failed"]}),r.jsx(Cs,{children:a})]}),r.jsx(qe,{className:"flex justify-center",children:s!=="loading"&&r.jsx(X,{onClick:()=>t("/social-connections"),children:s==="success"?"View Connected Accounts":"Try Again"})})]})})}function nlr(){const[e]=Cc(),t=Ks(),[s,n]=A.useState("loading"),[a,o]=A.useState("Connecting your LinkedIn account...");return A.useEffect(()=>{(async()=>{var g;const i=e.get("code"),d=e.get("state"),m=e.get("error"),p=e.get("error_description");if(m){console.error("LinkedIn OAuth error:",m,p),n("error"),o(p||"Failed to connect LinkedIn account"),we.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),we.error("No authorization code received");return}try{const{data:v,error:_}=await Y.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`),we.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"),we.error("Failed to connect LinkedIn")}})()},[e]),r.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background",children:r.jsxs(ze,{className:"w-full max-w-md",children:[r.jsxs(Wt,{className:"text-center",children:[r.jsxs("div",{className:"mx-auto mb-4 rounded-full bg-blue-600/10 p-4 w-fit",children:[s==="loading"&&r.jsx($r,{className:"h-8 w-8 animate-spin text-blue-600"}),s==="success"&&r.jsx(ui,{className:"h-8 w-8 text-green-600"}),s==="error"&&r.jsx(Fc,{className:"h-8 w-8 text-red-600"})]}),r.jsxs(Zt,{className:"flex items-center justify-center gap-2",children:[r.jsx(zm,{className:"h-5 w-5 text-blue-600"}),s==="loading"&&"Connecting...",s==="success"&&"Connected!",s==="error"&&"Connection Failed"]}),r.jsx(Cs,{children:a})]}),r.jsx(qe,{className:"flex justify-center",children:r.jsx(X,{onClick:()=>t("/social-connections"),disabled:s==="loading",children:s==="success"?"Continue":"Back to Connections"})})]})})}function alr(){const e=Ks(),[t,s]=A.useState(null),{data:n,isLoading:a}=AZe(t||void 0,!0),{data:o,isLoading:l}=Vbe(!0),{cartItems:i}=Bie(),d=i.reduce((p,g)=>p+g.quantity,0),m=p=>{e(`/marketplace/${p.id}`)};return a||l?r.jsx(Ur,{title:"Marketplace",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[1,2,3].map(p=>r.jsx(pr,{className:"h-10 w-24 flex-shrink-0"},p))}),r.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:[1,2,3,4].map(p=>r.jsx(pr,{className:"h-72 w-full"},p))})]})}):r.jsx(Ur,{title:"Marketplace",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Marketplace"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Shop exclusive products for LevelUp members"})]}),r.jsxs(X,{variant:"outline",onClick:()=>e("/marketplace/cart"),className:"relative",children:[r.jsx(Wh,{className:"h-4 w-4 mr-2"}),"Cart",d>0&&r.jsx(_t,{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&&r.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[r.jsx(X,{variant:t===null?"default":"outline",size:"sm",onClick:()=>s(null),children:"All"}),o.map(p=>r.jsx(X,{variant:t===p.id?"default":"outline",size:"sm",onClick:()=>s(p.id),children:p.name},p.id))]}),n&&n.length>0?r.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(p=>{var g;return r.jsxs(ze,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>m(p),children:[r.jsxs("div",{className:"aspect-square bg-muted relative",children:[p.images&&p.images.length>0?r.jsx("img",{src:((g=p.images.find(v=>v.is_primary))==null?void 0:g.image_url)||p.images[0].image_url,alt:p.name,className:"w-full h-full object-cover"}):r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx(ec,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&r.jsx(_t,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),r.jsxs(qe,{className:"p-4",children:[r.jsx("h3",{className:"font-semibold mb-1 line-clamp-1",children:p.name}),p.description&&r.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:p.description}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"font-bold text-lg",children:["$",Number(p.base_price).toFixed(2)]}),p.variants&&p.variants.length>0&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.variants.length," options"]})]})]})]},p.id)})}):r.jsxs("div",{className:"text-center py-12",children:[r.jsx(ec,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("p",{className:"text-muted-foreground",children:"No products available yet."})]})]})})}const PZe=A.forwardRef(({...e},t)=>r.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));PZe.displayName="Breadcrumb";const LZe=A.forwardRef(({className:e,...t},s)=>r.jsx("ol",{ref:s,className:Vt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));LZe.displayName="BreadcrumbList";const xre=A.forwardRef(({className:e,...t},s)=>r.jsx("li",{ref:s,className:Vt("inline-flex items-center gap-1.5",e),...t}));xre.displayName="BreadcrumbItem";const nye=A.forwardRef(({asChild:e,className:t,...s},n)=>{const a=e?S0e:"a";return r.jsx(a,{ref:n,className:Vt("transition-colors hover:text-foreground",t),...s})});nye.displayName="BreadcrumbLink";const DZe=A.forwardRef(({className:e,...t},s)=>r.jsx("span",{ref:s,role:"link","aria-disabled":"true","aria-current":"page",className:Vt("font-normal text-foreground",e),...t}));DZe.displayName="BreadcrumbPage";const aye=({children:e,className:t,...s})=>r.jsx("li",{role:"presentation","aria-hidden":"true",className:Vt("[&>svg]:size-3.5",t),...s,children:e??r.jsx(Zi,{})});aye.displayName="BreadcrumbSeparator";function ilr(){var oe,se;const{productId:e}=Bl(),t=Ks(),{data:s,isLoading:n}=cor(e||""),{addToCart:a,cartItems:o}=Bie(),[l,i]=A.useState(null),[d,m]=A.useState(1),[p,g]=A.useState(0),[v,_]=A.useState(null),[k,w]=A.useState(!1),[S,T]=A.useState(!1),C=(oe=s==null?void 0:s.variants)==null?void 0:oe.find(pe=>pe.id===l),I=((se=s==null?void 0:s.variants)==null?void 0:se.filter(pe=>pe.is_active))||[],R=Number((s==null?void 0:s.base_price)||0),D=C?Number(C.price_adjustment):0,B=R+D,$=Number((s==null?void 0:s.shipping_fee)||0),q=o.reduce((pe,ie)=>pe+ie.quantity,0),W=async pe=>{if(!pe.target.files||pe.target.files.length===0)return;w(!0);const ie=pe.target.files[0],de=ie.name.split(".").pop(),ce=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${de}`;try{const{error:ge}=await Y.storage.from("marketplace").upload(ce,ie);if(ge)throw ge;const{data:{publicUrl:Te}}=Y.storage.from("marketplace").getPublicUrl(ce);_(Te),we.success("Artwork uploaded successfully")}catch(ge){we.error("Failed to upload artwork: "+ge.message)}finally{w(!1)}},K=()=>{if(s){if(I.length>0&&!l){we.error("Please select an option");return}a(s,C||void 0,d,v||void 0),T(!0),we.success("Added to cart!"),setTimeout(()=>T(!1),2e3)}},re=()=>{s!=null&&s.images&&g(pe=>(pe+1)%s.images.length)},ae=()=>{s!=null&&s.images&&g(pe=>(pe-1+s.images.length)%s.images.length)};return n?r.jsx(Ur,{title:"Product",children:r.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[r.jsx(pr,{className:"aspect-square w-full"}),r.jsxs("div",{className:"space-y-4",children:[r.jsx(pr,{className:"h-8 w-3/4"}),r.jsx(pr,{className:"h-6 w-1/4"}),r.jsx(pr,{className:"h-24 w-full"}),r.jsx(pr,{className:"h-12 w-full"})]})]})}):s?r.jsxs(Ur,{title:s.name,children:[r.jsx(PZe,{className:"mb-6",children:r.jsxs(LZe,{children:[r.jsx(xre,{children:r.jsx(nye,{asChild:!0,children:r.jsx(vo,{to:"/marketplace",children:"Marketplace"})})}),s.category&&r.jsxs(r.Fragment,{children:[r.jsx(aye,{}),r.jsx(xre,{children:r.jsx(nye,{asChild:!0,children:r.jsx(vo,{to:`/marketplace?category=${s.category.id}`,children:s.category.name})})})]}),r.jsx(aye,{}),r.jsx(xre,{children:r.jsx(DZe,{children:s.name})})]})}),r.jsxs("div",{className:"grid gap-8 lg:grid-cols-2",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"relative aspect-square bg-muted rounded-lg overflow-hidden flex items-center justify-center",children:s.images&&s.images.length>0?r.jsxs(r.Fragment,{children:[r.jsx("img",{src:s.images[p].image_url,alt:s.name,className:"max-w-full max-h-full object-contain"}),s.images.length>1&&r.jsxs(r.Fragment,{children:[r.jsx(X,{variant:"ghost",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:ae,children:r.jsx(jc,{className:"h-6 w-6"})}),r.jsx(X,{variant:"ghost",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 bg-background/80 hover:bg-background",onClick:re,children:r.jsx(Zi,{className:"h-6 w-6"})})]})]}):r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx(ec,{className:"h-24 w-24 text-muted-foreground"})})}),s.images&&s.images.length>1&&r.jsx("div",{className:"flex gap-2 overflow-x-auto pb-2",children:s.images.map((pe,ie)=>r.jsx("button",{onClick:()=>g(ie),className:`w-16 h-16 flex-shrink-0 rounded-md overflow-hidden border-2 ${ie===p?"border-primary":"border-transparent"}`,children:r.jsx("img",{src:pe.image_url,alt:"",className:"w-full h-full object-cover"})},pe.id))}),s.video&&r.jsx(ze,{children:r.jsxs(qe,{className:"p-4",children:[r.jsx("h4",{className:"font-medium mb-2",children:"Product Video"}),r.jsx("div",{className:"aspect-video",children:r.jsx("iframe",{src:s.video.video_url,className:"w-full h-full rounded-lg",allowFullScreen:!0})})]})})]}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[s.category&&r.jsx(_t,{variant:"secondary",className:"mb-2",children:s.category.name}),r.jsx("h1",{className:"text-3xl font-bold mb-2",children:s.name}),r.jsxs("div",{className:"flex items-baseline gap-2",children:[r.jsxs("span",{className:"text-3xl font-bold",children:["$",B.toFixed(2)]}),$>0&&r.jsxs("span",{className:"text-muted-foreground",children:["+ $",$.toFixed(2)," shipping"]})]})]}),s.description&&r.jsx("div",{className:"prose prose-sm max-w-none",children:r.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.description})}),I.length>0&&r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Select Option"}),r.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(pe=>r.jsxs(X,{variant:l===pe.id?"default":"outline",onClick:()=>i(pe.id),children:[pe.name,Number(pe.price_adjustment)!==0&&r.jsxs("span",{className:"ml-1 opacity-70",children:["(",Number(pe.price_adjustment)>0?"+":"","$",Number(pe.price_adjustment).toFixed(2),")"]})]},pe.id))})]}),s.allow_artwork_upload&&r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Upload Your Artwork (Optional)"}),v?r.jsxs("div",{className:"relative inline-block",children:[r.jsx("img",{src:v,alt:"Your artwork",className:"h-24 w-auto rounded-lg border"}),r.jsx(X,{variant:"ghost",size:"sm",className:"absolute -top-2 -right-2",onClick:()=>_(null),children:"×"})]}):r.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[r.jsx("input",{type:"file",accept:"image/*,.pdf,.ai,.eps",onChange:W,className:"hidden",id:"artwork-upload",disabled:k}),r.jsxs("label",{htmlFor:"artwork-upload",className:"flex flex-col items-center cursor-pointer",children:[r.jsx(Xi,{className:"h-8 w-8 text-muted-foreground mb-2"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:k?"Uploading...":"Click to upload artwork"}),r.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:"Supported: JPG, PNG, PDF, AI, EPS"})]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Quantity"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(X,{variant:"outline",size:"icon",onClick:()=>m(pe=>Math.max(1,pe-1)),children:"-"}),r.jsx(Ye,{type:"number",value:d,onChange:pe=>m(Math.max(1,parseInt(pe.target.value)||1)),className:"w-20 text-center",min:"1"}),r.jsx(X,{variant:"outline",size:"icon",onClick:()=>m(pe=>pe+1),children:"+"})]})]}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx(X,{size:"lg",className:"flex-1",onClick:K,disabled:S,children:S?r.jsxs(r.Fragment,{children:[r.jsx(mi,{className:"h-5 w-5 mr-2"}),"Added!"]}):r.jsxs(r.Fragment,{children:[r.jsx(Wh,{className:"h-5 w-5 mr-2"}),"Add to Cart"]})}),r.jsxs(X,{variant:"outline",size:"lg",onClick:()=>t("/marketplace/cart"),className:"relative",children:[r.jsx(Wh,{className:"h-5 w-5"}),q>0&&r.jsx(_t,{className:"absolute -top-2 -right-2 h-5 w-5 flex items-center justify-center p-0 text-xs",children:q})]})]}),s.requires_proof_approval&&r.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."})]})]})]}):r.jsx(Ur,{title:"Product Not Found",children:r.jsxs("div",{className:"text-center py-12",children:[r.jsx(ec,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Product not found"}),r.jsx(X,{onClick:()=>t("/marketplace"),children:"Back to Marketplace"})]})})}function olr(){const e=Ks(),{cartItems:t,removeFromCart:s,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:d}=Bie(),[m,p]=A.useState(!1),[g,v]=A.useState(""),_=async()=>{if(t.length===0){we.error("Your cart is empty");return}p(!0);try{const{data:k,error:w}=await Y.functions.invoke("marketplace-checkout",{body:{items:t.map(S=>{var T;return{product_id:S.product.id,variant_id:((T=S.variant)==null?void 0:T.id)||null,quantity:S.quantity,artwork_url:S.artworkUrl||null}}),notes:g.trim()||null}});if(w)throw w;if(k!=null&&k.url)d(),window.open(k.url,"_blank");else throw new Error("No checkout URL received")}catch(k){we.error("Checkout failed: "+k.message)}finally{p(!1)}};return t.length===0?r.jsx(Ur,{title:"Shopping Cart",children:r.jsxs("div",{className:"text-center py-12",children:[r.jsx(mx,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your cart is empty"}),r.jsx("p",{className:"text-muted-foreground mb-6",children:"Add some products to get started!"}),r.jsx(X,{onClick:()=>e("/marketplace"),children:"Browse Marketplace"})]})}):r.jsx(Ur,{title:"Shopping Cart",children:r.jsxs("div",{className:"grid gap-8 lg:grid-cols-3",children:[r.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[t.map(k=>{var w,S;return r.jsx(ze,{children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"w-24 h-24 flex-shrink-0 bg-muted rounded-lg overflow-hidden",children:k.product.images&&k.product.images.length>0?r.jsx("img",{src:((w=k.product.images.find(T=>T.is_primary))==null?void 0:w.image_url)||k.product.images[0].image_url,alt:k.product.name,className:"w-full h-full object-cover"}):r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx(mx,{className:"h-8 w-8 text-muted-foreground"})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-semibold line-clamp-1",children:k.product.name}),k.variant&&r.jsx("p",{className:"text-sm text-muted-foreground",children:k.variant.name}),r.jsxs("p",{className:"font-medium mt-1",children:["$",a(k).toFixed(2),Number(k.product.shipping_fee)>0&&r.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:["+ $",Number(k.product.shipping_fee).toFixed(2)," shipping"]})]}),k.artworkUrl&&r.jsx("div",{className:"mt-2",children:r.jsx("span",{className:"text-xs text-muted-foreground",children:"Artwork uploaded ✓"})})]}),r.jsxs("div",{className:"flex flex-col items-end gap-2",children:[r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{var T;return s(k.product.id,(T=k.variant)==null?void 0:T.id)},children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var T;return n(k.product.id,(T=k.variant)==null?void 0:T.id,k.quantity-1)},disabled:k.quantity<=1,children:r.jsx(k1,{className:"h-3 w-3"})}),r.jsx(Ye,{type:"number",value:k.quantity,onChange:T=>{var C;return n(k.product.id,(C=k.variant)==null?void 0:C.id,parseInt(T.target.value)||1)},className:"w-14 h-8 text-center text-sm",min:"1"}),r.jsx(X,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>{var T;return n(k.product.id,(T=k.variant)==null?void 0:T.id,k.quantity+1)},children:r.jsx(gs,{className:"h-3 w-3"})})]})]})]})})},`${k.product.id}-${((S=k.variant)==null?void 0:S.id)||"base"}`)}),r.jsx(X,{variant:"ghost",className:"text-destructive",onClick:d,children:"Clear Cart"})]}),r.jsx("div",{children:r.jsxs(ze,{className:"sticky top-4",children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Order Summary"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsxs("span",{children:["Subtotal (",t.reduce((k,w)=>k+w.quantity,0)," items)"]}),r.jsxs("span",{children:["$",o().toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{children:"Shipping"}),r.jsxs("span",{children:["$",l().toFixed(2)]})]}),r.jsx(kd,{}),r.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[r.jsx("span",{children:"Total"}),r.jsxs("span",{children:["$",i().toFixed(2)]})]}),r.jsx(kd,{}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),r.jsx(qs,{id:"orderNotes",placeholder:"Add any special instructions, design notes, or comments for your order...",value:g,onChange:k=>v(k.target.value),rows:3,className:"resize-none"})]}),r.jsx(X,{className:"w-full",size:"lg",onClick:_,disabled:m,children:m?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):r.jsxs(r.Fragment,{children:["Checkout",r.jsx(Ki,{className:"h-5 w-5 ml-2"})]})}),r.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Secure checkout powered by Stripe"})]})]})})]})})}function llr(){const e=Ks(),{data:t,isLoading:s}=bor();return s?r.jsx(Ur,{title:"My Orders",children:r.jsx("div",{className:"space-y-4",children:[1,2,3].map(n=>r.jsx(pr,{className:"h-32 w-full"},n))})}):!t||t.length===0?r.jsx(Ur,{title:"My Orders",children:r.jsxs("div",{className:"text-center py-12",children:[r.jsx(ec,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No orders yet"}),r.jsx("p",{className:"text-muted-foreground mb-6",children:"Start shopping to see your orders here!"}),r.jsx(X,{onClick:()=>e("/marketplace"),children:"Browse Marketplace"})]})}):r.jsx(Ur,{title:"My Orders",children:r.jsx("div",{className:"space-y-4",children:t.map(n=>{var a,o,l;return r.jsx(ze,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>e(`/marketplace/orders/${n.id}`),children:r.jsxs(qe,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{children:[r.jsx("span",{className:"font-semibold",children:n.order_number}),r.jsx("span",{className:"text-muted-foreground text-sm ml-2",children:Xr(new Date(n.created_at),"MMM d, yyyy")})]}),r.jsx(_t,{className:Ube[n.status],children:a5[n.status]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsxs("div",{className:"flex -space-x-2",children:[(a=n.items)==null?void 0:a.slice(0,3).map((i,d)=>r.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&&r.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]})]}),r.jsxs("div",{children:[r.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`}),r.jsxs("p",{className:"font-semibold",children:["$",Number(n.total).toFixed(2)]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[n.tracking_url&&r.jsxs(X,{variant:"outline",size:"sm",onClick:i=>{i.stopPropagation(),window.open(n.tracking_url,"_blank")},children:[r.jsx(jn,{className:"h-4 w-4 mr-1"}),"Track"]}),r.jsx(Zi,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const zIe=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function clr({currentStatus:e,statusHistory:t}){const s=zIe.indexOf(e);return r.jsx("div",{className:"space-y-3",children:zIe.map((n,a)=>{const o=t==null?void 0:t.find(m=>m.status===n),l=as;return r.jsxs("div",{className:"flex items-start gap-3",children:[r.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?r.jsx(Ri,{className:"h-4 w-4"}):i?r.jsx(Pa,{className:"h-4 w-4"}):r.jsx("span",{className:"text-xs",children:a+1})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:`font-medium ${d?"text-muted-foreground":""}`,children:a5[n]}),o&&r.jsxs("p",{className:"text-xs text-muted-foreground",children:[Xr(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function dlr(){var T;const{orderId:e}=Bl(),t=Ks(),{data:s,isLoading:n,refetch:a}=wor(e||""),o=Nor(),l=Sor(),[i,d]=A.useState(!1),[m,p]=A.useState(null),[g,v]=A.useState(""),[_,k]=A.useState(null),w=async C=>{k(C);try{await o.mutateAsync({orderId:e,itemId:C}),we.success("Proof approved!"),a()}catch{we.error("Failed to approve proof")}finally{k(null)}},S=async()=>{if(m){k(m);try{await l.mutateAsync({orderId:e,itemId:m,reason:g}),we.success("Revision requested"),d(!1),v(""),p(null),a()}catch{we.error("Failed to request revision")}finally{k(null)}}};return n?r.jsx(Ur,{title:"Order Details",children:r.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[r.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[r.jsx(pr,{className:"h-64 w-full"}),r.jsx(pr,{className:"h-48 w-full"})]}),r.jsx(pr,{className:"h-96 w-full"})]})}):s?r.jsxs(Ur,{title:`Order ${s.order_number}`,children:[r.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[r.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[r.jsxs(ze,{children:[r.jsxs(Wt,{className:"flex flex-row items-center justify-between",children:[r.jsx(Zt,{children:"Order Status"}),r.jsx(_t,{className:Ube[s.status],children:a5[s.status]})]}),r.jsx(qe,{children:r.jsx(clr,{currentStatus:s.status,statusHistory:s.status_history})})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Items"})}),r.jsx(qe,{className:"space-y-4",children:(T=s.items)==null?void 0:T.map(C=>r.jsxs("div",{className:"border rounded-lg p-4",children:[r.jsxs("div",{className:"flex justify-between items-start mb-3",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"font-semibold",children:C.product_name}),C.variant_name&&r.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name}),r.jsxs("p",{className:"text-sm",children:["Qty: ",C.quantity," × $",Number(C.unit_price).toFixed(2)]})]}),r.jsxs("p",{className:"font-semibold",children:["$",(Number(C.unit_price)*C.quantity).toFixed(2)]})]}),C.artwork_url&&r.jsxs("div",{className:"mb-3",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your Artwork:"}),r.jsxs("a",{href:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[r.jsx(v1,{className:"h-4 w-4"}),"View Artwork",r.jsx(jn,{className:"h-3 w-3"})]})]}),C.proof_url&&r.jsxs("div",{className:"bg-muted rounded-lg p-3",children:[r.jsx("p",{className:"text-sm font-medium mb-2",children:"Proof Ready for Review"}),r.jsxs("a",{href:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[r.jsx(v1,{className:"h-4 w-4"}),"View Proof",r.jsx(jn,{className:"h-3 w-3"})]}),C.proof_status==="pending"&&r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs(X,{size:"sm",onClick:()=>w(C.id),disabled:_===C.id,children:[_===C.id?r.jsx($r,{className:"h-4 w-4 mr-1 animate-spin"}):r.jsx(Cd,{className:"h-4 w-4 mr-1"}),"Approve"]}),r.jsxs(X,{size:"sm",variant:"outline",onClick:()=>{p(C.id),d(!0)},disabled:_===C.id,children:[r.jsx(RE,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),C.proof_status==="approved"&&r.jsxs(_t,{className:"bg-green-100 text-green-800",children:[r.jsx(Ri,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),C.proof_status==="rejected"&&C.proof_notes&&r.jsxs("div",{className:"mt-2",children:[r.jsx(_t,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:C.proof_notes})]})]})]},C.id))})]}),s.shipping_name&&r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsxs(Zt,{className:"flex items-center gap-2",children:[r.jsx(zE,{className:"h-5 w-5"}),"Shipping"]})}),r.jsxs(qe,{children:[r.jsx("p",{className:"font-medium",children:s.shipping_name}),r.jsxs("p",{className:"text-muted-foreground",children:[s.shipping_address,r.jsx("br",{}),s.shipping_city,", ",s.shipping_state," ",s.shipping_zip]}),s.tracking_number&&r.jsxs("div",{className:"mt-4 p-3 bg-muted rounded-lg",children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracking Number:"}),r.jsx("p",{className:"font-mono font-medium",children:s.tracking_number}),s.tracking_url&&r.jsxs(X,{variant:"link",className:"p-0 h-auto mt-1",onClick:()=>window.open(s.tracking_url,"_blank"),children:["Track Package",r.jsx(jn,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),r.jsx("div",{children:r.jsxs(ze,{className:"sticky top-4",children:[r.jsx(Wt,{children:r.jsx(Zt,{children:"Order Summary"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",Xr(new Date(s.created_at),"MMMM d, yyyy")]}),r.jsx(kd,{}),r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{children:"Subtotal"}),r.jsxs("span",{children:["$",Number(s.subtotal).toFixed(2)]})]}),r.jsxs("div",{className:"flex justify-between text-sm",children:[r.jsx("span",{children:"Shipping"}),r.jsxs("span",{children:["$",Number(s.shipping_total).toFixed(2)]})]})]}),r.jsx(kd,{}),r.jsxs("div",{className:"flex justify-between font-bold text-lg",children:[r.jsx("span",{children:"Total"}),r.jsxs("span",{children:["$",Number(s.total).toFixed(2)]})]}),s.notes&&r.jsxs(r.Fragment,{children:[r.jsx(kd,{}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium mb-1",children:"Order Notes"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:s.notes})]})]})]})]})})]}),r.jsx(Ir,{open:i,onOpenChange:d,children:r.jsxs(Er,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Request Changes"}),r.jsx(Zs,{children:"Please describe what changes you'd like made to the proof."})]}),r.jsx(qs,{placeholder:"Describe the changes needed...",value:g,onChange:C=>v(C.target.value),rows:4}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),r.jsxs(X,{onClick:S,disabled:!g.trim()||_!==null,children:[_?r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Submit Request"]})]})]})})]}):r.jsx(Ur,{title:"Order Not Found",children:r.jsxs("div",{className:"text-center py-12",children:[r.jsx(ec,{className:"h-16 w-16 mx-auto text-muted-foreground mb-4"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Order not found"}),r.jsx(X,{onClick:()=>t("/marketplace/orders"),children:"View All Orders"})]})})}function ulr(){const e=Ks(),[t]=Cc();return t.get("session_id"),A.useEffect(()=>{localStorage.removeItem("marketplace-cart")},[]),r.jsx(Ur,{title:"Order Confirmed",children:r.jsx("div",{className:"max-w-lg mx-auto text-center py-8",children:r.jsx(ze,{children:r.jsxs(qe,{className:"pt-8 pb-6",children:[r.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:r.jsx(Ri,{className:"h-8 w-8 text-green-600"})}),r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Thank You for Your Order!"}),r.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."}),r.jsxs("div",{className:"bg-muted rounded-lg p-4 mb-6 text-left",children:[r.jsxs("h3",{className:"font-medium mb-2 flex items-center gap-2",children:[r.jsx(ec,{className:"h-4 w-4"}),"What happens next?"]}),r.jsxs("ul",{className:"text-sm text-muted-foreground space-y-2",children:[r.jsx("li",{children:"• We'll review your order and prepare it for production"}),r.jsx("li",{children:"• If your order requires a proof, you'll receive it for approval"}),r.jsx("li",{children:"• Once approved, we'll begin production and ship when ready"}),r.jsx("li",{children:"• You'll receive tracking info when your order ships"})]})]}),r.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[r.jsxs(X,{className:"flex-1",onClick:()=>e("/marketplace/orders"),children:["View My Orders",r.jsx(Ki,{className:"h-4 w-4 ml-2"})]}),r.jsx(X,{variant:"outline",className:"flex-1",onClick:()=>e("/marketplace"),children:"Continue Shopping"})]})]})})})})}function hlr(){const{user:e}=Gr(),[t,s]=A.useState("store"),[n,a]=A.useState(null),[o,l]=A.useState(null),[i,d]=A.useState(!1),[m,p]=A.useState(5),[g,v]=A.useState(""),[_,k]=A.useState(!1),[w,S]=A.useState(!1),[T,C]=A.useState(""),[I,R]=A.useState(null),[D,B]=A.useState(!1),{hasSubmittedReview:$,submitReview:q,markPostedToGoogle:W}=GBe(),{data:K}=IZe(),{data:re,isLoading:ae}=EZe(),{data:oe,isLoading:se}=Por(n),{data:pe,isLoading:ie}=Lor(e==null?void 0:e.id),{data:de=0}=Oor(e==null?void 0:e.id),ce=Ror(),ge=new Set((pe==null?void 0:pe.map(Le=>Le.item_id))||[]),Te=async()=>{if(o)try{await ce.mutateAsync(o.id),we.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Le){we.error(Le.message||"Failed to purchase item")}},_e=async()=>{if(!g.trim()){we.error("Please write a review");return}k(!0);const Le=await q(m,g);k(!1),Le.success?(we.success("Thank you for your review! You earned 25 points!"),C(g),S(!0),v(""),p(5)):we.error(Le.error||"Failed to submit review")},ve=()=>{navigator.clipboard.writeText(T),we.success("Review copied to clipboard!")},Me=()=>{W(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ze=()=>{S(!1),d(!1),C("")};return ae||se||ie?r.jsx(Ur,{title:"Reward Store",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx(pr,{className:"h-24 w-full"}),r.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(Le=>r.jsx(pr,{className:"h-64"},Le))})]})}):r.jsxs(Ur,{title:"Reward Store",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-5xl font-bold text-foreground",children:"Reward Store"}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Redeem your points for exclusive rewards"})]}),r.jsx(ze,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/20 flex items-center justify-center",children:r.jsx(Dn,{className:"h-6 w-6 text-primary"})}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Your Spendable Points"}),r.jsx("p",{className:"text-3xl font-bold text-primary",children:de.toLocaleString()})]})]}),r.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(go,{className:"h-4 w-4"}),r.jsx("span",{children:"Earn points by attending events"})]}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Om,{className:"h-4 w-4 text-orange-500"}),r.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),r.jsx(Ek,{open:D,onOpenChange:B,children:r.jsxs(ze,{className:"border-primary/20",children:[r.jsx(Ik,{asChild:!0,children:r.jsx(Wt,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center",children:r.jsx(go,{className:"h-5 w-5 text-primary"})}),r.jsxs("div",{children:[r.jsx(Zt,{className:"text-base",children:"How to Earn Points"}),r.jsx(Cs,{children:"See all the ways you can earn spendable points"})]})]}),D?r.jsx(cx,{className:"h-5 w-5 text-muted-foreground"}):r.jsx(ad,{className:"h-5 w-5 text-muted-foreground"})]})})}),r.jsx(Pk,{children:r.jsx(qe,{className:"pt-0",children:r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[K==null?void 0:K.filter(Le=>Le.is_active).map(Le=>{const Ue=Ve=>{switch(Ve){case"event_attendance":return r.jsx(An,{className:"h-5 w-5"});case"leave_review":return r.jsx(Dn,{className:"h-5 w-5"});case"add_listing":return r.jsx(Vn,{className:"h-5 w-5"});case"first_contact":return r.jsx(ws,{className:"h-5 w-5"});case"first_video":return r.jsx(ma,{className:"h-5 w-5"});case"first_community_post":return r.jsx(Vo,{className:"h-5 w-5"});default:return r.jsx(po,{className:"h-5 w-5"})}};return r.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50 border",children:[r.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center text-primary shrink-0",children:Ue(Le.action_key)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium text-sm",children:Le.action_name}),Le.description&&r.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Le.description})]}),r.jsxs(_t,{variant:"secondary",className:"font-bold shrink-0",children:["+",Le.points]})]},Le.id)}),r.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-orange-500/10 border border-orange-500/20",children:[r.jsx("div",{className:"h-10 w-10 rounded-full bg-orange-500/20 flex items-center justify-center text-orange-500 shrink-0",children:r.jsx(Om,{className:"h-5 w-5"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"font-medium text-sm",children:"Streak Bonuses"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Attend consecutive weeks for bonus points!"})]}),r.jsx(_t,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!$&&r.jsx(ze,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:r.jsx(qe,{className:"pt-6",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx("div",{className:"h-12 w-12 rounded-full bg-yellow-500/20 flex items-center justify-center",children:r.jsx(Vo,{className:"h-6 w-6 text-yellow-600"})}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Earn 25 Free Points!"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Leave a quick review and earn 25 spendable points"})]})]}),r.jsxs(X,{onClick:()=>d(!0),className:"bg-yellow-600 hover:bg-yellow-700",children:[r.jsx(Dn,{className:"h-4 w-4 mr-2"}),"Leave Review"]})]})})}),r.jsxs(ii,{value:t,onValueChange:s,children:[r.jsxs(si,{children:[r.jsxs(Kr,{value:"store",className:"flex items-center gap-2",children:[r.jsx(mx,{className:"h-4 w-4"}),"Store"]}),r.jsxs(Kr,{value:"my-rewards",className:"flex items-center gap-2",children:[r.jsx(ec,{className:"h-4 w-4"}),"My Rewards",pe&&pe.length>0&&r.jsx(_t,{variant:"secondary",className:"ml-1",children:pe.length})]})]}),r.jsxs(hs,{value:"store",className:"mt-6",children:[re&&re.length>0&&r.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[r.jsx(X,{variant:n===null?"default":"outline",size:"sm",onClick:()=>a(null),children:"All"}),re.map(Le=>r.jsxs(X,{variant:n===Le.id?"default":"outline",size:"sm",onClick:()=>a(Le.id),children:[Le.icon&&`${Le.icon} `,Le.name]},Le.id))]}),!oe||oe.length===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-12",children:r.jsxs("div",{className:"text-center text-muted-foreground",children:[r.jsx(po,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"font-medium",children:"No items available"}),r.jsx("p",{className:"text-sm",children:"Check back later for new rewards!"})]})})}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:oe.map(Le=>{const Ue=ge.has(Le.id),Ve=Le.max_quantity!==null&&Le.current_quantity===0,Ie=de>=Le.points_cost;return r.jsxs(ze,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Ue?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>R(Le),children:[Le.preview_image_url?r.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[r.jsx("img",{src:Le.preview_image_url,alt:Le.name,className:"w-full h-full object-cover"}),Ue&&r.jsx("div",{className:"absolute top-2 right-2",children:r.jsxs(_t,{className:"bg-green-500 text-white",children:[r.jsx(Ri,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Ve&&!Ue&&r.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:r.jsx(_t,{variant:"destructive",children:"Sold Out"})})]}):r.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[r.jsx(po,{className:"h-12 w-12 text-muted-foreground/50"}),Ue&&r.jsx("div",{className:"absolute top-2 right-2",children:r.jsxs(_t,{className:"bg-green-500 text-white",children:[r.jsx(Ri,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),r.jsxs(Wt,{className:"pb-2",children:[r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsx(Zt,{className:"text-lg",children:Le.name}),r.jsxs(_t,{variant:"secondary",className:"font-bold shrink-0",children:[r.jsx(Dn,{className:"h-3 w-3 mr-1"}),Le.points_cost]})]}),Le.category&&r.jsxs(_t,{variant:"outline",className:"w-fit",children:[Le.category.icon&&`${Le.category.icon} `,Le.category.name]})]}),r.jsxs(qe,{children:[r.jsx(Cs,{className:"mb-4 line-clamp-2",children:Le.description||"No description available"}),Le.max_quantity!==null&&!Ue&&r.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Le.current_quantity," of ",Le.max_quantity," remaining"]}),Ue?r.jsx(X,{className:"w-full",onClick:We=>{We.stopPropagation(),Le.file_url&&rme(Le.file_url,Le.name)},disabled:!Le.file_url,children:Le.item_type==="file"?r.jsxs(r.Fragment,{children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Download"]}):r.jsxs(r.Fragment,{children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Access"]})}):r.jsx(X,{className:"w-full",onClick:We=>{We.stopPropagation(),l(Le)},disabled:Ve||!Ie,children:Ve?"Sold Out":Ie?r.jsxs(r.Fragment,{children:[r.jsx(mx,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Le.points_cost-de} more pts`})]})]},Le.id)})})]}),r.jsx(hs,{value:"my-rewards",className:"mt-6",children:!pe||pe.length===0?r.jsx(ze,{children:r.jsx(qe,{className:"py-12",children:r.jsxs("div",{className:"text-center text-muted-foreground",children:[r.jsx(ec,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("p",{className:"font-medium",children:"No rewards yet"}),r.jsx("p",{className:"text-sm",children:"Purchase items from the store to see them here!"})]})})}):r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:pe.map(Le=>{var Ue,Ve,Ie,We,wt;return r.jsxs(ze,{className:"overflow-hidden",children:[(Ue=Le.item)!=null&&Ue.preview_image_url?r.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:r.jsx("img",{src:Le.item.preview_image_url,alt:((Ve=Le.item)==null?void 0:Ve.name)||"Reward",className:"w-full h-full object-cover"})}):r.jsx("div",{className:"aspect-video bg-muted flex items-center justify-center",children:r.jsx(po,{className:"h-12 w-12 text-muted-foreground/50"})}),r.jsxs(Wt,{className:"pb-2",children:[r.jsx(Zt,{className:"text-lg",children:((Ie=Le.item)==null?void 0:Ie.name)||"Unknown Item"}),r.jsxs(Cs,{className:"text-xs",children:["Purchased for ",Le.points_spent," points • ",new Date(Le.purchased_at).toLocaleDateString()]})]}),r.jsx(qe,{children:r.jsx(X,{className:"w-full",onClick:()=>{var Pe,st;(Pe=Le.item)!=null&&Pe.file_url&&rme(Le.item.file_url,(st=Le.item)==null?void 0:st.name)},disabled:!((We=Le.item)!=null&&We.file_url),children:((wt=Le.item)==null?void 0:wt.item_type)==="file"?r.jsxs(r.Fragment,{children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Download"]}):r.jsxs(r.Fragment,{children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Le.id)})})})]})]}),r.jsx($c,{open:!!o,onOpenChange:()=>l(null),children:r.jsxs(xc,{children:[r.jsxs(yc,{children:[r.jsx(_c,{children:"Confirm Purchase"}),r.jsxs(bc,{children:['Are you sure you want to purchase "',o==null?void 0:o.name,'" for ',o==null?void 0:o.points_cost," points?",r.jsx("br",{}),r.jsx("br",{}),"You currently have ",r.jsxs("strong",{children:[de," points"]}),". After this purchase, you'll have"," ",r.jsxs("strong",{children:[de-((o==null?void 0:o.points_cost)||0)," points"]})," remaining."]})]}),r.jsxs(vc,{children:[r.jsx(wc,{children:"Cancel"}),r.jsx(Ql,{onClick:Te,disabled:ce.isPending,children:ce.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),r.jsx(Ir,{open:i,onOpenChange:Le=>{!Le&&w?Ze():d(Le)},children:r.jsx(Er,{children:w?r.jsxs(r.Fragment,{children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[r.jsx(Ri,{className:"h-5 w-5 text-green-500"}),"Thank You for Your Review!"]}),r.jsx(Zs,{children:"Would you also share your review on Google? It helps other agents discover LevelUp!"})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[r.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your review:"}),r.jsxs("p",{className:"text-sm italic",children:['"',T,'"']})]}),r.jsxs(X,{variant:"outline",className:"w-full",onClick:ve,children:[r.jsx(uo,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),r.jsxs(Rn,{className:"flex-col sm:flex-row gap-2",children:[r.jsx(X,{variant:"outline",onClick:Ze,children:"Maybe Later"}),r.jsxs(X,{onClick:Me,className:"bg-blue-600 hover:bg-blue-700",children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):r.jsxs(r.Fragment,{children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Leave a Review"}),r.jsx(Zs,{children:"Share your experience with LevelUp and earn 25 spendable points!"})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Rating"}),r.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(Le=>r.jsx("button",{type:"button",onClick:()=>p(Le),className:"focus:outline-none",children:r.jsx(Dn,{className:`h-8 w-8 transition-colors ${m>=Le?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Le))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),r.jsx(qs,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:g,onChange:Le=>v(Le.target.value),rows:4})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),r.jsx(X,{onClick:_e,disabled:_,className:"bg-yellow-600 hover:bg-yellow-700",children:_?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),r.jsx(Ir,{open:!!I,onOpenChange:()=>R(null),children:r.jsxs(Er,{className:"max-w-lg",children:[r.jsxs(zr,{children:[r.jsxs(Fr,{className:"flex items-center gap-2",children:[I==null?void 0:I.name,r.jsxs(_t,{variant:"secondary",className:"font-bold",children:[r.jsx(Dn,{className:"h-3 w-3 mr-1"}),I==null?void 0:I.points_cost]})]}),(I==null?void 0:I.category)&&r.jsxs(_t,{variant:"outline",className:"w-fit",children:[I.category.icon&&`${I.category.icon} `,I.category.name]})]}),(I==null?void 0:I.preview_image_url)&&r.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted rounded-lg",children:r.jsx("img",{src:I.preview_image_url,alt:I.name,className:"w-full h-full object-cover"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsx("p",{className:"text-muted-foreground",children:(I==null?void 0:I.description)||"No description available"}),(I==null?void 0:I.max_quantity)!==null&&!ge.has((I==null?void 0:I.id)||"")&&r.jsxs("p",{className:"text-sm text-muted-foreground",children:[I==null?void 0:I.current_quantity," of ",I==null?void 0:I.max_quantity," remaining"]})]}),r.jsx(Rn,{children:I&&ge.has(I.id)?r.jsx(X,{className:"w-full",onClick:()=>{I.file_url&&rme(I.file_url,I.name)},disabled:!I.file_url,children:I.item_type==="file"?r.jsxs(r.Fragment,{children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Download"]}):r.jsxs(r.Fragment,{children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Access"]})}):I&&r.jsx(X,{className:"w-full",onClick:()=>{R(null),l(I)},disabled:I.max_quantity!==null&&I.current_quantity===0||de{const{user:e}=Gr(),t=Rr(),s=Ht({queryKey:["smart-presentations",e==null?void 0:e.id],queryFn:async()=>{const{data:m,error:p}=await Y.from("smart_presentations").select("*").eq("owner_user_id",e.id).neq("status","archived").order("created_at",{ascending:!1});if(p)throw p;return m||[]},enabled:!!e}),n=Ht({queryKey:["smart-presentation-templates",e==null?void 0:e.id],queryFn:async()=>{const{data:m,error:p}=await Y.from("smart_presentation_templates").select("*").eq("is_active",!0).order("created_at",{ascending:!0});if(p)throw p;return m||[]},enabled:!!e}),a=Qt({mutationFn:async m=>{const{data:p,error:g}=await Y.from("smart_presentations").insert({owner_user_id:e.id,...m}).select().single();if(g)throw g;return p},onSuccess:()=>{t.invalidateQueries({queryKey:["smart-presentations"]})}}),o=Qt({mutationFn:async({id:m,...p})=>{const{data:g,error:v}=await Y.from("smart_presentations").update(p).eq("id",m).select().single();if(v)throw v;return g},onSuccess:()=>{t.invalidateQueries({queryKey:["smart-presentations"]})}}),l=Qt({mutationFn:async m=>{const{data:p,error:g}=await Y.from("smart_presentations").update({status:"published",published_at:new Date().toISOString()}).eq("id",m).select().single();if(g)throw g;return p},onSuccess:()=>{t.invalidateQueries({queryKey:["smart-presentations"]}),we.success("Presentation published!")}}),i=Qt({mutationFn:async m=>{const{error:p}=await Y.from("smart_presentations").update({status:"archived"}).eq("id",m);if(p)throw p},onSuccess:()=>{t.invalidateQueries({queryKey:["smart-presentations"]}),we.success("Presentation archived")}}),d=Qt({mutationFn:async m=>{const{error:p}=await Y.from("smart_presentation_templates").insert({owner_user_id:e.id,name:m.title+" Template",description:"Created from "+m.title,template_type:"custom",icon:"📄",sections:m.sections,cta_config:{type:m.cta_type,label:m.cta_label},is_system:!1});if(p)throw p},onSuccess:()=>{t.invalidateQueries({queryKey:["smart-presentation-templates"]}),we.success("Saved as template!")}});return{presentations:s.data||[],templates:n.data||[],isLoading:s.isLoading,templatesLoading:n.isLoading,createPresentation:a,updatePresentation:o,publishPresentation:l,archivePresentation:i,saveAsTemplate:d}},mlr=[{value:"positive",label:"Love it",icon:Cd,color:"bg-emerald-100 text-emerald-700 border-emerald-300"},{value:"suggestion",label:"Suggestion",icon:$y,color:"bg-amber-100 text-amber-700 border-amber-300"},{value:"issue",label:"Issue",icon:ch,color:"bg-red-100 text-red-700 border-red-300"}],flr=({feature:e,children:t})=>{const{user:s}=Gr(),[n,a]=A.useState(!1),[o,l]=A.useState(null),[i,d]=A.useState(""),[m,p]=A.useState(!1),g=async()=>{var v;if(!o||!i.trim()){we.error("Please select a type and add your feedback");return}p(!0);try{const{error:_}=await Y.functions.invoke("send-beta-feedback",{body:{feature:e,sentiment:o,message:i.trim(),userName:((v=s==null?void 0:s.user_metadata)==null?void 0:v.name)||(s==null?void 0:s.email)||"Unknown",userEmail:(s==null?void 0:s.email)||"unknown"}});if(_)throw _;we.success("Thank you for your feedback!"),a(!1),l(null),d("")}catch(_){console.error("Feedback error:",_),we.error("Failed to send feedback. Please try again.")}finally{p(!1)}};return r.jsxs(Ir,{open:n,onOpenChange:a,children:[r.jsx(Qi,{asChild:!0,children:t||r.jsxs(X,{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:[r.jsx(jE,{className:"h-3.5 w-3.5"}),"Feedback"]})}),r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Share Your Feedback"}),r.jsx(Zs,{children:"This feature is in beta — your thoughts help us make it better!"})]}),r.jsxs("div",{className:"space-y-4 pt-2",children:[r.jsx("div",{className:"flex gap-2",children:mlr.map(v=>{const _=v.icon;return r.jsxs("button",{type:"button",onClick:()=>l(v.value),className:Vt("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:[r.jsx(_,{className:"h-5 w-5"}),v.label]},v.value)})}),r.jsx(qs,{placeholder:"Tell us what you think...",value:i,onChange:v=>d(v.target.value),rows:4,className:"resize-none"}),r.jsxs("div",{className:"flex gap-2 justify-end",children:[r.jsx(X,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),r.jsx(X,{onClick:g,disabled:m||!o||!i.trim(),children:m?"Sending...":"Send Feedback"})]})]})]})]})},plr=()=>{const e=Ks(),{presentations:t,isLoading:s,archivePresentation:n,saveAsTemplate:a}=OZe(),o=i=>i.status==="draft"?r.jsx(_t,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?r.jsx(_t,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?r.jsx(_t,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):r.jsx(_t,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const d=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(d),we.success("Link copied!")};return r.jsx(Ur,{title:"Smart Presentations",children:r.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"Smart Presentations"}),r.jsx(m1e,{}),r.jsx(flr,{feature:"Smart Presentations"})]}),r.jsx("p",{className:"text-muted-foreground mt-1",children:"Create personalized, video-first presentations for your clients"})]}),r.jsxs(X,{onClick:()=>e("/mission-control/presentations/new"),className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Create Presentation"]})]}),s?r.jsx("div",{className:"space-y-3",children:[1,2,3].map(i=>r.jsx(pr,{className:"h-20 w-full rounded-lg"},i))}):t.length===0?r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:r.jsx(Ff,{className:"h-8 w-8 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No presentations yet"}),r.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."}),r.jsxs(X,{onClick:()=>e("/mission-control/presentations/new"),className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Create Your First Presentation"]})]})}):r.jsx("div",{className:"space-y-3",children:t.map(i=>r.jsx(ze,{className:"hover:shadow-sm transition-shadow",children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center shrink-0",children:r.jsx(ya,{className:"h-5 w-5 text-primary"})}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("h3",{className:"font-semibold truncate",children:i.title}),o(i)]}),r.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&&r.jsx("span",{children:i.client_name}),r.jsxs("span",{children:["Created ",Xr(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ii,{className:"h-3 w-3"})," ",i.view_count," view",i.view_count!==1?"s":""]}),i.cta_clicked_count>0&&r.jsx("span",{className:"text-emerald-600 font-medium",children:"CTA clicked"})]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap sm:shrink-0",children:[i.status==="published"&&i.share_token&&r.jsxs(X,{variant:"outline",size:"sm",onClick:()=>l(i.share_token),children:[r.jsx(uo,{className:"h-3.5 w-3.5 mr-1"}),"Copy Link"]}),i.status==="published"&&r.jsx(X,{variant:"outline",size:"sm",onClick:()=>e(`/mission-control/presentations/${i.id}?edit=true`),children:"Edit"}),r.jsx(X,{variant:"outline",size:"sm",onClick:()=>e(`/mission-control/presentations/${i.id}`),children:i.status==="draft"?"Edit":"View"}),r.jsxs(Bu,{children:[r.jsx($u,{asChild:!0,children:r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",children:r.jsx(Qg,{className:"h-4 w-4"})})}),r.jsxs(vu,{align:"end",children:[i.status==="published"&&i.share_token&&r.jsxs(Ba,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[r.jsx(jn,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),r.jsxs(Ba,{onClick:()=>a.mutate(i),children:[r.jsx(ya,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),r.jsxs(Ba,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[r.jsx(_4,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},BIe={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."}]},glr=[{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 xlr(e){const t=BIe[e];if(t)return t;const s=e.toLowerCase();for(const[n,a]of Object.entries(BIe))if(s.includes(n.toLowerCase())||n.toLowerCase().includes(s))return a;return glr}function ylr({sectionTitle:e,contactId:t,onVideoReady:s}){const[n,a]=A.useState(!1),[o,l]=A.useState("script"),[i,d]=A.useState(0),[m,p]=A.useState(0),{canRecord:g}=lHe(),v=q3(),[_,k]=A.useState(""),[w,S]=A.useState(!1),[T,C]=A.useState(!0),[I,R]=A.useState(!1),[D,B]=A.useState(null),$=xlr(e),q=()=>{l("script"),d(0),p(0),k(""),S(!1),C(!0),R(!1),B(null)},W=se=>{!se&&(o==="uploading"||o==="processing")||(a(se),se||q())},K=se=>{B(se),k($[se].text),S(!1)},re=()=>{l("record"),C(_.trim().length>0)},ae=()=>{k(""),C(!1),l("record")},oe=A.useCallback(async(se,pe)=>{l("uploading");try{const ie=e||"Presentation Video",{videoId:de,uploadUrl:ce,libraryId:ge}=await boe(ie),{apiKey:Te}=await woe(de),_e=new XMLHttpRequest;_e.upload.onprogress=Le=>{Le.lengthComputable&&d(Le.loaded/Le.total*100)},await new Promise((Le,Ue)=>{_e.onload=()=>_e.status>=200&&_e.status<300?Le():Ue(new Error("Upload failed")),_e.onerror=()=>Ue(new Error("Upload failed")),_e.open("PUT",ce),_e.setRequestHeader("AccessKey",Te),_e.send(se)}),l("processing");let ve=0;const Me=Date.now(),Ze=9e4;let Ae=null;for(;ve<4;){if(await new Promise(Ue=>setTimeout(Ue,3e3)),Date.now()-Me>Ze){const Ue=se.size/1048576,Ve=`https://iframe.mediadelivery.net/embed/${ge}/${de}?responsive=true`;await v.mutateAsync({bunny_video_id:de,playback_url:Ve,file_size_mb:Ue,title:ie,contact_id:t||void 0,status:"processing",touch_type:"presentation"}),s(Ve),we.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Le=await jne(de);if(ve=Le.status,p(Le.encodeProgress||0),ve===4)Ae={playbackUrl:Le.directPlayUrl,thumbnailUrl:Le.thumbnailUrl,previewUrl:Le.previewUrl||null,duration:Le.length||pe,fileSizeMb:(Le.storageSize||se.size)/(1024*1024)};else if(ve===5||ve===6)throw new Error("Video processing failed")}if(!Ae)throw new Error("No video data");await v.mutateAsync({bunny_video_id:de,contact_id:t||void 0,playback_url:Ae.playbackUrl,thumbnail_url:Ae.thumbnailUrl,preview_url:Ae.previewUrl,duration_seconds:Ae.duration,file_size_mb:Ae.fileSizeMb,title:ie,status:"ready",touch_type:"presentation"}),s(Ae.playbackUrl),we.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ie){console.error("Recording upload error:",ie),we.error("Failed to process video. Please try again."),l("record")}},[e,t,s,v]);return r.jsxs(Ir,{open:n,onOpenChange:W,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Record a video",children:[r.jsx(ma,{className:"h-3.5 w-3.5"}),"Record"]})}),r.jsxs(Er,{className:"max-w-2xl max-h-[90vh] overflow-y-auto !top-[5%] !translate-y-0 sm:!top-[5%] sm:!translate-y-0",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:[o==="script"&&`Prepare your script for "${e}"`,o==="record"&&`Record video for "${e}"`,o==="uploading"&&"Uploading...",o==="processing"&&"Processing...",o==="done"&&"Done!"]})}),o==="script"&&r.jsxs("div",{className:"space-y-4",children:[r.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."}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Starter Scripts"}),r.jsx("div",{className:"grid gap-2",children:$.map((se,pe)=>r.jsxs("button",{onClick:()=>K(pe),className:Vt("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",D===pe?"border-primary bg-primary/5 ring-1 ring-primary":"border-border"),children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ya,{className:"h-3.5 w-3.5 text-primary shrink-0"}),r.jsx("span",{className:"text-sm font-medium",children:se.label})]}),r.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:se.text})]},pe))})]}),_&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Your Script"}),!w&&r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>S(!0),className:"h-7 text-xs gap-1",children:[r.jsx(Qa,{className:"h-3 w-3"}),"Edit"]})]}),w?r.jsx(qs,{value:_,onChange:se=>k(se.target.value),rows:5,placeholder:"Type your script here...",className:"text-sm"}):r.jsx("div",{className:"p-3 rounded-lg bg-muted/50 text-sm text-foreground leading-relaxed",children:_})]}),!_&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Or Write Your Own"}),r.jsx(qs,{value:_,onChange:se=>{k(se.target.value),B(null)},rows:4,placeholder:"Type your own script here...",className:"text-sm"})]}),r.jsxs("div",{className:"flex items-center justify-between pt-2",children:[r.jsx(X,{variant:"ghost",size:"sm",onClick:ae,className:"text-muted-foreground",children:"Skip — no teleprompter"}),r.jsx(X,{onClick:re,disabled:!1,children:_.trim()?"Continue with Script":"Continue Without Script"})]})]}),!g&&o==="record"?r.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 text-center",children:[r.jsx(ch,{className:"h-10 w-10 text-destructive"}),r.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"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Record up to 60 seconds. Saved to your library & auto-attached."}),_.trim()&&r.jsxs(X,{variant:"ghost",size:"sm",onClick:()=>C(!T),className:"h-7 text-xs gap-1",children:[T?r.jsx(Lf,{className:"h-3 w-3"}):r.jsx(Ii,{className:"h-3 w-3"}),T?"Hide Script":"Show Script"]})]}),r.jsx(zbe,{maxDurationSeconds:60,onRecordingComplete:oe,onRecordingStateChange:R,onError:se=>we.error(se),teleprompterContent:_.trim()?r.jsx(cZe,{text:_,isVisible:T,onToggleVisibility:()=>C(!T),isRecording:I,startCountdown:!1}):void 0}),r.jsx(X,{variant:"ghost",size:"sm",onClick:()=>l("script"),className:"text-xs text-muted-foreground",children:"← Back to script"})]}):o==="uploading"?r.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[r.jsx($r,{className:"h-10 w-10 animate-spin text-primary"}),r.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[r.jsx(zl,{value:i,className:"h-2"}),r.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Uploading... ",Math.round(i),"%"]})]})]}):o==="processing"?r.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[r.jsx($r,{className:"h-10 w-10 animate-spin text-primary"}),r.jsxs("div",{className:"w-full max-w-xs space-y-2",children:[r.jsx(zl,{value:m,className:"h-2"}),r.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Processing... ",Math.round(m),"%"]}),r.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"This usually takes less than a minute"})]})]}):o==="done"?r.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[r.jsx(ui,{className:"h-12 w-12 text-emerald-500"}),r.jsx("p",{className:"text-sm font-medium text-foreground",children:"Video attached!"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved to your video library"})]}):null]})]})}function vlr({sectionTitle:e,contactId:t,onVideoReady:s}){const[n,a]=A.useState(!1),[o,l]=A.useState(null),[i,d]=A.useState("idle"),[m,p]=A.useState(0),g=A.useRef(null),v=q3(),{data:_}=_oe(),k=(_==null?void 0:_.total_storage_mb)||0,S=((_==null?void 0:_.max_storage_mb)||1024)-k,T=()=>{l(null),d("idle"),p(0)},C=$=>{!$&&i!=="idle"&&i!=="done"||(a($),$||T())},I=$=>{var K;const q=(K=$.target.files)==null?void 0:K[0];if(!q)return;if(!q.type.startsWith("video/")){we.error("Please select a video file");return}const W=q.size/(1024*1024);if(W>500){we.error("Video file must be less than 500MB");return}if(W>S){we.error(`Not enough storage. You have ${S.toFixed(1)} MB remaining.`);return}l(q)},R=A.useCallback(async()=>{if(o){d("creating"),p(0);try{const $=e||o.name,{data:q,error:W}=await Y.functions.invoke("bunny-upload",{body:{action:"create",title:$,isAgentVideo:!0}});if(W)throw new Error(W.message);const{videoId:K,libraryId:re}=q;d("uploading");const{data:ae,error:oe}=await Y.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:K,isAgentVideo:!0}});if(oe)throw new Error(oe.message);await new Promise((ie,de)=>{const ce=new XMLHttpRequest;ce.upload.addEventListener("progress",ge=>{ge.lengthComputable&&p(Math.round(ge.loaded/ge.total*100))}),ce.addEventListener("load",()=>ce.status>=200&&ce.status<300?ie():de(new Error(`Upload failed (${ce.status})`))),ce.addEventListener("error",()=>de(new Error("Upload failed"))),ce.open("PUT",ae.uploadUrl),ce.setRequestHeader("AccessKey",ae.apiKey),ce.send(o)}),d("processing");const se=o.size/(1024*1024),pe=`https://iframe.mediadelivery.net/embed/${re}/${K}`;await v.mutateAsync({bunny_video_id:K,playback_url:pe,file_size_mb:se,title:$,contact_id:t||void 0,status:"processing",touch_type:"presentation"}),s(pe),d("done"),we.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch($){console.error("Upload error:",$),we.error($ instanceof Error?$.message:"Failed to upload video"),d("idle")}}},[o,e,t,s,v]),D=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${m}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},B=i!=="idle"&&i!=="done";return r.jsxs(Ir,{open:n,onOpenChange:C,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",title:"Upload a video file",children:[r.jsx(Xi,{className:"h-3.5 w-3.5"}),"Upload"]})}),r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsx(zr,{children:r.jsxs(Fr,{children:['Upload Video for "',e,'"']})}),r.jsxs("div",{className:"space-y-4 py-2",children:[o?r.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[r.jsx(ma,{className:"h-8 w-8 text-primary flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("p",{className:"text-sm font-medium truncate",children:o.name}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[(o.size/(1024*1024)).toFixed(1)," MB"]})]}),!B&&r.jsx(X,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.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:[r.jsx(Xi,{className:"h-8 w-8 mx-auto text-muted-foreground mb-2"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select a video file"}),r.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"MP4, MOV, WebM (max 500MB)"})]}),r.jsx("input",{ref:g,type:"file",accept:"video/*",className:"hidden",onChange:I,disabled:B}),B&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx($r,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{children:D()})]}),r.jsx(zl,{value:i==="uploading"?m:i==="processing"?100:10})]})]}),r.jsxs(Rn,{children:[r.jsx(X,{variant:"outline",onClick:()=>C(!1),disabled:B,children:"Cancel"}),r.jsx(X,{onClick:R,disabled:!o||B,children:B?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const $Ie=[{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"}],UIe=()=>{const e=Ks(),{id:t}=Bl(),{user:s}=Gr(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=OZe(),{isGmailConnected:d,gmailEmail:m}=kN(),[p,g]=A.useState(!1),[v,_]=A.useState("client"),[k,w]=A.useState(!1),[S,T]=A.useState(""),[C,I]=A.useState([]),[R,D]=A.useState(!1),[B,$]=A.useState(null),[q,W]=A.useState(!1),[K,re]=A.useState(""),[ae,oe]=A.useState(""),[se,pe]=A.useState(""),[ie,de]=A.useState("buyer"),[ce,ge]=A.useState(""),[Te,_e]=A.useState(null),[ve,Me]=A.useState(""),[Ze,Ae]=A.useState([]),[Le,Ue]=A.useState("schedule_call"),[Ve,Ie]=A.useState("Schedule a Call"),[We,wt]=A.useState(""),[Pe,st]=A.useState(""),[ue,$e]=A.useState(null),[tt,rt]=A.useState(t||null),[je,it]=A.useState(null),[Se,et]=A.useState(!1),Qe=async(Et,Pt)=>{if(!s)return;const Sr=5*1024*1024;if(Et.size>Sr){we.error("Image must be under 5MB");return}if(!Et.type.startsWith("image/")){we.error("Please upload an image file");return}$e(Pt);try{const fs=Et.name.split(".").pop()||"jpg",Ws=`${s.id}/${Date.now()}.${fs}`,{error:tn}=await Y.storage.from("listing-photos").upload(Ws,Et);if(tn)throw tn;const{data:{publicUrl:xi}}=Y.storage.from("listing-photos").getPublicUrl(Ws);Tt(Pt,{image_url:xi}),we.success("Image uploaded")}catch{we.error("Failed to upload image")}finally{$e(null)}};A.useEffect(()=>{t&&He(t)},[t]);const He=async Et=>{const{data:Pt,error:Sr}=await Y.from("smart_presentations").select("*").eq("id",Et).single();if(Sr||!Pt)return;const fs=Pt;if(w(!0),Me(fs.title),re(fs.client_name||""),ge(fs.property_address||""),Ae(fs.sections||[]),Ue(fs.cta_type||"schedule_call"),Ie(fs.cta_label||"Schedule a Call"),wt(fs.cta_url||""),st(fs.heading||""),it(fs.share_token),et(fs.status==="published"),rt(fs.id),_("builder"),fs.contact_id){const{data:Ws}=await Y.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",fs.contact_id).maybeSingle();Ws&&($(Ws),oe(Ws.email||""),pe(Ws.phone||""))}};A.useEffect(()=>{if(!s||S.length<1){I([]);return}const Et=setTimeout(async()=>{D(!0);const{data:Pt}=await Y.from("innercircle_contacts").select("id, first_name, last_name, email, phone, lead_source").eq("owner_user_id",s.id).or(`first_name.ilike.%${S}%,last_name.ilike.%${S}%,email.ilike.%${S}%`).limit(10);I(Pt||[]),D(!1)},300);return()=>clearTimeout(Et)},[S,s]);const ot=Et=>{$(Et),re(`${Et.first_name} ${Et.last_name||""}`.trim()),oe(Et.email||""),pe(Et.phone||""),W(!1)},ut=async()=>{if(!K.trim()){we.error("Client name is required");return}const Et=K.trim().split(" "),Pt=Et[0],Sr=Et.slice(1).join(" ")||null,{data:fs,error:Ws}=await Y.from("innercircle_contacts").insert({owner_user_id:s.id,first_name:Pt,last_name:Sr,email:ae||null,phone:se||null,lead_source:"Smart Presentation"}).select().single();if(Ws){we.error("Failed to create client");return}$(fs),we.success("Client created & saved to Agent OS"),_("template")},ft=Et=>{_e(Et);const Pt=(Et.sections||[]).map(Sr=>({...Sr,is_visible:!0,video_url:"",text:""}));if(Ae(Pt),Me(Et.name+(K?` for ${K}`:"")),Et.cta_config){const Sr=Et.cta_config;Ue(Sr.type||"schedule_call"),Ie(Sr.label||"Schedule a Call")}_("builder")},ct=()=>{Ae([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),Me(K?`Presentation for ${K}`:"New Presentation"),_("builder")},Tt=(Et,Pt)=>{Ae(Sr=>Sr.map((fs,Ws)=>Ws===Et?{...fs,...Pt}:fs))},Ot=Et=>{Tt(Et,{is_visible:!Ze[Et].is_visible})},rr=()=>{Ae(Et=>[...Et,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Lr=Et=>{Ae(Pt=>Pt.filter((Sr,fs)=>fs!==Et))},cr=async()=>{if(!ve.trim()){we.error("Title is required");return}try{if(tt){const Et=await l.mutateAsync({id:tt,title:ve,sections:Ze,client_name:K,property_address:ce||null,cta_type:Le,cta_label:Ve,cta_url:We||null,heading:Pe||null});we.success("Saved")}else{const Et=await o.mutateAsync({title:ve,contact_id:(B==null?void 0:B.id)||void 0,client_name:K,property_address:ce||void 0,template_id:(Te==null?void 0:Te.id)||void 0,sections:Ze,cta_type:Le,cta_label:Ve,cta_url:We||void 0,heading:Pe||void 0});rt(Et.id),it(Et.share_token),we.success("Presentation created!")}}catch(Et){console.error("Failed to save presentation:",Et);const Pt=(Et==null?void 0:Et.message)||(Et==null?void 0:Et.toString())||"Unknown error";we.error(`Failed to save: ${Pt}`)}},Mr=async()=>{try{await cr();const Et=tt;if(Et){const Pt=await i.mutateAsync(Et);it(Pt.share_token),et(!0),_("share")}}catch(Et){console.error("Failed to publish presentation:",Et),we.error(`Failed to publish: ${(Et==null?void 0:Et.message)||"Unknown error"}`)}},As=je?`https://presentations.relevelup.com/${je}`:"";return r.jsx(Ur,{title:"Smart Presentations",children:r.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>e("/mission-control/presentations"),children:r.jsx(gi,{className:"h-4 w-4"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:k?"Edit Presentation":"Create Smart Presentation"}),r.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"]})]})]}),!k&&r.jsx("div",{className:"flex items-center gap-2",children:["client","template","builder","share"].map((Et,Pt)=>r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:Vt("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",v===Et?"bg-primary text-primary-foreground":Pt<["client","template","builder","share"].indexOf(v)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:Pt<["client","template","builder","share"].indexOf(v)?r.jsx(mi,{className:"h-4 w-4"}):Pt+1}),r.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:Et}),Pt<3&&r.jsx("div",{className:"w-8 h-px bg-border"})]},Et))}),v==="client"&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs("button",{onClick:()=>{$(null),re(""),oe(""),pe(""),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:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:r.jsx(ai,{className:"h-4 w-4 text-primary"})}),r.jsxs("div",{className:"text-left",children:[r.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Skip — Use as Lead Gen Tool"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"No specific client. Share broadly to capture new leads."})]})]}),r.jsx(Ki,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors shrink-0"})]}),r.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx(qn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),r.jsxs(qe,{className:"space-y-3",children:[r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search by name or email...",value:S,onChange:Et=>T(Et.target.value),className:"pl-10"})]}),r.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[R&&r.jsx(pr,{className:"h-12 w-full"}),C.map(Et=>r.jsxs("button",{onClick:()=>ot(Et),className:Vt("w-full text-left p-3 rounded-lg border transition-colors",(B==null?void 0:B.id)===Et.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[r.jsxs("p",{className:"font-medium text-sm",children:[Et.first_name," ",Et.last_name]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:Et.email||Et.phone||"No contact info"})]},Et.id)),!S&&r.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),S&&C.length===0&&!R&&r.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),B&&r.jsxs(X,{onClick:()=>_("template"),className:"w-full gap-2",children:["Continue with ",B.first_name,r.jsx(Ki,{className:"h-4 w-4"})]})]})]}),r.jsxs(ze,{children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs(Zt,{className:"text-base flex items-center gap-2",children:[r.jsx(Kd,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),r.jsxs(qe,{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"col-span-2",children:[r.jsx(Ee,{className:"text-xs",children:"Name *"}),r.jsx(Ye,{value:K,onChange:Et=>{re(Et.target.value),W(!0),$(null)},placeholder:"Sarah & Mike Johnson"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs",children:"Email"}),r.jsx(Ye,{value:ae,onChange:Et=>oe(Et.target.value),placeholder:"Optional",type:"email"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs",children:"Phone"}),r.jsx(Ye,{value:se,onChange:Et=>pe(Et.target.value),placeholder:"Optional"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs",children:"Client Type"}),r.jsxs(ds,{value:ie,onValueChange:de,children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsxs(cs,{children:[r.jsx(Ut,{value:"buyer",children:"Buyer"}),r.jsx(Ut,{value:"seller",children:"Seller"}),r.jsx(Ut,{value:"recruit",children:"Recruit"}),r.jsx(Ut,{value:"other",children:"Other"})]})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs",children:"Property Address"}),r.jsx(Ye,{value:ce,onChange:Et=>ge(Et.target.value),placeholder:"Optional"})]})]}),q&&K&&r.jsxs(X,{onClick:ut,className:"w-full gap-2",children:["Create Client & Continue",r.jsx(Ki,{className:"h-4 w-4"})]})]})]})]})]}),v==="template"&&r.jsxs("div",{className:"space-y-6",children:[r.jsxs(ii,{defaultValue:"system",children:[r.jsxs(si,{children:[r.jsx(Kr,{value:"mine",children:"My Core Templates"}),r.jsx(Kr,{value:"system",children:"LevelUp Smart Templates"}),r.jsx(Kr,{value:"blank",children:"+ Start Blank"})]}),r.jsx(hs,{value:"mine",className:"mt-4",children:a?r.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(Et=>r.jsx(pr,{className:"h-32"},Et))}):r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Et=>!Et.is_system).length===0?r.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(Et=>!Et.is_system).map(Et=>r.jsx(VIe,{template:Et,onSelect:ft},Et.id))})}),r.jsx(hs,{value:"system",className:"mt-4",children:r.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Et=>Et.is_system).map(Et=>r.jsx(VIe,{template:Et,onSelect:ft},Et.id))})}),r.jsx(hs,{value:"blank",className:"mt-4",children:r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx("p",{className:"text-muted-foreground mb-4",children:"Start with a blank canvas and add your own sections."}),r.jsx(X,{onClick:ct,children:"Start from Scratch"})]})})})]}),r.jsxs(X,{variant:"outline",onClick:()=>_("client"),className:"gap-2",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back"]})]}),v==="builder"&&r.jsxs("div",{className:"space-y-6",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"pt-6 space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Presentation Title"}),r.jsx(Ye,{value:ve,onChange:Et=>Me(Et.target.value)})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Page Heading"}),r.jsx(Ye,{value:Pe,onChange:Et=>st(Et.target.value),placeholder:K?`Welcome, ${K}!`:"e.g. Welcome! or Your Custom Listing Plan"}),r.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:['The main heading visitors see. Leave blank for "Welcome, ',"",'!"']})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Client Name"}),r.jsx(Ye,{value:K,onChange:Et=>re(Et.target.value)})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Property Address"}),r.jsx(Ye,{value:ce,onChange:Et=>ge(Et.target.value),placeholder:"Optional"})]})]})]})}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("h2",{className:"text-lg font-semibold",children:"Sections"}),r.jsx(X,{variant:"outline",size:"sm",onClick:rr,children:"+ Add Section"})]}),r.jsx("div",{className:"space-y-3",children:Ze.map((Et,Pt)=>r.jsx(ze,{className:Vt(!Et.is_visible&&"opacity-50"),children:r.jsx(qe,{className:"p-4",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsxs("div",{className:"flex flex-col items-center gap-1 pt-1",children:[r.jsx(Df,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),r.jsx("span",{className:"text-lg",children:Et.icon})]}),r.jsxs("div",{className:"flex-1 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx(Ye,{value:Et.title,onChange:Sr=>Tt(Pt,{title:Sr.target.value}),className:"font-semibold border-none p-0 h-auto text-base focus-visible:ring-0 bg-transparent"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>Ot(Pt),children:Et.is_visible?r.jsx(Ii,{className:"h-4 w-4"}):r.jsx(Lf,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>Lr(Pt),className:"text-destructive hover:text-destructive",children:r.jsx(Os,{className:"h-4 w-4"})})]})]}),r.jsx(Ye,{value:Et.description||"",onChange:Sr=>Tt(Pt,{description:Sr.target.value}),placeholder:"Section description...",className:"text-sm"}),r.jsxs("div",{className:"flex items-end gap-2",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx(Ee,{className:"text-xs",children:"Video URL"}),r.jsx(Ye,{value:Et.video_url||"",onChange:Sr=>Tt(Pt,{video_url:Sr.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),r.jsx(ylr,{sectionTitle:Et.title,contactId:B==null?void 0:B.id,onVideoReady:Sr=>Tt(Pt,{video_url:Sr})}),r.jsx(vlr,{sectionTitle:Et.title,contactId:B==null?void 0:B.id,onVideoReady:Sr=>Tt(Pt,{video_url:Sr})}),r.jsx(_lr,{userId:s==null?void 0:s.id,onSelect:Sr=>Tt(Pt,{video_url:Sr})})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),Et.image_url?r.jsxs("div",{className:"relative mt-1 rounded-lg overflow-hidden border border-border bg-muted/30 group",children:[r.jsx("img",{src:Et.image_url,alt:"",className:"w-full max-h-40 object-cover"}),r.jsx(X,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>Tt(Pt,{image_url:""}),children:r.jsx(Xs,{className:"h-3.5 w-3.5"})})]}):r.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:[ue===Pt?r.jsx($r,{className:"h-4 w-4 animate-spin text-muted-foreground"}):r.jsx(j1,{className:"h-4 w-4 text-muted-foreground"}),r.jsx("span",{className:"text-sm text-muted-foreground",children:ue===Pt?"Uploading...":"Click to upload an image"}),r.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:ue===Pt,onChange:Sr=>{var Ws;const fs=(Ws=Sr.target.files)==null?void 0:Ws[0];fs&&Qe(fs,Pt),Sr.target.value=""}})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-xs",children:"Text (optional)"}),r.jsx(yg,{content:Et.text||"",onChange:Sr=>Tt(Pt,{text:Sr}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},Pt))})]}),r.jsxs(ze,{children:[r.jsx(Wt,{children:r.jsx(Zt,{className:"text-base",children:"Call to Action"})}),r.jsxs(qe,{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"CTA Type"}),r.jsxs(ds,{value:Le,onValueChange:Et=>{Ue(Et);const Pt=$Ie.find(Sr=>Sr.value===Et);Pt&&Ie(Pt.label)},children:[r.jsx(ls,{children:r.jsx(us,{})}),r.jsx(cs,{children:$Ie.map(Et=>r.jsx(Ut,{value:Et.value,children:Et.label},Et.value))})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Button Label"}),r.jsx(Ye,{value:Ve,onChange:Et=>Ie(Et.target.value)})]}),r.jsxs("div",{children:[r.jsxs(Ee,{children:["Link URL ",r.jsx("span",{className:"text-muted-foreground",children:"(optional — leave blank to show a lead capture form instead)"})]}),r.jsx(Ye,{value:We,onChange:Et=>wt(Et.target.value),placeholder:"https://calendly.com/..."}),!We&&r.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."})]})]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[!k&&r.jsxs(X,{variant:"outline",onClick:()=>_("template"),className:"gap-2",children:[r.jsx(gi,{className:"h-4 w-4"}),"Back"]}),r.jsxs("div",{className:"flex gap-3 ml-auto",children:[r.jsx(X,{variant:"outline",onClick:cr,disabled:o.isPending||l.isPending,children:"Save Draft"}),r.jsxs(X,{onClick:Mr,disabled:i.isPending,className:"gap-2",children:[r.jsx(ai,{className:"h-4 w-4"}),Se?"Update & Reshare":"Publish & Share"]})]})]})]}),v==="share"&&je&&r.jsxs("div",{className:"space-y-6",children:[r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center py-12 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-100 flex items-center justify-center mb-4",children:r.jsx(mi,{className:"h-8 w-8 text-emerald-600"})}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Your Presentation is Live!"}),r.jsxs("p",{className:"text-muted-foreground mb-6 max-w-md",children:["Share this link with ",K||"your client",". You'll be notified when they view it."]}),r.jsxs("div",{className:"flex items-center gap-2 w-full max-w-lg",children:[r.jsx(Ye,{value:As,readOnly:!0,className:"text-center font-mono text-sm"}),r.jsx(X,{onClick:()=>{navigator.clipboard.writeText(As),we.success("Link copied!")},children:r.jsx(uo,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex gap-3 mt-6",children:[r.jsxs(X,{variant:"outline",className:"gap-2",onClick:()=>{const Et=`Hi ${K||""}! I put together something for you — check it out: ${As}`;navigator.clipboard.writeText(Et),we.success("Message copied!")},children:[r.jsx(Vo,{className:"h-4 w-4"}),"Copy Text Message"]}),r.jsxs(X,{variant:"outline",className:"gap-2",onClick:()=>{d?g(!0):window.open(`mailto:${ae||""}?subject=${encodeURIComponent(ve)}&body=${encodeURIComponent(`Hi ${(B==null?void 0:B.first_name)||(K==null?void 0:K.split(" ")[0])||""}, I put together a personalized presentation for you: ${As} Looking forward to connecting!`)}`)},children:[r.jsx(Vs,{className:"h-4 w-4"}),"Send Email"]})]}),d&&r.jsx(yoe,{open:p,onOpenChange:g,contact:B?{id:B.id,first_name:B.first_name,last_name:B.last_name,email:ae||B.email||""}:ae?{id:"",first_name:(K==null?void 0:K.split(" ")[0])||"",last_name:(K==null?void 0:K.split(" ").slice(1).join(" "))||"",email:ae}:void 0,defaultSubject:ve,defaultBody:`Hi ${(B==null?void 0:B.first_name)||(K==null?void 0:K.split(" ")[0])||""}, I put together a personalized presentation for you: ${As} Looking forward to connecting!`,gmailEmail:m})]})}),r.jsxs("div",{className:"flex justify-between",children:[r.jsxs(X,{variant:"outline",onClick:()=>_("builder"),children:[r.jsx(gi,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),r.jsx(X,{onClick:()=>e("/mission-control/presentations"),children:"Done"})]})]})]})})},VIe=({template:e,onSelect:t})=>r.jsx(ze,{className:"hover:shadow-sm transition-shadow",children:r.jsxs(qe,{className:"p-5",children:[r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("span",{className:"text-2xl",children:e.icon}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h3",{className:"font-semibold",children:e.name}),r.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:e.description}),r.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[r.jsx(_t,{variant:"outline",className:"text-xs capitalize",children:e.template_type}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[(e.sections||[]).length," sections"]})]})]})]}),r.jsx(X,{className:"w-full mt-4",size:"sm",onClick:()=>t(e),children:"Use Template"})]})}),_lr=({userId:e,onSelect:t})=>{const[s,n]=A.useState(!1),[a,o]=A.useState([]),[l,i]=A.useState(!1),[d,m]=A.useState("");A.useEffect(()=>{!s||!e||(i(!0),Y.from("agent_videos").select("id, title, recipient_name, playback_url, thumbnail_url, created_at, duration_seconds").eq("owner_user_id",e).eq("is_deleted",!1).eq("status","ready").order("created_at",{ascending:!1}).limit(50).then(({data:g})=>{o(g||[]),i(!1)}))},[s,e]);const p=a.filter(g=>!d||(g.title||g.recipient_name||"").toLowerCase().includes(d.toLowerCase()));return r.jsxs(Ir,{open:s,onOpenChange:n,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"sm",className:"gap-1.5 shrink-0",children:[r.jsx(Ud,{className:"h-3.5 w-3.5"}),"Library"]})}),r.jsxs(Er,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Select from Video Library"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a video from your Agent OS library"})]}),r.jsxs("div",{className:"relative mb-3",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search videos...",value:d,onChange:g=>m(g.target.value),className:"pl-10"})]}),r.jsx("div",{className:"flex-1 overflow-y-auto space-y-2 min-h-0",children:l?r.jsxs(r.Fragment,{children:[r.jsx(pr,{className:"h-16 w-full"}),r.jsx(pr,{className:"h-16 w-full"})]}):p.length===0?r.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"}):p.map(g=>r.jsxs("button",{onClick:()=>{t(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:[r.jsx("div",{className:"w-16 h-10 rounded bg-muted flex items-center justify-center shrink-0 overflow-hidden",children:g.thumbnail_url?r.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 k=document.createElement("span");k.innerHTML="🎬",k.className="text-lg",_.appendChild(k)}}}):r.jsx(ma,{className:"h-4 w-4 text-muted-foreground"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"font-medium text-sm truncate",children:g.title||g.recipient_name||"Untitled Video"}),r.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))})]})]})},blr=()=>{var w;const{shareToken:e}=Bl(),[t,s]=A.useState(null),[n,a]=A.useState(!0),[o,l]=A.useState(0),[i,d]=A.useState(!1);A.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),A.useEffect(()=>{e&&m()},[e]);const m=async()=>{const{data:S,error:T}=await Y.from("smart_presentations").select("*").eq("share_token",e).eq("status","published").single();if(T||!S){d(!0),a(!1);return}const{data:C}=await Y.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",S.owner_user_id).single();let I;if(C!=null&&C.brokerage_id){const{data:D}=await Y.from("brokerages").select("name").eq("id",C.brokerage_id).single();I=(D==null?void 0:D.name)||void 0}let R=null;if(S.contact_id){const{data:D}=await Y.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",S.contact_id).single();R=D}s({...S,owner_name:C==null?void 0:C.name,owner_email:C==null?void 0:C.email,owner_phone:C==null?void 0:C.phone,owner_avatar:C==null?void 0:C.avatar_url,owner_title:(C==null?void 0:C.title)||void 0,brokerage_name:I,contact_name:R?[R.first_name,R.last_name].filter(Boolean).join(" "):void 0,contact_email:(R==null?void 0:R.email)||void 0,contact_phone:(R==null?void 0:R.phone)||void 0}),a(!1);try{await Y.rpc("log_presentation_view",{p_presentation_id:S.id,p_section_index:0,p_cta_clicked:!1,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch{}},p=async()=>{if(t){try{await Y.rpc("log_presentation_view",{p_presentation_id:t.id,p_section_index:null,p_cta_clicked:!0,p_ip_hash:null,p_user_agent:navigator.userAgent,p_referrer:null})}catch{}t.cta_url&&window.open(t.cta_url,"_blank")}};if(n)return r.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:r.jsxs("div",{className:"space-y-4 w-full max-w-2xl px-4",children:[r.jsx(pr,{className:"h-12 w-3/4 mx-auto"}),r.jsx(pr,{className:"h-64 w-full"}),r.jsx(pr,{className:"h-8 w-1/2 mx-auto"})]})});if(i||!t)return r.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Presentation Not Found"}),r.jsx("p",{className:"text-gray-500",children:"This presentation may have been removed or is no longer available."})]})});const g=t.sections.filter(S=>S.is_visible!==!1),v=g[o],_=S=>{const T=S.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(T)return`https://www.youtube.com/embed/${T[1]}?rel=0`;if(S.includes("iframe.mediadelivery.net/play/")){const R=S.replace("/play/","/embed/"),D=R.includes("?")?"&":"?";return`${R}${D}responsive=true`}if(S.includes("iframe.mediadelivery.net")){if(S.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const D=S.includes("?")?"&":"?";return`${S}${D}responsive=true`}return""}const C=S.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(C)return`https://www.loom.com/embed/${C[1]}`;const I=S.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return I?`https://iframe.mediadelivery.net/embed/${I[1]}/${I[2]}?responsive=true`:S},k=!!((w=t.cta_url)!=null&&w.trim());return r.jsxs("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white",children:[r.jsx("header",{className:"bg-white border-b border-gray-100 sticky top-0 z-10",children:r.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-3 flex items-center justify-between",children:[r.jsx("div",{}),r.jsxs("div",{className:"flex items-center gap-3",children:[t.owner_avatar&&r.jsx("img",{src:t.owner_avatar,alt:t.owner_name||"Agent",className:"h-10 w-10 rounded-full object-cover border border-gray-200"}),r.jsxs("div",{className:"text-right text-sm",children:[r.jsx("p",{className:"font-semibold text-gray-900",children:t.owner_name}),t.owner_title&&r.jsx("p",{className:"text-gray-500 text-xs",children:t.owner_title}),t.brokerage_name&&!t.owner_title&&r.jsx("p",{className:"text-gray-500 text-xs",children:t.brokerage_name})]})]})]})}),r.jsxs("main",{className:"max-w-5xl mx-auto px-4 py-8",children:[r.jsxs("div",{className:"text-center mb-8",children:[r.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-2",children:t.heading||(t.client_name?`Welcome, ${t.client_name}!`:t.title)}),t.property_address&&r.jsxs("p",{className:"text-lg text-gray-600",children:["Here's the plan for your home at ",r.jsx("strong",{children:t.property_address}),"."]})]}),r.jsxs("div",{className:"grid md:grid-cols-5 gap-8",children:[r.jsxs("div",{className:"md:col-span-3",children:[v!=null&&v.video_url&&_(v.video_url)?r.jsx("div",{className:"relative w-full rounded-xl overflow-hidden shadow-lg bg-gray-900",style:{paddingTop:"56.25%"},children:r.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?r.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:r.jsx("img",{src:v.image_url,alt:v.title,className:"w-full h-auto object-cover",loading:"lazy"})}):r.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:[r.jsx("span",{className:"text-5xl mb-3",children:v==null?void 0:v.icon}),r.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:v==null?void 0:v.title}),r.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:v==null?void 0:v.description})]}),(v==null?void 0:v.text)&&r.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}})]}),r.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((S,T)=>r.jsx("button",{onClick:()=>l(T),className:Vt("w-full text-left p-4 rounded-xl border transition-all",o===T?"border-blue-500 bg-blue-50 shadow-sm":"border-gray-200 bg-white hover:border-blue-200 hover:bg-blue-50/50"),children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsxs("span",{className:"text-blue-600 font-bold text-sm mt-0.5",children:[String(T+1).padStart(2,"0"),"."]}),r.jsxs("div",{children:[r.jsx("span",{className:"mr-2",children:S.icon}),r.jsx("span",{className:"font-semibold text-gray-900",children:S.title}),r.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:S.description})]})]})},T))})]}),r.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:[t.owner_avatar&&r.jsx("img",{src:t.owner_avatar,alt:t.owner_name||"Agent",className:"h-20 w-20 rounded-full object-cover mx-auto mb-3 border-2 border-gray-100"}),r.jsx("h3",{className:"text-lg font-bold text-gray-900",children:t.owner_name}),t.owner_title&&r.jsx("p",{className:"text-sm text-gray-500",children:t.owner_title}),t.brokerage_name&&r.jsx("p",{className:"text-sm text-gray-500",children:t.brokerage_name}),r.jsxs("div",{className:"mt-3 flex flex-col items-center gap-1 text-sm text-gray-600",children:[t.owner_phone&&r.jsx("a",{href:`tel:${t.owner_phone}`,className:"hover:text-blue-600 transition-colors",children:t.owner_phone}),t.owner_email&&r.jsx("a",{href:`mailto:${t.owner_email}`,className:"hover:text-blue-600 transition-colors",children:t.owner_email})]})]}),t.cta_label&&r.jsxs("div",{className:"text-center mt-8 py-8",children:[r.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"Ready to Get Started?"}),k?r.jsxs(X,{size:"lg",onClick:p,className:"text-lg px-8 py-6 rounded-xl bg-blue-600 hover:bg-blue-700 text-white shadow-lg",children:[t.cta_label,r.jsx(jn,{className:"h-5 w-5 ml-2"})]}):r.jsx("div",{className:"max-w-md mx-auto bg-white rounded-2xl border border-gray-200 shadow-sm p-6",children:r.jsx(c7e,{presentationId:t.id,ctaLabel:t.cta_label,agentName:t.owner_name||void 0,prefillName:t.contact_name,prefillEmail:t.contact_email,prefillPhone:t.contact_phone})})]})]}),r.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"})]})},iye="guestbook.relevelup.com";function wlr(){const{data:e,isLoading:t}=zgt(),s=$gt(),n=Ugt(),a=Vgt(),[o,l]=A.useState(!1),[i,d]=A.useState(null),{user:m}=Gr(),[p,g]=A.useState(null),[v,_]=A.useState(null),[k,w]=A.useState(!1),S=A.useRef(null),[T,C]=A.useState({property_address:"",city:"",state:"",zip:"",event_date:Xr(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below."}),I=$=>{var W;const q=(W=$.target.files)==null?void 0:W[0];if(q){if(q.size>5*1024*1024){ta({title:"Photo must be under 5MB",variant:"destructive"});return}g(q),_(URL.createObjectURL(q))}},R=()=>{g(null),_(null),S.current&&(S.current.value="")},D=async()=>{if(!T.property_address){ta({title:"Address is required",variant:"destructive"});return}let $;if(p&&m){w(!0);const q=p.name.split(".").pop(),W=`${m.id}/${Date.now()}.${q}`,{error:K}=await Y.storage.from("open-house-photos").upload(W,p,{upsert:!0});if(K){ta({title:"Photo upload failed",description:K.message,variant:"destructive"}),w(!1);return}const{data:re}=Y.storage.from("open-house-photos").getPublicUrl(W);$=re.publicUrl,w(!1)}await s.mutateAsync({...T,photo_url:$}),l(!1),C({property_address:"",city:"",state:"",zip:"",event_date:Xr(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below."}),R()},B=$=>{navigator.clipboard.writeText(`https://${iye}/${$}`),ta({title:"Link copied!"})};return r.jsxs(Ur,{title:"Guest Book",children:[r.jsx(nm,{children:r.jsx("title",{children:"Guest Book | LevelUp"})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-bold font-serif text-foreground",children:"Guest Book"}),r.jsx("p",{className:"text-muted-foreground text-sm",children:"The modern open house sign-in experience"})]}),r.jsxs(Ir,{open:o,onOpenChange:l,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"New Open House"]})}),r.jsxs(Er,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"Create Open House"}),r.jsx(Zs,{children:"Set up a new open house sign-in page"})]}),r.jsxs("div",{className:"space-y-4 pt-2 overflow-y-auto flex-1 pr-1",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Property Address *"}),r.jsx(Ye,{value:T.property_address,onChange:$=>C(q=>({...q,property_address:$.target.value})),placeholder:"123 Main Street"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"City"}),r.jsx(Ye,{value:T.city,onChange:$=>C(q=>({...q,city:$.target.value})),placeholder:"Austin"})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"State"}),r.jsx(Ye,{value:T.state,onChange:$=>C(q=>({...q,state:$.target.value})),placeholder:"TX",maxLength:2})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"ZIP"}),r.jsx(Ye,{value:T.zip,onChange:$=>C(q=>({...q,zip:$.target.value})),placeholder:"78701"})]})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{children:"Date"}),r.jsx(Ye,{type:"date",value:T.event_date,onChange:$=>C(q=>({...q,event_date:$.target.value}))})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Start Time"}),r.jsx(Ye,{type:"time",value:T.start_time,onChange:$=>C(q=>({...q,start_time:$.target.value}))})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"End Time"}),r.jsx(Ye,{type:"time",value:T.end_time,onChange:$=>C(q=>({...q,end_time:$.target.value}))})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Welcome Message"}),r.jsx(qs,{value:T.agent_greeting,onChange:$=>C(q=>({...q,agent_greeting:$.target.value})),placeholder:"Welcome! Please sign in below."})]}),r.jsxs("div",{children:[r.jsx(Ee,{children:"Property Photo"}),r.jsx("input",{ref:S,type:"file",accept:"image/*",onChange:I,className:"hidden"}),v?r.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[r.jsx("img",{src:v,alt:"Property preview",className:"w-full h-40 object-cover"}),r.jsx("button",{type:"button",onClick:R,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:r.jsx(Xs,{className:"h-4 w-4"})})]}):r.jsxs("button",{type:"button",onClick:()=>{var $;return($=S.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:[r.jsx(j1,{className:"h-6 w-6"}),r.jsx("span",{className:"text-sm",children:"Add a property photo"}),r.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),r.jsx(X,{onClick:D,disabled:s.isPending||k,className:"w-full",children:k?"Uploading photo...":s.isPending?"Creating...":"Create Open House"})]})]})]})]}),t?r.jsx("div",{className:"grid gap-4",children:[1,2].map($=>r.jsx(ze,{className:"animate-pulse",children:r.jsxs(Wt,{children:[r.jsx("div",{className:"h-5 bg-muted rounded w-48"}),r.jsx("div",{className:"h-4 bg-muted rounded w-32 mt-2"})]})},$))}):e!=null&&e.length?r.jsx("div",{className:"space-y-4",children:e.map($=>r.jsx(jlr,{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))}):r.jsx(ze,{className:"border-dashed",children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:r.jsx(Sk,{className:"h-8 w-8 text-primary"})}),r.jsx("h3",{className:"text-lg font-semibold mb-1",children:"No Open Houses Yet"}),r.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."}),r.jsxs(X,{onClick:()=>l(!0),children:[r.jsx(gs,{className:"h-4 w-4 mr-2"}),"Create Your First Open House"]})]})})]})]})}function jlr({openHouse:e,isExpanded:t,onToggle:s,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=Bgt(t?e.id:void 0),[i,d]=A.useState(!1),[m,p]=A.useState(!1),g=A.useRef(null),v=`https://${iye}/${e.slug}`,_=C=>{if(!C)return"";const[I,R]=C.split(":"),D=parseInt(I),B=D>=12?"PM":"AM";return`${D>12?D-12:D||12}:${R} ${B}`},k=()=>{if(!(l!=null&&l.length))return;const C=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],I=l.map(q=>[q.first_name,q.last_name||"",q.email||"",q.phone||"",q.visitor_intent||"",q.wants_market_updates?"Yes":"No",(q.message||"").replace(/"/g,'""'),Xr(new Date(q.created_at),"MM/dd/yyyy h:mm a")]),R=[C,...I].map(q=>q.map(W=>`"${W}"`).join(",")).join(` `),D=new Blob([R],{type:"text/csv"}),B=URL.createObjectURL(D),$=document.createElement("a");$.href=B,$.download=`${e.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,$.click(),URL.revokeObjectURL(B)},w=A.useCallback(()=>{if(!g.current)return;const C=g.current.querySelector("svg");if(!C)return;const I=new XMLSerializer().serializeToString(C),R=document.createElement("canvas");R.width=1024,R.height=1024;const D=R.getContext("2d"),B=new Image;B.onload=()=>{D==null||D.drawImage(B,0,0,1024,1024);const $=document.createElement("a");$.download=`${e.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,$.href=R.toDataURL("image/png"),$.click()},B.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(I)))},[e.property_address]),S=A.useCallback(()=>{if(!g.current)return;const C=g.current.querySelector("svg");if(!C)return;const I=new XMLSerializer().serializeToString(C),R="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(I))),D=Xr(new Date(e.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),B=e.start_time?`${_(e.start_time)}${e.end_time?" – "+_(e.end_time):""}`:"",$=[e.city,e.state].filter(Boolean).join(", "),q=e.agent_greeting||"Welcome! Please sign in below.",W=window.open("","_blank");W&&(W.document.write(` Open House – ${e.property_address}
Open House
${e.property_address}
${$?`
${$}${e.zip?" "+e.zip:""}
`:""}
Date
${D}
${B?`
Time
${B}
`:""}
${q}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),W.document.close(),setTimeout(()=>{W.focus(),W.print()},500))},[e,v]),T=async()=>{p(!0);try{const{error:C}=await Y.functions.invoke("guestbook-email-link",{body:{openHouseId:e.id}});if(C)throw C;ta({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(C){ta({title:"Failed to send",description:C.message,variant:"destructive"})}finally{p(!1)}};return r.jsxs(ze,{className:`transition-all ${e.is_active?"border-primary/30":"opacity-75"}`,children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(Zt,{className:"text-base truncate",children:e.property_address}),r.jsx(_t,{variant:e.is_active?"default":"secondary",className:"shrink-0",children:e.is_active?"Active":"Inactive"})]}),r.jsxs(Cs,{className:"flex flex-wrap items-center gap-3 text-xs",children:[e.city&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Yi,{className:"h-3 w-3"}),e.city,e.state?`, ${e.state}`:""]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(e.event_date+"T00:00:00"),"MMM d, yyyy")]}),e.start_time&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),_(e.start_time),e.end_time?` - ${_(e.end_time)}`:""]}),r.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[r.jsx(ws,{className:"h-3 w-3"}),e.visitor_count," visitors"]})]})]}),r.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[r.jsx(X,{variant:"ghost",size:"icon",onClick:n,title:"Copy link",children:r.jsx(uo,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>d(!0),title:"QR Code",children:r.jsx(Sk,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:()=>window.open(v,"_blank"),title:"Preview",children:r.jsx(jn,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:a,title:e.is_active?"Deactivate":"Activate",children:e.is_active?r.jsx(Lf,{className:"h-4 w-4"}):r.jsx(Ii,{className:"h-4 w-4"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:o,title:"Delete",children:r.jsx(Os,{className:"h-4 w-4 text-destructive"})}),r.jsx(X,{variant:"ghost",size:"icon",onClick:s,children:t?r.jsx(cx,{className:"h-4 w-4"}):r.jsx(ad,{className:"h-4 w-4"})})]})]})}),t&&r.jsxs(qe,{className:"pt-0",children:[r.jsx(kd,{className:"mb-4"}),r.jsxs("div",{className:"mb-3",children:[r.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Share Link"}),r.jsxs("code",{className:"text-xs bg-muted/50 px-2 py-1 rounded block truncate",children:["https://",iye,"/",e.slug]})]}),l!=null&&l.length?r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-xs font-medium text-muted-foreground",children:[l.length," Visitor",l.length!==1?"s":""]}),r.jsxs(X,{variant:"outline",size:"sm",onClick:k,className:"h-7 text-xs gap-1",children:[r.jsx(Fi,{className:"h-3 w-3"}),"Export CSV"]})]}),r.jsx("div",{className:"rounded-lg border overflow-hidden",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"bg-muted/30 text-xs text-muted-foreground",children:[r.jsx("th",{className:"text-left p-2 font-medium",children:"Name"}),r.jsx("th",{className:"text-left p-2 font-medium hidden sm:table-cell",children:"Contact"}),r.jsx("th",{className:"text-left p-2 font-medium hidden md:table-cell",children:"Intent"}),r.jsx("th",{className:"text-left p-2 font-medium",children:"Time"})]})}),r.jsx("tbody",{children:l.map(C=>r.jsxs("tr",{className:"border-t border-border/50",children:[r.jsxs("td",{className:"p-2 font-medium",children:[C.first_name,C.last_name?` ${C.last_name}`:""]}),r.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[C.email&&r.jsx("div",{className:"truncate max-w-[180px]",children:C.email}),C.phone&&r.jsx("div",{className:"text-xs",children:C.phone})]}),r.jsx("td",{className:"p-2 hidden md:table-cell",children:C.visitor_intent&&r.jsx(_t,{variant:"outline",className:"text-xs capitalize",children:C.visitor_intent})}),r.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:Xr(new Date(C.created_at),"h:mm a")})]},C.id))})]})})]}):r.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No visitors yet. Share the link to start collecting sign-ins!"})]}),r.jsx(Ir,{open:i,onOpenChange:d,children:r.jsxs(Er,{className:"sm:max-w-sm",children:[r.jsxs(zr,{children:[r.jsx(Fr,{children:"QR Code"}),r.jsx(Zs,{className:"truncate",children:e.property_address})]}),r.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[r.jsx("div",{ref:g,className:"bg-white p-4 rounded-xl",children:r.jsx($be,{value:v,size:240,level:"H"})}),r.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:v}),r.jsxs("div",{className:"flex gap-2 w-full",children:[r.jsxs(X,{variant:"outline",className:"flex-1",onClick:w,children:[r.jsx(Fi,{className:"h-4 w-4 mr-2"}),"Download"]}),r.jsxs(X,{variant:"outline",className:"flex-1",onClick:S,children:[r.jsx(TE,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),r.jsxs(X,{variant:"default",className:"w-full",onClick:T,disabled:m,children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),m?"Sending...":"Email Link to Me"]})]})]})})]})}const klr=i_({first_name:zo().trim().min(1,"First name is required").max(50),last_name:zo().trim().max(50).optional(),email:zo().trim().email("Please enter a valid email").max(255).optional().or(R5("")),phone:zo().trim().max(20).optional().or(R5(""))}),Nlr=[{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 Slr(){var R;const{slug:e}=Bl(),{data:t,isLoading:s,error:n}=d7e(e),a=u7e(),[o,l]=A.useState("welcome"),[i,d]=A.useState({first_name:"",last_name:"",email:"",phone:""}),[m,p]=A.useState(""),[g,v]=A.useState(!1),[_,k]=A.useState(""),w=D=>{if(!D)return"";const[B,$]=D.split(":"),q=parseInt(B),W=q>=12?"PM":"AM";return`${q>12?q-12:q||12}:${$} ${W}`},S=()=>{k("");const D=klr.safeParse(i);if(!D.success){k(D.error.issues[0].message);return}if(!i.email&&!i.phone){k("Please provide either an email or phone number");return}l("intent")},T=async D=>{p(D);try{await a.mutateAsync({open_house_id:t.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:D,wants_market_updates:g}),l("done")}catch{k("Something went wrong. Please try again.")}};if(s)return r.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:r.jsx("div",{className:"w-10 h-10 border-4 border-white/20 border-t-white rounded-full animate-spin"})});if(n||!t)return r.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:r.jsxs("div",{className:"text-center text-white",children:[r.jsx(Vn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Open House Not Found"}),r.jsx("p",{className:"text-white/60",children:"This sign-in page doesn't exist or is no longer active."})]})});const C=t.profiles,I=((R=C==null?void 0:C.name)==null?void 0:R.split(" ").map(D=>D[0]).join("").slice(0,2))||"?";return r.jsxs(r.Fragment,{children:[r.jsxs(nm,{children:[r.jsxs("title",{children:["Open House | ",t.property_address]}),r.jsx("meta",{name:"description",content:`Sign in to the open house at ${t.property_address}`}),r.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),r.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:r.jsxs("div",{className:"w-full max-w-md",children:[r.jsxs("div",{className:"text-center mb-6",children:[r.jsxs(cn,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[r.jsx(xa,{src:(C==null?void 0:C.avatar_url)||"",alt:(C==null?void 0:C.name)||""}),r.jsx(dn,{className:"bg-white/10 text-white text-lg",children:I})]}),r.jsx("p",{className:"text-white/60 text-sm",children:C==null?void 0:C.name}),(C==null?void 0:C.title)&&r.jsx("p",{className:"text-white/40 text-xs",children:C.title})]}),r.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl overflow-hidden",children:[t.photo_url&&r.jsxs("div",{className:"relative h-44 sm:h-52 overflow-hidden",children:[r.jsx("img",{src:t.photo_url,alt:t.property_address,className:"w-full h-full object-cover"}),r.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-slate-900/80 via-slate-900/20 to-transparent"}),r.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-6 pb-4",children:[r.jsx("h1",{className:"text-white font-bold text-lg leading-tight drop-shadow-md",children:t.property_address}),r.jsxs("div",{className:"flex flex-wrap gap-3 mt-1.5 text-white/70 text-xs",children:[t.city&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Yi,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""," ",t.zip]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` – ${w(t.end_time)}`:""]})]})]})]}),!t.photo_url&&r.jsx("div",{className:"bg-gradient-to-r from-slate-800 to-slate-700 px-6 py-5",children:r.jsxs("div",{className:"flex items-start gap-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-xl bg-white/10 flex items-center justify-center shrink-0 mt-0.5",children:r.jsx(Vn,{className:"h-5 w-5 text-white"})}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-white font-bold text-lg leading-tight",children:t.property_address}),r.jsxs("div",{className:"flex flex-wrap gap-3 mt-2 text-white/60 text-xs",children:[t.city&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Yi,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""," ",t.zip]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(An,{className:"h-3 w-3"}),Xr(new Date(t.event_date+"T00:00:00"),"MMM d, yyyy")]}),t.start_time&&r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Pa,{className:"h-3 w-3"}),w(t.start_time),t.end_time?` – ${w(t.end_time)}`:""]})]})]})]})}),r.jsxs("div",{className:"p-6",children:[o==="welcome"&&r.jsxs("div",{className:"text-center space-y-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Welcome!"}),r.jsx("p",{className:"text-slate-500 text-sm",children:t.agent_greeting||"Please sign in below."})]}),r.jsxs(X,{onClick:()=>l("info"),className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Sign In ",r.jsx(Ki,{className:"h-5 w-5 ml-2"})]}),r.jsx("p",{className:"text-xs text-slate-400",children:"Quick & easy — takes 30 seconds"})]}),o==="info"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("button",{onClick:()=>l("welcome"),className:"text-slate-400 hover:text-slate-600",children:r.jsx(gi,{className:"h-4 w-4"})}),r.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"Your Info"})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"First Name *"}),r.jsx(Ye,{value:i.first_name,onChange:D=>d(B=>({...B,first_name:D.target.value})),placeholder:"First",className:"mt-1 h-12 rounded-xl border-slate-200 text-base",autoFocus:!0})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"Last Name"}),r.jsx(Ye,{value:i.last_name,onChange:D=>d(B=>({...B,last_name:D.target.value})),placeholder:"Last",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"Email"}),r.jsx(Ye,{type:"email",value:i.email,onChange:D=>d(B=>({...B,email:D.target.value})),placeholder:"your@email.com",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),r.jsxs("div",{children:[r.jsx(Ee,{className:"text-slate-600 text-xs",children:"Phone"}),r.jsx(Ye,{type:"tel",value:i.phone,onChange:D=>d(B=>({...B,phone:D.target.value})),placeholder:"(555) 123-4567",className:"mt-1 h-12 rounded-xl border-slate-200 text-base"})]}),r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer pt-1",children:[r.jsx("input",{type:"checkbox",checked:g,onChange:D=>v(D.target.checked),className:"rounded border-slate-300 text-slate-900 focus:ring-slate-500"}),r.jsx("span",{className:"text-sm text-slate-600",children:"Send me market updates for this area"})]}),_&&r.jsx("p",{className:"text-destructive text-sm",children:_}),r.jsxs(X,{onClick:S,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",r.jsx(Ki,{className:"h-5 w-5 ml-2"})]})]}),o==="intent"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx("button",{onClick:()=>l("info"),className:"text-slate-400 hover:text-slate-600",children:r.jsx(gi,{className:"h-4 w-4"})}),r.jsx("h2",{className:"text-lg font-bold text-slate-900",children:"What brings you here?"})]}),r.jsx("div",{className:"grid grid-cols-2 gap-3",children:Nlr.map(D=>r.jsxs("button",{onClick:()=>T(D.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:[r.jsx("span",{className:"text-2xl",children:D.emoji}),r.jsx("span",{className:"text-sm font-medium text-slate-700 group-hover:text-slate-900",children:D.label})]},D.value))}),_&&r.jsx("p",{className:"text-destructive text-sm text-center",children:_})]}),o==="done"&&r.jsxs("div",{className:"text-center space-y-4 py-4",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-green-100 flex items-center justify-center mx-auto",children:r.jsx(Ri,{className:"h-8 w-8 text-green-600"})}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"You're all set!"}),r.jsxs("p",{className:"text-slate-500 text-sm mt-1",children:["Thanks for signing in, ",i.first_name,". Enjoy the open house!"]})]}),(C==null?void 0:C.name)&&r.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",r.jsx("strong",{className:"text-slate-600",children:C.name})]})]})]})]}),r.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function Clr(){const{slug:e}=Bl();return e?r.jsx(D7e,{slug:e}):r.jsx("div",{className:"min-h-screen bg-gradient-to-b from-slate-50 to-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Portal Not Found"}),r.jsx("p",{className:"text-slate-500",children:"No portal slug was provided."})]})})}function Mlr({contactId:e,onVideoReady:t}){const[s,n]=A.useState(!1),[a,o]=A.useState("record"),[l,i]=A.useState(0),[d,m]=A.useState(0),p=q3(),g=()=>{o("record"),i(0),m(0)},v=k=>{!k&&(a==="uploading"||a==="processing")||(n(k),k||g())},_=A.useCallback(async(k,w)=>{o("uploading");try{const S="Card Video",{videoId:T,libraryId:C}=await boe(S),{uploadUrl:I,apiKey:R}=await woe(T),D=new XMLHttpRequest;D.upload.onprogress=ae=>{ae.lengthComputable&&i(ae.loaded/ae.total*100)},await new Promise((ae,oe)=>{D.onload=()=>D.status>=200&&D.status<300?ae():oe(new Error("Upload failed")),D.onerror=()=>oe(new Error("Upload failed")),D.open("PUT",I),D.setRequestHeader("AccessKey",R),D.send(k)}),o("processing");let B=0;const $=Date.now(),q=9e4,W=`https://iframe.mediadelivery.net/embed/${C}/${T}`;for(;B<4;){if(await new Promise(oe=>setTimeout(oe,3e3)),Date.now()-$>q){const oe=k.size/1048576;await p.mutateAsync({bunny_video_id:T,playback_url:`https://iframe.mediadelivery.net/play/${C}/${T}`,file_size_mb:oe,title:S,contact_id:e||void 0,status:"processing",touch_type:"video"}),t(W),we.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),g()},1500);return}const ae=await jne(T);if(B=ae.status,m(ae.encodeProgress||0),B===5||B===6)throw new Error("Video processing failed")}const K=await jne(T),re=(K.storageSize||k.size)/(1024*1024);await p.mutateAsync({bunny_video_id:T,contact_id:e||void 0,playback_url:K.directPlayUrl||W,thumbnail_url:K.thumbnailUrl,preview_url:K.previewUrl||null,duration_seconds:K.length||w,file_size_mb:re,title:S,status:"ready",touch_type:"video"}),t(W),we.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),g()},1500)}catch(S){console.error("Recording upload error:",S),we.error("Failed to process video. Please try again."),o("record")}},[e,t,p]);return r.jsxs(Ir,{open:s,onOpenChange:v,children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{variant:"outline",size:"sm",className:"gap-1.5 w-full",children:[r.jsx(ma,{className:"h-3.5 w-3.5"}),"Record Video"]})}),r.jsxs(Er,{className:"sm:max-w-2xl max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Record a Video for Your Card"})}),a==="record"&&r.jsx(zbe,{maxDurationSeconds:60,onRecordingComplete:_,onError:k=>we.error(k)}),a==="uploading"&&r.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[r.jsx($r,{className:"h-10 w-10 animate-spin text-primary"}),r.jsx("p",{className:"text-sm font-medium",children:"Uploading video..."}),r.jsx(zl,{value:l,className:"w-64"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(l),"%"]})]}),a==="processing"&&r.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[r.jsx($r,{className:"h-10 w-10 animate-spin text-primary"}),r.jsx("p",{className:"text-sm font-medium",children:"Processing video..."}),r.jsx(zl,{value:d,className:"w-64"}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(d),"%"]})]}),a==="done"&&r.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[r.jsx(ui,{className:"h-12 w-12 text-emerald-500"}),r.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function RZe({photoUrl:e,videoUrl:t,onPhotoChange:s,onVideoChange:n,contactId:a}){const{user:o}=Gr(),l=q3(),i=A.useRef(null),d=A.useRef(null),[m,p]=A.useState(!1),[g,v]=A.useState(!1),[_,k]=A.useState(0),w=async T=>{if(o){p(!0);try{const C=T.name.split(".").pop()||"jpg",I=`${o.id}/card-${Date.now()}.${C}`,{error:R}=await Y.storage.from("listing-photos").upload(I,T);if(R)throw R;const{data:{publicUrl:D}}=Y.storage.from("listing-photos").getPublicUrl(I);s(D),we.success("Photo uploaded")}catch(C){we.error(C.message||"Failed to upload photo")}finally{p(!1)}}},S=async T=>{if(o){if(T.size>500*1024*1024){we.error("Video must be under 500MB");return}v(!0),k(0);try{const{videoId:C,libraryId:I}=await boe(`Card Video - ${Date.now()}`),{uploadUrl:R,apiKey:D}=await woe(C);await new Promise((q,W)=>{const K=new XMLHttpRequest;K.upload.addEventListener("progress",re=>{re.lengthComputable&&k(Math.round(re.loaded/re.total*100))}),K.addEventListener("load",()=>{K.status>=200&&K.status<300?q():W(new Error("Upload failed"))}),K.addEventListener("error",()=>W(new Error("Upload failed"))),K.open("PUT",R),K.setRequestHeader("AccessKey",D),K.send(T)});const B=`https://iframe.mediadelivery.net/embed/${I}/${C}`;n(B);const $=parseFloat((T.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:C,playback_url:`https://iframe.mediadelivery.net/play/${I}/${C}`,file_size_mb:$,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),we.success("Video uploaded & added to your library")}catch(C){we.error(C.message||"Failed to upload video")}finally{v(!1),k(0)}}};return r.jsxs("div",{className:"space-y-3",children:[r.jsx(Ee,{children:"Media (optional)"}),r.jsxs(ii,{defaultValue:"photo",className:"w-full",children:[r.jsxs(si,{className:"grid w-full grid-cols-2",children:[r.jsxs(Kr,{value:"photo",className:"gap-1.5 text-xs",children:[r.jsx(Nl,{className:"h-3.5 w-3.5"}),"Photo"]}),r.jsxs(Kr,{value:"video",className:"gap-1.5 text-xs",children:[r.jsx(ma,{className:"h-3.5 w-3.5"}),"Video"]})]}),r.jsxs(hs,{value:"photo",className:"mt-3",children:[e?r.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[r.jsx("img",{src:e,alt:"Card photo",className:"w-full h-40 object-cover"}),r.jsx(X,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>s(null),children:r.jsx(Xs,{className:"h-3.5 w-3.5"})})]}):r.jsx("button",{onClick:()=>{var T;return(T=i.current)==null?void 0:T.click()},disabled:m,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:m?r.jsx($r,{className:"h-6 w-6 animate-spin"}):r.jsxs(r.Fragment,{children:[r.jsx(ng,{className:"h-6 w-6"}),r.jsx("span",{className:"text-xs",children:"Upload a photo"})]})}),r.jsx("input",{ref:i,type:"file",accept:"image/*",className:"hidden",onChange:T=>{var I;const C=(I=T.target.files)==null?void 0:I[0];C&&w(C),T.target.value=""}})]}),r.jsxs(hs,{value:"video",className:"mt-3",children:[t?r.jsxs("div",{className:"relative rounded-lg overflow-hidden border border-border",children:[r.jsx("iframe",{src:`${t}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0}),r.jsx(X,{variant:"destructive",size:"icon",className:"absolute top-2 right-2 h-7 w-7",onClick:()=>n(null),children:r.jsx(Xs,{className:"h-3.5 w-3.5"})})]}):r.jsx("button",{onClick:()=>{var T;return(T=d.current)==null?void 0:T.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?r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx($r,{className:"h-6 w-6 animate-spin"}),r.jsxs("span",{className:"text-xs",children:["Uploading... ",_,"%"]}),r.jsx("div",{className:"w-32 h-1.5 bg-muted rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${_}%`}})})]}):r.jsxs(r.Fragment,{children:[r.jsx(Xi,{className:"h-6 w-6"}),r.jsx("span",{className:"text-xs",children:"Upload a video (max 500MB)"})]})}),!t&&!g&&r.jsx("div",{className:"mt-2",children:r.jsx(Mlr,{contactId:a,onVideoReady:T=>n(T)})}),r.jsx("input",{ref:d,type:"file",accept:"video/*",className:"hidden",onChange:T=>{var I;const C=(I=T.target.files)==null?void 0:I[0];C&&S(C),T.target.value=""}}),r.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-1.5 text-center",children:"Videos are also saved to your Video Library"})]})]})]})}const FZe=A.createContext({});function Tlr(e){const t=A.useRef(null);return t.current===null&&(t.current=e()),t.current}const Alr=typeof window<"u",Elr=Alr?A.useLayoutEffect:A.useEffect,qbe=A.createContext(null);function Hbe(e,t){e.indexOf(t)===-1&&e.push(t)}function jae(e,t){const s=e.indexOf(t);s>-1&&e.splice(s,1)}const Ax=(e,t,s)=>s>t?t:s{};const p0={},zZe=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function BZe(e){return typeof e=="object"&&e!==null}const $Ze=e=>/^0[^.\s]+$/u.test(e);function UZe(e){let t;return()=>(t===void 0&&(t=e()),t)}const Hf=e=>e,Ilr=(e,t)=>s=>t(e(s)),X6=(...e)=>e.reduce(Ilr),QP=(e,t,s)=>{const n=t-e;return n===0?1:(s-e)/n};class Gbe{constructor(){this.subscriptions=[]}add(t){return Hbe(this.subscriptions,t),()=>jae(this.subscriptions,t)}notify(t,s,n){const a=this.subscriptions.length;if(a)if(a===1)this.subscriptions[0](t,s,n);else for(let o=0;oe*1e3,Ef=e=>e/1e3;function VZe(e,t){return t?e*(1e3/t):0}const qZe=(e,t,s)=>(((1-3*s+3*t)*e+(3*s-6*t))*e+3*t)*e,Plr=1e-7,Llr=12;function Dlr(e,t,s,n,a){let o,l,i=0;do l=t+(s-t)/2,o=qZe(l,n,a)-e,o>0?s=l:t=l;while(Math.abs(o)>Plr&&++iDlr(o,0,1,e,s);return o=>o===0||o===1?o:qZe(a(o),t,n)}const HZe=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,WZe=e=>t=>1-e(1-t),GZe=Q6(.33,1.53,.69,.99),Kbe=WZe(GZe),KZe=HZe(Kbe),ZZe=e=>(e*=2)<1?.5*Kbe(e):.5*(2-Math.pow(2,-10*(e-1))),Zbe=e=>1-Math.sin(Math.acos(e)),YZe=WZe(Zbe),XZe=HZe(Zbe),Olr=Q6(.42,0,1,1),Rlr=Q6(0,0,.58,1),QZe=Q6(.42,0,.58,1),Flr=e=>Array.isArray(e)&&typeof e[0]!="number",JZe=e=>Array.isArray(e)&&typeof e[0]=="number",zlr={linear:Hf,easeIn:Olr,easeInOut:QZe,easeOut:Rlr,circIn:Zbe,circInOut:XZe,circOut:YZe,backIn:Kbe,backInOut:KZe,backOut:GZe,anticipate:ZZe},Blr=e=>typeof e=="string",qIe=e=>{if(JZe(e)){Wbe(e.length===4);const[t,s,n,a]=e;return Q6(t,s,n,a)}else if(Blr(e))return zlr[e];return e},p8=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function $lr(e,t){let s=new Set,n=new Set,a=!1,o=!1;const l=new WeakSet;let i={delta:0,timestamp:0,isProcessing:!1};function d(p){l.has(p)&&(m.schedule(p),e()),p(i)}const m={schedule:(p,g=!1,v=!1)=>{const k=v&&a?s:n;return g&&l.add(p),k.has(p)||k.add(p),p},cancel:p=>{n.delete(p),l.delete(p)},process:p=>{if(i=p,a){o=!0;return}a=!0,[s,n]=[n,s],s.forEach(d),s.clear(),a=!1,o&&(o=!1,m.process(p))}};return m}const Ulr=40;function eYe(e,t){let s=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>s=!0,l=p8.reduce((I,R)=>(I[R]=$lr(o),I),{}),{setup:i,read:d,resolveKeyframes:m,preUpdate:p,update:g,preRender:v,render:_,postRender:k}=l,w=()=>{const I=p0.useManualTiming?a.timestamp:performance.now();s=!1,p0.useManualTiming||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,Ulr),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),d.process(a),m.process(a),p.process(a),g.process(a),v.process(a),_.process(a),k.process(a),a.isProcessing=!1,s&&t&&(n=!1,e(w))},S=()=>{s=!0,n=!0,a.isProcessing||e(w)};return{schedule:p8.reduce((I,R)=>{const D=l[R];return I[R]=(B,$=!1,q=!1)=>(s||S(),D.schedule(B,$,q)),I},{}),cancel:I=>{for(let R=0;R(yre===void 0&&gh.set(cu.isProcessing||p0.useManualTiming?cu.timestamp:performance.now()),yre),set:e=>{yre=e,queueMicrotask(Vlr)}},tYe=e=>t=>typeof t=="string"&&t.startsWith(e),rYe=tYe("--"),qlr=tYe("var(--"),Ybe=e=>qlr(e)?Hlr.test(e.split("/*")[0].trim()):!1,Hlr=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function HIe(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const nM={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},JP={...nM,transform:e=>Ax(0,1,e)},g8={...nM,default:1},xI=e=>Math.round(e*1e5)/1e5,Xbe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Wlr(e){return e==null}const Glr=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Qbe=(e,t)=>s=>!!(typeof s=="string"&&Glr.test(s)&&s.startsWith(e)||t&&!Wlr(s)&&Object.prototype.hasOwnProperty.call(s,t)),sYe=(e,t,s)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(Xbe);return{[e]:parseFloat(a),[t]:parseFloat(o),[s]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},Klr=e=>Ax(0,255,e),nme={...nM,transform:e=>Math.round(Klr(e))},Jj={test:Qbe("rgb","red"),parse:sYe("red","green","blue"),transform:({red:e,green:t,blue:s,alpha:n=1})=>"rgba("+nme.transform(e)+", "+nme.transform(t)+", "+nme.transform(s)+", "+xI(JP.transform(n))+")"};function Zlr(e){let t="",s="",n="",a="";return e.length>5?(t=e.substring(1,3),s=e.substring(3,5),n=e.substring(5,7),a=e.substring(7,9)):(t=e.substring(1,2),s=e.substring(2,3),n=e.substring(3,4),a=e.substring(4,5),t+=t,s+=s,n+=n,a+=a),{red:parseInt(t,16),green:parseInt(s,16),blue:parseInt(n,16),alpha:a?parseInt(a,16)/255:1}}const oye={test:Qbe("#"),parse:Zlr,transform:Jj.transform},J6=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),yv=J6("deg"),bx=J6("%"),$n=J6("px"),Ylr=J6("vh"),Xlr=J6("vw"),WIe={...bx,parse:e=>bx.parse(e)/100,transform:e=>bx.transform(e*100)},i4={test:Qbe("hsl","hue"),parse:sYe("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:s,alpha:n=1})=>"hsla("+Math.round(e)+", "+bx.transform(xI(t))+", "+bx.transform(xI(s))+", "+xI(JP.transform(n))+")"},rd={test:e=>Jj.test(e)||oye.test(e)||i4.test(e),parse:e=>Jj.test(e)?Jj.parse(e):i4.test(e)?i4.parse(e):oye.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Jj.transform(e):i4.transform(e),getAnimatableNone:e=>{const t=rd.parse(e);return t.alpha=0,rd.transform(t)}},Qlr=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Jlr(e){var t,s;return isNaN(e)&&typeof e=="string"&&(((t=e.match(Xbe))==null?void 0:t.length)||0)+(((s=e.match(Qlr))==null?void 0:s.length)||0)>0}const nYe="number",aYe="color",ecr="var",tcr="var(",GIe="${}",rcr=/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 e6(e){const t=e.toString(),s=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=t.replace(rcr,d=>(rd.test(d)?(n.color.push(o),a.push(aYe),s.push(rd.parse(d))):d.startsWith(tcr)?(n.var.push(o),a.push(ecr),s.push(d)):(n.number.push(o),a.push(nYe),s.push(parseFloat(d))),++o,GIe)).split(GIe);return{values:s,split:i,indexes:n,types:a}}function iYe(e){return e6(e).values}function oYe(e){const{split:t,types:s}=e6(e),n=t.length;return a=>{let o="";for(let l=0;ltypeof e=="number"?0:rd.test(e)?rd.getAnimatableNone(e):e;function ncr(e){const t=iYe(e);return oYe(e)(t.map(scr))}const cg={test:Jlr,parse:iYe,createTransformer:oYe,getAnimatableNone:ncr};function ame(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+(t-e)*6*s:s<1/2?t:s<2/3?e+(t-e)*(2/3-s)*6:e}function acr({hue:e,saturation:t,lightness:s,alpha:n}){e/=360,t/=100,s/=100;let a=0,o=0,l=0;if(!t)a=o=l=s;else{const i=s<.5?s*(1+t):s+t-s*t,d=2*s-i;a=ame(d,i,e+1/3),o=ame(d,i,e),l=ame(d,i,e-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function kae(e,t){return s=>s>0?t:e}const Zl=(e,t,s)=>e+(t-e)*s,ime=(e,t,s)=>{const n=e*e,a=s*(t*t-n)+n;return a<0?0:Math.sqrt(a)},icr=[oye,Jj,i4],ocr=e=>icr.find(t=>t.test(e));function KIe(e){const t=ocr(e);if(!t)return!1;let s=t.parse(e);return t===i4&&(s=acr(s)),s}const ZIe=(e,t)=>{const s=KIe(e),n=KIe(t);if(!s||!n)return kae(e,t);const a={...s};return o=>(a.red=ime(s.red,n.red,o),a.green=ime(s.green,n.green,o),a.blue=ime(s.blue,n.blue,o),a.alpha=Zl(s.alpha,n.alpha,o),Jj.transform(a))},lye=new Set(["none","hidden"]);function lcr(e,t){return lye.has(e)?s=>s<=0?e:t:s=>s>=1?t:e}function ccr(e,t){return s=>Zl(e,t,s)}function Jbe(e){return typeof e=="number"?ccr:typeof e=="string"?Ybe(e)?kae:rd.test(e)?ZIe:hcr:Array.isArray(e)?lYe:typeof e=="object"?rd.test(e)?ZIe:dcr:kae}function lYe(e,t){const s=[...e],n=s.length,a=e.map((o,l)=>Jbe(o)(o,t[l]));return o=>{for(let l=0;l{for(const o in n)s[o]=n[o](a);return s}}function ucr(e,t){const s=[],n={color:0,var:0,number:0};for(let a=0;a{const s=cg.createTransformer(t),n=e6(e),a=e6(t);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?lye.has(e)&&!a.values.length||lye.has(t)&&!n.values.length?lcr(e,t):X6(lYe(ucr(n,a),a.values),s):kae(e,t)};function cYe(e,t,s){return typeof e=="number"&&typeof t=="number"&&typeof s=="number"?Zl(e,t,s):Jbe(e)(e,t)}const mcr=e=>{const t=({timestamp:s})=>e(s);return{start:(s=!0)=>hl.update(t,s),stop:()=>Z1(t),now:()=>cu.isProcessing?cu.timestamp:gh.now()}},dYe=(e,t,s=10)=>{let n="";const a=Math.max(Math.round(t/s),2);for(let o=0;o=Nae?1/0:t}function fcr(e,t=100,s){const n=s({...e,keyframes:[0,t]}),a=Math.min(ewe(n),Nae);return{type:"keyframes",ease:o=>n.next(a*o).value/t,duration:Ef(a)}}const pcr=5;function uYe(e,t,s){const n=Math.max(t-pcr,0);return VZe(s-e(n),t-n)}const lc={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},ome=.001;function gcr({duration:e=lc.duration,bounce:t=lc.bounce,velocity:s=lc.velocity,mass:n=lc.mass}){let a,o,l=1-t;l=Ax(lc.minDamping,lc.maxDamping,l),e=Ax(lc.minDuration,lc.maxDuration,Ef(e)),l<1?(a=m=>{const p=m*l,g=p*e,v=p-s,_=cye(m,l),k=Math.exp(-g);return ome-v/_*k},o=m=>{const g=m*l*e,v=g*s+s,_=Math.pow(l,2)*Math.pow(m,2)*e,k=Math.exp(-g),w=cye(Math.pow(m,2),l);return(-a(m)+ome>0?-1:1)*((v-_)*k)/w}):(a=m=>{const p=Math.exp(-m*e),g=(m-s)*e+1;return-ome+p*g},o=m=>{const p=Math.exp(-m*e),g=(s-m)*(e*e);return p*g});const i=5/e,d=ycr(a,o,i);if(e=lg(e),isNaN(d))return{stiffness:lc.stiffness,damping:lc.damping,duration:e};{const m=Math.pow(d,2)*n;return{stiffness:m,damping:l*2*Math.sqrt(n*m),duration:e}}}const xcr=12;function ycr(e,t,s){let n=s;for(let a=1;ae[s]!==void 0)}function bcr(e){let t={velocity:lc.velocity,stiffness:lc.stiffness,damping:lc.damping,mass:lc.mass,isResolvedFromDuration:!1,...e};if(!YIe(e,_cr)&&YIe(e,vcr))if(t.velocity=0,e.visualDuration){const s=e.visualDuration,n=2*Math.PI/(s*1.2),a=n*n,o=2*Ax(.05,1,1-(e.bounce||0))*Math.sqrt(a);t={...t,mass:lc.mass,stiffness:a,damping:o}}else{const s=gcr({...e,velocity:0});t={...t,...s,mass:lc.mass},t.isResolvedFromDuration=!0}return t}function Sae(e=lc.visualDuration,t=lc.bounce){const s=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:n,restDelta:a}=s;const o=s.keyframes[0],l=s.keyframes[s.keyframes.length-1],i={done:!1,value:o},{stiffness:d,damping:m,mass:p,duration:g,velocity:v,isResolvedFromDuration:_}=bcr({...s,velocity:-Ef(s.velocity||0)}),k=v||0,w=m/(2*Math.sqrt(d*p)),S=l-o,T=Ef(Math.sqrt(d/p)),C=Math.abs(S)<5;n||(n=C?lc.restSpeed.granular:lc.restSpeed.default),a||(a=C?lc.restDelta.granular:lc.restDelta.default);let I;if(w<1){const D=cye(T,w);I=B=>{const $=Math.exp(-w*T*B);return l-$*((k+w*T*S)/D*Math.sin(D*B)+S*Math.cos(D*B))}}else if(w===1)I=D=>l-Math.exp(-T*D)*(S+(k+T*S)*D);else{const D=T*Math.sqrt(w*w-1);I=B=>{const $=Math.exp(-w*T*B),q=Math.min(D*B,300);return l-$*((k+w*T*S)*Math.sinh(q)+D*S*Math.cosh(q))/D}}const R={calculatedDuration:_&&g||null,next:D=>{const B=I(D);if(_)i.done=D>=g;else{let $=D===0?k:0;w<1&&($=D===0?lg(k):uYe(I,D,B));const q=Math.abs($)<=n,W=Math.abs(l-B)<=a;i.done=q&&W}return i.value=i.done?l:B,i},toString:()=>{const D=Math.min(ewe(R),Nae),B=dYe($=>R.next(D*$).value,D,30);return D+"ms "+B},toTransition:()=>{}};return R}Sae.applyToOptions=e=>{const t=fcr(e,100,Sae);return e.ease=t.ease,e.duration=lg(t.duration),e.type="keyframes",e};function dye({keyframes:e,velocity:t=0,power:s=.8,timeConstant:n=325,bounceDamping:a=10,bounceStiffness:o=500,modifyTarget:l,min:i,max:d,restDelta:m=.5,restSpeed:p}){const g=e[0],v={done:!1,value:g},_=q=>i!==void 0&&qd,k=q=>i===void 0?d:d===void 0||Math.abs(i-q)-w*Math.exp(-q/n),I=q=>T+C(q),R=q=>{const W=C(q),K=I(q);v.done=Math.abs(W)<=m,v.value=v.done?T:K};let D,B;const $=q=>{_(v.value)&&(D=q,B=Sae({keyframes:[v.value,k(v.value)],velocity:uYe(I,q,v.value),damping:a,stiffness:o,restDelta:m,restSpeed:p}))};return $(0),{calculatedDuration:null,next:q=>{let W=!1;return!B&&D===void 0&&(W=!0,R(q),$(q)),D!==void 0&&q>=D?B.next(q-D):(!W&&R(q),v)}}}function wcr(e,t,s){const n=[],a=s||p0.mix||cYe,o=e.length-1;for(let l=0;lt[0];if(o===2&&t[0]===t[1])return()=>t[1];const l=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const i=wcr(t,n,a),d=i.length,m=p=>{if(l&&p1)for(;gm(Ax(e[0],e[o-1],p)):m}function kcr(e,t){const s=e[e.length-1];for(let n=1;n<=t;n++){const a=QP(0,t,n);e.push(Zl(s,1,a))}}function Ncr(e){const t=[0];return kcr(t,e.length-1),t}function Scr(e,t){return e.map(s=>s*t)}function Ccr(e,t){return e.map(()=>t||QZe).splice(0,e.length-1)}function yI({duration:e=300,keyframes:t,times:s,ease:n="easeInOut"}){const a=Flr(n)?n.map(qIe):qIe(n),o={done:!1,value:t[0]},l=Scr(s&&s.length===t.length?s:Ncr(t),e),i=jcr(l,t,{ease:Array.isArray(a)?a:Ccr(t,a)});return{calculatedDuration:e,next:d=>(o.value=i(d),o.done=d>=e,o)}}const Mcr=e=>e!==null;function twe(e,{repeat:t,repeatType:s="loop"},n,a=1){const o=e.filter(Mcr),i=a<0||t&&s!=="loop"&&t%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const Tcr={decay:dye,inertia:dye,tween:yI,keyframes:yI,spring:Sae};function hYe(e){typeof e.type=="string"&&(e.type=Tcr[e.type])}class rwe{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,s){return this.finished.then(t,s)}}const Acr=e=>e/100;class swe extends rwe{constructor(t){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:s}=this.options;s&&s.updatedAt!==gh.now()&&this.tick(gh.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(a=(n=this.options).onStop)==null||a.call(n))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;hYe(t);const{type:s=yI,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=t;let{keyframes:i}=t;const d=s||yI;d!==yI&&typeof i[0]!="number"&&(this.mixKeyframes=X6(Acr,cYe(i[0],i[1])),i=[0,100]);const m=d({...t,keyframes:i});o==="mirror"&&(this.mirroredGenerator=d({...t,keyframes:[...i].reverse(),velocity:-l})),m.calculatedDuration===null&&(m.calculatedDuration=ewe(m));const{calculatedDuration:p}=m;this.calculatedDuration=p,this.resolvedDuration=p+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=m}updateTime(t){const s=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=s}tick(t,s=!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:m=0,keyframes:p,repeat:g,repeatType:v,repeatDelay:_,type:k,onUpdate:w,finalKeyframe:S}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-a/this.speed,this.startTime)),s?this.currentTime=t:this.updateTime(t);const T=this.currentTime-m*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?T<0:T>a;this.currentTime=Math.max(T,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let I=this.currentTime,R=n;if(g){const q=Math.min(this.currentTime,a)/i;let W=Math.floor(q),K=q%1;!K&&q>=1&&(K=1),K===1&&W--,W=Math.min(W,g+1),!!(W%2)&&(v==="reverse"?(K=1-K,_&&(K-=_/i)):v==="mirror"&&(R=l)),I=Ax(0,1,K)*i}const D=C?{done:!1,value:p[0]}:R.next(I);o&&(D.value=o(D.value));let{done:B}=D;!C&&d!==null&&(B=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&B);return $&&k!==dye&&(D.value=twe(p,this.options,S,this.speed)),w&&w(D.value),$&&this.finish(),D}then(t,s){return this.finished.then(t,s)}get duration(){return Ef(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ef(t)}get time(){return Ef(this.currentTime)}set time(t){var s;t=lg(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),(s=this.driver)==null||s.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(gh.now());const s=this.playbackSpeed!==t;this.playbackSpeed=t,s&&(this.time=Ef(this.currentTime))}play(){var a,o;if(this.isStopped)return;const{driver:t=mcr,startTime:s}=this.options;this.driver||(this.driver=t(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=s??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(gh.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,s;this.notifyFinished(),this.teardown(),this.state="finished",(s=(t=this.options).onComplete)==null||s.call(t)}cancel(){var t,s;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(s=(t=this.options).onCancel)==null||s.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var s;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(s=this.driver)==null||s.stop(),t.observe(this)}}function Ecr(e){for(let t=1;te*180/Math.PI,uye=e=>{const t=ek(Math.atan2(e[1],e[0]));return hye(t)},Icr={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:uye,rotateZ:uye,skewX:e=>ek(Math.atan(e[1])),skewY:e=>ek(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},hye=e=>(e=e%360,e<0&&(e+=360),e),XIe=uye,QIe=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),JIe=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Pcr={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:QIe,scaleY:JIe,scale:e=>(QIe(e)+JIe(e))/2,rotateX:e=>hye(ek(Math.atan2(e[6],e[5]))),rotateY:e=>hye(ek(Math.atan2(-e[2],e[0]))),rotateZ:XIe,rotate:XIe,skewX:e=>ek(Math.atan(e[4])),skewY:e=>ek(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function mye(e){return e.includes("scale")?1:0}function fye(e,t){if(!e||e==="none")return mye(t);const s=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(s)n=Pcr,a=s;else{const i=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=Icr,a=i}if(!a)return mye(t);const o=n[t],l=a[1].split(",").map(Dcr);return typeof o=="function"?o(l):l[o]}const Lcr=(e,t)=>{const{transform:s="none"}=getComputedStyle(e);return fye(s,t)};function Dcr(e){return parseFloat(e.trim())}const aM=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],iM=new Set(aM),ePe=e=>e===nM||e===$n,Ocr=new Set(["x","y","z"]),Rcr=aM.filter(e=>!Ocr.has(e));function Fcr(e){const t=[];return Rcr.forEach(s=>{const n=e.getValue(s);n!==void 0&&(t.push([s,n.get()]),n.set(s.startsWith("scale")?1:0))}),t}const o1={width:({x:e},{paddingLeft:t="0",paddingRight:s="0"})=>e.max-e.min-parseFloat(t)-parseFloat(s),height:({y:e},{paddingTop:t="0",paddingBottom:s="0"})=>e.max-e.min-parseFloat(t)-parseFloat(s),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>fye(t,"x"),y:(e,{transform:t})=>fye(t,"y")};o1.translateX=o1.x;o1.translateY=o1.y;const $k=new Set;let pye=!1,gye=!1,xye=!1;function mYe(){if(gye){const e=Array.from($k).filter(n=>n.needsMeasurement),t=new Set(e.map(n=>n.element)),s=new Map;t.forEach(n=>{const a=Fcr(n);a.length&&(s.set(n,a),n.render())}),e.forEach(n=>n.measureInitialState()),t.forEach(n=>{n.render();const a=s.get(n);a&&a.forEach(([o,l])=>{var i;(i=n.getValue(o))==null||i.set(l)})}),e.forEach(n=>n.measureEndState()),e.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}gye=!1,pye=!1,$k.forEach(e=>e.complete(xye)),$k.clear()}function fYe(){$k.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(gye=!0)})}function zcr(){xye=!0,fYe(),mYe(),xye=!1}class nwe{constructor(t,s,n,a,o,l=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=s,this.name=n,this.motionValue=a,this.element=o,this.isAsync=l}scheduleResolve(){this.state="scheduled",this.isAsync?($k.add(this),pye||(pye=!0,hl.read(fYe),hl.resolveKeyframes(mYe))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:s,element:n,motionValue:a}=this;if(t[0]===null){const o=a==null?void 0:a.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(n&&s){const i=n.readValue(s,l);i!=null&&(t[0]=i)}t[0]===void 0&&(t[0]=l),a&&o===void 0&&a.set(t[0])}Ecr(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),$k.delete(this)}cancel(){this.state==="scheduled"&&($k.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Bcr=e=>e.startsWith("--");function $cr(e,t,s){Bcr(t)?e.style.setProperty(t,s):e.style[t]=s}const Ucr={};function pYe(e,t){const s=UZe(e);return()=>Ucr[t]??s()}const Vcr=pYe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),gYe=pYe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),QA=([e,t,s,n])=>`cubic-bezier(${e}, ${t}, ${s}, ${n})`,tPe={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:QA([0,.65,.55,1]),circOut:QA([.55,0,1,.45]),backIn:QA([.31,.01,.66,-.59]),backOut:QA([.33,1.53,.69,.99])};function xYe(e,t){if(e)return typeof e=="function"?gYe()?dYe(e,t):"ease-out":JZe(e)?QA(e):Array.isArray(e)?e.map(s=>xYe(s,t)||tPe.easeOut):tPe[e]}function qcr(e,t,s,{delay:n=0,duration:a=300,repeat:o=0,repeatType:l="loop",ease:i="easeOut",times:d}={},m=void 0){const p={[t]:s};d&&(p.offset=d);const g=xYe(i,a);Array.isArray(g)&&(p.easing=g);const v={delay:n,duration:a,easing:Array.isArray(g)?"linear":g,fill:"both",iterations:o+1,direction:l==="reverse"?"alternate":"normal"};return m&&(v.pseudoElement=m),e.animate(p,v)}function yYe(e){return typeof e=="function"&&"applyToOptions"in e}function Hcr({type:e,...t}){return yYe(e)&&gYe()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class vYe extends rwe{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:s,name:n,keyframes:a,pseudoElement:o,allowFlatten:l=!1,finalKeyframe:i,onComplete:d}=t;this.isPseudoElement=!!o,this.allowFlatten=l,this.options=t,Wbe(typeof t.type!="string");const m=Hcr(t);this.animation=qcr(s,n,a,m,o),m.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=twe(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),$cr(s,n,p),this.animation.cancel()}d==null||d(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,s;(s=(t=this.animation).finish)==null||s.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var s,n,a;const t=(s=this.options)==null?void 0:s.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((a=(n=this.animation).commitStyles)==null||a.call(n))}get duration(){var s,n;const t=((n=(s=this.animation.effect)==null?void 0:s.getComputedTiming)==null?void 0:n.call(s).duration)||0;return Ef(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+Ef(t)}get time(){return Ef(Number(this.animation.currentTime)||0)}set time(t){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=lg(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:s,rangeEnd:n,observe:a}){var o;return this.allowFlatten&&((o=this.animation.effect)==null||o.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&Vcr()?(this.animation.timeline=t,s&&(this.animation.rangeStart=s),n&&(this.animation.rangeEnd=n),Hf):a(this)}}const _Ye={anticipate:ZZe,backInOut:KZe,circInOut:XZe};function Wcr(e){return e in _Ye}function Gcr(e){typeof e.ease=="string"&&Wcr(e.ease)&&(e.ease=_Ye[e.ease])}const lme=10;class Kcr extends vYe{constructor(t){Gcr(t),hYe(t),super(t),t.startTime!==void 0&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:s,onUpdate:n,onComplete:a,element:o,...l}=this.options;if(!s)return;if(t!==void 0){s.set(t);return}const i=new swe({...l,autoplay:!1}),d=Math.max(lme,gh.now()-this.startTime),m=Ax(0,lme,d-lme);s.setWithVelocity(i.sample(Math.max(0,d-m)).value,i.sample(d).value,m),i.stop()}}const rPe=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(cg.test(e)||e==="0")&&!e.startsWith("url("));function Zcr(e){const t=e[0];if(e.length===1)return!0;for(let s=0;sObject.hasOwnProperty.call(Element.prototype,"animate"));function Jcr(e){var p;const{motionValue:t,name:s,repeatDelay:n,repeatType:a,damping:o,type:l}=e;if(!(((p=t==null?void 0:t.owner)==null?void 0:p.current)instanceof HTMLElement))return!1;const{onUpdate:d,transformTemplate:m}=t.owner.getProps();return Qcr()&&s&&Xcr.has(s)&&(s!=="transform"||!m)&&!d&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const edr=40;class tdr extends rwe{constructor({autoplay:t=!0,delay:s=0,type:n="keyframes",repeat:a=0,repeatDelay:o=0,repeatType:l="loop",keyframes:i,name:d,motionValue:m,element:p,...g}){var k;super(),this.stop=()=>{var w,S;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(S=this.keyframeResolver)==null||S.cancel()},this.createdAt=gh.now();const v={autoplay:t,delay:s,type:n,repeat:a,repeatDelay:o,repeatType:l,name:d,motionValue:m,element:p,...g},_=(p==null?void 0:p.KeyframeResolver)||nwe;this.keyframeResolver=new _(i,(w,S,T)=>this.onKeyframesResolved(w,S,v,!T),d,m,p),(k=this.keyframeResolver)==null||k.scheduleResolve()}onKeyframesResolved(t,s,n,a){var S,T;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:d,isHandoff:m,onUpdate:p}=n;this.resolvedAt=gh.now(),Ycr(t,o,l,i)||((p0.instantAnimations||!d)&&(p==null||p(twe(t,n,s))),t[0]=t[t.length-1],yye(n),n.repeat=0);const v={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>edr?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:s,...n,keyframes:t},_=!m&&Jcr(v),k=(T=(S=v.motionValue)==null?void 0:S.owner)==null?void 0:T.current,w=_?new Kcr({...v,element:k}):new swe(v);w.finished.then(()=>{this.notifyFinished()}).catch(Hf),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(t,s){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),zcr()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function bYe(e,t,s,n=0,a=1){const o=Array.from(e).sort((m,p)=>m.sortNodePosition(p)).indexOf(t),l=e.size,i=(l-1)*n;return typeof s=="function"?s(o,l):a===1?o*n:i-o*n}const rdr=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function sdr(e){const t=rdr.exec(e);if(!t)return[,];const[,s,n,a]=t;return[`--${s??n}`,a]}function wYe(e,t,s=1){const[n,a]=sdr(e);if(!n)return;const o=window.getComputedStyle(t).getPropertyValue(n);if(o){const l=o.trim();return zZe(l)?parseFloat(l):l}return Ybe(a)?wYe(a,t,s+1):a}const ndr={type:"spring",stiffness:500,damping:25,restSpeed:10},adr=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),idr={type:"keyframes",duration:.8},odr={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ldr=(e,{keyframes:t})=>t.length>2?idr:iM.has(e)?e.startsWith("scale")?adr(t[1]):ndr:odr,cdr=e=>e!==null;function ddr(e,{repeat:t,repeatType:s="loop"},n){const a=e.filter(cdr),o=t&&s!=="loop"&&t%2===1?0:a.length-1;return a[o]}function jYe(e,t){if(e!=null&&e.inherit&&t){const{inherit:s,...n}=e;return{...t,...n}}return e}function awe(e,t){const s=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return s!==e?jYe(s,e):s}function udr({when:e,delay:t,delayChildren:s,staggerChildren:n,staggerDirection:a,repeat:o,repeatType:l,repeatDelay:i,from:d,elapsed:m,...p}){return!!Object.keys(p).length}const iwe=(e,t,s,n={},a,o)=>l=>{const i=awe(n,e)||{},d=i.delay||n.delay||0;let{elapsed:m=0}=n;m=m-lg(d);const p={keyframes:Array.isArray(s)?s:[null,s],ease:"easeOut",velocity:t.getVelocity(),...i,delay:-m,onUpdate:v=>{t.set(v),i.onUpdate&&i.onUpdate(v)},onComplete:()=>{l(),i.onComplete&&i.onComplete()},name:e,motionValue:t,element:o?void 0:a};udr(i)||Object.assign(p,ldr(e,p)),p.duration&&(p.duration=lg(p.duration)),p.repeatDelay&&(p.repeatDelay=lg(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let g=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(yye(p),p.delay===0&&(g=!0)),(p0.instantAnimations||p0.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(g=!0,yye(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,g&&!o&&t.get()!==void 0){const v=ddr(p.keyframes,i);if(v!==void 0){hl.update(()=>{p.onUpdate(v),p.onComplete()});return}}return i.isSync?new swe(p):new tdr(p)};function sPe(e){const t=[{},{}];return e==null||e.values.forEach((s,n)=>{t[0][n]=s.get(),t[1][n]=s.getVelocity()}),t}function owe(e,t,s,n){if(typeof t=="function"){const[a,o]=sPe(n);t=t(s!==void 0?s:e.custom,a,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[a,o]=sPe(n);t=t(s!==void 0?s:e.custom,a,o)}return t}function i5(e,t,s){const n=e.getProps();return owe(n,t,s!==void 0?s:n.custom,e)}const kYe=new Set(["width","height","top","left","right","bottom",...aM]),nPe=30,hdr=e=>!isNaN(parseFloat(e));class mdr{constructor(t,s={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=gh.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(t),this.owner=s.owner}setCurrent(t){this.current=t,this.updatedAt=gh.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=hdr(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,s){this.events[t]||(this.events[t]=new Gbe);const n=this.events[t].add(s);return t==="change"?()=>{n(),hl.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,s){this.passiveEffect=t,this.stopPassiveEffect=s}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,s,n){this.set(s),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-n}jump(t,s=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,s&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=gh.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>nPe)return 0;const s=Math.min(this.updatedAt-this.prevUpdatedAt,nPe);return VZe(parseFloat(this.current)-parseFloat(this.prevFrameValue),s)}start(t){return this.stop(),new Promise(s=>{this.hasAnimated=!0,this.animation=t(s),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 t,s;(t=this.dependents)==null||t.clear(),(s=this.events.destroy)==null||s.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function p3(e,t){return new mdr(e,t)}const vye=e=>Array.isArray(e);function fdr(e,t,s){e.hasValue(t)?e.getValue(t).set(s):e.addValue(t,p3(s))}function pdr(e){return vye(e)?e[e.length-1]||0:e}function gdr(e,t){const s=i5(e,t);let{transitionEnd:n={},transition:a={},...o}=s||{};o={...o,...n};for(const l in o){const i=pdr(o[l]);fdr(e,l,i)}}const Iu=e=>!!(e&&e.getVelocity);function xdr(e){return!!(Iu(e)&&e.add)}function _ye(e,t){const s=e.getValue("willChange");if(xdr(s))return s.add(t);if(!s&&p0.WillChange){const n=new p0.WillChange("auto");e.addValue("willChange",n),n.add(t)}}function lwe(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const ydr="framerAppearId",NYe="data-"+lwe(ydr);function SYe(e){return e.props[NYe]}function vdr({protectedKeys:e,needsAnimating:t},s){const n=e.hasOwnProperty(s)&&t[s]!==!0;return t[s]=!1,n}function CYe(e,t,{delay:s=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=t;const d=e.getDefaultTransition();o=o?jYe(o,d):d;const m=o==null?void 0:o.reduceMotion;n&&(o=n);const p=[],g=a&&e.animationState&&e.animationState.getState()[a];for(const v in i){const _=e.getValue(v,e.latestValues[v]??null),k=i[v];if(k===void 0||g&&vdr(g,v))continue;const w={delay:s,...awe(o||{},v)},S=_.get();if(S!==void 0&&!_.isAnimating&&!Array.isArray(k)&&k===S&&!w.velocity)continue;let T=!1;if(window.MotionHandoffAnimation){const R=SYe(e);if(R){const D=window.MotionHandoffAnimation(R,v,hl);D!==null&&(w.startTime=D,T=!0)}}_ye(e,v);const C=m??e.shouldReduceMotion;_.start(iwe(v,_,k,C&&kYe.has(v)?{type:!1}:w,e,T));const I=_.animation;I&&p.push(I)}if(l){const v=()=>hl.update(()=>{l&&gdr(e,l)});p.length?Promise.all(p).then(v):v()}return p}function bye(e,t,s={}){var d;const n=i5(e,t,s.type==="exit"?(d=e.presenceContext)==null?void 0:d.custom:void 0);let{transition:a=e.getDefaultTransition()||{}}=n||{};s.transitionOverride&&(a=s.transitionOverride);const o=n?()=>Promise.all(CYe(e,n,s)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(m=0)=>{const{delayChildren:p=0,staggerChildren:g,staggerDirection:v}=a;return _dr(e,t,m,p,g,v,s)}:()=>Promise.resolve(),{when:i}=a;if(i){const[m,p]=i==="beforeChildren"?[o,l]:[l,o];return m().then(()=>p())}else return Promise.all([o(),l(s.delay)])}function _dr(e,t,s=0,n=0,a=0,o=1,l){const i=[];for(const d of e.variantChildren)d.notify("AnimationStart",t),i.push(bye(d,t,{...l,delay:s+(typeof n=="function"?0:n)+bYe(e.variantChildren,d,n,a,o)}).then(()=>d.notify("AnimationComplete",t)));return Promise.all(i)}function bdr(e,t,s={}){e.notify("AnimationStart",t);let n;if(Array.isArray(t)){const a=t.map(o=>bye(e,o,s));n=Promise.all(a)}else if(typeof t=="string")n=bye(e,t,s);else{const a=typeof t=="function"?i5(e,t,s.custom):t;n=Promise.all(CYe(e,a,s))}return n.then(()=>{e.notify("AnimationComplete",t)})}const wdr={test:e=>e==="auto",parse:e=>e},MYe=e=>t=>t.test(e),TYe=[nM,$n,bx,yv,Xlr,Ylr,wdr],aPe=e=>TYe.find(MYe(e));function jdr(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||$Ze(e):!0}const kdr=new Set(["brightness","contrast","saturate","opacity"]);function Ndr(e){const[t,s]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[n]=s.match(Xbe)||[];if(!n)return e;const a=s.replace(n,"");let o=kdr.has(t)?1:0;return n!==s&&(o*=100),t+"("+o+a+")"}const Sdr=/\b([a-z-]*)\(.*?\)/gu,wye={...cg,getAnimatableNone:e=>{const t=e.match(Sdr);return t?t.map(Ndr).join(" "):e}},jye={...cg,getAnimatableNone:e=>{const t=cg.parse(e);return cg.createTransformer(e)(t.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},iPe={...nM,transform:Math.round},Cdr={rotate:yv,rotateX:yv,rotateY:yv,rotateZ:yv,scale:g8,scaleX:g8,scaleY:g8,scaleZ:g8,skew:yv,skewX:yv,skewY:yv,distance:$n,translateX:$n,translateY:$n,translateZ:$n,x:$n,y:$n,z:$n,perspective:$n,transformPerspective:$n,opacity:JP,originX:WIe,originY:WIe,originZ:$n},cwe={borderWidth:$n,borderTopWidth:$n,borderRightWidth:$n,borderBottomWidth:$n,borderLeftWidth:$n,borderRadius:$n,borderTopLeftRadius:$n,borderTopRightRadius:$n,borderBottomRightRadius:$n,borderBottomLeftRadius:$n,width:$n,maxWidth:$n,height:$n,maxHeight:$n,top:$n,right:$n,bottom:$n,left:$n,inset:$n,insetBlock:$n,insetBlockStart:$n,insetBlockEnd:$n,insetInline:$n,insetInlineStart:$n,insetInlineEnd:$n,padding:$n,paddingTop:$n,paddingRight:$n,paddingBottom:$n,paddingLeft:$n,paddingBlock:$n,paddingBlockStart:$n,paddingBlockEnd:$n,paddingInline:$n,paddingInlineStart:$n,paddingInlineEnd:$n,margin:$n,marginTop:$n,marginRight:$n,marginBottom:$n,marginLeft:$n,marginBlock:$n,marginBlockStart:$n,marginBlockEnd:$n,marginInline:$n,marginInlineStart:$n,marginInlineEnd:$n,fontSize:$n,backgroundPositionX:$n,backgroundPositionY:$n,...Cdr,zIndex:iPe,fillOpacity:JP,strokeOpacity:JP,numOctaves:iPe},Mdr={...cwe,color:rd,backgroundColor:rd,outlineColor:rd,fill:rd,stroke:rd,borderColor:rd,borderTopColor:rd,borderRightColor:rd,borderBottomColor:rd,borderLeftColor:rd,filter:wye,WebkitFilter:wye,mask:jye,WebkitMask:jye},AYe=e=>Mdr[e],Tdr=new Set([wye,jye]);function EYe(e,t){let s=AYe(e);return Tdr.has(s)||(s=cg),s.getAnimatableNone?s.getAnimatableNone(t):void 0}const Adr=new Set(["auto","none","0"]);function Edr(e,t,s){let n=0,a;for(;n{t.getValue(d).set(m)}),this.resolveNoneKeyframes()}}const Pdr=new Set(["opacity","clipPath","filter","transform"]);function IYe(e,t,s){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let n=document;const a=(s==null?void 0:s[e])??n.querySelectorAll(e);return a?Array.from(a):[]}return Array.from(e).filter(n=>n!=null)}const PYe=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function Ldr(e){return BZe(e)&&"offsetHeight"in e}const{schedule:dwe}=eYe(queueMicrotask,!1),Lp={x:!1,y:!1};function LYe(){return Lp.x||Lp.y}function Ddr(e){return e==="x"||e==="y"?Lp[e]?null:(Lp[e]=!0,()=>{Lp[e]=!1}):Lp.x||Lp.y?null:(Lp.x=Lp.y=!0,()=>{Lp.x=Lp.y=!1})}function DYe(e,t){const s=IYe(e),n=new AbortController,a={passive:!0,...t,signal:n.signal};return[s,a,()=>n.abort()]}function Odr(e){return!(e.pointerType==="touch"||LYe())}function Rdr(e,t,s={}){const[n,a,o]=DYe(e,s);return n.forEach(l=>{let i=!1,d=!1,m;const p=()=>{l.removeEventListener("pointerleave",k)},g=S=>{m&&(m(S),m=void 0),p()},v=S=>{i=!1,window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v),d&&(d=!1,g(S))},_=()=>{i=!0,window.addEventListener("pointerup",v,a),window.addEventListener("pointercancel",v,a)},k=S=>{if(S.pointerType!=="touch"){if(i){d=!0;return}g(S)}},w=S=>{if(!Odr(S))return;d=!1;const T=t(l,S);typeof T=="function"&&(m=T,l.addEventListener("pointerleave",k,a))};l.addEventListener("pointerenter",w,a),l.addEventListener("pointerdown",_,a)}),o}const OYe=(e,t)=>t?e===t?!0:OYe(e,t.parentElement):!1,uwe=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Fdr=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function zdr(e){return Fdr.has(e.tagName)||e.isContentEditable===!0}const Bdr=new Set(["INPUT","SELECT","TEXTAREA"]);function $dr(e){return Bdr.has(e.tagName)||e.isContentEditable===!0}const vre=new WeakSet;function oPe(e){return t=>{t.key==="Enter"&&e(t)}}function cme(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const Udr=(e,t)=>{const s=e.currentTarget;if(!s)return;const n=oPe(()=>{if(vre.has(s))return;cme(s,"down");const a=oPe(()=>{cme(s,"up")}),o=()=>cme(s,"cancel");s.addEventListener("keyup",a,t),s.addEventListener("blur",o,t)});s.addEventListener("keydown",n,t),s.addEventListener("blur",()=>s.removeEventListener("keydown",n),t)};function lPe(e){return uwe(e)&&!LYe()}const cPe=new WeakSet;function Vdr(e,t,s={}){const[n,a,o]=DYe(e,s),l=i=>{const d=i.currentTarget;if(!lPe(i)||cPe.has(i))return;vre.add(d),s.stopPropagation&&cPe.add(i);const m=t(d,i),p=(_,k)=>{window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",v),vre.has(d)&&vre.delete(d),lPe(_)&&typeof m=="function"&&m(_,{success:k})},g=_=>{p(_,d===window||d===document||s.useGlobalTarget||OYe(d,_.target))},v=_=>{p(_,!1)};window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",v,a)};return n.forEach(i=>{(s.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),Ldr(i)&&(i.addEventListener("focus",m=>Udr(m,a)),!zdr(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function hwe(e){return BZe(e)&&"ownerSVGElement"in e}const _re=new WeakMap;let vv;const RYe=(e,t,s)=>(n,a)=>a&&a[0]?a[0][e+"Size"]:hwe(n)&&"getBBox"in n?n.getBBox()[t]:n[s],qdr=RYe("inline","width","offsetWidth"),Hdr=RYe("block","height","offsetHeight");function Wdr({target:e,borderBoxSize:t}){var s;(s=_re.get(e))==null||s.forEach(n=>{n(e,{get width(){return qdr(e,t)},get height(){return Hdr(e,t)}})})}function Gdr(e){e.forEach(Wdr)}function Kdr(){typeof ResizeObserver>"u"||(vv=new ResizeObserver(Gdr))}function Zdr(e,t){vv||Kdr();const s=IYe(e);return s.forEach(n=>{let a=_re.get(n);a||(a=new Set,_re.set(n,a)),a.add(t),vv==null||vv.observe(n)}),()=>{s.forEach(n=>{const a=_re.get(n);a==null||a.delete(t),a!=null&&a.size||vv==null||vv.unobserve(n)})}}const bre=new Set;let o4;function Ydr(){o4=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};bre.forEach(t=>t(e))},window.addEventListener("resize",o4)}function Xdr(e){return bre.add(e),o4||Ydr(),()=>{bre.delete(e),!bre.size&&typeof o4=="function"&&(window.removeEventListener("resize",o4),o4=void 0)}}function dPe(e,t){return typeof e=="function"?Xdr(e):Zdr(e,t)}function Qdr(e){return hwe(e)&&e.tagName==="svg"}const Jdr=[...TYe,rd,cg],eur=e=>Jdr.find(MYe(e)),uPe=()=>({translate:0,scale:1,origin:0,originPoint:0}),l4=()=>({x:uPe(),y:uPe()}),hPe=()=>({min:0,max:0}),vd=()=>({x:hPe(),y:hPe()}),tur=new WeakMap;function _le(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function t6(e){return typeof e=="string"||Array.isArray(e)}const mwe=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],fwe=["initial",...mwe];function ble(e){return _le(e.animate)||fwe.some(t=>t6(e[t]))}function FYe(e){return!!(ble(e)||e.variants)}function rur(e,t,s){for(const n in t){const a=t[n],o=s[n];if(Iu(a))e.addValue(n,a);else if(Iu(o))e.addValue(n,p3(a,{owner:e}));else if(o!==a)if(e.hasValue(n)){const l=e.getValue(n);l.liveStyle===!0?l.jump(a):l.hasAnimated||l.set(a)}else{const l=e.getStaticValue(n);e.addValue(n,p3(l!==void 0?l:a,{owner:e}))}}for(const n in s)t[n]===void 0&&e.removeValue(n);return t}const kye={current:null},zYe={current:!1},sur=typeof window<"u";function nur(){if(zYe.current=!0,!!sur)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>kye.current=e.matches;e.addEventListener("change",t),t()}else kye.current=!1}const mPe=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Cae={};function BYe(e){Cae=e}function aur(){return Cae}class iur{scrapeMotionValuesFromProps(t,s,n){return{}}constructor({parent:t,props:s,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=nwe,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 _=gh.now();this.renderScheduledAt<_&&(this.renderScheduledAt=_,hl.render(this.render,!1,!0))};const{latestValues:m,renderState:p}=i;this.latestValues=m,this.baseTarget={...m},this.initialValues=s.initial?{...m}:{},this.renderState=p,this.parent=t,this.props=s,this.presenceContext=n,this.depth=t?t.depth+1:0,this.reducedMotionConfig=a,this.skipAnimationsConfig=o,this.options=d,this.blockInitialAnimation=!!l,this.isControllingVariants=ble(s),this.isVariantNode=FYe(s),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:g,...v}=this.scrapeMotionValuesFromProps(s,{},this);for(const _ in v){const k=v[_];m[_]!==void 0&&Iu(k)&&k.set(m[_])}}mount(t){var s,n;if(this.hasBeenMounted)for(const a in this.initialValues)(s=this.values.get(a))==null||s.jump(this.initialValues[a]),this.latestValues[a]=this.initialValues[a];this.current=t,tur.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),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:(zYe.current||nur(),this.shouldReduceMotion=kye.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),Z1(this.notifyUpdate),Z1(this.render),this.valueSubscriptions.forEach(s=>s()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const s in this.events)this.events[s].clear();for(const s in this.features){const n=this.features[s];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,s){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),s.accelerate&&Pdr.has(t)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:d,ease:m,duration:p}=s.accelerate,g=new vYe({element:this.current,name:t,keyframes:i,times:d,ease:m,duration:lg(p)}),v=l(g);this.valueSubscriptions.set(t,()=>{v(),g.cancel()});return}const n=iM.has(t);n&&this.onBindTransform&&this.onBindTransform();const a=s.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&hl.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;typeof window<"u"&&window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,s)),this.valueSubscriptions.set(t,()=>{a(),o&&o(),s.owner&&s.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Cae){const s=Cae[t];if(!s)continue;const{isEnabled:n,Feature:a}=s;if(!this.features[t]&&a&&n(this.props)&&(this.features[t]=new a(this)),this.features[t]){const o=this.features[t];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):vd()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,s){this.latestValues[t]=s}update(t,s){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=s;for(let n=0;ns.variantChildren.delete(t)}addValue(t,s){const n=this.values.get(t);s!==n&&(n&&this.removeValue(t),this.bindToMotionValue(t,s),this.values.set(t,s),this.latestValues[t]=s.get())}removeValue(t){this.values.delete(t);const s=this.valueSubscriptions.get(t);s&&(s(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,s){if(this.props.values&&this.props.values[t])return this.props.values[t];let n=this.values.get(t);return n===void 0&&s!==void 0&&(n=p3(s===null?void 0:s,{owner:this}),this.addValue(t,n)),n}readValue(t,s){let n=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return n!=null&&(typeof n=="string"&&(zZe(n)||$Ze(n))?n=parseFloat(n):!eur(n)&&cg.test(s)&&(n=EYe(t,s)),this.setBaseTarget(t,Iu(n)?n.get():n)),Iu(n)?n.get():n}setBaseTarget(t,s){this.baseTarget[t]=s}getBaseTarget(t){var o;const{initial:s}=this.props;let n;if(typeof s=="string"||typeof s=="object"){const l=owe(this.props,s,(o=this.presenceContext)==null?void 0:o.custom);l&&(n=l[t])}if(s&&n!==void 0)return n;const a=this.getBaseTargetFromProps(this.props,t);return a!==void 0&&!Iu(a)?a:this.initialValues[t]!==void 0&&n===void 0?void 0:this.baseTarget[t]}on(t,s){return this.events[t]||(this.events[t]=new Gbe),this.events[t].add(s)}notify(t,...s){this.events[t]&&this.events[t].notify(...s)}scheduleRenderMicrotask(){dwe.render(this.render)}}class $Ye extends iur{constructor(){super(...arguments),this.KeyframeResolver=Idr}sortInstanceNodePosition(t,s){return t.compareDocumentPosition(s)&2?1:-1}getBaseTargetFromProps(t,s){const n=t.style;return n?n[s]:void 0}removeValueFromRenderState(t,{vars:s,style:n}){delete s[t],delete n[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Iu(t)&&(this.childSubscription=t.on("change",s=>{this.current&&(this.current.textContent=`${s}`)}))}}class g_{constructor(t){this.isMounted=!1,this.node=t}update(){}}function UYe({top:e,left:t,right:s,bottom:n}){return{x:{min:t,max:s},y:{min:e,max:n}}}function our({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function lur(e,t){if(!t)return e;const s=t({x:e.left,y:e.top}),n=t({x:e.right,y:e.bottom});return{top:s.y,left:s.x,bottom:n.y,right:n.x}}function dme(e){return e===void 0||e===1}function Nye({scale:e,scaleX:t,scaleY:s}){return!dme(e)||!dme(t)||!dme(s)}function Ij(e){return Nye(e)||VYe(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function VYe(e){return fPe(e.x)||fPe(e.y)}function fPe(e){return e&&e!=="0%"}function Mae(e,t,s){const n=e-s,a=t*n;return s+a}function pPe(e,t,s,n,a){return a!==void 0&&(e=Mae(e,a,n)),Mae(e,s,n)+t}function Sye(e,t=0,s=1,n,a){e.min=pPe(e.min,t,s,n,a),e.max=pPe(e.max,t,s,n,a)}function qYe(e,{x:t,y:s}){Sye(e.x,t.translate,t.scale,t.originPoint),Sye(e.y,s.translate,s.scale,s.originPoint)}const gPe=.999999999999,xPe=1.0000000000001;function cur(e,t,s,n=!1){const a=s.length;if(!a)return;t.x=t.y=1;let o,l;for(let i=0;igPe&&(t.x=1),t.ygPe&&(t.y=1)}function c4(e,t){e.min=e.min+t,e.max=e.max+t}function yPe(e,t,s,n,a=.5){const o=Zl(e.min,e.max,a);Sye(e,t,s,o,n)}function vPe(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function d4(e,t){yPe(e.x,vPe(t.x,e.x),t.scaleX,t.scale,t.originX),yPe(e.y,vPe(t.y,e.y),t.scaleY,t.scale,t.originY)}function HYe(e,t){return UYe(lur(e.getBoundingClientRect(),t))}function dur(e,t,s){const n=HYe(e,s),{scroll:a}=t;return a&&(c4(n.x,a.offset.x),c4(n.y,a.offset.y)),n}const uur={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},hur=aM.length;function mur(e,t,s){let n="",a=!0;for(let o=0;o{if(!t.target)return e;if(typeof e=="string")if($n.test(e))e=parseFloat(e);else return e;const s=_Pe(e,t.target.x),n=_Pe(e,t.target.y);return`${s}% ${n}%`}},fur={correct:(e,{treeScale:t,projectionDelta:s})=>{const n=e,a=cg.parse(e);if(a.length>5)return n;const o=cg.createTransformer(e),l=typeof a[0]!="number"?1:0,i=s.x.scale*t.x,d=s.y.scale*t.y;a[0+l]/=i,a[1+l]/=d;const m=Zl(i,d,.5);return typeof a[2+l]=="number"&&(a[2+l]/=m),typeof a[3+l]=="number"&&(a[3+l]/=m),o(a)}},Cye={borderRadius:{...LA,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:LA,borderTopRightRadius:LA,borderBottomLeftRadius:LA,borderBottomRightRadius:LA,boxShadow:fur};function GYe(e,{layout:t,layoutId:s}){return iM.has(e)||e.startsWith("origin")||(t||s!==void 0)&&(!!Cye[e]||e==="opacity")}function gwe(e,t,s){var l;const n=e.style,a=t==null?void 0:t.style,o={};if(!n)return o;for(const i in n)(Iu(n[i])||a&&Iu(a[i])||GYe(i,e)||((l=s==null?void 0:s.getValue(i))==null?void 0:l.liveStyle)!==void 0)&&(o[i]=n[i]);return o}function pur(e){return window.getComputedStyle(e)}class gur extends $Ye{constructor(){super(...arguments),this.type="html",this.renderInstance=WYe}readValueFromInstance(t,s){var n;if(iM.has(s))return(n=this.projection)!=null&&n.isProjecting?mye(s):Lcr(t,s);{const a=pur(t),o=(rYe(s)?a.getPropertyValue(s):a[s])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:s}){return HYe(t,s)}build(t,s,n){pwe(t,s,n.transformTemplate)}scrapeMotionValuesFromProps(t,s,n){return gwe(t,s,n)}}const xur={offset:"stroke-dashoffset",array:"stroke-dasharray"},yur={offset:"strokeDashoffset",array:"strokeDasharray"};function vur(e,t,s=1,n=0,a=!0){e.pathLength=1;const o=a?xur:yur;e[o.offset]=`${-n}`,e[o.array]=`${t} ${s}`}const _ur=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function KYe(e,{attrX:t,attrY:s,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},d,m,p){if(pwe(e,i,m),d){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:g,style:v}=e;g.transform&&(v.transform=g.transform,delete g.transform),(v.transform||g.transformOrigin)&&(v.transformOrigin=g.transformOrigin??"50% 50%",delete g.transformOrigin),v.transform&&(v.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete g.transformBox);for(const _ of _ur)g[_]!==void 0&&(v[_]=g[_],delete g[_]);t!==void 0&&(g.x=t),s!==void 0&&(g.y=s),n!==void 0&&(g.scale=n),a!==void 0&&vur(g,a,o,l,!1)}const ZYe=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"]),YYe=e=>typeof e=="string"&&e.toLowerCase()==="svg";function bur(e,t,s,n){WYe(e,t,void 0,n);for(const a in t.attrs)e.setAttribute(ZYe.has(a)?a:lwe(a),t.attrs[a])}function XYe(e,t,s){const n=gwe(e,t,s);for(const a in e)if(Iu(e[a])||Iu(t[a])){const o=aM.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=e[a]}return n}class wur extends $Ye{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=vd}getBaseTargetFromProps(t,s){return t[s]}readValueFromInstance(t,s){if(iM.has(s)){const n=AYe(s);return n&&n.default||0}return s=ZYe.has(s)?s:lwe(s),t.getAttribute(s)}scrapeMotionValuesFromProps(t,s,n){return XYe(t,s,n)}build(t,s,n){KYe(t,s,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(t,s,n,a){bur(t,s,n,a)}mount(t){this.isSVGTag=YYe(t.tagName),super.mount(t)}}const jur=fwe.length;function QYe(e){if(!e)return;if(!e.isControllingVariants){const s=e.parent?QYe(e.parent)||{}:{};return e.props.initial!==void 0&&(s.initial=e.props.initial),s}const t={};for(let s=0;sPromise.all(t.map(({animation:s,options:n})=>bdr(e,s,n)))}function Cur(e){let t=Sur(e),s=bPe(),n=!0,a=!1;const o=m=>(p,g)=>{var _;const v=i5(e,g,m==="exit"?(_=e.presenceContext)==null?void 0:_.custom:void 0);if(v){const{transition:k,transitionEnd:w,...S}=v;p={...p,...S,...w}}return p};function l(m){t=m(e)}function i(m){const{props:p}=e,g=QYe(e.parent)||{},v=[],_=new Set;let k={},w=1/0;for(let T=0;Tw&&D,K=!1;const re=Array.isArray(R)?R:[R];let ae=re.reduce(o(C),{});B===!1&&(ae={});const{prevResolvedValues:oe={}}=I,se={...oe,...ae},pe=ce=>{W=!0,_.has(ce)&&(K=!0,_.delete(ce)),I.needsAnimating[ce]=!0;const ge=e.getValue(ce);ge&&(ge.liveStyle=!1)};for(const ce in se){const ge=ae[ce],Te=oe[ce];if(k.hasOwnProperty(ce))continue;let _e=!1;vye(ge)&&vye(Te)?_e=!JYe(ge,Te):_e=ge!==Te,_e?ge!=null?pe(ce):_.add(ce):ge!==void 0&&_.has(ce)?pe(ce):I.protectedKeys[ce]=!0}I.prevProp=R,I.prevResolvedValues=ae,I.isActive&&(k={...k,...ae}),(n||a)&&e.blockInitialAnimation&&(W=!1);const ie=$&&q;W&&(!ie||K)&&v.push(...re.map(ce=>{const ge={type:C};if(typeof ce=="string"&&(n||a)&&!ie&&e.manuallyAnimateOnMount&&e.parent){const{parent:Te}=e,_e=i5(Te,ce);if(Te.enteringChildren&&_e){const{delayChildren:ve}=_e.transition||{};ge.delay=bYe(Te.enteringChildren,e,ve)}}return{animation:ce,options:ge}}))}if(_.size){const T={};if(typeof p.initial!="boolean"){const C=i5(e,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(T.transition=C.transition)}_.forEach(C=>{const I=e.getBaseTarget(C),R=e.getValue(C);R&&(R.liveStyle=!0),T[C]=I??null}),v.push({animation:T})}let S=!!v.length;return n&&(p.initial===!1||p.initial===p.animate)&&!e.manuallyAnimateOnMount&&(S=!1),n=!1,a=!1,S?t(v):Promise.resolve()}function d(m,p){var v;if(s[m].isActive===p)return Promise.resolve();(v=e.variantChildren)==null||v.forEach(_=>{var k;return(k=_.animationState)==null?void 0:k.setActive(m,p)}),s[m].isActive=p;const g=i(m);for(const _ in s)s[_].protectedKeys={};return g}return{animateChanges:i,setActive:d,setAnimateFunction:l,getState:()=>s,reset:()=>{s=bPe(),a=!0}}}function Mur(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!JYe(t,e):!1}function hb(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function bPe(){return{animate:hb(!0),whileInView:hb(),whileHover:hb(),whileTap:hb(),whileDrag:hb(),whileFocus:hb(),exit:hb()}}function wPe(e,t){e.min=t.min,e.max=t.max}function Tp(e,t){wPe(e.x,t.x),wPe(e.y,t.y)}function jPe(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const eXe=1e-4,Tur=1-eXe,Aur=1+eXe,tXe=.01,Eur=0-tXe,Iur=0+tXe;function xh(e){return e.max-e.min}function Pur(e,t,s){return Math.abs(e-t)<=s}function kPe(e,t,s,n=.5){e.origin=n,e.originPoint=Zl(t.min,t.max,e.origin),e.scale=xh(s)/xh(t),e.translate=Zl(s.min,s.max,e.origin)-e.originPoint,(e.scale>=Tur&&e.scale<=Aur||isNaN(e.scale))&&(e.scale=1),(e.translate>=Eur&&e.translate<=Iur||isNaN(e.translate))&&(e.translate=0)}function vI(e,t,s,n){kPe(e.x,t.x,s.x,n?n.originX:void 0),kPe(e.y,t.y,s.y,n?n.originY:void 0)}function NPe(e,t,s){e.min=s.min+t.min,e.max=e.min+xh(t)}function Lur(e,t,s){NPe(e.x,t.x,s.x),NPe(e.y,t.y,s.y)}function SPe(e,t,s){e.min=t.min-s.min,e.max=e.min+xh(t)}function Tae(e,t,s){SPe(e.x,t.x,s.x),SPe(e.y,t.y,s.y)}function CPe(e,t,s,n,a){return e-=t,e=Mae(e,1/s,n),a!==void 0&&(e=Mae(e,1/a,n)),e}function Dur(e,t=0,s=1,n=.5,a,o=e,l=e){if(bx.test(t)&&(t=parseFloat(t),t=Zl(l.min,l.max,t/100)-l.min),typeof t!="number")return;let i=Zl(o.min,o.max,n);e===o&&(i-=t),e.min=CPe(e.min,t,s,i,a),e.max=CPe(e.max,t,s,i,a)}function MPe(e,t,[s,n,a],o,l){Dur(e,t[s],t[n],t[a],t.scale,o,l)}const Our=["x","scaleX","originX"],Rur=["y","scaleY","originY"];function TPe(e,t,s,n){MPe(e.x,t,Our,s?s.x:void 0,n?n.x:void 0),MPe(e.y,t,Rur,s?s.y:void 0,n?n.y:void 0)}function APe(e){return e.translate===0&&e.scale===1}function rXe(e){return APe(e.x)&&APe(e.y)}function EPe(e,t){return e.min===t.min&&e.max===t.max}function Fur(e,t){return EPe(e.x,t.x)&&EPe(e.y,t.y)}function IPe(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function sXe(e,t){return IPe(e.x,t.x)&&IPe(e.y,t.y)}function PPe(e){return xh(e.x)/xh(e.y)}function LPe(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Kg(e){return[e("x"),e("y")]}function zur(e,t,s){let n="";const a=e.x.translate/t.x,o=e.y.translate/t.y,l=(s==null?void 0:s.z)||0;if((a||o||l)&&(n=`translate3d(${a}px, ${o}px, ${l}px) `),(t.x!==1||t.y!==1)&&(n+=`scale(${1/t.x}, ${1/t.y}) `),s){const{transformPerspective:m,rotate:p,rotateX:g,rotateY:v,skewX:_,skewY:k}=s;m&&(n=`perspective(${m}px) ${n}`),p&&(n+=`rotate(${p}deg) `),g&&(n+=`rotateX(${g}deg) `),v&&(n+=`rotateY(${v}deg) `),_&&(n+=`skewX(${_}deg) `),k&&(n+=`skewY(${k}deg) `)}const i=e.x.scale*t.x,d=e.y.scale*t.y;return(i!==1||d!==1)&&(n+=`scale(${i}, ${d})`),n||"none"}const nXe=["TopLeft","TopRight","BottomLeft","BottomRight"],Bur=nXe.length,DPe=e=>typeof e=="string"?parseFloat(e):e,OPe=e=>typeof e=="number"||$n.test(e);function $ur(e,t,s,n,a,o){a?(e.opacity=Zl(0,s.opacity??1,Uur(n)),e.opacityExit=Zl(t.opacity??1,0,Vur(n))):o&&(e.opacity=Zl(t.opacity??1,s.opacity??1,n));for(let l=0;lnt?1:s(QP(e,t,n))}function qur(e,t,s){const n=Iu(e)?e:p3(e);return n.start(iwe("",n,t,s)),n.animation}function r6(e,t,s,n={passive:!0}){return e.addEventListener(t,s,n),()=>e.removeEventListener(t,s)}const Hur=(e,t)=>e.depth-t.depth;class Wur{constructor(){this.children=[],this.isDirty=!1}add(t){Hbe(this.children,t),this.isDirty=!0}remove(t){jae(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(Hur),this.isDirty=!1,this.children.forEach(t)}}function Gur(e,t){const s=gh.now(),n=({timestamp:a})=>{const o=a-s;o>=t&&(Z1(n),e(o-t))};return hl.setup(n,!0),()=>Z1(n)}function wre(e){return Iu(e)?e.get():e}class Kur{constructor(){this.members=[]}add(t){Hbe(this.members,t);for(let s=this.members.length-1;s>=0;s--){const n=this.members[s];if(n===t||n===this.lead||n===this.prevLead)continue;const a=n.instance;(!a||a.isConnected===!1)&&!n.snapshot&&(jae(this.members,n),n.unmount())}t.scheduleRender()}remove(t){if(jae(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const s=this.members[this.members.length-1];s&&this.promote(s)}}relegate(t){var s;for(let n=this.members.indexOf(t)-1;n>=0;n--){const a=this.members[n];if(a.isPresent!==!1&&((s=a.instance)==null?void 0:s.isConnected)!==!1)return this.promote(a),!0}return!1}promote(t,s){var a;const n=this.lead;if(t!==n&&(this.prevLead=n,this.lead=t,t.show(),n)){n.updateSnapshot(),t.scheduleRender();const{layoutDependency:o}=n.options,{layoutDependency:l}=t.options;(o===void 0||o!==l)&&(t.resumeFrom=n,s&&(n.preserveOpacity=!0),n.snapshot&&(t.snapshot=n.snapshot,t.snapshot.latestValues=n.animationValues||n.latestValues),(a=t.root)!=null&&a.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var s,n,a,o,l;(n=(s=t.options).onExitComplete)==null||n.call(s),(l=(a=t.resumingFrom)==null?void 0:(o=a.options).onExitComplete)==null||l.call(o)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const jre={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ume=["","X","Y","Z"],Zur=1e3;let Yur=0;function hme(e,t,s,n){const{latestValues:a}=t;a[e]&&(s[e]=a[e],t.setStaticValue(e,0),n&&(n[e]=0))}function iXe(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const s=SYe(t);if(window.MotionHasOptimisedAnimation(s,"transform")){const{layout:a,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(s,"transform",hl,!(a||o))}const{parent:n}=e;n&&!n.hasCheckedOptimisedAppear&&iXe(n)}function oXe({attachResizeListener:e,defaultParent:t,measureScroll:s,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=t==null?void 0:t()){this.id=Yur++,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(Jur),this.nodes.forEach(shr),this.nodes.forEach(nhr),this.nodes.forEach(ehr)},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;hl.read(()=>{g=window.innerWidth}),e(l,()=>{const _=window.innerWidth;_!==g&&(g=_,this.root.updateBlockedByResize=!0,p&&p(),p=Gur(v,250),jre.hasAnimatedSinceResize&&(jre.hasAnimatedSinceResize=!1,this.nodes.forEach(BPe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&m&&(i||d)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:g,hasRelativeLayoutChanged:v,layout:_})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const k=this.options.transition||m.getDefaultTransition()||chr,{onLayoutAnimationStart:w,onLayoutAnimationComplete:S}=m.getProps(),T=!this.targetLayout||!sXe(this.targetLayout,_),C=!g&&v;if(this.options.layoutRoot||this.resumeFrom||C||g&&(T||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const I={...awe(k,"layout"),onPlay:w,onComplete:S};(m.shouldReduceMotion||this.options.layoutRoot)&&(I.delay=0,I.type=!1),this.startAnimation(I),this.setAnimationOrigin(p,C)}else g||BPe(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(),Z1(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(ahr),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&&iXe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!xh(this.snapshot.measuredBox.x)&&!xh(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 D=R/1e3;$Pe(g.x,l.x,D),$Pe(g.y,l.y,D),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Tae(v,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ohr(this.relativeTarget,this.relativeTargetOrigin,v,D),I&&Fur(this.relativeTarget,I)&&(this.isProjectionDirty=!1),I||(I=vd()),Tp(I,this.relativeTarget)),w&&(this.animationValues=p,$ur(p,m,this.latestValues,D,C,T)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(l){var i,d,m;this.notifyListeners("animationStart"),(i=this.currentAnimation)==null||i.stop(),(m=(d=this.resumingFrom)==null?void 0:d.currentAnimation)==null||m.stop(),this.pendingAnimation&&(Z1(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=hl.update(()=>{jre.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=p3(0)),this.motionValue.jump(0,!1),this.currentAnimation=qur(this.motionValue,[0,1e3],{...l,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),l.onUpdate&&l.onUpdate(p)},onStop:()=>{},onComplete:()=>{l.onComplete&&l.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const l=this.getStack();l&&l.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Zur),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const l=this.getLead();let{targetWithTransforms:i,target:d,layout:m,latestValues:p}=l;if(!(!i||!d||!m)){if(this!==l&&this.layout&&m&&lXe(this.options.animationType,this.layout.layoutBox,m.layoutBox)){d=this.target||vd();const g=xh(this.layout.layoutBox.x);d.x.min=l.target.x.min,d.x.max=d.x.min+g;const v=xh(this.layout.layoutBox.y);d.y.min=l.target.y.min,d.y.max=d.y.min+v}Tp(i,d),d4(i,p),vI(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new Kur),this.sharedNodes.get(l).add(i);const m=i.options.initialPromotionConfig;i.promote({transition:m?m.transition:void 0,preserveFollowOpacity:m&&m.shouldPreserveFollowOpacity?m.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 m=this.getStack();m&&m.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 m={};d.z&&hme("z",l,m,this.animationValues);for(let p=0;p{var i;return(i=l.currentAnimation)==null?void 0:i.stop()}),this.root.nodes.forEach(FPe),this.root.sharedNodes.clear()}}}function Xur(e){e.updateLayout()}function Qur(e){var s;const t=((s=e.resumeFrom)==null?void 0:s.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:a}=e.layout,{animationType:o}=e.options,l=t.source!==e.layout.source;o==="size"?Kg(g=>{const v=l?t.measuredBox[g]:t.layoutBox[g],_=xh(v);v.min=n[g].min,v.max=v.min+_}):lXe(o,t.layoutBox,n)&&Kg(g=>{const v=l?t.measuredBox[g]:t.layoutBox[g],_=xh(n[g]);v.max=v.min+_,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[g].max=e.relativeTarget[g].min+_)});const i=l4();vI(i,n,t.layoutBox);const d=l4();l?vI(d,e.applyTransform(a,!0),t.measuredBox):vI(d,n,t.layoutBox);const m=!rXe(i);let p=!1;if(!e.resumeFrom){const g=e.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:v,layout:_}=g;if(v&&_){const k=vd();Tae(k,t.layoutBox,v.layoutBox);const w=vd();Tae(w,n,_.layoutBox),sXe(k,w)||(p=!0),g.options.layoutRoot&&(e.relativeTarget=w,e.relativeTargetOrigin=k,e.relativeParent=g)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:d,layoutDelta:i,hasLayoutChanged:m,hasRelativeLayoutChanged:p})}else if(e.isLead()){const{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function Jur(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function ehr(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function thr(e){e.clearSnapshot()}function FPe(e){e.clearMeasurements()}function zPe(e){e.isLayoutDirty=!1}function rhr(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function BPe(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function shr(e){e.resolveTargetDelta()}function nhr(e){e.calcProjection()}function ahr(e){e.resetSkewAndRotation()}function ihr(e){e.removeLeadSnapshot()}function $Pe(e,t,s){e.translate=Zl(t.translate,0,s),e.scale=Zl(t.scale,1,s),e.origin=t.origin,e.originPoint=t.originPoint}function UPe(e,t,s,n){e.min=Zl(t.min,s.min,n),e.max=Zl(t.max,s.max,n)}function ohr(e,t,s,n){UPe(e.x,t.x,s.x,n),UPe(e.y,t.y,s.y,n)}function lhr(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const chr={duration:.45,ease:[.4,0,.1,1]},VPe=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),qPe=VPe("applewebkit/")&&!VPe("chrome/")?Math.round:Hf;function HPe(e){e.min=qPe(e.min),e.max=qPe(e.max)}function dhr(e){HPe(e.x),HPe(e.y)}function lXe(e,t,s){return e==="position"||e==="preserve-aspect"&&!Pur(PPe(t),PPe(s),.2)}function uhr(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const hhr=oXe({attachResizeListener:(e,t)=>r6(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),mme={current:void 0},cXe=oXe({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!mme.current){const e=new hhr({});e.mount(window),e.setOptions({layoutScroll:!0}),mme.current=e}return mme.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),dXe=A.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function mhr(e=!0){const t=A.useContext(qbe);if(t===null)return[!0,null];const{isPresent:s,onExitComplete:n,register:a}=t,o=A.useId();A.useEffect(()=>{if(e)return a(o)},[e]);const l=A.useCallback(()=>e&&n&&n(o),[o,n,e]);return!s&&n?[!1,l]:[!0]}const uXe=A.createContext({strict:!1}),WPe={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 GPe=!1;function fhr(){if(GPe)return;const e={};for(const t in WPe)e[t]={isEnabled:s=>WPe[t].some(n=>!!s[n])};BYe(e),GPe=!0}function hXe(){return fhr(),aur()}function phr(e){const t=hXe();for(const s in e)t[s]={...t[s],...e[s]};BYe(t)}const ghr=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 Aae(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||ghr.has(e)}let mXe=e=>!Aae(e);function xhr(e){typeof e=="function"&&(mXe=t=>t.startsWith("on")?!Aae(t):e(t))}try{xhr(require("@emotion/is-prop-valid").default)}catch{}function yhr(e,t,s){const n={};for(const a in e)a==="values"&&typeof e.values=="object"||(mXe(a)||s===!0&&Aae(a)||!t&&!Aae(a)||e.draggable&&a.startsWith("onDrag"))&&(n[a]=e[a]);return n}const wle=A.createContext({});function vhr(e,t){if(ble(e)){const{initial:s,animate:n}=e;return{initial:s===!1||t6(s)?s:void 0,animate:t6(n)?n:void 0}}return e.inherit!==!1?t:{}}function _hr(e){const{initial:t,animate:s}=vhr(e,A.useContext(wle));return A.useMemo(()=>({initial:t,animate:s}),[KPe(t),KPe(s)])}function KPe(e){return Array.isArray(e)?e.join(" "):e}const xwe=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function fXe(e,t,s){for(const n in t)!Iu(t[n])&&!GYe(n,s)&&(e[n]=t[n])}function bhr({transformTemplate:e},t){return A.useMemo(()=>{const s=xwe();return pwe(s,t,e),Object.assign({},s.vars,s.style)},[t])}function whr(e,t){const s=e.style||{},n={};return fXe(n,s,e),Object.assign(n,bhr(e,t)),n}function jhr(e,t){const s={},n=whr(e,t);return e.drag&&e.dragListener!==!1&&(s.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(s.tabIndex=0),s.style=n,s}const pXe=()=>({...xwe(),attrs:{}});function khr(e,t,s,n){const a=A.useMemo(()=>{const o=pXe();return KYe(o,t,YYe(n),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};fXe(o,e.style,e),a.style={...o,...a.style}}return a}const Nhr=["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 ywe(e){return typeof e!="string"||e.includes("-")?!1:!!(Nhr.indexOf(e)>-1||/[A-Z]/u.test(e))}function Shr(e,t,s,{latestValues:n},a,o=!1,l){const d=(l??ywe(e)?khr:jhr)(t,n,a,e),m=yhr(t,typeof e=="string",o),p=e!==A.Fragment?{...m,...d,ref:s}:{},{children:g}=t,v=A.useMemo(()=>Iu(g)?g.get():g,[g]);return A.createElement(e,{...p,children:v})}function Chr({scrapeMotionValuesFromProps:e,createRenderState:t},s,n,a){return{latestValues:Mhr(s,n,a,e),renderState:t()}}function Mhr(e,t,s,n){const a={},o=n(e,{});for(const v in o)a[v]=wre(o[v]);let{initial:l,animate:i}=e;const d=ble(e),m=FYe(e);t&&m&&!d&&e.inherit!==!1&&(l===void 0&&(l=t.initial),i===void 0&&(i=t.animate));let p=s?s.initial===!1:!1;p=p||l===!1;const g=p?i:l;if(g&&typeof g!="boolean"&&!_le(g)){const v=Array.isArray(g)?g:[g];for(let _=0;_(t,s)=>{const n=A.useContext(wle),a=A.useContext(qbe),o=()=>Chr(e,t,n,a);return s?o():Tlr(o)},Thr=gXe({scrapeMotionValuesFromProps:gwe,createRenderState:xwe}),Ahr=gXe({scrapeMotionValuesFromProps:XYe,createRenderState:pXe}),Ehr=Symbol.for("motionComponentSymbol");function Ihr(e,t,s){const n=A.useRef(s);A.useInsertionEffect(()=>{n.current=s});const a=A.useRef(null);return A.useCallback(o=>{var i;o&&((i=e.onMount)==null||i.call(e,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);t&&(o?t.mount(o):t.unmount())},[t])}const xXe=A.createContext({});function zC(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Phr(e,t,s,n,a,o){var I,R;const{visualElement:l}=A.useContext(wle),i=A.useContext(uXe),d=A.useContext(qbe),m=A.useContext(dXe),p=m.reducedMotion,g=m.skipAnimations,v=A.useRef(null),_=A.useRef(!1);n=n||i.renderer,!v.current&&n&&(v.current=n(e,{visualState:t,parent:l,props:s,presenceContext:d,blockInitialAnimation:d?d.initial===!1:!1,reducedMotionConfig:p,skipAnimations:g,isSVG:o}),_.current&&v.current&&(v.current.manuallyAnimateOnMount=!0));const k=v.current,w=A.useContext(xXe);k&&!k.projection&&a&&(k.type==="html"||k.type==="svg")&&Lhr(v.current,s,a,w);const S=A.useRef(!1);A.useInsertionEffect(()=>{k&&S.current&&k.update(s,d)});const T=s[NYe],C=A.useRef(!!T&&typeof window<"u"&&!((I=window.MotionHandoffIsComplete)!=null&&I.call(window,T))&&((R=window.MotionHasOptimisedAnimation)==null?void 0:R.call(window,T)));return Elr(()=>{_.current=!0,k&&(S.current=!0,window.MotionIsMounted=!0,k.updateFeatures(),k.scheduleRenderMicrotask(),C.current&&k.animationState&&k.animationState.animateChanges())}),A.useEffect(()=>{k&&(!C.current&&k.animationState&&k.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var D;(D=window.MotionHandoffMarkAsComplete)==null||D.call(window,T)}),C.current=!1),k.enteringChildren=void 0)}),k}function Lhr(e,t,s,n){const{layoutId:a,layout:o,drag:l,dragConstraints:i,layoutScroll:d,layoutRoot:m,layoutCrossfade:p}=t;e.projection=new s(e.latestValues,t["data-framer-portal-id"]?void 0:yXe(e.parent)),e.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&zC(i),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:p,layoutScroll:d,layoutRoot:m})}function yXe(e){if(e)return e.options.allowProjection!==!1?e.projection:yXe(e.parent)}function fme(e,{forwardMotionProps:t=!1,type:s}={},n,a){n&&phr(n);const o=s?s==="svg":ywe(e),l=o?Ahr:Thr;function i(m,p){let g;const v={...A.useContext(dXe),...m,layoutId:Dhr(m)},{isStatic:_}=v,k=_hr(m),w=l(m,_);if(!_&&typeof window<"u"){Ohr();const S=Rhr(v);g=S.MeasureLayout,k.visualElement=Phr(e,w,v,a,S.ProjectionNode,o)}return r.jsxs(wle.Provider,{value:k,children:[g&&k.visualElement?r.jsx(g,{visualElement:k.visualElement,...v}):null,Shr(e,m,Ihr(w,k.visualElement,p),w,_,t,o)]})}i.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const d=A.forwardRef(i);return d[Ehr]=e,d}function Dhr({layoutId:e}){const t=A.useContext(FZe).id;return t&&e!==void 0?t+"-"+e:e}function Ohr(e,t){A.useContext(uXe).strict}function Rhr(e){const t=hXe(),{drag:s,layout:n}=t;if(!s&&!n)return{};const a={...s,...n};return{MeasureLayout:s!=null&&s.isEnabled(e)||n!=null&&n.isEnabled(e)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}function Fhr(e,t){if(typeof Proxy>"u")return fme;const s=new Map,n=(o,l)=>fme(o,l,e,t),a=(o,l)=>n(o,l);return new Proxy(a,{get:(o,l)=>l==="create"?n:(s.has(l)||s.set(l,fme(l,void 0,e,t)),s.get(l))})}const zhr=(e,t)=>t.isSVG??ywe(e)?new wur(t):new gur(t,{allowProjection:e!==A.Fragment});class Bhr extends g_{constructor(t){super(t),t.animationState||(t.animationState=Cur(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();_le(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:s}=this.node.prevProps||{};t!==s&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let $hr=0;class Uhr extends g_{constructor(){super(...arguments),this.id=$hr++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:s}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===n)return;const a=this.node.animationState.setActive("exit",!t);s&&!t&&a.then(()=>{s(this.id)})}mount(){const{register:t,onExitComplete:s}=this.node.presenceContext||{};s&&s(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Vhr={animation:{Feature:Bhr},exit:{Feature:Uhr}};function eL(e){return{point:{x:e.pageX,y:e.pageY}}}const qhr=e=>t=>uwe(t)&&e(t,eL(t));function _I(e,t,s,n){return r6(e,t,qhr(s),n)}const vXe=({current:e})=>e?e.ownerDocument.defaultView:null,ZPe=(e,t)=>Math.abs(e-t);function Hhr(e,t){const s=ZPe(e.x,t.x),n=ZPe(e.y,t.y);return Math.sqrt(s**2+n**2)}const YPe=new Set(["auto","scroll"]);class _Xe{constructor(t,s,{transformPagePoint:n,contextWindow:a=window,dragSnapToOrigin:o=!1,distanceThreshold:l=3,element:i}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=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;const _=gme(this.lastMoveEventInfo,this.history),k=this.startEvent!==null,w=Hhr(_.offset,{x:0,y:0})>=this.distanceThreshold;if(!k&&!w)return;const{point:S}=_,{timestamp:T}=cu;this.history.push({...S,timestamp:T});const{onStart:C,onMove:I}=this.handlers;k||(C&&C(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),I&&I(this.lastMoveEvent,_)},this.handlePointerMove=(_,k)=>{this.lastMoveEvent=_,this.lastMoveEventInfo=pme(k,this.transformPagePoint),hl.update(this.updatePoint,!0)},this.handlePointerUp=(_,k)=>{this.end();const{onEnd:w,onSessionEnd:S,resumeAnimation:T}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&T&&T(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=gme(_.type==="pointercancel"?this.lastMoveEventInfo:pme(k,this.transformPagePoint),this.history);this.startEvent&&w&&w(_,C),S&&S(_,C)},!uwe(t))return;this.dragSnapToOrigin=o,this.handlers=s,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const d=eL(t),m=pme(d,this.transformPagePoint),{point:p}=m,{timestamp:g}=cu;this.history=[{...p,timestamp:g}];const{onSessionStart:v}=s;v&&v(t,gme(m,this.history)),this.removeListeners=X6(_I(this.contextWindow,"pointermove",this.handlePointerMove),_I(this.contextWindow,"pointerup",this.handlePointerUp),_I(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(t){let s=t.parentElement;for(;s;){const n=getComputedStyle(s);(YPe.has(n.overflowX)||YPe.has(n.overflowY))&&this.scrollPositions.set(s,{x:s.scrollLeft,y:s.scrollTop}),s=s.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(t){const s=this.scrollPositions.get(t);if(!s)return;const n=t===window,a=n?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},o={x:a.x-s.x,y:a.y-s.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(t,a),hl.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Z1(this.updatePoint)}}function pme(e,t){return t?{point:t(e.point)}:e}function XPe(e,t){return{x:e.x-t.x,y:e.y-t.y}}function gme({point:e},t){return{point:e,delta:XPe(e,bXe(t)),offset:XPe(e,Whr(t)),velocity:Ghr(t,.1)}}function Whr(e){return e[0]}function bXe(e){return e[e.length-1]}function Ghr(e,t){if(e.length<2)return{x:0,y:0};let s=e.length-1,n=null;const a=bXe(e);for(;s>=0&&(n=e[s],!(a.timestamp-n.timestamp>lg(t)));)s--;if(!n)return{x:0,y:0};n===e[0]&&e.length>2&&a.timestamp-n.timestamp>lg(t)*2&&(n=e[1]);const o=Ef(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 Khr(e,{min:t,max:s},n){return t!==void 0&&es&&(e=n?Zl(s,e,n.max):Math.min(e,s)),e}function QPe(e,t,s){return{min:t!==void 0?e.min+t:void 0,max:s!==void 0?e.max+s-(e.max-e.min):void 0}}function Zhr(e,{top:t,left:s,bottom:n,right:a}){return{x:QPe(e.x,s,a),y:QPe(e.y,t,n)}}function JPe(e,t){let s=t.min-e.min,n=t.max-e.max;return t.max-t.minn?s=QP(t.min,t.max-n,e.min):n>a&&(s=QP(e.min,e.max-a,t.min)),Ax(0,1,s)}function Qhr(e,t){const s={};return t.min!==void 0&&(s.min=t.min-e.min),t.max!==void 0&&(s.max=t.max-e.min),s}const Mye=.35;function Jhr(e=Mye){return e===!1?e=0:e===!0&&(e=Mye),{x:e6e(e,"left","right"),y:e6e(e,"top","bottom")}}function e6e(e,t,s){return{min:t6e(e,t),max:t6e(e,s)}}function t6e(e,t){return typeof e=="number"?e:e[t]||0}const emr=new WeakMap;class tmr{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=vd(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:s=!1,distanceThreshold:n}={}){const{presenceContext:a}=this.visualElement;if(a&&a.isPresent===!1)return;const o=g=>{s&&this.snapToCursor(eL(g).point),this.stopAnimation()},l=(g,v)=>{const{drag:_,dragPropagation:k,onDragStart:w}=this.getProps();if(_&&!k&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ddr(_),!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),Kg(T=>{let C=this.getAxisMotionValue(T).get()||0;if(bx.test(C)){const{projection:I}=this.visualElement;if(I&&I.layout){const R=I.layout.layoutBox[T];R&&(C=xh(R)*(parseFloat(C)/100))}}this.originPoint[T]=C}),w&&hl.update(()=>w(g,v),!1,!0),_ye(this.visualElement,"transform");const{animationState:S}=this.visualElement;S&&S.setActive("whileDrag",!0)},i=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v;const{dragPropagation:_,dragDirectionLock:k,onDirectionLock:w,onDrag:S}=this.getProps();if(!_&&!this.openDragLock)return;const{offset:T}=v;if(k&&this.currentDirection===null){this.currentDirection=smr(T),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",v.point,T),this.updateAxis("y",v.point,T),this.visualElement.render(),S&&hl.update(()=>S(g,v),!1,!0)},d=(g,v)=>{this.latestPointerEvent=g,this.latestPanInfo=v,this.stop(g,v),this.latestPointerEvent=null,this.latestPanInfo=null},m=()=>{const{dragSnapToOrigin:g}=this.getProps();(g||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new _Xe(t,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:d,resumeAnimation:m},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:vXe(this.visualElement),element:this.visualElement.current})}stop(t,s){const n=t||this.latestPointerEvent,a=s||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&&hl.postRender(()=>i(n,a))}cancel(){this.isDragging=!1;const{projection:t,animationState:s}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),s&&s.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,s,n){const{drag:a}=this.getProps();if(!n||!x8(t,a,this.currentDirection))return;const o=this.getAxisMotionValue(t);let l=this.originPoint[t]+n[t];this.constraints&&this.constraints[t]&&(l=Khr(l,this.constraints[t],this.elastic[t])),o.set(l)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:s}=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;t&&zC(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&n?this.constraints=Zhr(n.layoutBox,t):this.constraints=!1,this.elastic=Jhr(s),a!==this.constraints&&!zC(t)&&n&&this.constraints&&!this.hasMutatedConstraints&&Kg(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=Qhr(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:s}=this.getProps();if(!t||!zC(t))return!1;const n=t.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=dur(n,a.root,this.visualElement.getTransformPagePoint());let l=Yhr(a.layout.layoutBox,o);if(s){const i=s(our(l));this.hasMutatedConstraints=!!i,i&&(l=UYe(i))}return l}startAnimation(t){const{drag:s,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),d=this.constraints||{},m=Kg(p=>{if(!x8(p,s,this.currentDirection))return;let g=d&&d[p]||{};l&&(g={min:0,max:0});const v=a?200:1e6,_=a?40:1e7,k={type:"inertia",velocity:n?t[p]:0,bounceStiffness:v,bounceDamping:_,timeConstant:750,restDelta:1,restSpeed:10,...o,...g};return this.startAxisValueAnimation(p,k)});return Promise.all(m).then(i)}startAxisValueAnimation(t,s){const n=this.getAxisMotionValue(t);return _ye(this.visualElement,t),n.start(iwe(t,n,0,s,this.visualElement,!1))}stopAnimation(){Kg(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const s=`_drag${t.toUpperCase()}`,n=this.visualElement.getProps(),a=n[s];return a||this.visualElement.getValue(t,(n.initial?n.initial[t]:void 0)||0)}snapToCursor(t){Kg(s=>{const{drag:n}=this.getProps();if(!x8(s,n,this.currentDirection))return;const{projection:a}=this.visualElement,o=this.getAxisMotionValue(s);if(a&&a.layout){const{min:l,max:i}=a.layout.layoutBox[s],d=o.get()||0;o.set(t[s]-Zl(l,i,.5)+d)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:s}=this.getProps(),{projection:n}=this.visualElement;if(!zC(s)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Kg(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const d=i.get();a[l]=Xhr({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(),Kg(l=>{if(!x8(l,t,null))return;const i=this.getAxisMotionValue(l),{min:d,max:m}=this.constraints[l];i.set(Zl(d,m,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;emr.set(this.visualElement,this);const t=this.visualElement.current,s=_I(t,"pointerdown",m=>{const{drag:p,dragListener:g=!0}=this.getProps(),v=m.target,_=v!==t&&$dr(v);p&&g&&!_&&this.start(m)});let n;const a=()=>{const{dragConstraints:m}=this.getProps();zC(m)&&m.current&&(this.constraints=this.resolveRefConstraints(),n||(n=rmr(t,m.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),hl.read(a);const i=r6(window,"resize",()=>this.scalePositionWithinConstraints()),d=o.addEventListener("didUpdate",({delta:m,hasLayoutChanged:p})=>{this.isDragging&&p&&(Kg(g=>{const v=this.getAxisMotionValue(g);v&&(this.originPoint[g]+=m[g].translate,v.set(v.get()+m[g].translate))}),this.visualElement.render())});return()=>{i(),s(),l(),d&&d(),n&&n()}}getProps(){const t=this.visualElement.getProps(),{drag:s=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:o=!1,dragElastic:l=Mye,dragMomentum:i=!0}=t;return{...t,drag:s,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function r6e(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function rmr(e,t,s){const n=dPe(e,r6e(s)),a=dPe(t,r6e(s));return()=>{n(),a()}}function x8(e,t,s){return(t===!0||t===e)&&(s===null||s===e)}function smr(e,t=10){let s=null;return Math.abs(e.y)>t?s="y":Math.abs(e.x)>t&&(s="x"),s}class nmr extends g_{constructor(t){super(t),this.removeGroupControls=Hf,this.removeListeners=Hf,this.controls=new tmr(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hf}update(){const{dragControls:t}=this.node.getProps(),{dragControls:s}=this.node.prevProps||{};t!==s&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const xme=e=>(t,s)=>{e&&hl.update(()=>e(t,s),!1,!0)};class amr extends g_{constructor(){super(...arguments),this.removePointerDownListener=Hf}onPointerDown(t){this.session=new _Xe(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:vXe(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:s,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:xme(t),onStart:xme(s),onMove:xme(n),onEnd:(o,l)=>{delete this.session,a&&hl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=_I(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let yme=!1;class imr extends A.Component{componentDidMount(){const{visualElement:t,layoutGroup:s,switchLayoutGroup:n,layoutId:a}=this.props,{projection:o}=t;o&&(s.group&&s.group.add(o),n&&n.register&&a&&n.register(o),yme&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),jre.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:s,visualElement:n,drag:a,isPresent:o}=this.props,{projection:l}=n;return l&&(l.isPresent=o,t.layoutDependency!==s&&l.setOptions({...l.options,layoutDependency:s}),yme=!0,a||t.layoutDependency!==s||s===void 0||t.isPresent!==o?l.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?l.promote():l.relegate()||hl.postRender(()=>{const i=l.getStack();(!i||!i.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),dwe.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:s,switchLayoutGroup:n}=this.props,{projection:a}=t;yme=!0,a&&(a.scheduleCheckAfterUnmount(),s&&s.group&&s.group.remove(a),n&&n.deregister&&n.deregister(a))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function wXe(e){const[t,s]=mhr(),n=A.useContext(FZe);return r.jsx(imr,{...e,layoutGroup:n,switchLayoutGroup:A.useContext(xXe),isPresent:t,safeToRemove:s})}const omr={pan:{Feature:amr},drag:{Feature:nmr,ProjectionNode:cXe,MeasureLayout:wXe}};function s6e(e,t,s){const{props:n}=e;e.animationState&&n.whileHover&&e.animationState.setActive("whileHover",s==="Start");const a="onHover"+s,o=n[a];o&&hl.postRender(()=>o(t,eL(t)))}class lmr extends g_{mount(){const{current:t}=this.node;t&&(this.unmount=Rdr(t,(s,n)=>(s6e(this.node,n,"Start"),a=>s6e(this.node,a,"End"))))}unmount(){}}class cmr extends g_{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=X6(r6(this.node.current,"focus",()=>this.onFocus()),r6(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function n6e(e,t,s){const{props:n}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&n.whileTap&&e.animationState.setActive("whileTap",s==="Start");const a="onTap"+(s==="End"?"":s),o=n[a];o&&hl.postRender(()=>o(t,eL(t)))}class dmr extends g_{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:s,propagate:n}=this.node.props;this.unmount=Vdr(t,(a,o)=>(n6e(this.node,o,"Start"),(l,{success:i})=>n6e(this.node,l,i?"End":"Cancel")),{useGlobalTarget:s,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const Tye=new WeakMap,vme=new WeakMap,umr=e=>{const t=Tye.get(e.target);t&&t(e)},hmr=e=>{e.forEach(umr)};function mmr({root:e,...t}){const s=e||document;vme.has(s)||vme.set(s,{});const n=vme.get(s),a=JSON.stringify(t);return n[a]||(n[a]=new IntersectionObserver(hmr,{root:e,...t})),n[a]}function fmr(e,t,s){const n=mmr(t);return Tye.set(e,s),n.observe(e),()=>{Tye.delete(e),n.unobserve(e)}}const pmr={some:0,all:1};class gmr extends g_{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:s,margin:n,amount:a="some",once:o}=t,l={root:s?s.current:void 0,rootMargin:n,threshold:typeof a=="number"?a:pmr[a]},i=d=>{const{isIntersecting:m}=d;if(this.isInView===m||(this.isInView=m,o&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:p,onViewportLeave:g}=this.node.getProps(),v=m?p:g;v&&v(d)};return fmr(this.node.current,l,i)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:s}=this.node;["amount","margin","root"].some(xmr(t,s))&&this.startObserver()}unmount(){}}function xmr({viewport:e={}},{viewport:t={}}={}){return s=>e[s]!==t[s]}const ymr={inView:{Feature:gmr},tap:{Feature:dmr},focus:{Feature:cmr},hover:{Feature:lmr}},vmr={layout:{ProjectionNode:cXe,MeasureLayout:wXe}},_mr={...Vhr,...ymr,...omr,...vmr},Ln=Fhr(_mr,zhr),bmr=[{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 wmr({onSelect:e}){return r.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:bmr.map((t,s)=>r.jsxs(Ln.button,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:s*.04,duration:.25},onClick:()=>e(t.type),className:`group relative flex flex-col items-start gap-1 p-3.5 rounded-xl border bg-gradient-to-br ${t.gradient} hover:shadow-md hover:scale-[1.02] active:scale-[0.98] transition-all text-left`,children:[r.jsx("span",{className:"text-2xl",children:t.emoji}),r.jsx("span",{className:"text-sm font-semibold text-foreground",children:t.label}),r.jsx("span",{className:"text-[11px] text-muted-foreground leading-tight",children:t.description})]},t.type))})}const jle={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 a6e({initialOpen:e,initialCardType:t,initialContactId:s,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Gr(),d=Rr(),[m,p]=A.useState(!1),[g,v]=A.useState("type"),[_,k]=A.useState(""),[w,S]=A.useState(null),[T,C]=A.useState(!1),[I,R]=A.useState("home_anniversary"),[D,B]=A.useState(""),[$,q]=A.useState(""),[W,K]=A.useState(""),[re,ae]=A.useState(""),[oe,se]=A.useState("elegant"),[pe,ie]=A.useState(null),[de,ce]=A.useState(null),ge=A.useState(!1);!ge[0]&&e&&t&&(ge[1](!0),p(!0),R(t),s&&S(s),n&&B(n),a&&q(a),o&&K(o),v(n?"details":"contact"));const{data:Te}=Ht({queryKey:["contacts-for-card",i==null?void 0:i.id,_],queryFn:async()=>{let We=Y.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);_&&(We=We.or(`first_name.ilike.%${_}%,last_name.ilike.%${_}%`));const{data:wt,error:Pe}=await We;if(Pe)throw Pe;return wt},enabled:!!(i!=null&&i.id)&&m}),{data:_e}=Ht({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:We,error:wt}=await Y.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(wt)throw wt;return We},enabled:!!(i!=null&&i.id)}),ve=We=>{S(We.id),B(`${We.first_name}${We.last_name?" "+We.last_name:""}`),q([We.address,We.city,We.state].filter(Boolean).join(", ")),K(We.home_anniversary||""),v("details")},Me=We=>{R(We),v("contact")},Ze=async()=>{var We;if(!(!i||!_e)){C(!0);try{const wt={owner_user_id:i.id,contact_id:w,card_type:I,template:oe,recipient_name:D,property_address:$||null,home_anniversary_date:W||null,custom_message:re||null,property_photo_url:pe||null,video_url:de||null,agent_name:_e.name||"Agent",agent_photo_url:_e.avatar_url,agent_phone:_e.phone,agent_email:_e.email,agent_brokerage:((We=_e.brokerage)==null?void 0:We.name)||null},{error:Pe}=await Y.from("sendable_cards").insert(wt);if(Pe)throw Pe;we.success("Card created! Copy the link to share it."),d.invalidateQueries({queryKey:["sendable-cards"]}),Ae()}catch(wt){we.error(wt.message||"Failed to create card")}finally{C(!1)}}},Ae=()=>{p(!1),v("type"),R("home_anniversary"),k(""),S(null),B(""),q(""),K(""),ae(""),se("elegant"),ie(null),ce(null)},Le={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"},Ue=jle[I],Ve=I==="home_anniversary",Ie=["home_anniversary","just_listed","just_sold"].includes(I);return r.jsxs(Ir,{open:m,onOpenChange:We=>{We?p(!0):(Ae(),l==null||l(!1))},children:[r.jsx(Qi,{asChild:!0,children:r.jsxs(X,{className:"gap-2",children:[r.jsx(gs,{className:"h-4 w-4"}),"Create Card"]})}),r.jsxs(Er,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:g==="type"?"What type of card?":g==="contact"?`${Le[I]} — Choose a Contact`:`${Le[I]} — Customize`})}),g==="type"&&r.jsx(wmr,{onSelect:Me}),g==="contact"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs(X,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("type"),children:[r.jsx(gi,{className:"h-3.5 w-3.5"})," Back to card types"]}),r.jsxs("div",{className:"relative",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search contacts...",value:_,onChange:We=>k(We.target.value),className:"pl-9"})]}),r.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[Te==null?void 0:Te.map(We=>r.jsxs("button",{onClick:()=>ve(We),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-accent text-left transition-colors",children:[r.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:r.jsx(Fl,{className:"h-4 w-4 text-primary"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("p",{className:"text-sm font-medium truncate",children:[We.first_name," ",We.last_name]}),We.address&&r.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[r.jsx(Vn,{className:"h-3 w-3"}),We.address]})]}),We.home_anniversary&&I==="home_anniversary"&&r.jsx("span",{className:"text-[10px] text-emerald-600 bg-emerald-500/10 px-2 py-0.5 rounded-full shrink-0",children:"Anniversary set"})]},We.id)),(Te==null?void 0:Te.length)===0&&r.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No contacts found"})]}),r.jsx("div",{className:"border-t pt-3",children:r.jsx(X,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{v("details")},children:"Skip — enter details manually"})})]}),g==="details"&&r.jsxs("div",{className:"space-y-4",children:[r.jsxs(X,{variant:"ghost",size:"sm",className:"gap-1.5 -ml-2 text-muted-foreground",onClick:()=>v("contact"),children:[r.jsx(gi,{className:"h-3.5 w-3.5"})," Back"]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Recipient Name"}),r.jsx(Ye,{value:D,onChange:We=>B(We.target.value),placeholder:"John & Jane Smith"})]}),Ie&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Property Address"}),r.jsx(Ye,{value:$,onChange:We=>q(We.target.value),placeholder:"123 Main St, Austin, TX"})]}),Ve&&r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Home Anniversary Date"}),r.jsx(Ye,{type:"date",value:W,onChange:We=>K(We.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Personal Message (optional)"}),r.jsx(qs,{value:re,onChange:We=>ae(We.target.value),placeholder:Ue.defaultMessage,rows:3})]}),r.jsx(RZe,{photoUrl:pe,videoUrl:de,onPhotoChange:ie,onVideoChange:ce,contactId:w}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Template Style"}),r.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(We=>r.jsxs("button",{onClick:()=>se(We),className:`p-3 rounded-lg border-2 transition-all text-center ${oe===We?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[r.jsx("div",{className:`h-12 rounded-md mb-2 ${We==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":We==="bold"?"bg-gradient-to-br from-violet-500 to-fuchsia-500":"bg-gradient-to-br from-amber-200 to-orange-300"}`}),r.jsx("span",{className:"text-xs font-medium capitalize",children:We})]},We))})]}),r.jsxs("div",{className:"flex gap-2 pt-2",children:[r.jsx(X,{variant:"outline",onClick:()=>v("contact"),className:"flex-1",children:"Back"}),r.jsx(X,{onClick:Ze,disabled:!D||T,className:"flex-1 gap-2",children:T?"Creating...":"Create Card"})]})]})]})]})}const jmr={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 kmr({card:e}){const{user:t}=Gr(),{isGmailConnected:s}=kN(),n=Rr(),[a,o]=A.useState(!1),[l,i]=A.useState("");A.useEffect(()=>{a&&e.contact_id&&!l&&Y.from("innercircle_contacts").select("email").eq("id",e.contact_id).maybeSingle().then(({data:w})=>{w!=null&&w.email&&i(w.email)})},[a,e.contact_id]);const d={home_anniversary:`🏡 Happy Home Anniversary, ${e.recipient_name}!`,just_listed:`🏠 Just Listed — Check This Out, ${e.recipient_name}!`,just_sold:`🎉 Just Sold! Congrats, ${e.recipient_name}!`,congratulations:`🏆 Congratulations, ${e.recipient_name}!`,birthday:`🎂 Happy Birthday, ${e.recipient_name}!`,holiday:`🎄 Happy Holidays, ${e.recipient_name}!`,thank_you:`💐 Thank You, ${e.recipient_name}!`,thinking_of_you:`💭 Thinking of You, ${e.recipient_name}!`},[m,p]=A.useState(d[e.card_type]||`A Special Card for ${e.recipient_name}!`),[g,v]=A.useState(""),_=`https://cardstudio.relevelup.com/c/${e.share_token}`,k=Qt({mutationFn:async()=>{var I;if(!l)throw new Error("Recipient email is required");const w=`
${g?`

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


`:""}

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

${e.property_address?`

${e.property_address}

`:""}
`,{data:S}=await Y.auth.getSession(),T=(I=S==null?void 0:S.session)==null?void 0:I.access_token,C=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${T}`},body:JSON.stringify({to:l,subject:m,body:w,contactId:e.contact_id||void 0})});if(!C.ok){const R=await C.json();throw new Error(R.error||"Failed to send")}return C.json()},onSuccess:async()=>{await Y.from("sendable_cards").update({sent_at:new Date().toISOString(),sent_via:"gmail"}).eq("id",e.id),n.invalidateQueries({queryKey:["sendable-cards"]}),we.success(`Card sent to ${l}!`),o(!1)},onError:w=>{we.error(w.message||"Failed to send email")}});return s?r.jsxs(Ir,{open:a,onOpenChange:o,children:[r.jsx(Qi,{asChild:!0,children:r.jsx(X,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:r.jsx(ai,{className:"h-3 w-3"})})}),r.jsxs(Er,{className:"sm:max-w-md",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Send Card via Gmail"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"To"}),r.jsx(Ye,{type:"email",value:l,onChange:w=>i(w.target.value),placeholder:"recipient@email.com"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Subject"}),r.jsx(Ye,{value:m,onChange:w=>p(w.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Personal Note (optional)"}),r.jsx(qs,{value:g,onChange:w=>v(w.target.value),placeholder:"Add a warm personal note before the card link...",rows:3})]}),r.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:",r.jsx("br",{}),r.jsx("span",{className:"font-mono text-foreground",children:_})]}),r.jsx(X,{onClick:()=>k.mutate(),disabled:!l||k.isPending,className:"w-full gap-2",children:k.isPending?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 animate-spin"})," Sending..."]}):r.jsxs(r.Fragment,{children:[r.jsx(ai,{className:"h-4 w-4"})," Send Card"]})})]})]})]}):r.jsx(X,{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:r.jsx(ai,{className:"h-3 w-3"})})}function Nmr({card:e}){const t=Rr(),[s,n]=A.useState(!1),[a,o]=A.useState(!1),[l,i]=A.useState(e.recipient_name),[d,m]=A.useState(e.property_address||""),[p,g]=A.useState(e.home_anniversary_date||""),[v,_]=A.useState(e.custom_message||""),[k,w]=A.useState(e.template),[S,T]=A.useState(e.property_photo_url),[C,I]=A.useState(e.video_url||null),R=B=>{B&&(i(e.recipient_name),m(e.property_address||""),g(e.home_anniversary_date||""),_(e.custom_message||""),w(e.template),T(e.property_photo_url),I(e.video_url||null)),n(B)},D=async()=>{if(!l.trim()){we.error("Recipient name is required");return}o(!0);try{const{error:B}=await Y.from("sendable_cards").update({recipient_name:l.trim(),property_address:d.trim()||null,home_anniversary_date:p||null,custom_message:v.trim()||null,template:k,property_photo_url:S||null,video_url:C||null}).eq("id",e.id);if(B)throw B;t.invalidateQueries({queryKey:["sendable-cards"]}),we.success("Card updated"),n(!1)}catch(B){we.error(B.message||"Failed to update card")}finally{o(!1)}};return r.jsxs(Ir,{open:s,onOpenChange:R,children:[r.jsx(Qi,{asChild:!0,children:r.jsx(X,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:r.jsx(Qa,{className:"h-3 w-3"})})}),r.jsxs(Er,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[r.jsx(zr,{children:r.jsx(Fr,{children:"Edit Card"})}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Recipient Name"}),r.jsx(Ye,{value:l,onChange:B=>i(B.target.value),placeholder:"John & Jane Smith"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Property Address"}),r.jsx(Ye,{value:d,onChange:B=>m(B.target.value),placeholder:"123 Main St, Austin, TX"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Home Anniversary Date"}),r.jsx(Ye,{type:"date",value:p,onChange:B=>g(B.target.value)})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Personal Message (optional)"}),r.jsx(qs,{value:v,onChange:B=>_(B.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),r.jsx(RZe,{photoUrl:S,videoUrl:C,onPhotoChange:T,onVideoChange:I,contactId:e.contact_id}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ee,{children:"Template Style"}),r.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(B=>r.jsxs("button",{onClick:()=>w(B),className:`p-3 rounded-lg border-2 transition-all text-center ${k===B?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[r.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"}`}),r.jsx("span",{className:"text-xs font-medium capitalize",children:B})]},B))})]}),r.jsx(X,{onClick:D,disabled:!l.trim()||a,className:"w-full gap-2",children:a?r.jsxs(r.Fragment,{children:[r.jsx($r,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function Smr(){const{user:e}=Gr(),t=Rr(),[s,n]=A.useState(""),[a,o]=Cc(),l=a.get("cardType"),i=a.get("contactId"),d=a.get("name"),m=a.get("address"),p=a.get("date"),g=!!l,{data:v,isLoading:_}=Ht({queryKey:["sendable-cards",e==null?void 0:e.id],queryFn:async()=>{const{data:I,error:R}=await Y.from("sendable_cards").select("*").eq("owner_user_id",e.id).order("created_at",{ascending:!1});if(R)throw R;return I},enabled:!!(e!=null&&e.id)}),k=Qt({mutationFn:async I=>{const{error:R}=await Y.from("sendable_cards").delete().eq("id",I);if(R)throw R},onSuccess:()=>{t.invalidateQueries({queryKey:["sendable-cards"]}),we.success("Card deleted")}}),w=I=>{const R=`https://cardstudio.relevelup.com/c/${I}`;navigator.clipboard.writeText(R),we.success("Share link copied!")},S=v==null?void 0:v.filter(I=>{var R;return!s||I.recipient_name.toLowerCase().includes(s.toLowerCase())||((R=I.property_address)==null?void 0:R.toLowerCase().includes(s.toLowerCase()))}),T={elegant:"Elegant",bold:"Bold",warm:"Warm"},C={home_anniversary:"Home Anniversary",just_listed:"Just Listed",just_sold:"Just Sold",congratulations:"Congratulations",birthday:"Birthday",holiday:"Holiday",thank_you:"Thank You",thinking_of_you:"Thinking of You"};return r.jsx(Ur,{title:"Card Studio",children:r.jsxs("div",{className:"max-w-6xl mx-auto space-y-6",children:[r.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Card Studio"}),r.jsx(m1e,{})]}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create & send beautiful branded cards to your clients"})]}),r.jsx(a6e,{initialOpen:g,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:m||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]}),r.jsxs("div",{className:"relative max-w-sm",children:[r.jsx(qn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),r.jsx(Ye,{placeholder:"Search cards...",value:s,onChange:I=>n(I.target.value),className:"pl-9"})]}),_?r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(I=>r.jsx(ze,{className:"animate-pulse",children:r.jsxs(qe,{className:"p-4",children:[r.jsx("div",{className:"h-40 bg-muted rounded-lg mb-3"}),r.jsx("div",{className:"h-4 bg-muted rounded w-2/3 mb-2"}),r.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})},I))}):S!=null&&S.length?r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:S.map(I=>r.jsxs(ze,{className:"group overflow-hidden hover:shadow-lg transition-shadow",children:[r.jsxs("div",{className:`aspect-[16/10] flex items-center justify-center relative overflow-hidden ${I.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":I.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:[I.template==="elegant"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"absolute top-0 left-0 w-full h-full opacity-10",children:[r.jsx("div",{className:"absolute top-3 left-3 w-16 h-16 border-t-2 border-l-2 border-primary/40 rounded-tl-lg"}),r.jsx("div",{className:"absolute bottom-3 right-3 w-16 h-16 border-b-2 border-r-2 border-primary/40 rounded-br-lg"})]}),r.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"})]}),I.template==="bold"&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute -top-8 -right-8 w-32 h-32 rounded-full bg-white/10 blur-sm"}),r.jsx("div",{className:"absolute -bottom-6 -left-6 w-24 h-24 rounded-full bg-white/10 blur-sm"}),r.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.15)_0%,transparent_70%)]"})]}),I.template==="warm"&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute -top-4 -left-4 w-28 h-28 rounded-full bg-orange-400/15 blur-md"}),r.jsx("div",{className:"absolute -bottom-6 -right-6 w-32 h-32 rounded-full bg-rose-400/15 blur-md"})]}),r.jsxs("div",{className:"text-center px-4 relative z-10",children:[r.jsx("div",{className:"text-3xl mb-1.5 opacity-80",children:I.card_type==="home_anniversary"?"🏡":I.card_type==="birthday"?"🎂":I.card_type==="just_sold"?"🎉":I.card_type==="just_listed"?"🏠":I.card_type==="thank_you"?"💐":I.card_type==="congratulations"?"🏆":I.card_type==="holiday"?"🎄":I.card_type==="thinking_of_you"?"💭":"✉️"}),r.jsx("p",{className:`text-[10px] uppercase tracking-[0.2em] mb-1 ${I.template==="bold"?"text-white/70":"text-muted-foreground"}`,children:C[I.card_type]||I.card_type}),r.jsx("p",{className:`font-semibold text-base ${I.template==="bold"?"text-white":"text-foreground"}`,children:I.recipient_name}),I.property_address&&r.jsx("p",{className:`text-xs mt-1 ${I.template==="bold"?"text-white/60":"text-muted-foreground"}`,children:I.property_address})]}),r.jsx("div",{className:"absolute top-2 right-2 z-10",children:r.jsx(_t,{variant:I.template==="bold"?"outline":"secondary",className:`text-[10px] ${I.template==="bold"?"border-white/30 text-white/80":""}`,children:T[I.template]||I.template})})]}),r.jsxs(qe,{className:"p-3",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[r.jsx(Ii,{className:"h-3 w-3"}),I.view_count," views"]}),r.jsx("span",{className:"text-xs text-muted-foreground",children:gu(new Date(I.created_at),{addSuffix:!0})})]}),I.sent_at&&r.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",Xr(new Date(I.sent_at),"MMM d, yyyy")," via ",I.sent_via]}),r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsxs(X,{variant:"outline",size:"sm",className:"flex-1 gap-1 text-xs",onClick:()=>w(I.share_token),children:[r.jsx(uo,{className:"h-3 w-3"}),"Copy Link"]}),r.jsx(Nmr,{card:I}),r.jsx(kmr,{card:I}),r.jsx(X,{variant:"outline",size:"sm",className:"gap-1 text-xs",onClick:()=>window.open(`https://cardstudio.relevelup.com/c/${I.share_token}`,"_blank"),children:r.jsx(jn,{className:"h-3 w-3"})}),r.jsx(X,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive gap-1 text-xs",onClick:()=>k.mutate(I.id),children:r.jsx(Os,{className:"h-3 w-3"})})]})]})]},I.id))}):r.jsx(ze,{className:"border-dashed",children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-16",children:[r.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:r.jsx(Vs,{className:"h-8 w-8 text-primary"})}),r.jsx("h3",{className:"font-semibold text-lg mb-1",children:"No cards yet"}),r.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create your first digital card to send to a client"}),r.jsx(a6e,{initialOpen:g,initialCardType:l,initialContactId:i||void 0,initialRecipientName:d||void 0,initialAddress:m||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function DA({delay:e,x:t,y:s,size:n}){return r.jsx(Ln.div,{className:"absolute rounded-full bg-slate-300/30 dark:bg-slate-500/20",style:{left:t,top:s,width:n,height:n},animate:{y:[0,-20,0],opacity:[.3,.7,.3],scale:[1,1.2,1]},transition:{duration:4,delay:e,repeat:1/0,ease:"easeInOut"}})}function Cmr(e){const{cardType:t,recipientName:s,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:m,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=e,_=jle[t];return r.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:[r.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[r.jsx(Ln.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"}}),r.jsx(Ln.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"}}),r.jsx(DA,{delay:0,x:"15%",y:"20%",size:8}),r.jsx(DA,{delay:1,x:"80%",y:"30%",size:6}),r.jsx(DA,{delay:2,x:"60%",y:"70%",size:10}),r.jsx(DA,{delay:.5,x:"25%",y:"80%",size:7}),r.jsx(DA,{delay:1.5,x:"70%",y:"15%",size:5})]}),r.jsxs(Ln.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:[r.jsxs(Ln.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:[r.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:r.jsx(Ln.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"}})}),r.jsxs("div",{className:"px-8 py-10 text-center",children:[r.jsxs(Ln.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:[r.jsx(Ln.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"}}),r.jsx("span",{className:"text-4xl",children:_.icon})]}),t==="home_anniversary"&&a!==null&&a>0&&r.jsx(Ln.div,{className:"inline-block mb-4",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:.4,delay:.6},children:r.jsxs("span",{className:"text-sm font-semibold tracking-[0.25em] uppercase text-blue-400 dark:text-blue-300",children:[a," ",a===1?"Year":"Years"]})}),r.jsx(Ln.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]&&r.jsx(Ln.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]}),r.jsxs(Ln.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5,delay:1},children:[r.jsx("p",{className:"text-xl font-medium text-slate-700 dark:text-slate-200 mb-1",children:s}),n&&r.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mb-6",children:n})]}),r.jsx(Ln.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&&r.jsx(Ln.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:r.jsx("img",{src:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&r.jsx(Ln.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:r.jsx("iframe",{src:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),r.jsx(Ln.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}),r.jsxs(Ln.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:[r.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?r.jsx(Ln.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}}):r.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:r.jsx("span",{className:"text-sm font-semibold text-slate-600 dark:text-slate-300",children:l.charAt(0)})}),r.jsxs("div",{className:"text-left",children:[r.jsx("p",{className:"text-sm font-semibold text-slate-700 dark:text-slate-200",children:l}),p&&r.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500",children:p})]})]}),r.jsxs("div",{className:"flex items-center justify-center gap-3 mt-4",children:[d&&r.jsxs(Ln.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:[r.jsx(fi,{className:"h-3.5 w-3.5"})," Call"]}),m&&r.jsxs(Ln.a,{href:`mailto:${m}`,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:[r.jsx(Vs,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),r.jsx(Ln.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:e,x:t,y:s,color:n,size:a}){return r.jsx(Ln.div,{className:`absolute rounded-full blur-2xl ${n}`,style:{left:t,top:s,width:a,height:a},animate:{scale:[1,1.4,1],opacity:[.2,.5,.2]},transition:{duration:5,delay:e,repeat:1/0,ease:"easeInOut"}})}function OA({delay:e,x:t,y:s}){return r.jsx(Ln.div,{className:"absolute text-white/30 text-lg",style:{left:t,top:s},animate:{opacity:[0,1,0],scale:[.5,1,.5],rotate:[0,180,360]},transition:{duration:3,delay:e,repeat:1/0,ease:"easeInOut"},children:"✦"})}const i6e={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 Mmr(e){const{cardType:t,recipientName:s,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:m,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=e,_=jle[t],k=i6e[t]||i6e.home_anniversary;return r.jsxs("div",{className:`min-h-screen bg-gradient-to-br ${k.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[r.jsx(_me,{delay:0,x:"10%",y:"10%",color:k.orbs[0],size:200}),r.jsx(_me,{delay:1,x:"70%",y:"60%",color:k.orbs[1],size:180}),r.jsx(_me,{delay:2,x:"50%",y:"20%",color:k.orbs[2],size:150}),r.jsx(OA,{delay:0,x:"20%",y:"25%"}),r.jsx(OA,{delay:.8,x:"75%",y:"15%"}),r.jsx(OA,{delay:1.6,x:"85%",y:"65%"}),r.jsx(OA,{delay:2.4,x:"10%",y:"75%"}),r.jsx(OA,{delay:.4,x:"45%",y:"85%"}),r.jsxs(Ln.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:[r.jsxs(Ln.div,{className:"relative rounded-3xl overflow-hidden",initial:{scale:.9},animate:{scale:1},transition:{duration:.5,delay:.2,type:"spring",stiffness:150},children:[r.jsx(Ln.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%"}}),r.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:[r.jsxs(Ln.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:[r.jsx(Ln.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"}}),r.jsx("span",{className:"text-4xl relative z-10",children:_.icon})]}),t==="home_anniversary"&&a!==null&&a>0&&r.jsxs(Ln.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:[r.jsx(Ln.span,{className:"text-3xl font-black text-white",initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),r.jsx("span",{className:"text-xs font-semibold text-violet-200 uppercase tracking-widest",children:a===1?"Year":"Years"})]}),r.jsx(Ln.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]&&r.jsx(Ln.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]}),r.jsx(Ln.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("")}),r.jsxs(Ln.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[r.jsx("p",{className:"text-xl font-semibold text-white/90 mb-1",children:s}),n&&r.jsxs("p",{className:"text-sm text-violet-300/70 mb-6 flex items-center justify-center gap-1.5",children:[r.jsx(Vn,{className:"h-3.5 w-3.5"}),n]})]}),g&&r.jsx(Ln.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:r.jsx("img",{src:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&r.jsx(Ln.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:r.jsx("iframe",{src:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),r.jsx(Ln.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:r.jsx("p",{className:"text-sm text-violet-100/80 leading-relaxed",children:o||_.defaultMessage})}),r.jsxs(Ln.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[r.jsxs("div",{className:"flex items-center justify-center gap-3",children:[i?r.jsx(Ln.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}}):r.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:r.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),r.jsxs("div",{className:"text-left",children:[r.jsx("p",{className:"text-sm font-bold text-white",children:l}),p&&r.jsx("p",{className:"text-xs text-violet-300/60",children:p})]})]}),r.jsxs("div",{className:"flex items-center justify-center gap-2 mt-5",children:[d&&r.jsxs(Ln.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:[r.jsx(fi,{className:"h-3.5 w-3.5"})," Call Me"]}),m&&r.jsxs(Ln.a,{href:`mailto:${m}`,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:[r.jsx(Vs,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),r.jsx(Ln.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 Tmr({emoji:e,delay:t,x:s,duration:n}){return r.jsx(Ln.div,{className:"absolute text-2xl pointer-events-none",style:{left:s,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:t,repeat:1/0,ease:"easeOut"},children:e})}const o6e={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 Amr(e){const{cardType:t,recipientName:s,propertyAddress:n,anniversaryYears:a,customMessage:o,agentName:l,agentPhotoUrl:i,agentPhone:d,agentEmail:m,agentBrokerage:p,propertyPhotoUrl:g,videoUrl:v}=e,_=jle[t],k=o6e[t]||o6e.home_anniversary;return r.jsxs("div",{className:`min-h-screen bg-gradient-to-b ${k.bg} flex items-center justify-center p-4 overflow-hidden relative`,children:[_.emojis.map((w,S)=>r.jsx(Tmr,{emoji:w,delay:S*1.2,x:`${15+S*14}%`,duration:5+S%3},S)),r.jsx(Ln.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"}}),r.jsxs(Ln.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.7},children:[r.jsxs(Ln.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:[r.jsxs(Ln.div,{className:`h-28 bg-gradient-to-r ${k.header} relative overflow-hidden`,children:[r.jsx(Ln.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"}}),r.jsx(Ln.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]}),r.jsx(Ln.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]}),r.jsx(Ln.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]})]}),r.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[r.jsx(Ln.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:r.jsx(Ln.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:r.jsx("span",{className:"text-3xl",children:_.icon})})}),t==="home_anniversary"&&a!==null&&a>0&&r.jsx(Ln.div,{className:"mb-3",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.6},children:r.jsxs("span",{className:`inline-flex items-baseline gap-1.5 ${k.accent}`,children:[r.jsx(Ln.span,{className:"text-5xl font-black",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.8},children:a}),r.jsx("span",{className:"text-sm font-semibold",children:a===1?"year":"wonderful years"})]})}),r.jsxs(Ln.h1,{className:`text-3xl font-bold ${k.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[_.title.join(" ")," ",_.emojis[4]]}),r.jsxs(Ln.div,{initial:{opacity:0},animate:{opacity:1},transition:{delay:1.1},children:[r.jsx("p",{className:`text-lg font-semibold ${k.text} mb-1`,children:s}),n&&r.jsxs("p",{className:`text-sm ${k.text} opacity-70 flex items-center justify-center gap-1 mb-5`,children:[r.jsx(Yi,{className:"h-3 w-3"}),n]})]}),g&&r.jsx(Ln.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:r.jsx("img",{src:g,alt:"Property",className:"w-full h-48 object-cover"})}),v&&r.jsx(Ln.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:r.jsx("iframe",{src:`${v}?autoplay=false&responsive=true`,className:"w-full aspect-video",allow:"autoplay; encrypted-media",allowFullScreen:!0})}),r.jsx(Ln.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:r.jsxs("p",{className:`text-sm ${k.text} leading-relaxed italic`,children:['"',o||_.defaultMessage,'"']})}),r.jsxs(Ln.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:1.5},children:[r.jsxs("div",{className:"flex items-center gap-3 justify-center",children:[i?r.jsx(Ln.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}}):r.jsx("div",{className:`h-12 w-12 rounded-full bg-gradient-to-br ${k.header} flex items-center justify-center shadow-md`,children:r.jsx("span",{className:"text-sm font-bold text-white",children:l.charAt(0)})}),r.jsxs("div",{className:"text-left",children:[r.jsx("p",{className:`text-sm font-bold ${k.accent}`,children:l}),p&&r.jsx("p",{className:`text-xs ${k.text} opacity-60`,children:p})]})]}),r.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[d&&r.jsxs(Ln.a,{href:`tel:${d}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${k.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[r.jsx(fi,{className:"h-3.5 w-3.5"})," Call"]}),m&&r.jsxs(Ln.a,{href:`mailto:${m}`,className:`flex items-center gap-1.5 px-5 py-2.5 rounded-full bg-gradient-to-r ${k.header} text-xs font-semibold text-white shadow-md`,whileHover:{scale:1.05},whileTap:{scale:.95},children:[r.jsx(Vs,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),r.jsx(Ln.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 jXe(){const{shareToken:e}=Bl(),{data:t,isLoading:s,error:n}=Ht({queryKey:["public-sendable-card",e],queryFn:async()=>{const{data:l,error:i}=await Y.from("sendable_cards").select("*").eq("share_token",e).single();if(i)throw i;return l},enabled:!!e});if(A.useEffect(()=>{e&&Y.rpc("log_sendable_card_view",{p_share_token:e}).then(({error:l})=>{l&&console.error("Error tracking view:",l)})},[e]),s)return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:r.jsxs("div",{className:"animate-pulse space-y-4 text-center",children:[r.jsx("div",{className:"h-8 w-48 bg-muted rounded mx-auto"}),r.jsx("div",{className:"h-4 w-32 bg-muted rounded mx-auto"})]})});if(n||!t)return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Card not found"}),r.jsx("p",{className:"text-muted-foreground",children:"This card may have been removed or the link is invalid."})]})});const a=t.home_anniversary_date?Math.floor((Date.now()-new Date(t.home_anniversary_date).getTime())/(365.25*24*60*60*1e3)):null,o={cardType:t.card_type||"home_anniversary",recipientName:t.recipient_name,propertyAddress:t.property_address,anniversaryYears:a,customMessage:t.custom_message,agentName:t.agent_name,agentPhotoUrl:t.agent_photo_url,agentPhone:t.agent_phone,agentEmail:t.agent_email,agentBrokerage:t.agent_brokerage,propertyPhotoUrl:t.property_photo_url,videoUrl:t.video_url||null};switch(t.template){case"bold":return r.jsx(Mmr,{...o});case"warm":return r.jsx(Amr,{...o});case"elegant":default:return r.jsx(Cmr,{...o})}}const kXe=()=>{const e=sm();return A.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),r.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),r.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),r.jsx("a",{href:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})};function Emr(){return A.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),r.jsxs(y8e,{children:[r.jsx(es,{path:"/c/:shareToken",element:r.jsx(jXe,{})}),r.jsx(es,{path:"*",element:r.jsx(kXe,{})})]})}const Imr=({team:e,onSelect:t})=>{const{data:s}=Ht({queryKey:["team-card-info",e.id],queryFn:async()=>{const{data:n}=await Y.from("team_members").select("user_id, role").eq("team_id",e.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 Y.from("profiles").select("name, avatar_url").eq("id",o.user_id).single();l=i}return{count:a,leaderProfile:l}}});return r.jsxs(ze,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:t,children:[r.jsx(Wt,{className:"pb-3",children:r.jsxs("div",{className:"flex items-start justify-between",children:[r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx(Zt,{className:"text-lg truncate",children:e.name}),e.description&&r.jsx(Cs,{className:"mt-1 line-clamp-2",children:e.description})]}),r.jsxs(_t,{variant:"secondary",className:"ml-2 shrink-0",children:[r.jsx(ws,{className:"h-3 w-3 mr-1"}),(s==null?void 0:s.count)??"…"]})]})}),r.jsxs(qe,{className:"space-y-3",children:[(s==null?void 0:s.leaderProfile)&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(cn,{className:"h-6 w-6",children:[r.jsx(xa,{src:s.leaderProfile.avatar_url||""}),r.jsx(dn,{className:"text-xs",children:(s.leaderProfile.name||"?").charAt(0).toUpperCase()})]}),r.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[r.jsx(_h,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),s.leaderProfile.name||"Team Leader"]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-sm text-muted-foreground",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(Ou,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:"capitalize text-xs",children:e.contact_visibility.replace("_"," ")})]}),e.lead_pond_enabled&&r.jsx(_t,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),e.shared_assets_enabled&&r.jsx(_t,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),e.shared_videos_enabled&&r.jsx(_t,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},Pmr=()=>{const{user:e,isAdmin:t,isBrokerageManager:s,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Gr(),l=o||(a.length>0?a[0].id:n),i=t?void 0:l||void 0,{teams:d,isLoading:m,createTeam:p,updateTeam:g,deleteTeam:v,addMember:_,removeMember:k,updateMemberRole:w}=jN(i),[S,T]=A.useState(!1),[C,I]=A.useState(null),{data:R}=Ht({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:$,error:q}=await Y.from("brokerages").select("id, name").order("name");if(q)throw q;return $||[]},enabled:t}),{data:D}=Ht({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:$,error:q}=await Y.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(q)throw q;return $||[]},enabled:!!l}),B=async $=>{const q=$.brokerage_id||l||null,W=await p.mutateAsync({name:$.name,brokerage_id:q,description:$.description});if($.leaderId&&$.leaderId!=="none"&&await _.mutateAsync({team_id:W.id,user_id:$.leaderId,role:"team_leader"}),$.memberIds)for(const K of $.memberIds)await _.mutateAsync({team_id:W.id,user_id:K,role:"team_member"});T(!1)};return!s&&!t?r.jsx(Ur,{title:"Teams",description:"Team Management",children:r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ws,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),r.jsx("p",{className:"text-muted-foreground",children:"You need brokerage manager access to manage teams."})]})}):r.jsx(Ur,{title:"Teams",description:"Create and manage teams within your brokerage",children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Teams"}),r.jsx("p",{className:"text-muted-foreground",children:"Organize your agents into teams with leaders and shared resources."})]}),r.jsxs(X,{onClick:()=>T(!0),children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),r.jsx(Aqe,{open:S,onOpenChange:T,onCreateTeam:B,isCreating:p.isPending,brokerageAgents:D||[],isAdmin:t,allBrokerages:R,activeBrokerageId:l}),m&&r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map($=>r.jsx(ze,{children:r.jsxs(qe,{className:"p-6",children:[r.jsx(pr,{className:"h-5 w-32 mb-3"}),r.jsx(pr,{className:"h-4 w-48 mb-4"}),r.jsx(pr,{className:"h-8 w-full"})]})},$))}),!m&&d.length===0&&!C&&r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ws,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Yet"}),r.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first team to organize agents and share resources."}),r.jsxs(X,{onClick:()=>T(!0),children:[r.jsx(gs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!m&&d.length>0&&!C&&r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:d.map($=>r.jsx(Imr,{team:$,onSelect:()=>I($)},$.id))}),C&&r.jsx(Tqe,{team:C,brokerageAgents:D||[],onBack:()=>I(null),onUpdate:$=>g.mutateAsync({id:C.id,...$}).then(q=>I(q)),onAddMember:($,q)=>_.mutateAsync({team_id:C.id,user_id:$,role:q}),onRemoveMember:$=>k.mutateAsync({team_id:C.id,member_id:$}),onUpdateRole:($,q)=>w.mutateAsync({team_id:C.id,member_id:$,role:q}),onDeleteTeam:()=>v.mutate(C.id),isUpdating:g.isPending,isAddingMember:_.isPending})]})})},Lmr=()=>{const{data:e,isLoading:t}=o_(),{useTeamMembers:s}=jN(),{data:n=[],isLoading:a}=s((e==null?void 0:e.teamId)||"");if(t)return r.jsx(Ur,{title:"My Team",description:"Your team",children:r.jsxs("div",{className:"space-y-4",children:[r.jsx(pr,{className:"h-8 w-48"}),r.jsx(pr,{className:"h-40 w-full"})]})});if(!e)return r.jsx(Ur,{title:"My Team",description:"Your team",children:r.jsx(ze,{children:r.jsxs(qe,{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ws,{className:"h-12 w-12 text-muted-foreground mb-4"}),r.jsx("h2",{className:"text-xl font-semibold mb-2",children:"No Team Yet"}),r.jsx("p",{className:"text-muted-foreground",children:"You haven't been assigned to a team. Ask your brokerage manager to add you."})]})})});const o=e.team;return r.jsx(Ur,{title:"My Team",description:o.name,children:r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:o.name}),r.jsx(_t,{variant:e.role==="team_leader"?"default":"secondary",className:"capitalize",children:e.role==="team_leader"?r.jsxs(r.Fragment,{children:[r.jsx(_h,{className:"mr-1 h-3 w-3"})," Leader"]}):"Member"})]}),o.description&&r.jsx("p",{className:"text-muted-foreground mt-1",children:o.description})]}),r.jsxs(ii,{defaultValue:"members",className:"space-y-4",children:[r.jsxs(si,{className:"flex-wrap",children:[r.jsx(Kr,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&r.jsxs(Kr,{value:"contacts",children:[r.jsx(xk,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&r.jsxs(Kr,{value:"lead-pond",children:[r.jsx(dx,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&r.jsxs(Kr,{value:"shared-assets",children:[r.jsx(Jh,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),r.jsx(hs,{value:"members",className:"space-y-2",children:a?r.jsx("div",{className:"space-y-3",children:[1,2,3].map(l=>r.jsx(pr,{className:"h-16 w-full"},l))}):n.map(l=>{var i,d,m,p;return r.jsx(ze,{children:r.jsxs(qe,{className:"flex items-center gap-3 p-4",children:[r.jsxs(cn,{className:"h-10 w-10",children:[r.jsx(xa,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),r.jsx(dn,{children:(((d=l.profile)==null?void 0:d.name)||"?").charAt(0).toUpperCase()})]}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"font-medium",children:((m=l.profile)==null?void 0:m.name)||"Unknown"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:(p=l.profile)==null?void 0:p.email})]}),l.role==="team_leader"?r.jsxs(_t,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[r.jsx(_h,{className:"mr-1 h-3 w-3"})," Leader"]}):r.jsx(_t,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&r.jsx(hs,{value:"contacts",className:"space-y-4",children:r.jsx(x_e,{})}),o.lead_pond_enabled&&r.jsx(hs,{value:"lead-pond",className:"space-y-4",children:r.jsx(y_e,{teamId:e.teamId})}),o.shared_assets_enabled&&r.jsx(hs,{value:"shared-assets",className:"space-y-4",children:r.jsx(Mqe,{teamId:e.teamId})})]})]})})},Dmr=new Yot,Omr=()=>{const e=window.location.hostname;return e==="listings.relevelup.com"||e.startsWith("listings.")},Rmr=()=>{const e=window.location.hostname;return e==="cards.relevelup.com"||e.startsWith("cards.")},Fmr=()=>{const e=window.location.hostname;return e==="presentations.relevelup.com"||e.startsWith("presentations.")},zmr=()=>{const e=window.location.hostname;return e==="guestbook.relevelup.com"||e.startsWith("guestbook.")},Bmr=()=>{const e=window.location.hostname;return e==="clients.relevelup.com"||e.startsWith("clients.")},$mr=()=>{const e=window.location.hostname;return e==="cardstudio.relevelup.com"||e.startsWith("cardstudio.")},Umr=()=>r.jsx(tlt,{client:Dmr,children:r.jsx(N8e,{children:r.jsxs(xN,{children:[r.jsx(gat,{}),r.jsx(Kat,{}),r.jsx(mct,{children:r.jsx(yht,{children:r.jsx(vht,{children:r.jsxs(bht,{children:[r.jsx(_ht,{}),r.jsx(Jft,{}),r.jsx(ppt,{}),$mr()?r.jsx(Emr,{}):Rmr()?r.jsx(Lgt,{}):Omr()?r.jsx(rgt,{}):Fmr()?r.jsx(Rgt,{}):zmr()?r.jsx(N0t,{}):Bmr()?r.jsx(H0t,{}):r.jsxs(y8e,{children:[r.jsx(es,{path:"/",element:r.jsx(evt,{})}),r.jsx(es,{path:"/privacy-policy",element:r.jsx(tvt,{})}),r.jsx(es,{path:"/terms-of-service",element:r.jsx(rvt,{})}),r.jsx(es,{path:"/data-deletion",element:r.jsx(svt,{})}),r.jsx(es,{path:"/public/listings",element:r.jsx(r7e,{})}),r.jsx(es,{path:"/public/listing/:slugOrId",element:r.jsx(abt,{})}),r.jsx(es,{path:"/card/:slug",element:r.jsx(ibt,{})}),r.jsx(es,{path:"/auth",element:r.jsx(avt,{})}),r.jsx(es,{path:"/subscription-success",element:r.jsx(ivt,{})}),r.jsx(es,{path:"/subscription",element:r.jsx(Ss,{children:r.jsx(m_t,{})})}),r.jsx(es,{path:"/share/video",element:r.jsx(tbt,{}),children:r.jsx(es,{path:":shareToken",element:r.jsx(ebt,{})})}),r.jsx(es,{path:"/p/:shareToken",element:r.jsx(blr,{})}),r.jsx(es,{path:"/portal/:slug",element:r.jsx(Clr,{})}),r.jsx(es,{path:"/og/video/:token",element:r.jsx(rbt,{})}),r.jsx(es,{path:"/setup-brokerage",element:r.jsx(Ss,{children:r.jsx(f_t,{})})}),r.jsx(es,{path:"/claim-account",element:r.jsx(J4e,{})}),r.jsx(es,{path:"/claim",element:r.jsx(J4e,{})}),r.jsx(es,{path:"/join",element:r.jsx(p_t,{})}),r.jsx(es,{path:"/trial",element:r.jsx(S_t,{})}),r.jsx(es,{path:"/trial/success",element:r.jsx(C_t,{})}),r.jsx(es,{path:"/dashboard",element:r.jsx(Ss,{children:r.jsx(dwt,{})})}),r.jsx(es,{path:"/profile",element:r.jsx(Ss,{children:r.jsx(J5t,{})})}),r.jsx(es,{path:"/apps",element:r.jsx(Ss,{children:r.jsx(h3t,{})})}),r.jsx(es,{path:"/admin",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(XTt,{})})}),r.jsx(es,{path:"/admin/apps",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(eAt,{})})}),r.jsx(es,{path:"/admin/members",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(lAt,{})})}),r.jsx(es,{path:"/admin/invite-codes",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(cAt,{})})}),r.jsx(es,{path:"/admin/events",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(pAt,{})})}),r.jsx(es,{path:"/events",element:r.jsx(Ss,{children:r.jsx(c3t,{})})}),r.jsx(es,{path:"/events/:eventId",element:r.jsx(Ss,{children:r.jsx(u3t,{})})}),r.jsx(es,{path:"/templates",element:r.jsx(Ss,{children:r.jsx(m3t,{})})}),r.jsx(es,{path:"/templates/:templateId",element:r.jsx(Ss,{children:r.jsx(x3t,{})})}),r.jsx(es,{path:"/admin/templates",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(gAt,{})})}),r.jsx(es,{path:"/academy",element:r.jsx(Ss,{children:r.jsx(y3t,{})})}),r.jsx(es,{path:"/academy/:videoId",element:r.jsx(Ss,{children:r.jsx(_3t,{})})}),r.jsx(es,{path:"/admin/academy",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(yAt,{})})}),r.jsx(es,{path:"/toolbox",element:r.jsx(Ss,{children:r.jsx(b3t,{})})}),r.jsx(es,{path:"/toolbox/:kitId",element:r.jsx(Ss,{children:r.jsx(w3t,{})})}),r.jsx(es,{path:"/admin/toolbox",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(vAt,{})})}),r.jsx(es,{path:"/social-swag",element:r.jsx(Ss,{children:r.jsx(j3t,{})})}),r.jsx(es,{path:"/social-swag-2",element:r.jsx(Ss,{children:r.jsx(bTt,{})})}),r.jsx(es,{path:"/social-swag/:swagId",element:r.jsx(Ss,{children:r.jsx(wTt,{})})}),r.jsx(es,{path:"/social-connections",element:r.jsx(Ss,{children:r.jsx(tlr,{})})}),r.jsx(es,{path:"/social-connections/callback",element:r.jsx(Ss,{children:r.jsx(rlr,{})})}),r.jsx(es,{path:"/social-connections/linkedin-callback",element:r.jsx(Ss,{children:r.jsx(nlr,{})})}),r.jsx(es,{path:"/social-connections/google-callback",element:r.jsx(Ss,{children:r.jsx(slr,{})})}),r.jsx(es,{path:"/admin/social-swag",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(_At,{})})}),r.jsx(es,{path:"/admin/social-swag-2",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(oIt,{})})}),r.jsx(es,{path:"/community",element:r.jsx(Ss,{children:r.jsx($Tt,{})})}),r.jsx(es,{path:"/support",element:r.jsx(Ss,{children:r.jsx(UTt,{})})}),r.jsx(es,{path:"/admin/community",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(lIt,{})})}),r.jsx(es,{path:"/admin/support-tickets",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(gIt,{})})}),r.jsx(es,{path:"/admin/email-templates",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(vIt,{})})}),r.jsx(es,{path:"/admin/agent-email-templates",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(_It,{})})}),r.jsx(es,{path:"/admin/analytics",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(mIt,{})})}),r.jsx(es,{path:"/admin/brokerage-resources",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(fIt,{})})}),r.jsx(es,{path:"/admin/dashboard-management",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(pIt,{})})}),r.jsx(es,{path:"/brokerage/dashboard",element:r.jsx(Ss,{requireBrokerageManager:!0,children:r.jsx(IIt,{})})}),r.jsx(es,{path:"/brokerage/teams",element:r.jsx(Ss,{requireBrokerageManager:!0,children:r.jsx(Pmr,{})})}),r.jsx(es,{path:"/my-team",element:r.jsx(Ss,{children:r.jsx(Lmr,{})})}),r.jsx(es,{path:"/my-brokerage",element:r.jsx(Ss,{children:r.jsx(FIt,{})})}),r.jsx(es,{path:"/brokerage-resources",element:r.jsx(Ss,{requireBrokerageManager:!0,children:r.jsx(KTt,{})})}),r.jsx(es,{path:"/brokerage-resources/:resourceId",element:r.jsx(Ss,{requireBrokerageManager:!0,children:r.jsx(ZTt,{})})}),r.jsx(es,{path:"/newsletters",element:r.jsx(Ss,{children:r.jsx(zIt,{})})}),r.jsx(es,{path:"/newsletters/:id",element:r.jsx(Ss,{children:r.jsx($It,{})})}),r.jsx(es,{path:"/wishlist",element:r.jsx(Ss,{children:r.jsx(qIt,{})})}),r.jsx(es,{path:"/wishlist/:itemId",element:r.jsx(Ss,{children:r.jsx(HIt,{})})}),r.jsx(es,{path:"/admin/wishlist",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(WIt,{})})}),r.jsx(es,{path:"/admin/levelup-brief",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(GIt,{})})}),r.jsx(es,{path:"/admin/newsletters",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(VIt,{})})}),r.jsx(es,{path:"/admin/additional-services",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(KIt,{})})}),r.jsx(es,{path:"/admin/discounts",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(ZIt,{})})}),r.jsx(es,{path:"/admin/subscriptions",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(YIt,{})})}),r.jsx(es,{path:"/admin/referrals",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(XIt,{})})}),r.jsx(es,{path:"/admin/prospector",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(elr,{})})}),r.jsx(es,{path:"/admin/onboarding-checklist",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(JIt,{})})}),r.jsx(es,{path:"/admin/marketplace",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Eor,{})})}),r.jsx(es,{path:"/admin/agent-points",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(eor,{})})}),r.jsx(es,{path:"/admin/reward-store",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Wor,{})})}),r.jsx(es,{path:"/admin/integrations",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Kor,{})})}),r.jsx(es,{path:"/admin/integrations/callback",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Jor,{})})}),r.jsx(es,{path:"/reward-store",element:r.jsx(Ss,{children:r.jsx(hlr,{})})}),r.jsx(es,{path:"/additional-services",element:r.jsx(Ss,{children:r.jsx(dPt,{})})}),r.jsx(es,{path:"/additional-services/:serviceId",element:r.jsx(Ss,{children:r.jsx(uPt,{})})}),r.jsx(es,{path:"/ai-toolkit",element:r.jsx(Ss,{children:r.jsx(hPt,{})})}),r.jsx(es,{path:"/mission-control",element:r.jsx(Ss,{children:r.jsx(SPt,{})})}),r.jsx(es,{path:"/mission-control/contacts",element:r.jsx(Ss,{children:r.jsx(HPt,{})})}),r.jsx(es,{path:"/mission-control/contacts/:contactId",element:r.jsx(Ss,{children:r.jsx(n6t,{})})}),r.jsx(es,{path:"/mission-control/plans",element:r.jsx(Ss,{children:r.jsx(a6t,{})})}),r.jsx(es,{path:"/mission-control/popbys",element:r.jsx(Ss,{children:r.jsx(l6t,{})})}),r.jsx(es,{path:"/mission-control/popbys/map",element:r.jsx(Ss,{children:r.jsx(c6t,{})})}),r.jsx(es,{path:"/admin/notification-settings",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Yor,{})})}),r.jsx(es,{path:"/admin/agent-os",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(tPt,{})})}),r.jsx(es,{path:"/mission-control/listings",element:r.jsx(Ss,{children:r.jsx(Knr,{})})}),r.jsx(es,{path:"/mission-control/listings/new",element:r.jsx(Ss,{children:r.jsx(EIe,{})})}),r.jsx(es,{path:"/mission-control/listings/:listingId",element:r.jsx(Ss,{children:r.jsx(car,{})})}),r.jsx(es,{path:"/mission-control/listings/:listingId/edit",element:r.jsx(Ss,{children:r.jsx(EIe,{})})}),r.jsx(es,{path:"/admin/listing-exchange",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Kir,{})})}),r.jsx(es,{path:"/mission-control/pipeline",element:r.jsx(Ss,{children:r.jsx(hir,{})})}),r.jsx(es,{path:"/mission-control/my-card",element:r.jsx(Ss,{children:r.jsx(Iir,{})})}),r.jsx(es,{path:"/mission-control/integrations",element:r.jsx(Ss,{children:r.jsx(Bir,{})})}),r.jsx(es,{path:"/mission-control/integrations/gmail/callback",element:r.jsx(Ss,{children:r.jsx($ir,{})})}),r.jsx(es,{path:"/mission-control/integrations/canva/callback",element:r.jsx(Uir,{})}),r.jsx(es,{path:"/mission-control/integrations/meta/callback",element:r.jsx(Ss,{children:r.jsx(Vir,{})})}),r.jsx(es,{path:"/mission-control/scorecard",element:r.jsx(Ss,{children:r.jsx(Fnr,{})})}),r.jsx(es,{path:"/admin/scorecard",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Hir,{})})}),r.jsx(es,{path:"/admin/scorecard/:userId",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Gir,{})})}),r.jsx(es,{path:"/admin/membership-reviews",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Zir,{})})}),r.jsx(es,{path:"/admin/weekly-digest",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Qir,{})})}),r.jsx(es,{path:"/mission-control/video/record",element:r.jsx(Ss,{children:r.jsx(xar,{})})}),r.jsx(es,{path:"/mission-control/video-library",element:r.jsx(Ss,{children:r.jsx(kar,{})})}),r.jsx(es,{path:"/marketplace",element:r.jsx(Ss,{children:r.jsx(alr,{})})}),r.jsx(es,{path:"/marketplace/:productId",element:r.jsx(Ss,{children:r.jsx(ilr,{})})}),r.jsx(es,{path:"/marketplace/cart",element:r.jsx(Ss,{children:r.jsx(olr,{})})}),r.jsx(es,{path:"/marketplace/orders",element:r.jsx(Ss,{children:r.jsx(llr,{})})}),r.jsx(es,{path:"/marketplace/orders/:orderId",element:r.jsx(Ss,{children:r.jsx(dlr,{})})}),r.jsx(es,{path:"/marketplace/success",element:r.jsx(Ss,{children:r.jsx(ulr,{})})}),r.jsx(es,{path:"/admin/agent-cards",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(tor,{})})}),r.jsx(es,{path:"/admin/presentation-analytics",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Xor,{})})}),r.jsx(es,{path:"/admin/guest-book-analytics",element:r.jsx(Ss,{requireAdmin:!0,children:r.jsx(Qor,{})})}),r.jsx(es,{path:"/mission-control/presentations",element:r.jsx(Ss,{children:r.jsx(plr,{})})}),r.jsx(es,{path:"/mission-control/presentations/new",element:r.jsx(Ss,{children:r.jsx(UIe,{})})}),r.jsx(es,{path:"/mission-control/presentations/:id",element:r.jsx(Ss,{children:r.jsx(UIe,{})})}),r.jsx(es,{path:"/mission-control/guest-book",element:r.jsx(Ss,{children:r.jsx(wlr,{})})}),r.jsx(es,{path:"/guestbook/:slug",element:r.jsx(Slr,{})}),r.jsx(es,{path:"/mission-control/card-studio",element:r.jsx(Ss,{children:r.jsx(Smr,{})})}),r.jsx(es,{path:"/c/:shareToken",element:r.jsx(jXe,{})}),r.jsx(es,{path:"*",element:r.jsx(kXe,{})})]}),")"]})})})})]})})});EDe(document.getElementById("root")).render(r.jsx(Umr,{}));